Changing data is done in more or less the same way as creating a data.

However, in case of changes, you must always provide the full URL of the data that you want to change (so including ID). For example, you forward /api/v1/invoices/1001 to change invoice with ID 1001.

The method used (POST or PUT) has a major impact on how the data is changed.

You can use the POST method to change only part of the existing data. For example, you can only provide the description of an invoice item and other fields such as the amount will remain unchanged.

When using the PUT method, you must always provide all the data. Data not provided will be deleted.

If you use XML or JSON as a format, it is important to provide the ID of underlying elements (both for POST and PUT). If you give an underlying element without an ID, it is assumed that you want to create this data.

If you use the PUT method and you wish, for example, to change some details of an invoice but also to remove all payments from the invoice, you must provide an empty block (XML) or empty array (JSON) for 'payments' in the invoice. If you do not provide a 'payments' block or array, no 'payments' will be removed. So when giving an empty block or array, the data is deleted from this block/array. Otherwise, they will be left untouched.

An example in PHP how you can change an item of an invoice (put method):

$email = '';
$password = '123456';
$item = "<item><description>bestelling van 1/4/2012</description>
$p = curl_init('');
curl_setopt($p, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', 
                                          'Accept: application/xml'));
curl_setopt($p, CURLOPT_USERPWD, $email . ':' . $password);
curl_setopt($p, CURLOPT_POSTFIELDS, $item);
curl_setopt($p, CURLOPT_CUSTOMREQUEST, "PUT");
$result_in_xml_string = curl_exec($p);