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

# X (Twitter)

> Monitor X mentions and direct messages and respond from within PingBack.

Connecting an X (Twitter) channel lets you receive Direct Messages and mentions as PingBack conversations. Agents can reply from within PingBack and the reply is posted back on X.

<Note>X is available on the **Mini** and **Pro** plans only.</Note>

## Prerequisites

Before you start, you need an **X Developer App** with the following settings configured in the [X Developer Portal](https://developer.twitter.com/):

* **App permissions**: Read and Write
* **Direct Message access**: Enabled
* All four credentials generated: **API Key**, **API Key Secret**, **Access Token**, and **Access Token Secret**
* A **Bearer Token** for the app

## Setup

<Steps>
  <Step title="Gather your X credentials">
    From your X Developer App dashboard, collect the following five values:

    | Field                 | Where to find it                              |
    | --------------------- | --------------------------------------------- |
    | `api_key`             | App **Keys and Tokens** > API Key             |
    | `api_secret`          | App **Keys and Tokens** > API Key Secret      |
    | `access_token`        | App **Keys and Tokens** > Access Token        |
    | `access_token_secret` | App **Keys and Tokens** > Access Token Secret |
    | `bearer_token`        | App **Keys and Tokens** > Bearer Token        |
  </Step>

  <Step title="Create the X channel in PingBack">
    Send a `POST` request to `/api/v1/channels/` with `type` set to `"x"` and all five credentials in the `config` object.

    <CodeGroup>
      ```bash curl theme={null}
      curl -X POST https://api.pingback.live/api/v1/channels/ \
        -H "Authorization: Bearer <your_token>" \
        -H "Content-Type: application/json" \
        -d '{
          "type": "x",
          "config": {
            "api_key": "xxxxxxxxxxxxxxxxxxxxxxxxx",
            "api_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "access_token": "0000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "access_token_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "bearer_token": "AAAAAAAAAAAAAAAAAAAAAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
          },
          "is_active": true
        }'
      ```

      ```json response theme={null}
      {
        "id": 74,
        "type": "x",
        "is_active": true,
        "config": {
          "api_key": "xxxxxxxxxxxxxxxxxxxxxxxxx",
          "api_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          "access_token": "0000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          "access_token_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          "bearer_token": "AAAAAAAAAAAAAAAAAAAAAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        }
      }
      ```
    </CodeGroup>

    <Warning>If either `api_key` or `access_token` is missing, PingBack will reject the request with a `400` error.</Warning>
  </Step>

  <Step title="Webhook registration (automatic)">
    PingBack automatically registers a webhook endpoint for your X channel at:

    ```
    https://api.pingback.live/api/v1/webhooks/x/{channel_id}
    ```

    Where `{channel_id}` is the numeric `id` returned in the response above. You may need to register this URL as the webhook endpoint in your X Developer App's **Dev Environments** section if you are using the Account Activity API.
  </Step>

  <Step title="Test the connection">
    Send a Direct Message to your connected X account from another account. The message should appear as a new conversation in your PingBack inbox within seconds.
  </Step>
</Steps>
