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

# Authentication

> Generate an API token and authenticate your requests with the x-api-key header.

Every Clapvo API request must be authenticated with a **personal access token**, passed in the `x-api-key` header. You generate and manage these tokens from the **Developer** section of Clapvo.

```bash theme={null}
x-api-key: <YOUR_API_TOKEN>
```

## Generate an API token

Personal access tokens function like ordinary access tokens — they authenticate your scripts and integrations to the Clapvo API.

<Steps>
  <Step title="Open the Developer section">
    In the left sidebar, under **Manage**, click **Developer**, then open the **API Tokens** tab. If you haven't created one yet, you'll see an empty state.

    <Frame>
      <img src="https://mintcdn.com/clapvo/wWBlwsB4KjPuxM4V/images/developer_api_tokens_empty.png?fit=max&auto=format&n=wWBlwsB4KjPuxM4V&q=85&s=b87f3cd0d2bb19189d47465f4c27b7e7" alt="Empty API Tokens tab in the Developer section" width="1912" height="941" data-path="images/developer_api_tokens_empty.png" />
    </Frame>
  </Step>

  <Step title="Click Generate new token">
    Select **Generate new token** in the top right to open the **Create API Token** form.
  </Step>

  <Step title="Name the token">
    Enter an **API Key Name** that describes where the token will be used (for example, `Order notifications` or `CRM integration`). This helps you identify the token later.
  </Step>

  <Step title="Set an expiration">
    Choose an **Expiration** for the token. Pick a shorter window for temporary use, or a longer one for a permanent integration.
  </Step>

  <Step title="Select the events">
    Under **Events**, choose what this token is allowed to do. For sending messages, check **Messaging → Send Message**. A token can only trigger the events you select here.

    <Frame>
      <img src="https://mintcdn.com/clapvo/wWBlwsB4KjPuxM4V/images/developer_create_api_token.png?fit=max&auto=format&n=wWBlwsB4KjPuxM4V&q=85&s=5af24550757ec9a8ab4707074e1a6af6" alt="Create API Token form with the Send Message event selected" width="1912" height="941" data-path="images/developer_create_api_token.png" />
    </Frame>
  </Step>

  <Step title="Generate the key">
    Click **Generate API Key**. The new token appears in your **API Tokens** list.
  </Step>
</Steps>

## Copy and store your token

In the **API Tokens** list, each token is masked by default. Use the **eye** icon to reveal it and the **copy** icon to copy it to your clipboard.

<Frame>
  <img src="https://mintcdn.com/clapvo/wWBlwsB4KjPuxM4V/images/developer_api_tokens_list.png?fit=max&auto=format&n=wWBlwsB4KjPuxM4V&q=85&s=db302de96c48ee8dbfdc9cbc08b638df" alt="API Tokens list showing a generated token" width="1912" height="941" data-path="images/developer_api_tokens_list.png" />
</Frame>

<Warning>
  Treat your token like a password. Copy it as soon as it's created and store it somewhere secure. Never expose it in client-side code, public repositories, or shared links. If a token is leaked, delete it from the list and generate a new one.
</Warning>

## Use the token in a request

Pass the token in the `x-api-key` header on every request:

```bash theme={null}
curl --request POST \
  --url https://api.clapvo.com/chat/api/v1/public/message/send \
  --header 'x-api-key: <YOUR_API_TOKEN>' \
  --header 'Content-Type: application/json' \
  --data '{
    "from": "918495632548",
    "message": {
      "type": "message",
      "message": "ok public"
    },
    "to": "918965742135"
  }'
```

Requests sent without a valid token, or with a token that lacks the required event, are rejected.

## Next steps

* [Send a message](/docs/api-reference/messages/send-a-message) — try the endpoint live with your token.
