# Variables

URL: https://www.callshift.ai/docs/api/variables

Named values of the account that agents say in their prompts and use as transfer numbers, with a default value and one value per entity.

## List variables

`GET /v1/variables`

Bearer API key

A variable is a named value used in agent prompts as `{{variable.key}}`, the key being the camelCase form of its name ("Current offer" gives `currentOffer`), and as the destination of a call transfer. It has a default value, for all entities, and each entity can have its own, which replaces it. On a call, the value is the one of the call's entity: the agent's entity, or the line's when the agent is shared.

Variables are sorted by name, each with the entities that have their own value and the number of agents using it.

### Authorization

- `Authorization` (string, required): `Bearer <API key>`, a key created at app.callshift.ai/api-keys.

### Responses

**200**

Variables retrieved successfully

- `data` (object[], required)

  - `id` (string<uuid>, required) · example `7c9e6679-7425-40de-944b-e07fc1f90ae7`
  - `key` (string, required): What an agent writes after `variable.`: the camelCase form of the name. · example `currentOffer`
  - `name` (string, required) · example `Current offer`
  - `value` (string | null, required): The default value, for all entities, or `null` when there is none. · example `First month free`
  - `entityValues` (object[], required): The entities that have their own value.

    - `entityId` (string<uuid>, required) · example `550e8400-e29b-41d4-a716-446655440000`
    - `value` (string, required)
  - `createdAt` (string, required) · example `2026-01-01T00:00:00.000Z`
  - `updatedAt` (string, required) · example `2026-01-01T00:00:00.000Z`
  - `agents` (integer, required): The agents whose prompts or transfers use the variable. · example `3`

**401**

Unauthorized

- `error` (string, required)

**500**

Internal server error

- `error` (string, required)

**Request**

**cURL**

```bash
curl "https://api.callshift.ai/v1/variables" \
  -H "Authorization: Bearer $CALLSHIFT_API_KEY"
```

**JavaScript**

```javascript
const res = await fetch("https://api.callshift.ai/v1/variables", {
  headers: {
    Authorization: `Bearer ${process.env.CALLSHIFT_API_KEY}`,
  },
});
const data = await res.json();
```

**Python**

```python
import os
import requests

res = requests.get(
    "https://api.callshift.ai/v1/variables",
    headers={"Authorization": f"Bearer {os.environ['CALLSHIFT_API_KEY']}"},
)
print(res.json())
```

**Response**

**200**

```json
{
  "data": [
    {
      "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
      "key": "currentOffer",
      "name": "Current offer",
      "value": "First month free",
      "entityValues": [
        {
          "entityId": "550e8400-e29b-41d4-a716-446655440000",
          "value": "string"
        }
      ],
      "createdAt": "2026-01-01T00:00:00.000Z",
      "updatedAt": "2026-01-01T00:00:00.000Z",
      "agents": 3
    }
  ]
}
```

**401**

```json
{
  "error": "Authentication error"
}
```

**500**

```json
{
  "error": "Internal server error"
}
```

## Create a variable

`POST /v1/variables`

Bearer API key

A variable is a named value used in agent prompts as `{{variable.key}}`, the key being the camelCase form of its name ("Current offer" gives `currentOffer`), and as the destination of a call transfer. It has a default value, for all entities, and each entity can have its own, which replaces it. On a call, the value is the one of the call's entity: the agent's entity, or the line's when the agent is shared.

The name is in plain words and cannot be changed afterwards; its camelCase form is the key, unique within the account. The value is the default value, for all entities; leave it out when only entities have a value.

### Authorization

- `Authorization` (string, required): `Bearer <API key>`, a key created at app.callshift.ai/api-keys.

### Body application/json

- `name` (string, required) · 1 to 255 characters
- `value` (string | null) · up to 10000 characters

### Responses

**201**

Variable created successfully

- `id` (string<uuid>, required) · example `7c9e6679-7425-40de-944b-e07fc1f90ae7`
- `key` (string, required): What an agent writes after `variable.`: the camelCase form of the name. · example `currentOffer`
- `name` (string, required) · example `Current offer`
- `value` (string | null, required): The default value, for all entities, or `null` when there is none. · example `First month free`
- `entityValues` (object[], required): The entities that have their own value.

  - `entityId` (string<uuid>, required) · example `550e8400-e29b-41d4-a716-446655440000`
  - `value` (string, required)
