You can only create data using the POST method. Use the domain and possibly subdomain of the data you want to create.


For example, if you want to create a new invoice, use the URL https://api.simplybooks.be/api/v1/invoices or https://api.simplybooks.be/api/v1/invoices/1001/payments to create a new payment for invoice with ID 1001.


The data you provide can be passed on in XML, JSON and in form-encoding. With XML and JSON you can pass on all data in 1x (e.g. an invoice with items), with form encoding you have to pass on each block separately (e.g. first the invoice and then one by one the items).


As a result, you get an 'error' or 'success' back. If the data has been created correctly, you will also receive the new ID of the created data as well as the URI with which you can retrieve the complete data.



Example in case of error:

<data>
  <error>description is required</error>
</data>

Example of succes:

<data>
  <success>invoice created</success>
  <invoice_id>1001</invoice_id>
  <uri>https://eenvoudigfactureren.be/api/v1/invoices/1001</uri>
</data>


An example in PHP how to create an invoice:

$email = '[email protected]';
$password = '123456';
 
$invoice = (object)[
    'client_id' => 101,
    'number' => "INV2012-001",
    'days_due' => 10,
    'items' => [
        (object)[
            'description' => "jouw bestelling",
            'amount' => 20.5,
            'tax_rate' => 21,
        ],
        (object)[
            'description' => "levering",
            'amount' => 4,
            'tax_rate' => 21,
        ],
    ]
];
 
$p = curl_init('https://eenvoudigfactureren.be/api/v1/invoices');
curl_setopt($p, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 
                                          'Accept: application/json'));
curl_setopt($p, CURLOPT_USERPWD, $email . ':' . $password);
curl_setopt($p, CURLOPT_POSTFIELDS, json_encode($invoice));
curl_setopt($p, CURLOPT_RETURNTRANSFER, TRUE);
$result = json_decode(curl_exec($p));


  More info about the API? Read the useful articles below