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

# Twitter/X Posting API for Automated Tweets | Dohoo

> Use the Dohoo Twitter/X posting API to list connected accounts and publish authenticated tweets programmatically.

The Twitter/X endpoints give you two capabilities: listing your active Twitter/X connections and publishing text tweets to any of those connected accounts. Use the connections endpoint to discover available account IDs, then pass the relevant `connectionId` to the publish endpoint to send a tweet. All requests authenticate with your Dohoo API key.

***

## List Twitter/X connections

Retrieve all active Twitter/X account connections linked to your Dohoo workspace.

### Endpoint

```
GET https://dohoo.ai/api/v2/twitter/connections
```

### Request headers

| Header      | Required | Description        |
| ----------- | -------- | ------------------ |
| `X-API-Key` | ✅        | Your Dohoo API key |

### Example request

```bash theme={null}
curl -X GET https://dohoo.ai/api/v2/twitter/connections \
  -H "X-API-Key: dh_live_xxxxxxxxxxxxxxxxxxxxxxxx"
```

### Example response

```json theme={null}
{
  "success": true,
  "connections": [
    {
      "connectionId": "conn_twitter_001",
      "username": "@yourhandle",
      "displayName": "Your Name",
      "status": "active",
      "connectedAt": "2024-11-01T08:00:00Z"
    },
    {
      "connectionId": "conn_twitter_002",
      "username": "@brandhandle",
      "displayName": "Brand Account",
      "status": "active",
      "connectedAt": "2024-12-15T12:30:00Z"
    }
  ]
}
```

***

## Publish a tweet

Post a text tweet to a connected Twitter/X account.

### Endpoint

```
POST https://dohoo.ai/api/v2/twitter/publish
```

### Request headers

| Header         | Required | Description                |
| -------------- | -------- | -------------------------- |
| `X-API-Key`    | ✅        | Your Dohoo API key         |
| `Content-Type` | ✅        | Must be `application/json` |

### Request body

| Field          | Type   | Required | Description                                      |
| -------------- | ------ | -------- | ------------------------------------------------ |
| `connectionId` | string | ✅        | The ID of the Twitter/X connection to tweet from |
| `text`         | string | ✅        | The tweet content. Maximum 280 characters        |

### Example request

```bash theme={null}
curl -X POST https://dohoo.ai/api/v2/twitter/publish \
  -H "X-API-Key: dh_live_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "connectionId": "conn_twitter_001",
    "text": "Your tweet text here (max 280 characters)"
  }'
```

### Example response

```json theme={null}
{
  "success": true,
  "platform": "twitter",
  "tweetId": "1879012345678901234",
  "connectionId": "conn_twitter_001",
  "status": "published",
  "publishedAt": "2025-01-15T16:45:00Z",
  "url": "https://x.com/yourhandle/status/1879012345678901234"
}
```

<Note>
  The current Twitter/X API integration supports **text-only tweets**. Media attachments (images, videos, GIFs) are not yet supported but are coming in a future release.
</Note>

<Warning>
  Twitter/X enforces a 280-character limit on tweet text. Requests exceeding this limit will be rejected with a `400 Bad Request` response. Count characters in your application before calling this endpoint.
</Warning>

<Tip>
  Use the `GET /api/v2/twitter/connections` endpoint to programmatically discover all your connected Twitter/X accounts and retrieve their `connectionId` values rather than hardcoding them.
</Tip>