- `createdAt` (string, required) · example `2026-01-01T00:00:00.000Z`
- `updatedAt` (string, required) · example `2026-01-01T00:00:00.000Z`

**400**

Invalid request body

**Validation Error Response**

- `success` (enum<boolean>, required) · allowed: `false`
- `error` (object, required)

  - `name` (enum<string>, required) · allowed: `ZodError`
  - `issues` (object[], required)

    - `code` (string, required) · example `invalid_enum_value`
    - `path` (string | number[], required)
    - `message` (string, required) · example `Invalid email`

**Error Response**

- `error` (string, required)

**401**

Unauthorized

- `error` (string, required)

**409**

Another variable already has the key this name gives

- `error` (string, required)

**415**

The body was not sent as `application/json`

- `error` (string, required)

**500**

Internal server error

- `error` (string, required)

**Request**

**cURL**

```bash
curl -X POST "https://api.callshift.ai/v1/variables" \
  -H "Authorization: Bearer $CALLSHIFT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Current offer",
    "value": "First month free"
  }'
```

**JavaScript**

```javascript
const res = await fetch("https://api.callshift.ai/v1/variables", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CALLSHIFT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "Current offer",
    "value": "First month free"
  }),
});
const data = await res.json();
```

**Python**

```python
import os
import requests

res = requests.post(
    "https://api.callshift.ai/v1/variables",
    headers={"Authorization": f"Bearer {os.environ['CALLSHIFT_API_KEY']}"},
    json={
        "name": "Current offer",
        "value": "First month free",
    },
)
print(res.json())
```

**Response**

**201**

```json
{
  "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "key": "currentOffer",
  "name": "Current offer",
  "value": "First month free",
  "entityValues": [
    {
      "entityId": "550e8400-e29b-41d4-a716-446655440000",
      "value": "string"
    }
  ],
  "createdAt": "2026-01-01T00:00:00.000Z",
  "updatedAt": "2026-01-01T00:00:00.000Z"
}
```

**400**

```json
{
  "success": false,
  "error": {
    "name": "ZodError",
    "issues": [
      {
        "code": "invalid_enum_value",
        "path": [
          "contacts",
          0,
          "email"
        ],
        "message": "Invalid email"
      }
    ]
  }
}
```

**401**

```json
{
  "error": "Authentication error"
}
```

**409**

```json
{
  "error": "Another variable already has the key this name gives"
}
```

**415**

```json
{
  "error": "The body was not sent as `application/json`"
}
```

**500**

```json
{
  "error": "Internal server error"
}
```

## Update a variable's default value

`PATCH /v1/variables/{variableId}`

Bearer API key

Change or remove the default value, the one for all entities. Entities that have their own value keep it. The change applies to the next call of every agent using the variable.

### Authorization

- `Authorization` (string, required): `Bearer <API key>`, a key created at app.callshift.ai/api-keys.

### Path parameters

- `variableId` (string<uuid>, required) · example `7c9e6679-7425-40de-944b-e07fc1f90ae7`

### Body application/json

The default value, for all entities. `null` removes it; entities keep their own.

- `value` (string | null, required) · up to 10000 characters

### Responses

**200**

Variable updated successfully

- `success` (boolean, required)

**400**

Invalid request body

**Validation Error Response**

- `success` (enum<boolean>, required) · allowed: `false`
- `error` (object, required)

  - `name` (enum<string>, required) · allowed: `ZodError`
  - `issues` (object[], required)

    - `code` (string, required) · example `invalid_enum_value`
    - `path` (string | number[], required)
    - `message` (string, required) · example `Invalid email`

**Error Response**

- `error` (string, required)

**401**

Unauthorized

- `error` (string, required)

**404**

Variable not found

- `error` (string, required)

**415**

The body was not sent as `application/json`

- `error` (string, required)

**500**

Internal server error

- `error` (string, required)

**Request**

**cURL**

```bash
curl -X PATCH "https://api.callshift.ai/v1/variables/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer $CALLSHIFT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "Two weeks free"
  }'
```

