> ## Documentation Index
> Fetch the complete documentation index at: https://www.voiceflow.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Functions

API operations for functions. Browse the routes below for parameters, request examples, and responses.

API version: Selected per operation

## List functions

Returns every function in the environment. A function is custom JavaScript that runs in Voiceflow’s sandbox and returns through a named path. The call takes no paging parameters, so one request yields the whole set.

### Endpoint

```http
GET /v1/stable/function
```

Server: https://realtime-api.voiceflow.com

### Authentication

```json
[
  {
    "token": []
  }
]
```

`token`:

```json
{
  "scheme": "bearer",
  "bearerFormat": "JWT",
  "type": "http",
  "description": "Voiceflow bearer token"
}
```

### Query parameters

#### `projectID`

Required · string

The ID of the project to operate on.

```json
{
  "type": "string",
  "description": "The ID of the project to operate on."
}
```

#### `environmentAlias`

Required · string

The alias of the environment to operate on (e.g. `main`).

```json
{
  "type": "string",
  "description": "The alias of the environment to operate on (e.g. `main`)."
}
```

### Responses

#### 200

Returns every function saved in the project's environment, each with its name, description, settings, and full JavaScript source code.

Schema:

```json
{
  "$ref": "#/components/schemas/StableFunctionListResponse"
}
```

Example:

```json
{
  "functions": [
    {
      "id": "<string>",
      "name": "<string>",
      "code": "<string>",
      "image": "<string>",
      "settings": "<FunctionSettings>",
      "createdAt": "2026-09-10T00:00:00.000Z",
      "updatedAt": "2026-09-10T00:00:00.000Z",
      "pathOrder": [
        "<string>"
      ],
      "description": "<string>"
    }
  ]
}
```

### Request examples

#### cURL

```bash
curl --request GET \
  --url 'https://realtime-api.voiceflow.com/v1/stable/function?projectID=<projectID>&environmentAlias=<environmentAlias>' \
  --header 'Authorization: Bearer <token>'
```

#### JavaScript

```javascript
const response = await fetch('https://realtime-api.voiceflow.com/v1/stable/function?projectID=<projectID>&environmentAlias=<environmentAlias>', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <token>',
  },
});
const data = await response.json();
```

#### Python

```python
import requests

response = requests.get(
    'https://realtime-api.voiceflow.com/v1/stable/function?projectID=<projectID>&environmentAlias=<environmentAlias>',
    headers={'Authorization': 'Bearer <token>'},
)
data = response.json()
```

#### Voiceflow CLI

```bash
vf function list --project-id <projectID> --environment-alias <environmentAlias>
```


## Create function

Adds a function to the environment, custom JavaScript that runs in Voiceflow’s sandbox and returns through a named path. The response carries the ID that later calls address it by.

### Endpoint

```http
POST /v1/stable/function
```

Server: https://realtime-api.voiceflow.com

### Authentication

```json
[
  {
    "token": []
  }
]
```

`token`:

```json
{
  "scheme": "bearer",
  "bearerFormat": "JWT",
  "type": "http",
  "description": "Voiceflow bearer token"
}
```

### Query parameters

#### `projectID`

Required · string

The ID of the project to operate on.

```json
{
  "type": "string",
  "description": "The ID of the project to operate on."
}
```

#### `environmentAlias`

Required · string

The alias of the environment to operate on (e.g. `main`).

```json
{
  "type": "string",
  "description": "The alias of the environment to operate on (e.g. `main`)."
}
```

### Request body

Required

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/StableFunctionCreateRequest"
      }
    }
  }
}
```

### Responses

#### 201

Creates the function and returns it in full, including its new ID and the JavaScript source stored for it.

Schema:

```json
{
  "$ref": "#/components/schemas/StableFunctionResponse"
}
```

Example:

```json
{
  "function": {
    "id": "<string>",
    "name": "<string>",
    "code": "<string>",
    "image": "<string>",
    "settings": {
      "timeoutMs": 0
    },
    "createdAt": "2026-09-10T00:00:00.000Z",
    "updatedAt": "2026-09-10T00:00:00.000Z",
    "pathOrder": [
      "<string>"
    ],
    "description": "<string>"
  }
}
```

### Request examples

#### cURL

```bash
curl --request POST \
  --url 'https://realtime-api.voiceflow.com/v1/stable/function?projectID=<projectID>&environmentAlias=<environmentAlias>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "<string>",
  "code": "<string>",
  "settings": {
    "timeoutMs": 0
  },
  "description": "<string>"
}'
```

#### JavaScript

```javascript
const response = await fetch('https://realtime-api.voiceflow.com/v1/stable/function?projectID=<projectID>&environmentAlias=<environmentAlias>', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "<string>",
    "code": "<string>",
    "settings": {
      "timeoutMs": 0
    },
    "description": "<string>"
  }),
});
const data = await response.json();
```

#### Python

```python
import requests

