API-V2

Application Programming Interface

InvoiceXpress Documentation

Create

POST /sequences.json

Creates and registers a new sequence. For portuguese accounts, it’s necessary to have AT credentials configured. View all information here.

Example Request

curl

curl --request POST \
  --url 'https://account_name.app.invoicexpress.com/sequences.json?api_key=YOUR%20API%20KEY%20HERE' \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{"sequence":{"serie":"2017","default_sequence":"1"}}'

Ruby

require 'uri'
require 'net/http'

url = URI("https://account_name.app.invoicexpress.com/sequences.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 = "{\"sequence\":{\"serie\":\"2017\",\"default_sequence\":\"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": "/sequences.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({ sequence: { serie: '2017', default_sequence: '1' } }));
req.end();

Python

import http.client

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

payload = "{\"sequence\":{\"serie\":\"2017\",\"default_sequence\":\"1\"}}"

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

conn.request("POST", "/sequences.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/sequences.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 => "{\"sequence\":{\"serie\":\"2017\",\"default_sequence\":\"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/sequences.json?api_key=YOUR%20API%20KEY%20HERE"

    payload := strings.NewReader("{\"sequence\":{\"serie\":\"2017\",\"default_sequence\":\"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
sequenceObjectRequiredSequence data to be created
serieStringRequiredSeries name
default_sequenceStringIf “1”, this sequence is chosen as the default sequence on your account. Other values are ignored.

Example Request Body

{
  "sequence": {
    "serie": "2023",
    "default_sequence": "1"
  }
}

Responses

201SUCCESSSequences Get
401ACCESS DENIED
The API Key parameter is missing or is incorrectly entered.
(Empty Response)
409CONFLICT
The sequences are in a conflicting state.
The sequence is already registered.

{ "code": "006", "message": "The sequence is already being registered." }

Available codes:
006: The sequence is already being registered.
422UNPROCESSABLE ENTITY
Some parameters were incorrect.
{ "code": "001", "message": "Sequence name not allowed." }

Available codes:
001: Sequence name not allowed.
002: Sequence already exists.
003: Invalid sequence.
004: Invalid Tax Authority credentials.
005: Account fiscal ID doesn’t have open activity in Tax Authority.
000: Unknown error.

Example Success Body Response

{
  "sequence": {
    "id": 146090,
    "serie": "2023",
    "default_sequence": 1,
    "current_invoice_number": 0,
    "current_invoice_sequence_id": 146090,
    "current_invoice_validation_code": "ABCD123
    "current_invoice_receipt_number": 0,
    "current_invoice_receipt_sequence_id": 146092,
    "current_invoice_receipt_validation_code": "ABCD1231",
    "current_simplified_invoice_number": 0,
    "current_simplified_invoice_sequence_id": 146091,
    "current_simplified_invoice_validation_code": "ABCD1232",
    "current_credit_note_number": 0,
    "current_credit_note_sequence_id": 146095,
    "current_credit_note_validation_code": "ABCD1233",
    "current_debit_note_number": 0,
    "current_debit_note_sequence_id": 146094,
    "current_debit_note_validation_code": "ABCD1234",
    "current_receipt_number": 0,
    "current_receipt_sequence_id": 146093,
    "current_receipt_validation_code": "ABCD1235",
    "current_shipping_number": 0,
    "current_shipping_sequence_id": 146104,
    "current_shipping_validation_code": "ABCD1236",
    "current_transport_number": 0,
    "current_transport_sequence_id": 146106,
    "current_transport_validation_code": "ABCD1237",
    "current_devolution_number": 0,
    "current_devolution_sequence_id": 146105,
    "current_devolution_validation_code": "ABCD1238",
    "current_proforma_number": 0,
    "current_proforma_sequence_id": 146102,
    "current_proforma_validation_code": "ABCD1239",
    "current_quote_number": 0,
    "current_quote_sequence_id": 146101,
    "current_quote_validation_code": "ABCD1240",
    "current_fees_note_number": 0,
    "current_fees_note_sequence_id": 146103,
    "current_fees_note_validation_code": "N/A",
    "current_vat_moss_invoice_number": 0,
    "current_vat_moss_invoice_sequence_id": 146097,
    "current_vat_moss_invoice_validation_code": "N/A",
    "current_vat_moss_credit_note_number": 0,
    "current_vat_moss_credit_note_sequence_id": 146098,
    "current_vat_moss_credit_note_validation_code": "N/A",
    "current_vat_moss_receipt_number": 0,
    "current_vat_moss_receipt_sequence_id": 146099,
    "current_vat_moss_receipt_validation_code": "N/A",
  }
}

Possible values for fields current_<document type>_validation_code:

  • ABCD1234 or similar: validation code for each sequence that is registered in the Tax Authority.
  • N/D: The sequence is relevant for ATCUD but is not registered in the Tax Authority.
  • N/A: The sequence is not relevant for ATCUD and is not registered in the Tax Authority.