**JavaScript**

```javascript
const res = await fetch("https://api.callshift.ai/v1/variables/550e8400-e29b-41d4-a716-446655440000", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.CALLSHIFT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "value": "Two weeks free"
  }),
});
const data = await res.json();
```

**Python**

```python
import os
import requests

res = requests.patch(
    "https://api.callshift.ai/v1/variables/550e8400-e29b-41d4-a716-446655440000",
    headers={"Authorization": f"Bearer {os.environ['CALLSHIFT_API_KEY']}"},
    json={
        "value": "Two weeks free",
    },
)
print(res.json())
```

**Response**

**200**

```json
{
  "success": true
}
```

**400**

```json
{
  "success": false,
  "error": {
    "name": "ZodError",
    "issues": [
      {
        "code": "invalid_enum_value",
        "path": [
          "contacts",
          0,
          "email"
        ],
        "message": "Invalid email"
      }
    ]
  }
}
```

**401**

```json
{
  "error": "Authentication error"
}
```

**404**

```json
{
  "error": "Variable not found"
}
```

**415**

```json
{
  "error": "The body was not sent as `application/json`"
}
```

**500**

```json
{
  "error": "Internal server error"
}
```

## Delete a variable

`DELETE /v1/variables/{variableId}`

Bearer API key

Delete a variable and every entity's own value of it. While an agent still uses it the request is refused with the number of agents, rather than leaving their prompts or transfers with a blank.

### Authorization

- `Authorization` (string, required): `Bearer <API key>`, a key created at app.callshift.ai/api-keys.

### Path parameters

- `variableId` (string<uuid>, required) · example `7c9e6679-7425-40de-944b-e07fc1f90ae7`

### Responses

**204**

Variable deleted successfully

No content.

**401**

Unauthorized

- `error` (string, required)

**404**

Variable not found

- `error` (string, required)

**409**

Agents still use the variable. Remove it from their prompts and transfers first.

- `error` (string, required)
- `agents` (integer, required)

**500**

Internal server error

- `error` (string, required)

**Request**

**cURL**

```bash
curl -X DELETE "https://api.callshift.ai/v1/variables/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer $CALLSHIFT_API_KEY"
```

**JavaScript**

```javascript
const res = await fetch("https://api.callshift.ai/v1/variables/550e8400-e29b-41d4-a716-446655440000", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.CALLSHIFT_API_KEY}`,
  },
});
console.log(res.status); // 204
```

**Python**

```python
import os
import requests

res = requests.delete(
    "https://api.callshift.ai/v1/variables/550e8400-e29b-41d4-a716-446655440000",
    headers={"Authorization": f"Bearer {os.environ['CALLSHIFT_API_KEY']}"},
)
print(res.status_code)  # 204
```

**Response**

**204**

```
No content
```

**401**

```json
{
  "error": "Authentication error"
}
```

**404**

```json
{
  "error": "Variable not found"
}
```

**409**

```json
{
  "error": "Agents still use the variable. Remove it from their prompts and transfers first",
  "agents": 0
}
```

**500**

```json
{
  "error": "Internal server error"
}
```

## Get the variable values of an entity

`GET /v1/entities/{entityId}/variables`

Bearer API key

The value each variable takes on a call of this entity: the entity's own, else the default value.

### Authorization

- `Authorization` (string, required): `Bearer <API key>`, a key created at app.callshift.ai/api-keys.

### Path parameters

- `entityId` (string<uuid>, required) · example `550e8400-e29b-41d4-a716-446655440000`

### Responses

**200**

Values retrieved successfully

- `values` (object, required): The value each variable takes for the entity: its own, else the default value. A variable with neither is left out.

**401**

Unauthorized

- `error` (string, required)

**404**

Entity not found

- `error` (string, required)

**500**

Internal server error

- `error` (string, required)

**Request**

**cURL**

```bash
curl "https://api.callshift.ai/v1/entities/550e8400-e29b-41d4-a716-446655440000/variables" \
  -H "Authorization: Bearer $CALLSHIFT_API_KEY"