response = requests.post(
    'https://realtime-api.voiceflow.com/v1/stable/function?projectID=<projectID>&environmentAlias=<environmentAlias>',
    headers={'Authorization': 'Bearer <token>'},
    json={
      "name": "<string>",
      "code": "<string>",
      "settings": {
        "timeoutMs": 0
      },
      "description": "<string>"
    },
)
data = response.json()
```

#### Voiceflow CLI

```bash
vf function create --project-id <projectID> --environment-alias <environmentAlias> <<'JSON'
{
  "name": "<string>",
  "code": "<string>",
  "settings": {
    "timeoutMs": 0
  },
  "description": "<string>"
}
JSON
```


## Create many functions

Adds several functions to the environment in one request, each taking the fields the single-create call takes. The response carries the created functions in the same shape the list call returns.

### Endpoint

```http
POST /v1/stable/function/batch
```

Server: https://realtime-api.voiceflow.com

### Authentication

```json
[
  {
    "token": []
  }
]
```

`token`:

```json
{
  "scheme": "bearer",
  "bearerFormat": "JWT",
  "type": "http",
  "description": "Voiceflow bearer token"
}
```

### Query parameters

#### `projectID`

Required · string

The ID of the project to operate on.

```json
{
  "type": "string",
  "description": "The ID of the project to operate on."
}
```

#### `environmentAlias`

Required · string

The alias of the environment to operate on (e.g. `main`).

```json
{
  "type": "string",
  "description": "The alias of the environment to operate on (e.g. `main`)."
}
```

### Request body

Required

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/StableFunctionCreateManyRequest"
      }
    }
  }
}
```

### Responses

#### 201

Creates every function in the request and returns them all, each with its own ID, stored JavaScript source, and exit path order.

Schema:

```json
{
  "$ref": "#/components/schemas/StableFunctionListResponse"
}
```

Example:

```json
{
  "functions": [
    {
      "id": "<string>",
      "name": "<string>",
      "code": "<string>",
      "image": "<string>",
      "settings": "<FunctionSettings>",
      "createdAt": "2026-09-10T00:00:00.000Z",
      "updatedAt": "2026-09-10T00:00:00.000Z",
      "pathOrder": [
        "<string>"
      ],
      "description": "<string>"
    }
  ]
}
```

### Request examples

#### cURL

```bash
curl --request POST \
  --url 'https://realtime-api.voiceflow.com/v1/stable/function/batch?projectID=<projectID>&environmentAlias=<environmentAlias>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "functions": [
    {
      "name": "<string>",
      "code": "<string>",
      "settings": "<FunctionSettings>",
      "description": "<string>"
    }
  ]
}'
```

#### JavaScript

```javascript
const response = await fetch('https://realtime-api.voiceflow.com/v1/stable/function/batch?projectID=<projectID>&environmentAlias=<environmentAlias>', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "functions": [
      {
        "name": "<string>",
        "code": "<string>",
        "settings": "<FunctionSettings>",
        "description": "<string>"
      }
    ]
  }),
});
const data = await response.json();
```

#### Python

```python
import requests

response = requests.post(
    'https://realtime-api.voiceflow.com/v1/stable/function/batch?projectID=<projectID>&environmentAlias=<environmentAlias>',
    headers={'Authorization': 'Bearer <token>'},
    json={
      "functions": [
        {
          "name": "<string>",
          "code": "<string>",
          "settings": "<FunctionSettings>",
          "description": "<string>"
        }
      ]
    },
)
data = response.json()
```

#### Voiceflow CLI

