API-V2

Application Programming Interface

InvoiceXpress Documentation

Create

POST /clients.json

Creates a new client.

Example Request

curl

curl --request POST \
  --url 'https://account_name.app.invoicexpress.com/clients.json?api_key=YOUR%20API%20KEY%20HERE' \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{"client":{"name":"Client Name","code":"12345","email":"foo@bar.com","language":"pt","address":"Avenida da República, Lisboa","city":"Lisboa","postal_code":"1050-555","country":"Portugal","fiscal_id":"508025338","website":"www.invoicexpress.com","phone":"213456789","fax":"213456788","preferred_contact":{"name":"Bruce Norris","email":"email@invoicexpress.com","phone":"213456789"},"observations":"Observations","send_options":"1"}}'

Ruby

require 'uri'
require 'net/http'

url = URI("https://account_name.app.invoicexpress.com/clients.json?api_key=YOUR%20API%20KEY%20HERE")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request.body = "{\"client\":{\"name\":\"Client Name\",\"code\":\"12345\",\"email\":\"foo@bar.com\",\"language\":\"pt\",\"address\":\"Avenida da República, Lisboa\",\"city\":\"Lisboa\",\"postal_code\":\"1050-555\",\"country\":\"Portugal\",\"fiscal_id\":\"508025338\",\"website\":\"www.invoicexpress.com\",\"phone\":\"213456789\",\"fax\":\"213456788\",\"preferred_contact\":{\"name\":\"Bruce Norris\",\"email\":\"email@invoicexpress.com\",\"phone\":\"213456789\"},\"observations\":\"Observations\",\"send_options\":\"1\"}}"

response = http.request(request)
puts response.read_body

Node

var http = require("https");

var options = {
  "method": "POST",
  "hostname": "account_name.app.invoicexpress.com",
  "port": null,
  "path": "/clients.json?api_key=YOUR%20API%20KEY%20HERE",
  "headers": {
    "accept": "application/json",
    "content-type": "application/json"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ client:
   { name: 'Client Name',
     code: '12345',
     email: 'foo@bar.com',
     language: 'pt',
     address: 'Avenida da República, Lisboa',
     city: 'Lisboa',
     postal_code: '1050-555',
     country: 'Portugal',
     fiscal_id: '508025338',
     website: 'www.invoicexpress.com',
     phone: '213456789',
     fax: '213456788',
     preferred_contact:
      { name: 'Bruce Norris',
        email: 'email@invoicexpress.com',
        phone: '213456789' },
     observations: 'Observations',
     send_options: '1' } }));
req.end();

Python

import http.client

conn = http.client.HTTPSConnection("account_name.app.invoicexpress.com")

payload = "{\"client\":{\"name\":\"Client Name\",\"code\":\"12345\",\"email\":\"foo@bar.com\",\"language\":\"pt\",\"address\":\"Avenida da República, Lisboa\",\"city\":\"Lisboa\",\"postal_code\":\"1050-555\",\"country\":\"Portugal\",\"fiscal_id\":\"508025338\",\"website\":\"www.invoicexpress.com\",\"phone\":\"213456789\",\"fax\":\"213456788\",\"preferred_contact\":{\"name\":\"Bruce Norris\",\"email\":\"email@invoicexpress.com\",\"phone\":\"213456789\"},\"observations\":\"Observations\",\"send_options\":\"1\"}}"

headers = {
    'accept': "application/json",
    'content-type': "application/json"
    }

