Calling the API

Assuming you have obtained a valid Access token (see here how to do get it) you can now make requests to endpoints that are within the scope that you required when obtaining authorization.

The following example shows how to create an invoice:

URL: https://api.smallinvoice.com/v2/receivables/invoices
Method: POST
HTTP-Headers: Content-Type: application/json
             Authorization: Bearer YOURACCESSTOKEN

BODY:
{
    "contact_id":985673512,
    "contact_address_id":452539101,
    "date":"2024-07-27",
    "due":"2024-08-26",
    "currency":"CHF",
    "language":"de",
    "positions":[
        {
            "type":"N",
            "catalog_type":"P",
            "name":"Position name",
            "description":"Position description",
            "price":7982.94,
            "amount":1.0,
            "unit_id":7,
            "vat":7.7
        }
    ]
}

A simple example using command line CURL would look like this:

curl -X POST --header 'Content-Type: application/json' --header 'Authorization: Bearer YOURACCESSTOKEN' \
-d '{ \
     "contact_id":985673512, \
     "contact_address_id":452539101, \
     "date":"2018-06-12", \
     "due":"2018-07-12", \
     "currency":"CHF", \
     "language":"de", \
     "positions":[ \
         { \
         "type":"N", \
         "catalog_type":"P", \
         "name":"Position name", \
         "description":"Position description", \
         "price":7982.94, \
         "amount":1.0, \
         "unit_id":7, \
         "vat":7.7 \
         } \
     ] \
 }' 'https://api.smallinvoice.com/v2/receivables/invoices'

The same example using PHP would look like this: (Important Note: For PHP we have a fully prepared Wrapper available. See Introduction for further information)

$ch = curl_init();

$payload = json_encode([
    'contact_id'     => 985673512,
    'contact_address_id' => 452539101,
    'date' => '2024-07-27',
    'due' => '2024-08-26',
    'currency' => 'CHF',
    'language' => 'de',
    'positions' => [
        [
            'type' => 'N',
            'catalog_type' => 'P',
            'name' => 'Position name',
            'description' => 'Position description',
            'price' => 7982.94,
            'amount' => 1.0,
            'unit_id' => 7,
            'vat' => 7.7,
        ],
    ],
]);

curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_URL, 'https://api.smallinvoice.com/v2/receivables/invoices');
curl_setopt($ch, CURLOPT_HTTPHEADER,
            ['Content-Type: application/json', 'Authorization: Bearer YOURACCESSTOKEN']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);


In the same way, all other endpoints and actions are used. Detailed description of all available endpoints as well as fields and their values can be found here.