```bash
vf function create-many --project-id <projectID> --environment-alias <environmentAlias> <<'JSON'
{
  "functions": [
    {
      "name": "<string>",
      "code": "<string>",
      "settings": "<FunctionSettings>",
      "description": "<string>"
    }
  ]
}
JSON
```


## Get function

Returns a single function by ID, with the fields that define it. A function is custom JavaScript that runs in Voiceflow’s sandbox and returns through a named path.

### Endpoint

```http
GET /v1/stable/function/{functionID}
```

Server: https://realtime-api.voiceflow.com

### Authentication

```json
[
  {
    "token": []
  }
]
```

`token`:

```json
{
  "scheme": "bearer",
  "bearerFormat": "JWT",
  "type": "http",
  "description": "Voiceflow bearer token"
}
```

### Path parameters

#### `functionID`

Required · string

The ID of the function to operate on.

```json
{
  "type": "string"
}
```

### Query parameters

#### `projectID`

Required · string

The ID of the project to operate on.

```json
{
  "type": "string",
  "description": "The ID of the project to operate on."
}
```

#### `environmentAlias`

Required · string

The alias of the environment to operate on (e.g. `main`).

```json
{
  "type": "string",
  "description": "The alias of the environment to operate on (e.g. `main`)."
}
```

### Responses

#### 200

Returns a single function, including the JavaScript source that runs when it is called and the ordered list of path IDs that controls the display order of its exit paths.

Schema:

```json
{
  "$ref": "#/components/schemas/StableFunctionResponse"
}
```

Example:

```json
{
  "function": {
    "id": "<string>",
    "name": "<string>",
    "code": "<string>",
    "image": "<string>",
    "settings": {
      "timeoutMs": 0
    },
    "createdAt": "2026-09-10T00:00:00.000Z",
    "updatedAt": "2026-09-10T00:00:00.000Z",
    "pathOrder": [
      "<string>"
    ],
    "description": "<string>"
  }
}
```

### Request examples

#### cURL

```bash
curl --request GET \
  --url 'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>?projectID=<projectID>&environmentAlias=<environmentAlias>' \
  --header 'Authorization: Bearer <token>'
```

#### JavaScript

```javascript
const response = await fetch('https://realtime-api.voiceflow.com/v1/stable/function/<functionID>?projectID=<projectID>&environmentAlias=<environmentAlias>', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <token>',
  },
});
const data = await response.json();
```

#### Python

```python
import requests

response = requests.get(
    'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>?projectID=<projectID>&environmentAlias=<environmentAlias>',
    headers={'Authorization': 'Bearer <token>'},
)
data = response.json()
```

#### Voiceflow CLI

```bash
vf function get --function-id <functionID> --project-id <projectID> --environment-alias <environmentAlias>
```


## Update function

Changes an existing function in place. The response carries only a confirmation message, so refetch the function to read its new values.

### Endpoint

```http
PATCH /v1/stable/function/{functionID}
```

Server: https://realtime-api.voiceflow.com

### Authentication

```json
[
  {
    "token": []
  }
]
```

`token`:

```json
{
  "scheme": "bearer",
  "bearerFormat": "JWT",
  "type": "http",
  "description": "Voiceflow bearer token"
}
```

### Path parameters

#### `functionID`

Required · string

The ID of the function to operate on.

```json
{
  "type": "string"
}
```

### Query parameters

#### `projectID`

Required · string

The ID of the project to operate on.

```json
{
  "type": "string",
  "description": "The ID of the project to operate on."
}
```

#### `environmentAlias`

Required · string

The alias of the environment to operate on (e.g. `main`).

```json
{
  "type": "string",
  "description": "The alias of the environment to operate on (e.g. `main`)."
}
```

### Request body

