> ## 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.

# Update Agent Action

> Update an existing action for a voice AI agent. Modifies the behavior and configuration of an agent action.

Update an existing action for a voice AI agent. Modifies the behavior and configuration of an agent action.

```http theme={null}
PUT https://services.leadconnectorhq.com/voice-ai/actions/{actionId}
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Path parameters

<ParamField path="actionId" type="string" required>
  Unique identifier for the action
</ParamField>

## Body

<ParamField body="agentId" type="string" required default="507f1f77bcf86cd799439011">
  Agent ID to attach the action to
</ParamField>

<ParamField body="locationId" type="string" required default="507f1f77bcf86cd799439012">
  Account ID
</ParamField>

<ParamField body="actionType" type="string" required default="CALL_TRANSFER">
  Type of action Posibles valores: 'CALL\_TRANSFER', 'DATA\_EXTRACTION', 'IN\_CALL\_DATA\_EXTRACTION', 'WORKFLOW\_TRIGGER', 'SMS', 'APPOINTMENT\_BOOKING', 'CUSTOM\_ACTION', 'KNOWLEDGE\_BASE'
</ParamField>

<ParamField body="name" type="string" required default="Transfer to Manager">
  Human-readable name for this action
</ParamField>

<ParamField body="actionParameters" type="object" required>
  Action parameters - structure varies by actionType
</ParamField>

## Respuestas

<Accordion title="200 - Action updated successfully">
  <ResponseField name="id" type="string" required default="507f1f77bcf86cd799439011">
    Unique identifier for the created action
  </ResponseField>

  <ResponseField name="actionType" type="string" required default="CALL_TRANSFER">
    Type of action Posibles valores: 'CALL\_TRANSFER', 'DATA\_EXTRACTION', 'IN\_CALL\_DATA\_EXTRACTION', 'WORKFLOW\_TRIGGER', 'SMS', 'APPOINTMENT\_BOOKING', 'CUSTOM\_ACTION', 'KNOWLEDGE\_BASE'
  </ResponseField>

  <ResponseField name="name" type="string" required default="Transfer to Manager">
    Human-readable name for this action
  </ResponseField>

  <ResponseField name="actionParameters" type="object" required>
    Action parameters - structure varies by actionType
  </ResponseField>

  ```json theme={null}
  {
    "id": "507f1f77bcf86cd799439011",
    "actionType": "CALL_TRANSFER",
    "name": "Transfer to Manager"
  }
  ```
</Accordion>

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT 'https://services.leadconnectorhq.com/voice-ai/actions/YOUR_actionId' \
    -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 theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/voice-ai/actions/YOUR_actionId', {
    method: 'PUT',
    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 theme={null}
  import os, requests
  response = requests.request(
      'PUT',
      'https://services.leadconnectorhq.com/voice-ai/actions/YOUR_actionId',
      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 theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/voice-ai/actions/YOUR_actionId');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'PUT',
      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);
  ```
</CodeGroup>
