CRMchat APIBeta

Updating Resources

How partial updates work using JSON Merge Patch (RFC 7396)

View in Markdown

The CRMchat API uses JSON Merge Patch (RFC 7396) for partial updates via PATCH endpoints.

TL;DR

  • Send a PATCH request with Content-Type: application/merge-patch+json.
  • Include only the fields you want to change.
  • Send null to remove a field.
InputEffect
Field omittedNo change
{ "name": "New" }Sets name to "New"
{ "name": null }Removes name (optional fields only)
{ "telegram": { "id": 123456 } }Updates only telegram.id
{ "telegram": { "id": null } }Removes telegram.id
{ "telegram": null }Removes all fields inside telegram
{ "tags": ["vip", "enterprise"] }Replaces the entire tags array
{ "tags": [] }Clears the tags array

Content Type

Per RFC 7396, PATCH requests should use:

Content-Type: application/merge-patch+json

For convenience, application/json is also accepted with the same merge-patch semantics. Requests with any other Content-Type receive a 415 Unsupported Media Type response.

Example

curl -X PATCH https://api.crmchat.ai/v1/organizations/abc123 \
  -H "Authorization: Bearer sk_your_api_key" \
  -H "Content-Type: application/merge-patch+json" \
  -d '{ "name": "New Name" }'
Response (200)
{
  "data": {
    "id": "abc123",
    "name": "New Name",
    "createdAt": "2026-03-12T10:00:00.000Z",
    "updatedAt": "2026-03-12T10:05:00.000Z"
  }
}

Removing Fields

Per RFC 7396, sending null for a key means "remove this field". Only optional fields can be set to null — required fields reject null values with a 400 error.

For nested objects, sending null for the parent removes all fields inside it. You can also target individual subfields:

Remove a single subfield
{ "telegram": { "id": null } }
Remove all fields inside telegram
{ "telegram": null }

Updating Arrays

JSON Merge Patch does not support partial array updates — there is no way to add, remove, or reorder individual items. When a field is an array, you must always send the complete replacement array.

Replace the full array
{ "tags": ["vip", "enterprise"] }

Sending a partial array does not merge — it overwrites. If you send ["vip"] when the current value is ["vip", "enterprise"], the result is ["vip"].

To remove all items, send an empty array:

Clear the array
{ "tags": [] }

Sending null for an array field removes the field entirely (if it is optional). To keep the field but empty it, send [] instead.

Unknown Fields

Unknown or non-writable fields in the request body are silently ignored, consistent with the merge-patch philosophy of "ignore what you don't understand".

Error Responses

StatusCodeWhen
400BAD_REQUESTMalformed JSON or validation failure
415UNSUPPORTED_MEDIA_TYPEMissing or wrong Content-Type header

Authorization errors (401, 403, 404) are the same as for other endpoints. See Authentication for details.

On this page