# Get an action

`GET https://api.chat-data.com/api/v2/get-action/{chatbotId}`

Canonical: https://www.chat-data.com/api-reference/get-action

## Authentication

Send an API key as a Bearer token: `Authorization: Bearer $CHAT_DATA_API_KEY`. Workspace keys reach every chatbot in the workspace; chatbot-scoped keys reach only their chatbot. Keep keys on the server.

## Description

Retrieves a specific action by name or index for the specified chatbot. Send exactly one of `name` or `index`.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| chatbotId | path | string | yes | The unique identifier allocated to the chatbot. |
| name | query | string | no | The name of the action to retrieve (mutually exclusive with `index`). |
| index | query | integer | no | The index of the action to retrieve (mutually exclusive with `name`). |

## Example request

```bash
curl 'https://api.chat-data.com/api/v2/get-action/6650f1c2a9e4b83d2c7a1f05?index=0' \
  -H "Authorization: Bearer $CHAT_DATA_API_KEY"
```

## Example response (200)

```json
{
  "status": "success",
  "action": {
    "index": 0,
    "name": "stockPriceLookup",
    "description": "The user wants to know the current stock price of a company",
    "type": "api",
    "url": "https://api.example.com/stocks/{symbol}/price",
    "method": "GET",
    "headers": [
      {
        "name": "Authorization",
        "value": "Bearer stk_live_3f9a2c7d1e"
      }
    ],
    "pathParams": [
      {
        "name": "symbol",
        "type": "string",
        "description": "The stock ticker symbol to look up.",
        "required": true,
        "example": "AAPL"
      }
    ],
    "return_file": false
  }
}
```

## Responses

| Status | Description |
| --- | --- |
| 200 | Successfully retrieved action. |
| 400 | Neither or both of `name` and `index` were provided. |
| 401 | Authentication failed: the `Authorization` header is missing or not in the `Bearer <key>` format, the API key does not exist, its workspace is unavailable or has no owner, or the workspace's plan does not include API access. `message` says which. |
| 403 | The API key cannot access the requested chatbot. A chatbot-scoped key used with another chatbot's ID gets `Access denied to this chatbot`. A workspace key gets `Chatbot <id> was not found in this API key's workspace. It may have been deleted or moved to another workspace.` when the chatbot does not exist or belongs to another workspace. |
| 404 | The chatbot has no action with this name or index. |
| 429 | The workspace sent more than 600 API requests in the last minute. Wait the number of seconds given in the `Retry-After` header (and in `message`) before retrying. |