```

**JavaScript**

```javascript
const res = await fetch("https://api.callshift.ai/v1/entities/550e8400-e29b-41d4-a716-446655440000/variables", {
  headers: {
    Authorization: `Bearer ${process.env.CALLSHIFT_API_KEY}`,
  },
});
const data = await res.json();
```

**Python**

```python
import os
import requests

res = requests.get(
    "https://api.callshift.ai/v1/entities/550e8400-e29b-41d4-a716-446655440000/variables",
    headers={"Authorization": f"Bearer {os.environ['CALLSHIFT_API_KEY']}"},
)
print(res.json())
```

**Response**

**200**

```json
{
  "values": {
    "currentOffer": "No joining fee"
  }
}
```

**401**

```json
{
  "error": "Authentication error"
}
```

**404**

```json
{
  "error": "Entity not found"
}
```

**500**

```json
{
  "error": "Internal server error"
}
```

## Set the variable values of an entity

`PUT /v1/entities/{entityId}/variables`

Bearer API key

Give an entity its own values, by variable key, in one call. Answers with the value each variable now takes for the entity. The change applies to the entity's next call.

### Authorization

- `Authorization` (string, required): `Bearer <API key>`, a key created at app.callshift.ai/api-keys.

### Path parameters

- `entityId` (string<uuid>, required) · example `550e8400-e29b-41d4-a716-446655440000`

### Body application/json

The entity's own values, by variable key. `null` clears the entity's own value, so the variable takes the default value again. Variables left out are unchanged.

- `values` (object, required)

### Responses

**200**

Values written successfully

- `values` (object, required): The value each variable takes for the entity: its own, else the default value. A variable with neither is left out.

**400**

Invalid request body

**Validation Error Response**

- `success` (enum<boolean>, required) · allowed: `false`
- `error` (object, required)

  - `name` (enum<string>, required) · allowed: `ZodError`
  - `issues` (object[], required)

    - `code` (string, required) · example `invalid_enum_value`
    - `path` (string | number[], required)
    - `message` (string, required) · example `Invalid email`

**Error Response**

- `error` (string, required)

**401**

Unauthorized

- `error` (string, required)

**404**

Entity not found

- `error` (string, required)

**415**

The body was not sent as `application/json`

- `error` (string, required)

**422**

A key matches no variable. Nothing was written.

- `error` (string, required)
- `keys` (string[], required)

**500**

Internal server error

- `error` (string, required)

**Request**

**cURL**

```bash
curl -X PUT "https://api.callshift.ai/v1/entities/550e8400-e29b-41d4-a716-446655440000/variables" \
  -H "Authorization: Bearer $CALLSHIFT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "values": {
      "currentOffer": "No joining fee",
      "openingHours": null
    }
  }'
```

**JavaScript**

```javascript
const res = await fetch("https://api.callshift.ai/v1/entities/550e8400-e29b-41d4-a716-446655440000/variables", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.CALLSHIFT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "values": {
      "currentOffer": "No joining fee",
      "openingHours": null
    }
  }),
});
const data = await res.json();
```

**Python**

```python
import os
import requests

res = requests.put(
    "https://api.callshift.ai/v1/entities/550e8400-e29b-41d4-a716-446655440000/variables",
    headers={"Authorization": f"Bearer {os.environ['CALLSHIFT_API_KEY']}"},
    json={
        "values": {
            "currentOffer": "No joining fee",
            "openingHours": None,
        },
    },
)
print(res.json())
```

**Response**

**200**

```json
{
  "values": {
    "currentOffer": "No joining fee"
  }
}
```

**400**

```json
{
  "success": false,
  "error": {
    "name": "ZodError",
    "issues": [
      {
        "code": "invalid_enum_value",
        "path": [
          "contacts",
          0,
          "email"
        ],
        "message": "Invalid email"
      }
    ]
  }
}
```

**401**

```json
{
  "error": "Authentication error"
}
```

**404**

```json
{
  "error": "Entity not found"
}
```

**415**

```json
{
  "error": "The body was not sent as `application/json`"
}
```

**422**

```json
{
  "error": "A key matches no variable. Nothing was written",
  "keys": [
    "string"
  ]
}
```

**500**

```json
{
  "error": "Internal server error"
}
```