conn.request("POST", "/clients.json?api_key=YOUR%20API%20KEY%20HERE", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://account_name.app.invoicexpress.com/clients.json?api_key=YOUR%20API%20KEY%20HERE",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"client\":{\"name\":\"Client Name\",\"code\":\"12345\",\"email\":\"foo@bar.com\",\"language\":\"pt\",\"address\":\"Avenida da República, Lisboa\",\"city\":\"Lisboa\",\"postal_code\":\"1050-555\",\"country\":\"Portugal\",\"fiscal_id\":\"508025338\",\"website\":\"www.invoicexpress.com\",\"phone\":\"213456789\",\"fax\":\"213456788\",\"preferred_contact\":{\"name\":\"Bruce Norris\",\"email\":\"email@invoicexpress.com\",\"phone\":\"213456789\"},\"observations\":\"Observations\",\"send_options\":\"1\"}}",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Go

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://account_name.app.invoicexpress.com/clients.json?api_key=YOUR%20API%20KEY%20HERE"

    payload := strings.NewReader("{\"client\":{\"name\":\"Client Name\",\"code\":\"12345\",\"email\":\"foo@bar.com\",\"language\":\"pt\",\"address\":\"Avenida da República, Lisboa\",\"city\":\"Lisboa\",\"postal_code\":\"1050-555\",\"country\":\"Portugal\",\"fiscal_id\":\"508025338\",\"website\":\"www.invoicexpress.com\",\"phone\":\"213456789\",\"fax\":\"213456788\",\"preferred_contact\":{\"name\":\"Bruce Norris\",\"email\":\"email@invoicexpress.com\",\"phone\":\"213456789\"},\"observations\":\"Observations\",\"send_options\":\"1\"}}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("accept", "application/json")
    req.Header.Add("content-type", "application/json")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}

Request Body

NameTypeRequiredDescription
clientObjectRequiredClient data to be created
nameStringRequiredClient name, normally used for a company name.
codeStringRequiredClient code, your specific code for the client.
emailStringClient email address. Must be a valid email address ex: foo@bar.com
languageStringClient language. May be en, pt or es; defaults to the account language.
addressStringClient company address.
cityStringClient’s city.
postal_codeStringClient’s postal code for it’s company address.
countryStringCountry, normally used for a company country. Although country is optional, when supplied, it should match one of the country list on the Appendix of this Documentation.
fiscal_idStringThe client fiscal ID (Número de Contribuinte).
websiteStringThe client web address.
phoneStringThe client phone number
faxStringThe client fax number.
preferred_contactObjectThe preferred contact details.
nameStringName of the preferred contact on your new client.
emailStringEmail of the preferred contact on your new client.
phoneStringPhone number of the preferred contact on your new client.
observationsStringDefault observations for the client, the text in here will be added to the observations field of all the invoices sent to this client.
send_optionsIntegerSend options for the client. Available options are: 1 – send only the original document / 2 – the original and duplicate / 3 – the original, duplicate and triplicate. These affect the generated pdf.

Example Request Body

{
  "client": {
    "name": "Client Name",
    "code": "12345",
    "email": "foo@bar.com",
    "language": "pt",
    "address": "Avenida da República, Lisboa",
    "city": "Lisboa",
    "postal_code": "1050-555",
    "country": "Portugal",
    "fiscal_id": "508025338",
    "website": "www.invoicexpress.com",
    "phone": "213456789",
    "fax": "213456788",
    "preferred_contact": {
      "name": "Bruce Norris",
      "email": "email@invoicexpress.com",
      "phone": "213456789"
    },
    "observations": "Observations",
    "send_options": "1"
  }
}

Responses

201SUCCESSClients Get
401ACCESS DENIED
The API Key parameter is missing or is incorrectly entered.
(Empty Response)
422UNPROCESSABLE ENTITY
Some parameters were incorrect.
(Empty Response)

Example Success Body Response

{
  "client": {
    "id": "1",
    "name": "Ricardo Pereira",
    "email": "someone@example.com",
    "address": "Lisbon",
    "city": "Lisbon",
    "postal_code": "1750-455",
    "fiscal_id": "508025338",
    "website": "www.invoicexpress.com",
    "country": "Portugal",
    "phone": "2313423424",
    "fax": "2313423425",
    "preferred_contact": {
      "name": "Ricardo Pereira",
      "email": "someone@example.com",
      "phone": "2233442233"
    },
    "observations": "Computer Processed",
    "open_account_link": "https://www.app.invoicexpress.com/suppliers/1f7bba947948c50e04af20d329db5bc67c38cf89",
    "send_options": "1",
    "payment_days": "0",
    "tax_exemption_code": "M00"
  }
}