Required

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StableFunctionUpdateRequest"
          }
        ]
      }
    }
  }
}
```

### Responses

#### 200

Confirms the function was updated. Only a message is returned, not the revised function, so fetch the function again to read back its saved code.

Schema:

```json
{
  "$ref": "#/components/schemas/StableUpdateResponse"
}
```

Example:

```json
{
  "message": "<string>"
}
```

### Request examples

#### cURL

```bash
curl --request PATCH \
  --url 'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>?projectID=<projectID>&environmentAlias=<environmentAlias>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "<string>",
  "code": "<string>",
  "settings": {
    "timeoutMs": 0
  },
  "pathOrder": [
    "<string>"
  ],
  "description": "<string>"
}'
```

#### JavaScript

```javascript
const response = await fetch('https://realtime-api.voiceflow.com/v1/stable/function/<functionID>?projectID=<projectID>&environmentAlias=<environmentAlias>', {
  method: 'PATCH',
  headers: {
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "<string>",
    "code": "<string>",
    "settings": {
      "timeoutMs": 0
    },
    "pathOrder": [
      "<string>"
    ],
    "description": "<string>"
  }),
});
const data = await response.json();
```

#### Python

```python
import requests

response = requests.patch(
    'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>?projectID=<projectID>&environmentAlias=<environmentAlias>',
    headers={'Authorization': 'Bearer <token>'},
    json={
      "name": "<string>",
      "code": "<string>",
      "settings": {
        "timeoutMs": 0
      },
      "pathOrder": [
        "<string>"
      ],
      "description": "<string>"
    },
)
data = response.json()
```

#### Voiceflow CLI

```bash
vf function update --function-id <functionID> --project-id <projectID> --environment-alias <environmentAlias> <<'JSON'
{
  "name": "<string>",
  "code": "<string>",
  "settings": {
    "timeoutMs": 0
  },
  "pathOrder": [
    "<string>"
  ],
  "description": "<string>"
}
JSON
```


## Delete function

Deletes a single function by ID. A function is custom JavaScript that runs in Voiceflow’s sandbox and returns through a named path. The response carries only a confirmation message, so refetch the functions to see what is left.

### Endpoint

```http
DELETE /v1/stable/function/{functionID}
```

Server: https://realtime-api.voiceflow.com

### Authentication

```json
[
  {
    "token": []
  }
]
```

`token`:

```json
{
  "scheme": "bearer",
  "bearerFormat": "JWT",
  "type": "http",
  "description": "Voiceflow bearer token"
}
```

### Path parameters

#### `functionID`

Required · string

The ID of the function to operate on.

```json
{
  "type": "string"
}
```

### Query parameters

#### `projectID`

Required · string

The ID of the project to operate on.

```json
{
  "type": "string",
  "description": "The ID of the project to operate on."
}
```

#### `environmentAlias`

Required · string

The alias of the environment to operate on (e.g. `main`).

```json
{
  "type": "string",
  "description": "The alias of the environment to operate on (e.g. `main`)."
}
```

### Responses

#### 200

Confirms the function was deleted. The response is a message, not the removed function, so its JavaScript source is not recoverable from this call.

Schema:

```json
{
  "$ref": "#/components/schemas/StableDeleteResponse"
}
```

Example:

```json
{
  "message": "<string>"
}
```

### Request examples

#### cURL

```bash
curl --request DELETE \
  --url 'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>?projectID=<projectID>&environmentAlias=<environmentAlias>' \
  --header 'Authorization: Bearer <token>'
```

#### JavaScript

```javascript
const response = await fetch('https://realtime-api.voiceflow.com/v1/stable/function/<functionID>?projectID=<projectID>&environmentAlias=<environmentAlias>', {
  method: 'DELETE',
  headers: {
    Authorization: 'Bearer <token>',
  },
});
const data = await response.json();
```

#### Python

```python
import requests

