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

# API

> Connect a REST channel so your own app can send messages to the agent with an API key

The API channel lets you send customer messages to Botcadence over HTTPS. You get a webhook URL and an API key shown once at create time.

## Prerequisites

* Permission to create channels
* A client that can POST JSON with an `Authorization: Bearer` header

## Connect

<Steps>
  <Step title="Open Channels">
    In the project sidebar, select **Channels**.
  </Step>

  <Step title="Create API">
    Select **API**. Enter **Channel Name** and **API Endpoint Name** (the channel identifier, for example `my-api-endpoint`). Create the channel.
  </Step>

  <Step title="Save the API key">
    Copy **Your API Key** immediately. It is shown only once. Store it somewhere safe.
  </Step>
</Steps>

<Warning>
  If you close the key dialog without copying, rotate the key later in channel settings (**Rotate API Key**). The old key stops working.
</Warning>

## Verify

<Check>
  POST a test message to the webhook URL from the channel list, with `Authorization: Bearer` and your key. The conversation appears in [Conversations](/docs/operate/conversations).
</Check>

## Use it

**Webhook URL:** the endpoint shown for this channel (organization, project, and channel id).

**Authentication:** `Authorization: Bearer YOUR_API_KEY`

**Example:**

```bash theme={null}
curl -X POST "https://backend.botcadence.com/organizations/ORG_ID/projects/PROJECT_ID/channels/CHANNEL_ID/webhook" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message_id": "msg_123456",
    "user_id": "user123",
    "message": "Hello, how can you help me?",
    "message_type": "text",
    "conversation_id": "conv_001"
  }'
```

Replace `ORG_ID`, `PROJECT_ID`, `CHANNEL_ID`, and `YOUR_API_KEY` with your values. Do not commit real keys.

In channel settings you can rename the channel. **Channel Identifier** cannot change. Use **API Key Management** to see a masked key and rotate it.

## Limits

* One API key is active at a time. Rotate invalidates the previous key.
* The identifier is fixed after create.

## Troubleshooting

<AccordionGroup>
  <Accordion title="401 or unauthorized">
    Use the current key after a rotate. Send `Authorization: Bearer` with no extra quotes around the token.
  </Accordion>

  <Accordion title="I lost the key">
    Open the API channel settings and choose **Rotate API Key**. Copy the new key once.
  </Accordion>

  <Accordion title="No conversation appears">
    Confirm the URL includes the correct organization, project, and channel ids, and that the JSON includes `message` and `user_id`.
  </Accordion>
</AccordionGroup>
