Custom variables
A campaign's custom contact fields and whether AI may read them.
Path parameters
The endpoints whose path names one of these take it as described here. An endpoint's own table lists a path parameter only when it describes it differently.
| Name | In | Type | Required | Description |
|---|---|---|---|---|
campaignId | path | integer (int64) | required | Id of the campaign. |
variableKey | path | string | required | Key of the variable, such as renewal_date. Kenso normalizes it as on create. |
Headers
The endpoints on this page take these headers. Each endpoint's curl shows the ones it sends.
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Ken-Version | header | string, one of: 2026-11-02, 1.1 | optional | The API version, a date in YYYY-MM-DD form. 1.1 is another name for the first dated version. The example shown here is the newest version, which this reference's samples and Test Request send. Leave it out to use your API key's pinned version. Keys created in the Kenso app are pinned to the newest version; keys minted by the CLI login are not. A key with no pinned version and no header gets the legacy shape where the path has one, and 404 where the path exists only in this version. A date that is not a version answers 400 unsupported_version; any other value that is not a version is treated as legacy. |
X-Ken-Workspace-Id | header | integer (int64) | optional | The id of the workspace to act in. Leave it out when your API key reaches only one workspace. When the key reaches more than one, a request without this header answers 400 workspace_required. A workspace you are not a member of answers 404 not_found. |
List a campaign's custom variables
/v1/campaigns/{campaignId}/custom-variablescustom-variables.list- Permission
- Campaigns view
- Rate limit
- 12,000 requests a minute per API key
Returns the campaign's custom variables, ordered by key. Use q to keep the variables whose key or name contains the text.
Errors:
400 validation_failed:limitis outside 1 to 200, orcursoris not valid.404 not_found: the campaign does not exist in this workspace.
Requires Campaigns view.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
q | query | string | optional | Text to find in the key or the name, ignoring case. Omitted returns every variable. |
limit | query | integer (int32) | optional | Page size, from 1 to 200. Defaults to 50. |
cursor | query | string | optional | The nextCursor of the previous page. Omit it for the first page. |
curl -X GET "https://api.ken.so/v1/campaigns/812/custom-variables?limit=50" \
-H "Authorization: Bearer $KENSO_API_KEY" \
-H "Ken-Version: 2026-11-02" \
-H "X-Ken-Workspace-Id: $KENSO_WORKSPACE_ID"Response 200
data is a list of CustomVariable. Each item has these fields. The response also carries pagination.
Show the 5 response fields and an example
The fields and an example are also on this endpoint's Markdown page.
Create a custom variable
/v1/campaigns/{campaignId}/custom-variablescustom-variables.create- Permission
- Campaigns edit
- Rate limit
- 4,800 requests a minute per API key
Adds a custom variable to the campaign, so its sequence steps can use the {key} token before any contact has a value for it. Returns 201 with the variable and its Location.
variableKey is required. Kenso normalizes it to lowercase snake_case, so Renewal Date becomes renewal_date. The normalized key must start with a letter and hold only letters, digits and underscores. It cannot be a field Kenso fills itself, such as first_name, email or custom_image. name defaults to the key.
When the campaign already has the key, the call updates that variable and still returns 201. It applies useAsAiContext and isRequiredForSending if you send them, and keeps the stored name.
Errors:
400 validation_failed:variableKeyis missing, cannot be used as a token or is a reserved field, or the campaign already has 50 custom variables.404 not_found: the campaign does not exist in this workspace.
Requires Campaigns edit.
Request body
application/json, optional.
The variable to create.
| Field | Type | Required | Description |
|---|---|---|---|
variableKey | string | required | Key of the variable. Required. Kenso normalizes it to lowercase snake_case, so Renewal Date becomes renewal_date. |
name | string | optional | Display name. Omitted uses the normalized key. |
useAsAiContext | boolean | optional | Whether Ken reads this variable as context for AI content. Omitted is true for a new variable and keeps the value of an existing one. |
isRequiredForSending | boolean | optional | Whether a contact needs a value for this variable to be ready to send. Omitted is false for a new variable and keeps the value of an existing one. |
curl -X POST "https://api.ken.so/v1/campaigns/812/custom-variables" \
-H "Authorization: Bearer $KENSO_API_KEY" \
-H "Ken-Version: 2026-11-02" \
-H "X-Ken-Workspace-Id: $KENSO_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"variableKey": "string",
"name": "string",
"useAsAiContext": true,
"isRequiredForSending": true
}'Response 201
data is a CustomVariable.
Show the 5 response fields and an example
The fields and an example are also on this endpoint's Markdown page.
Update a custom variable
/v1/campaigns/{campaignId}/custom-variables/{variableKey}custom-variables.update- Permission
- Campaigns edit
- Rate limit
- 4,800 requests a minute per API key
Changes a custom variable's name or settings. Fields you leave out keep their value, and a blank name keeps the current name. The key never changes.
Errors:
400 validation_failed:variableKeyin the path cannot be used as a key.404 not_found: the campaign or the variable does not exist in this workspace.
Requires Campaigns edit.
Request body
application/json, optional.
The fields to change.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | optional | New display name. Omitted or blank keeps the current name. |
useAsAiContext | boolean | optional | Whether Ken reads this variable as context for AI content. Omitted keeps the current value. |
isRequiredForSending | boolean | optional | Whether a contact needs a value for this variable to be ready to send. Omitted keeps the current value. |
curl -X PATCH "https://api.ken.so/v1/campaigns/812/custom-variables/renewal_date" \
-H "Authorization: Bearer $KENSO_API_KEY" \
-H "Ken-Version: 2026-11-02" \
-H "X-Ken-Workspace-Id: $KENSO_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"name": "string",
"useAsAiContext": true,
"isRequiredForSending": true
}'Response 200
data is a CustomVariable.
Show the 5 response fields and an example
The fields and an example are also on this endpoint's Markdown page.
Delete a custom variable
/v1/campaigns/{campaignId}/custom-variables/{variableKey}custom-variables.delete- Permission
- Campaigns edit
- Rate limit
- 4,800 requests a minute per API key
Removes the variable from the campaign. Returns 204. Values that contacts already have for the key stay on the contacts.
Errors:
400 validation_failed:variableKeyin the path cannot be used as a key.404 not_found: the campaign or the variable does not exist in this workspace.
Requires Campaigns edit.
curl -X DELETE "https://api.ken.so/v1/campaigns/812/custom-variables/renewal_date" \
-H "Authorization: Bearer $KENSO_API_KEY" \
-H "Ken-Version: 2026-11-02" \
-H "X-Ken-Workspace-Id: $KENSO_WORKSPACE_ID"Response 204
HTTP/1.1 204 No ContentMore in Copy and personalization:AI promptsPrompt versionsImage variablesCopy gradesCopy checksVoicesVoice notesVoice note previewsMessage templatesAll resources