response = requests.delete(
    'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>?projectID=<projectID>&environmentAlias=<environmentAlias>',
    headers={'Authorization': 'Bearer <token>'},
)
data = response.json()
```

#### Voiceflow CLI

```bash
vf function delete --function-id <functionID> --project-id <projectID> --environment-alias <environmentAlias>
```


## Get function schema

Returns what a function takes and gives back: its input variables, its output variables, and its exit paths, read from the environment's draft. Call it before executing to learn the input names.

### Endpoint

```http
GET /v1/stable/function/{functionID}/schema
```

Server: https://realtime-api.voiceflow.com

### Authentication

```json
[
  {
    "token": []
  }
]
```

`token`:

```json
{
  "scheme": "bearer",
  "bearerFormat": "JWT",
  "type": "http",
  "description": "Voiceflow bearer token"
}
```

### Path parameters

#### `functionID`

Required · string

The ID of the function whose schema to read.

```json
{
  "type": "string"
}
```

### Query parameters

#### `projectID`

Required · string

The ID of the project to operate on.

```json
{
  "type": "string",
  "description": "The ID of the project to operate on."
}
```

#### `environmentAlias`

Required · string

The alias of the environment to operate on (e.g. `main`).

```json
{
  "type": "string",
  "description": "The alias of the environment to operate on (e.g. `main`)."
}
```

### Responses

#### 200

Returns the function's inputs, output variables, and exit path names.

Schema:

```json
{
  "$ref": "#/components/schemas/StableFunctionSchemaReadResponse"
}
```

Example:

```json
{
  "inputs": [
    {
      "name": "<string>",
      "type": "<string>",
      "required": true,
      "description": "<string>"
    }
  ],
  "outputs": [
    {
      "name": "<string>",
      "description": "<string>"
    }
  ],
  "paths": [
    "<string>"
  ]
}
```

### Request examples

#### cURL

```bash
curl --request GET \
  --url 'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>/schema?projectID=<projectID>&environmentAlias=<environmentAlias>' \
  --header 'Authorization: Bearer <token>'
```

#### JavaScript

```javascript
const response = await fetch('https://realtime-api.voiceflow.com/v1/stable/function/<functionID>/schema?projectID=<projectID>&environmentAlias=<environmentAlias>', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <token>',
  },
});
const data = await response.json();
```

#### Python

```python
import requests

response = requests.get(
    'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>/schema?projectID=<projectID>&environmentAlias=<environmentAlias>',
    headers={'Authorization': 'Bearer <token>'},
)
data = response.json()
```

#### Voiceflow CLI

```bash
vf function get-schema --function-id <functionID> --project-id <projectID> --environment-alias <environmentAlias>
```


## Execute function

Runs the saved draft of a function once with the inputs in the body, without compiling the agent or starting a conversation. The run stops at the function's timeout or 18 seconds, whichever is shorter, and nothing is saved.

### Endpoint

```http
POST /v1/stable/function/{functionID}/execute
```

Server: https://realtime-api.voiceflow.com

### Authentication

```json
[
  {
    "token": []
  }
]
```

`token`:

```json
{
  "scheme": "bearer",
  "bearerFormat": "JWT",
  "type": "http",
  "description": "Voiceflow bearer token"
}
```

### Path parameters

#### `functionID`

Required · string

The ID of the function to execute.

```json
{
  "type": "string"
}
```

### Query parameters

#### `projectID`

Required · string

The ID of the project to operate on.

```json
{
  "type": "string",
  "description": "The ID of the project to operate on."
}
```

#### `environmentAlias`

Required · string

The alias of the environment to operate on (e.g. `main`).

```json
{
  "type": "string",
  "description": "The alias of the environment to operate on (e.g. `main`)."
}
```

### Request body

Required

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/StableFunctionExecuteRequest"
      }
    }
  }
}
```

### Responses

#### 200

Returns the function's output variables, the exit path it chose, and the traces it emitted, with success, latencyMs, and error fields.

Schema:

```json
{
  "$ref": "#/components/schemas/StableFunctionExecuteResponse"
}
```

Example:

```json
{
  "success": true,
  "latencyMs": 0,
  "error": "<string>",
  "truncated": true,
  "output": {
    "outputVars": {},
    "path": "<string>",
    "traces": [
      "<StableFunctionExecuteTrace>"
    ]
  }
}
```

### Request examples

#### cURL

```bash
curl --request POST \
  --url 'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>/execute?projectID=<projectID>&environmentAlias=<environmentAlias>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "inputs": {}
}'
```

#### JavaScript

```javascript
const response = await fetch('https://realtime-api.voiceflow.com/v1/stable/function/<functionID>/execute?projectID=<projectID>&environmentAlias=<environmentAlias>', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "inputs": {}
  }),
});
const data = await response.json();
```

#### Python

```python
import requests

response = requests.post(
    'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>/execute?projectID=<projectID>&environmentAlias=<environmentAlias>',
    headers={'Authorization': 'Bearer <token>'},
    json={
      "inputs": {}
    },
)
data = response.json()
```

