GET
/
api
/
v1
/
context-variables

Get Context Variable Definitions

Retrieve all context variable definitions for your account. You can filter by context type to get only contact or business variables.

Endpoint

GET /api/v1/context-variables

Authentication

This endpoint requires an API key with the can_read_contacts permission.

Query Parameters

ParameterTypeRequiredDescription
context_typestringNoFilter by context type (contact/business)

Response

{
  "count": 3,
  "variables": [
    {
      "id": 1,
      "name": "last_payment_date",
      "display_name": "Last Payment Date",
      "description": "Date of customer's last payment",
      "variable_type": "date",
      "context_type": "contact",
      "is_default": false,
      "select_options": null
    },
    {
      "id": 2,
      "name": "membership_level",
      "display_name": "Membership Level",
      "description": "Customer's current membership tier",
      "variable_type": "select",
      "context_type": "contact",
      "is_default": false,
      "select_options": ["Bronze", "Silver", "Gold", "Platinum"]
    },
    {
      "id": 3,
      "name": "support_hours",
      "display_name": "Support Hours",
      "description": "Business support hours",
      "variable_type": "text",
      "context_type": "business",
      "is_default": true,
      "select_options": null
    }
  ]
}

Response Properties

PropertyTypeDescription
countintegerTotal number of variable definitions returned
variablesarrayArray of variable definition objects

Variable Definition Object

PropertyTypeDescription
idintegerUnique identifier for the variable definition
namestringVariable name (API identifier, e.g., last_payment_date)
display_namestringUser-friendly display name (e.g., “Last Payment Date”)
descriptionstringOptional description of the variable
variable_typestringData type (text, number, date, boolean, select)
context_typestringContext type (contact, business)
is_defaultbooleanWhether this is a default system variable
select_optionsarrayAvailable options for select type variables

Error Codes

Status CodeError CodeDescription
401authentication_requiredNo API key was provided
401invalid_keyThe API key is invalid or inactive
403permission_deniedThe API key doesn’t have the required permission
500server_errorAn unexpected server error occurred

Example Request

Filter by context type

curl -X GET 'https://api.klen.ai/api/v1/context-variables?context_type=contact' \
  -H 'Authorization: Bearer klen_abcdef123456789'

Get all variables

curl -X GET 'https://api.klen.ai/api/v1/context-variables' \
  -H 'Authorization: Bearer klen_abcdef123456789'

Example Response

{
  "count": 2,
  "variables": [
    {
      "id": 1,
      "name": "last_payment_date",
      "display_name": "Last Payment Date",
      "description": "Date of customer's last payment",
      "variable_type": "date",
      "context_type": "contact",
      "is_default": false,
      "select_options": null
    },
    {
      "id": 2,
      "name": "membership_level",
      "display_name": "Membership Level",
      "description": "Customer's current membership tier",
      "variable_type": "select",
      "context_type": "contact",
      "is_default": false,
      "select_options": ["Bronze", "Silver", "Gold", "Platinum"]
    }
  ]
}

Notes

  • Default variables (is_default: true) are system-provided variables that cannot be deleted
  • The response includes all variable definitions the authenticated user has access to, through direct ownership or team access