Skip to main content
POST
/
ai-agents
/
agent-builder
/
agents
/
variables
/
custom
Create Custom Variable
curl --request POST \
  --url https://{appId}.api-{region}.cometchat.io/v3/ai-agents/agent-builder/agents/variables/custom \
  --header 'Content-Type: application/json' \
  --header 'apikey: <api-key>' \
  --data '
{
  "name": "user.preferred_language",
  "sourceType": "user_metadata",
  "description": "The preferred language of the user",
  "sourcePath": "language",
  "constantValue": "en",
  "defaultValue": "en"
}
'
{
  "_id": "507f1f77bcf86cd799439011",
  "appId": "my-app-id",
  "name": "user.plan",
  "description": "The user subscription plan",
  "sourceType": "user_metadata",
  "sourcePath": "metadata.plan",
  "constantValue": "",
  "defaultValue": "free",
  "category": "custom",
  "createdAt": 1700000000000,
  "updatedAt": 1700000000000
}

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-docs-android-v6-beta2.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

For the complete error reference, see Error Guide.

Authorizations

apikey
string
header
required

API Key (i.e. Rest API Key from the Dashboard).

Body

application/json
name
string
required

Unique variable name. Must start with a letter and contain only alphanumeric characters, underscores, and dots.

Maximum string length: 50
Pattern: ^[a-zA-Z][a-zA-Z0-9_.]*$
Example:

"user.preferred_language"

sourceType
enum<string>
required

Source from which the variable value is resolved

Available options:
message_metadata,
user_metadata,
constant
Example:

"user_metadata"

description
string

Human-readable description of the variable

Maximum string length: 200
Example:

"The preferred language of the user"

sourcePath
string

Dot-notation path to extract the value from the source metadata

Maximum string length: 100
Example:

"language"

constantValue
string

Fixed value used when sourceType is constant

Maximum string length: 500
Example:

"en"

defaultValue
string

Fallback value used when the source path does not resolve

Maximum string length: 200
Example:

"en"

Response

200 - application/json

Custom variable created successfully

_id
string
Example:

"507f1f77bcf86cd799439011"

appId
string
Example:

"my-app-id"

name
string
Example:

"user.plan"

description
string
Example:

"The user subscription plan"

sourceType
string
Example:

"user_metadata"

sourcePath
string
Example:

"metadata.plan"

constantValue
string
Example:

"premium"

defaultValue
string
Example:

"free"

category
string
Example:

"custom"

createdAt
number
Example:

1700000000000

updatedAt
number
Example:

1700000000000