Set context variables for a specific contact
Set context variables for a specific contact. These variables can be used for personalization in AI calls, templates, and other communications.
This endpoint requires an API key with the can_write_contacts
permission.
Parameter | Type | Required | Description |
---|---|---|---|
contact_id | integer | Yes | ID of the contact |
Parameter | Type | Required | Description |
---|---|---|---|
variables | object | Yes | Map of variable names to values |
auto_create_variables | boolean | No | Whether to automatically create undefined variables |
Status Code | Error Code | Description |
---|---|---|
400 | invalid_json | Invalid JSON payload |
400 | invalid_value | A variable value doesn’t match its defined type |
400 | undefined_variable | A variable is not defined (when auto_create_variables is false) |
401 | authentication_required | No API key was provided |
401 | invalid_key | The API key is invalid or inactive |
403 | permission_denied | The API key doesn’t have the required permission |
404 | not_found | Contact not found or you do not have access |
500 | server_error | An unexpected server error occurred |
Values are validated against the variable’s defined type:
Type | Valid Values | Examples |
---|---|---|
text | Any string | "Premium Support" |
number | Numbers, numeric strings | 250.50 , "42" |
date | ISO date strings | "2023-12-01" , "2023-01-15T14:30:00Z" |
boolean | Boolean values, boolean strings | true , false , "true" , "yes" , "1" |
select | Value from predefined options | Must match one of the defined options |
When auto_create_variables
is set to true
:
last_payment_date
→ “Last Payment Date”)When auto_create_variables
is false
(default):
null
will remove it from the contact’s context