API-V2

Application Programming Interface

InvoiceXpress Documentation

Update

PUT /api/accounts/:account-id/update.json

Updates account data.

Example Request

curl

curl --request PUT \
  --url 'https://account_name.app.invoicexpress.com/api/accounts/:account-id/update.json?api_key=YOUR%20API%20KEY%20HERE' \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{"account":{"organization_name":"Your Company Name","fiscal_id":"999999990","address":"Avenida Duque D'\''Avila, Saldanha","postal_code":"1500-555","city":"Lisbon","email":"email@company.com"}}'

Ruby

require 'uri'
require 'net/http'

url = URI("https://account_name.app.invoicexpress.com/api/accounts/:account-id/update.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::Put.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request.body = "{\"account\":{\"organization_name\":\"Your Company Name\",\"fiscal_id\":\"999999990\",\"address\":\"Avenida Duque D'Avila, Saldanha\",\"postal_code\":\"1500-555\",\"city\":\"Lisbon\",\"email\":\"email@company.com\"}}"

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

Node

var http = require("https");

var options = {
  "method": "PUT",
  "hostname": "account_name.app.invoicexpress.com",
  "port": null,
  "path": "/api/accounts/:account-id/update.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({ account:
   { organization_name: 'Your Company Name',
     fiscal_id: '999999990',
     address: 'Avenida Duque D\'Avila, Saldanha',
     postal_code: '1500-555',
     city: 'Lisbon',
     email: 'email@company.com' } }));
req.end();

Python

import http.client

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

payload = "{\"account\":{\"organization_name\":\"Your Company Name\",\"fiscal_id\":\"999999990\",\"address\":\"Avenida Duque D'Avila, Saldanha\",\"postal_code\":\"1500-555\",\"city\":\"Lisbon\",\"email\":\"email@company.com\"}}"

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

conn.request("PUT", "/api/accounts/:account-id/update.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/api/accounts/:account-id/update.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 => "PUT",
  CURLOPT_POSTFIELDS => "{\"account\":{\"organization_name\":\"Your Company Name\",\"fiscal_id\":\"999999990\",\"address\":\"Avenida Duque D'Avila, Saldanha\",\"postal_code\":\"1500-555\",\"city\":\"Lisbon\",\"email\":\"email@company.com\"}}",
  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/api/accounts/:account-id/update.json?api_key=YOUR%20API%20KEY%20HERE"

    payload := strings.NewReader("{\"account\":{\"organization_name\":\"Your Company Name\",\"fiscal_id\":\"999999990\",\"address\":\"Avenida Duque D'Avila, Saldanha\",\"postal_code\":\"1500-555\",\"city\":\"Lisbon\",\"email\":\"email@company.com\"}}")

    req, _ := http.NewRequest("PUT", 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))

}

Query Parameters

NameTypeRequiredDescriptionExample
account-idIntegerRequiredThe ID of the account to be updated.42

Request Body Parameters

NameTypeRequiredDescription
accountObjectRequiredAccount data to be created
first_nameStringThe user’s first name.
last_nameStringThe user’s last name.
organization_nameStringRequiredThe name of the company.
phoneStringThe account phone number.
emailStringRequiredThe account email.
passwordStringRequiredThe account password.
fiscal_idStringThe company fiscal ID (vat number). The fiscal_id, if present, must be unique in the system.
tax_countryStringThe account country. Options: 1 (Portugal); 2 (Ireland); 3 (UK). See the Appendix for more countries.
languageStringThe account language. Options: pt (Portuguese); en (English); es (Spanish).
termsStringRequiredThe terms and conditions. Options: 1 (Accepted); 0 (Not accepted).
marketingStringSigning up to receive the marketing newsletter. Options: 1 (Accepted); 0 (Not accepted).
credentialsObjectObject that contains details about the credentials to be configured.
usernameStringRequired if credentials is presentCredentials username. Must be in the format 123456789/X.
Regex: (^\d{9}/)
passwordStringRequired if credentials is presentCredentials password. Must be encoded in Base64.
typeStringInstitution the credentials will be used for. Case sensitive. Defaults to AT.

Possible values:
– AT
contextStringContext of the credentials. Case sensitive. Defaults to Sequences.

Possible values:
– Sequences

Example Request Body

{
  "account": {
    "organization_name": "Your Company Name",
    "fiscal_id": "999999990",
    "address": "Avenida Duque D'Avila, Saldanha",
    "postal_code": "1500-555",
    "city": "Lisbon",
    "email": "email@company.com",
    "terms": 1,
    "credentials": {
      "username": "123456789/1", 
      "password": "cGFzc3dvcmQ=",
      "context": "Sequences",
      "type": "AT"
    }
  }
}

Responses

401ACCESS DENIED
The API Key parameter is missing or is incorrectly entered.
(Empty Response)
404NOT FOUND
The account doesn’t exist.
(Empty Response)
422UNPROCESSABLE ENTITY
Some parameters were incorrect.
(Empty Response)

Possible Errors for HTTP: 422

  • Postal Code must have the following format DDDD-DDD
  • Vat Number can’t be changed
  • Vat Number is already used in another account
  • Username is not valid.
  • Password is not valid.
  • Username doesn’t match required format.
  • Credential type is invalid.
  • Credential context is invalid.