#### Voiceflow CLI

```bash
vf function execute --function-id <functionID> --project-id <projectID> --environment-alias <environmentAlias> <<'JSON'
{
  "inputs": {}
}
JSON
```


## Check function

Run a function's saved code on test cases and compare the results.

### Endpoint

```http
POST /v1/stable/function/{functionID}/check
```

Server: https://realtime-api.voiceflow.com

### Authentication

```json
[
  {
    "token": []
  }
]
```

`token`:

```json
{
  "scheme": "bearer",
  "bearerFormat": "JWT",
  "type": "http",
  "description": "Voiceflow bearer token"
}
```

### Path parameters

#### `functionID`

Required · string



```json
{
  "type": "string"
}
```

### Query parameters

#### `projectID`

Required · string

The ID of the project to operate on.

```json
{
  "type": "string",
  "description": "The ID of the project to operate on."
}
```

#### `environmentAlias`

Required · string

The alias of the environment to operate on (e.g. `main`).

```json
{
  "type": "string",
  "description": "The alias of the environment to operate on (e.g. `main`)."
}
```

### Request body

Required

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/StableFunctionCheckRequest"
      }
    }
  }
}
```

### Responses

#### 200

Schema:

```json
{
  "$ref": "#/components/schemas/StableFunctionCheckResponse"
}
```

Example:

```json
{
  "checked": false,
  "reason": "<string>"
}
```

### Request examples

#### cURL

```bash
curl --request POST \
  --url 'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>/check?projectID=<projectID>&environmentAlias=<environmentAlias>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "cases": [
    {
      "name": "<string>",
      "inputs": {},
      "expectPath": "<string>",
      "expectOutputs": {}
    }
  ]
}'
```

#### JavaScript

```javascript
const response = await fetch('https://realtime-api.voiceflow.com/v1/stable/function/<functionID>/check?projectID=<projectID>&environmentAlias=<environmentAlias>', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "cases": [
      {
        "name": "<string>",
        "inputs": {},
        "expectPath": "<string>",
        "expectOutputs": {}
      }
    ]
  }),
});
const data = await response.json();
```

#### Python

```python
import requests

response = requests.post(
    'https://realtime-api.voiceflow.com/v1/stable/function/<functionID>/check?projectID=<projectID>&environmentAlias=<environmentAlias>',
    headers={'Authorization': 'Bearer <token>'},
    json={
      "cases": [
        {
          "name": "<string>",
          "inputs": {},
          "expectPath": "<string>",
          "expectOutputs": {}
        }
      ]
    },
)
data = response.json()
```

#### Voiceflow CLI

```bash
vf function check --function-id <functionID> --project-id <projectID> --environment-alias <environmentAlias> <<'JSON'
{
  "cases": [
    {
      "name": "<string>",
      "inputs": {},
      "expectPath": "<string>",
      "expectOutputs": {}
    }
  ]
}
JSON
```


## Schema definitions

### ExecuteInputString

```json
{
  "type": "string",
  "description": "A value sent to a tool for one run, never stored. Plain text. {secret_name} inserts a project secret: the server fills in the value this environment would use in a conversation, and the value reads [secret] wherever it appears in the result. Brace text is a token when the text between the braces has no space at either end and holds only letters, digits, underscores, inner spaces, ., [, ], $ or -. A token that names no project secret, such as {customer_id} or {var name}, is refused before the tool runs, because a single run has no conversation to read a variable from: pass the value itself. Any other brace text is sent as written, so code, JSON and GraphQL such as query { user { id } } run as they are. Compact brace text such as {id} still reads as a token: write { id } to send it as text. A secret whose name is not letters, digits and underscores cannot be referenced. A {secret_name} token is filled in only in a top-level string value of inputs. Inside a nested object or array it is sent as written, and no secret is filled in."
}
```

### FunctionSettings

```json
{
  "type": "object",
  "properties": {
    "timeoutMs": {
      "type": "integer",
      "minimum": 0,
      "exclusiveMinimum": true,
      "maximum": 600000
    }
  }
}
```

### StableDeleteResponse

```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "A human-readable message confirming the deletion."
    }
  },
  "required": [
    "message"
  ]
}
```

### StableExecuteInput

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "The input name, used as its key in `inputs` when executing."
    },
    "type": {
      "type": "string",
      "description": "The JSON type the value must have, such as `string`, `number` or `boolean`. Always `string` for a function or an API tool, and `any` when an MCP tool does not say."
    },
    "required": {
      "type": "boolean",
      "description": "Whether execute needs a value for this input."
    },
    "description": {
      "nullable": true,
      "description": "What the input holds, as the tool describes it.",
      "type": "string"
    }
  },
  "required": [
    "name",
    "type",
    "required",
    "description"
  ]
}
```

