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

# Create Agent Action

> Create a new action for a voice AI agent. Actions define specific behaviors and capabilities for the agent during calls.

Create a new action for a voice AI agent. Actions define specific behaviors and capabilities for the agent during calls.

```http
POST https://services.leadconnectorhq.com/voice-ai/actions
```

## Authorization

| Name | Type | Required | Example | Description |
| --- | --- | --- | --- | --- |
| `Authorization` | string | Yes |   | Bearer token generated from the Leadway portal. See [Authentication](https://developers.leadwaycrm.com/authentication). |
| `Version` | string | Yes | `2021-07-28` | API version. |

## Body

| Name | Type | Required | Example | Description |
| --- | --- | --- | --- | --- |
| `agentId` | string | Yes | `507f1f77bcf86cd799439011` | Agent ID to attach the action to |
| `locationId` | string | Yes | `507f1f77bcf86cd799439012` | Account ID |
| `actionType` | string | Yes | `CALL_TRANSFER` | Type of action Possible values: 'CALL\_TRANSFER', 'DATA\_EXTRACTION', 'IN\_CALL\_DATA\_EXTRACTION', 'WORKFLOW\_TRIGGER', 'SMS', 'APPOINTMENT\_BOOKING', 'CUSTOM\_ACTION', 'KNOWLEDGE\_BASE' |
| `name` | string | Yes | `Transfer to Manager` | Human-readable name for this action |
| `actionParameters` | object | Yes |   | Action parameters - structure varies by actionType |

## Responses

**201 - Action created successfully**

- `id` (string, required): Unique identifier for the created action Example: `507f1f77bcf86cd799439011`
- `actionType` (string, required): Type of action Possible values: 'CALL\_TRANSFER', 'DATA\_EXTRACTION', 'IN\_CALL\_DATA\_EXTRACTION', 'WORKFLOW\_TRIGGER', 'SMS', 'APPOINTMENT\_BOOKING', 'CUSTOM\_ACTION', 'KNOWLEDGE\_BASE' Example: `CALL_TRANSFER`
- `name` (string, required): Human-readable name for this action Example: `Transfer to Manager`
- `actionParameters` (object, required): Action parameters - structure varies by actionType

```json
{
  "id": "507f1f77bcf86cd799439011",
  "actionType": "CALL_TRANSFER",
  "name": "Transfer to Manager"
}
```

**400 - Bad Request**

```json
{}
```

**401 - Unauthorized**

```json
{}
```

**422 - Unprocessable Entity**

```json
{}
```

## Example

```bash cURL
curl -X POST 'https://services.leadconnectorhq.com/voice-ai/actions' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Version: 2021-07-28' \
  -H 'Content-Type: application/json' \
  -d '{
  "agentId": "507f1f77bcf86cd799439011",
  "locationId": "507f1f77bcf86cd799439012",
  "actionType": "CALL_TRANSFER",
  "name": "Transfer to Manager"
}'
```

```javascript Node.js
const response = await fetch('https://services.leadconnectorhq.com/voice-ai/actions', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
    Version: '2021-07-28',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"agentId": "507f1f77bcf86cd799439011", "locationId": "507f1f77bcf86cd799439012", "actionType": "CALL_TRANSFER", "name": "Transfer to Manager"}),
});
const data = await response.json();
```

```python Python
import os, requests
response = requests.request(
    'POST',
    'https://services.leadconnectorhq.com/voice-ai/actions',
    headers={
        'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
        'Version': '2021-07-28',
        'Content-Type': 'application/json',
    },
    json={"agentId": "507f1f77bcf86cd799439011", "locationId": "507f1f77bcf86cd799439012", "actionType": "CALL_TRANSFER", "name": "Transfer to Manager"},
)
data = response.json()
```

```php PHP
<?php
$ch = curl_init('https://services.leadconnectorhq.com/voice-ai/actions');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
        'Version: 2021-07-28',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode({'agentId': '507f1f77bcf86cd799439011', 'locationId': '507f1f77bcf86cd799439012', 'actionType': 'CALL_TRANSFER', 'name': 'Transfer to Manager'}),
]);
$data = json_decode(curl_exec($ch), true);
```
