Adding a new record

Use the POST methods on the API to create new records.

POST /api/organisation

In the following example we’re using curl to create a new organisation record.

curl -u d4a581cceff06c03a47015643661ee75:x -H "Content-type:application/xml" -i -d "<organisation><name>New Co.</name></organisation>" https://sample.capsulecrm.com/api/organisation

When the record is created the response header will contain an HTTP status of 201 Created and the Location header contains the URL you can use to retrieve the record over the API. To display the response header in CURL the -i command line option has been added.

Response

HTTP/1.1 201 Created
Location: https://sample.capsulecrm.com/api/party/1000

The content of the Location can be used to with the GET method to retrieve the newly created record.

curl -u d4a581cceff06c03a47015643661ee75:x -H "Accept:application/xml" https://sample.capsulecrm.com/api/party/1000

Adding a record using JSON

Here is the same example creating a new record using JSON instead of XML. When using XML change the Content-type header to application/json.

curl -u d4a581cceff06c03a47015643661ee75:x -H "Content-type:application/json" -i -d '{"organisation": { "name": "New Co."}}' https://sample.capsulecrm.com/api/organisation

Updating an existing record

Use the PUT method on the API to update existing records on the API.

PUT /api/organisation/:party-id
curl -u d4a581cceff06c03a47015643661ee75:x -H "Content-type:application/xml" -i -X PUT -d "<organisation><name>New Company</name></organisation>" https://sample.capsulecrm.com/api/organisation/1000

Response

HTTP/1.1 200 OK

To simplify updates on the API only the details you’re updating need to be included in the XML or JSON document you submit to the API. For example when creating an organisation record the name is required; however when making an update that can be left out if for example you’re only updating contact details. Any details that are not includes in the request body remain unchanged on the record.

Deleting a record

Use the DELETE method to remove record from your account.

DELETE /api/party/:party-id
curl -u d4a581cceff06c03a47015643661ee75:x -i -X DELETE https://sample.capsulecrm.com/api/party/1000

Response

HTTP/1.1 200 OK

Next Step Troubleshooting