Browse Documentation
PUT Update contact

Update Contact

PUT /contacts/:id

You can use either a PUT or POST request to update an existing contact. Only parameters that need to be updated need to be supplied. Parameters not part of the update request will remain unchanged.

Creating, updating and deleting contact persons when updating a contact:

• Supplying an existing contact person with an id will update that contact person
• Supplying a contact person without id will add a new contact person to the contact
• Not supplying an existing contact will delete the contact person
• When the contact_person object is not part of the request, no changes will be made to any of the existing contact persons.

Example

Below is an example contact we'll update

      
{
    "contact": {
        "id": "423c6d20d7e26c137e13bf14ad886aae55a1c8d1",
        "organization_id": "daa71f0644647c0d82dd2d03d0b29779644b1a48",
        "name": "new contact",
        "address": "Oude Baan 2",
        "city": "Boutersem",
        "zip_code": "3370",
        "country_code": "BE",
        "email": "[email protected]",
        "fax": "+3847550505",
        "phone": "+384940405",
        "tax_number": "BE364474748484",
        "is_client": true,
        "is_supplier": false,
        "contact_persons": [{
            "id": "9726882a45051aac98a647547b28a37d8eff0129",
            "first_name": "contact 01",
            "last_name": null,
            "email": "[email protected]",
            "phone": "+38394944"
        }, {
            "id": "2127e7fc3fed716af57187f71343c6e2f037b4c5",
            "first_name": "contact 02",
            "last_name": null,
            "email": "[email protected]",
            "phone": "+38394944"
        }]
    }
}
    

Request

    
{
    "contact": {
    "name": "new contact",
    "address": "New Address",
    "city": "New City",
    "is_client": false,
    "is_supplier": true,
    "contact_persons": [{
        "id": "9726882a45051aac98a647547b28a37d8eff0129",
        "first_name": "contact 01",
        "last_name": "last name",
        "email": "[email protected]",
        "phone": "+38394944"
    }, {
        "first_name": "contact 03",
        "last_name": null,
        "email": "[email protected]",
        "phone": "+38394944"
    }]
    }
}
    

Response

    
{
    "id": "423c6d20d7e26c137e13bf14ad886aae55a1c8d1",
    "organization_id": "daa71f0644647c0d82dd2d03d0b29779644b1a48",
    "name": "new contact",
    "address": "New Address",
    "city": "New City",
    "zip_code": "3370",
    "country_code": "BE",
    "email": "[email protected]",
    "fax": "+3847550505",
    "phone": "+384940405",
    "tax_number": "BE364474748484",
    "is_client": false,
    "is_supplier": true,
    "contact_persons": [{
        "id": "9726882a45051aac98a647547b28a37d8eff0129",
        "first_name": "contact 01",
        "last_name": "last name",
        "email": "[email protected]",
        "phone": "+38394944"
    }, {
        "id": "c582e984e8fa1eafaf42f3a2158a5a65aa7120a0",
        "first_name": "contact 03",
        "last_name": null,
        "email": "[email protected]",
        "phone": "+38394944"
   }]
}
    

As you can see contact 01 got updated because we supplied the id in the update request. Contact 02 was deleted because it was not part of the update request. Contact 03 was added as a new contact person because no id was supplied.

Parameters not supplied were not updated. If you want to remove a parameter you explicitly need to set it to null.