### StableFunction

```json
{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "code": {
      "type": "string",
      "maxLength": 1048576,
      "description": "The JavaScript source code executed when the function runs."
    },
    "image": {
      "nullable": true,
      "description": "The URL of the image displayed for the function in the Voiceflow UI.",
      "type": "string"
    },
    "settings": {
      "nullable": true,
      "allOf": [
        {
          "$ref": "#/components/schemas/FunctionSettings"
        }
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
    },
    "pathOrder": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "An ordered list of path IDs controlling the display order of the function's exit paths."
    },
    "description": {
      "nullable": true,
      "description": "A human-readable description of what the function does.",
      "type": "string"
    }
  },
  "required": [
    "id",
    "name",
    "code",
    "image",
    "settings",
    "createdAt",
    "updatedAt",
    "pathOrder",
    "description"
  ]
}
```

### StableFunctionCheckCaseResult

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "ran": {
      "type": "boolean"
    },
    "success": {
      "type": "boolean"
    },
    "path": {
      "nullable": true,
      "type": "string"
    },
    "outputs": {
      "type": "object",
      "additionalProperties": {}
    },
    "error": {
      "nullable": true,
      "type": "string"
    },
    "matched": {
      "type": "boolean"
    },
    "mismatches": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "uncompared": {
      "description": "Expected outputs left uncompared because the run cut a long value.",
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "name",
    "ran",
    "success",
    "path",
    "outputs",
    "error"
  ]
}
```

### StableFunctionCheckRequest

```json
{
  "type": "object",
  "properties": {
    "cases": {
      "minItems": 1,
      "maxItems": 12,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "description": "What this case checks, e.g. \"3 items, at the limit\"."
          },
          "inputs": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "A text value for every input of the function, by input name, as a variable sends it. Send \"0\" for what an unset variable sends."
          },
          "expectPath": {
            "description": "The exit path this case should take. The result says whether it did.",
            "type": "string"
          },
          "expectOutputs": {
            "description": "Output values this case should return, compared as text.",
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "name",
          "inputs"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "cases"
  ],
  "additionalProperties": false
}
```

### StableFunctionCheckResponse

```json
{
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "checked": {
          "type": "boolean",
          "enum": [
            false
          ],
          "x-enumNames": [
            "FALSE"
          ]
        },
        "reason": {
          "type": "string"
        }
      },
      "required": [
        "checked",
        "reason"
      ]
    },
    {
      "type": "object",
      "properties": {
        "checked": {
          "type": "boolean",
          "enum": [
            true
          ],
          "x-enumNames": [
            "TRUE"
          ]
        },
        "functionID": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        },
        "cases": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/StableFunctionCheckCaseResult"
          }
        }
      },
      "required": [
        "checked",
        "functionID",
        "summary",
        "cases"
      ]
    }
  ]
}
```

### StableFunctionCreateManyRequest

```json
{
  "type": "object",
  "properties": {
    "functions": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/StableFunctionCreateRequest"
      }
    }
  },
  "required": [
    "functions"
  ]
}
```

### StableFunctionCreateRequest

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "code": {
      "type": "string",
      "maxLength": 1048576,
      "description": "The JavaScript source code executed when the function runs."
    },
    "settings": {
      "nullable": true,
      "allOf": [
        {
          "$ref": "#/components/schemas/FunctionSettings"
        }
      ]
    },
    "description": {
      "nullable": true,
      "description": "A human-readable description of what the function does.",
      "type": "string"
    }
  },
  "required": [
    "name",
    "code"
  ],
  "additionalProperties": false
}
```

### StableFunctionExecuteOutput

```json
{
  "type": "object",
  "properties": {
    "outputVars": {
      "type": "object",
      "additionalProperties": {},
      "description": "The output variables the function returned, keyed by name. At runtime only string, number and boolean values reach a variable."
    },
    "path": {
      "nullable": true,
      "description": "The exit path the function chose with `next: { path }`, or null when it chose none.",
      "type": "string"
    },
    "traces": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/StableFunctionExecuteTrace"
      },
      "description": "The traces the function emitted, in order. A failed run may carry a `debug` trace that says why, but not always."
    }
  },
  "required": [
    "outputVars",
    "path",
    "traces"
  ]
}
```

### StableFunctionExecuteRequest

```json
{
  "type": "object",
  "properties": {
    "inputs": {
      "default": {},
      "description": "A value for each of the function's input variables, keyed by input name. Every declared input needs a value, and a name the function does not declare is refused. List them with get_schema.",
      "type": "object",
      "additionalProperties": {
        "$ref": "#/components/schemas/ExecuteInputString"
      }
    }
  },
  "additionalProperties": false
}
```

### StableFunctionExecuteResponse

```json
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean",
      "description": "Whether the tool ran and reported no error."
    },
    "latencyMs": {
      "type": "number",
      "description": "How long the run took, in milliseconds, measured by this API around the call."
    },
    "error": {
      "nullable": true,
      "description": "Why the run failed when `success` is false, otherwise null. Secret values read `[secret]`.",
      "type": "string"
    },
    "truncated": {
      "type": "boolean",
      "description": "Whether a returned payload was over 64 KB and was cut to its first 64 KB of JSON text, which then arrives as a string."
    },
    "output": {
      "nullable": true,
      "description": "What the function returned, on failure too. Null only when general-runtime did not answer in time.",
      "allOf": [
        {
          "$ref": "#/components/schemas/StableFunctionExecuteOutput"
        }
      ]
    }
  },
  "required": [
    "success",
    "latencyMs",
    "error",
    "truncated",
    "output"
  ]
}
```

### StableFunctionExecuteTrace

```json
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "description": "The trace type, such as `text`, `speak`, `choice`, `cardV2` or `debug`."
    },
    "payload": {
      "description": "The trace payload as the function emitted it. Secret values read `[secret]`."
    }
  },
  "required": [
    "type",
    "payload"
  ]
}
```

### StableFunctionListResponse

```json
{
  "type": "object",
  "properties": {
    "functions": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/StableFunction"
      }
    }
  },
  "required": [
    "functions"
  ]
}
```

### StableFunctionResponse

```json
{
  "type": "object",
  "properties": {
    "function": {
      "$ref": "#/components/schemas/StableFunction"
    }
  },
  "required": [
    "function"
  ]
}
```

### StableFunctionSchemaOutput

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "The output variable name, a key of `outputVars`."
    },
    "description": {
      "nullable": true,
      "description": "What the output variable holds, as written on the function.",
      "type": "string"
    }
  },
  "required": [
    "name",
    "description"
  ]
}
```

### StableFunctionSchemaReadResponse

```json
{
  "type": "object",
  "properties": {
    "inputs": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/StableExecuteInput"
      },
      "description": "The inputs execute takes, one per input variable, sorted by name. Every one is a required string."
    },
    "outputs": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/StableFunctionSchemaOutput"
      },
      "description": "The output variables the function may return, sorted by name."
    },
    "paths": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The exit path names the function may return with `next: { path }`, in path order."
    }
  },
  "required": [
    "inputs",
    "outputs",
    "paths"
  ]
}
```

### StableFunctionUpdateRequest

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "code": {
      "type": "string",
      "maxLength": 1048576,
      "description": "The JavaScript source code executed when the function runs."
    },
    "settings": {
      "nullable": true,
      "allOf": [
        {
          "$ref": "#/components/schemas/FunctionSettings"
        }
      ]
    },
    "pathOrder": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "An ordered list of path IDs controlling the display order of the function's exit paths."
    },
    "description": {
      "nullable": true,
      "description": "A human-readable description of what the function does.",
      "type": "string"
    }
  },
  "additionalProperties": false
}
```

### StableUpdateResponse

```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "A human-readable message confirming the update."
    }
  },
  "required": [
    "message"
  ]
}
```
