# X API for messages, posts and comments

> Otobiz gives you one REST API for X: 77 endpoints for messages, posts and comments, called with one Bearer key.

Page: https://otobiz.ai/x-api

## Three steps to your first call

### Make an API key

In Otobiz, open API keys and make one. It acts with the role you pick, and is shown once. https://app.otobiz.ai/apikeys

```sh
# The key from Otobiz, under API keys
export OTOBIZ_API_KEY="otbz_..."

curl https://app.otobiz.ai/api/v1/account \
  -H "Authorization: Bearer $OTOBIZ_API_KEY"
```

### Connect X by link

Ask for a connect link and open it. Nothing is connected until you finish the steps there.

```sh
# The answer carries "url": open it to connect X
curl https://app.otobiz.ai/api/v1/connect-sessions \
  -H "Authorization: Bearer $OTOBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "kind": "x" }'
```

### Make one call

Every call is HTTPS and JSON, with the key as a Bearer token.

```sh
# Reply in a X chat
curl https://app.otobiz.ai/api/v1/conversations/$CHAT_ID/messages \
  -H "Authorization: Bearer $OTOBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: reply-1042" \
  -d '{ "text": "Your order ships today." }'
```

```sh
# Save a X post as a draft
curl https://app.otobiz.ai/api/v1/posts \
  -H "Authorization: Bearer $OTOBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: post-12" \
  -d '{ "accounts": ["x"], "content": "Open until 9pm this week." }'

# Publish it now
curl -X POST https://app.otobiz.ai/api/v1/posts/$POST_ID/publish \
  -H "Authorization: Bearer $OTOBIZ_API_KEY"
```

## X endpoints by job

77 endpoints work on X, read from the API's own spec. Every path starts with https://app.otobiz.ai/api/v1.

### Chats and messages (19)

| Method | Path | What it does |
|---|---|---|
| POST | `/conversations/{id}/ai-reply/send` | Send the AI's reply |
| GET | `/inbox/availability` | Who is away, and your own availability |
| PATCH | `/inbox/availability` | Set your own availability |
| GET | `/inbox/conversations` | List chats |
| POST | `/inbox/conversations` | Start a chat |
| GET | `/inbox/conversations/requests` | List message requests |
| GET | `/inbox/conversations/{conversationId}` | Get a conversation |
| GET | `/inbox/conversations/{conversationId}/contact-profile` | Get a Messenger chat's language, time zone and gender |
| POST | `/inbox/conversations/{conversationId}/events` | Record an event on a chat: a fact the agent grounds on, or one it tells the customer about |
| GET | `/inbox/conversations/{conversationId}/members` | List who is in a group conversation |
| GET | `/inbox/conversations/{conversationId}/messages` | Read a conversation's messages |
| POST | `/inbox/conversations/{conversationId}/messages` | Send a message |
| GET | `/inbox/conversations/{conversationId}/messages/{messageId}` | Get a message |
| PATCH | `/inbox/conversations/{conversationId}/messages/{messageId}` | Edit a sent message, or move a scheduled one |
| POST | `/inbox/conversations/{conversationId}/messages/{messageId}/retry` | Send a failed message again |
| GET | `/inbox/items` | List what waits in the Inbox |
| GET | `/inbox/labels` | List the brand's inbox labels |
| POST | `/inbox/labels` | Create an inbox label |
| POST | `/inbox/messages/search` | Search messages |

### Broadcasts (16)

| Method | Path | What it does |
|---|---|---|
| GET | `/broadcasts` | List broadcasts |
| POST | `/broadcasts` | Create a draft broadcast |
| GET | `/broadcasts/calendar` | Upcoming occasions, each with a send day and a counted audience |
| PATCH | `/broadcasts/calendar/choices` | Follow, hide or clear a moment, for every year |
| GET | `/broadcasts/recommendations` | Who to send to next: counted audiences from your customers and campaigns |
| GET | `/broadcasts/senders` | List the accounts a broadcast can send from |
| GET | `/broadcasts/settings` | Get the brand's broadcast settings |
| PATCH | `/broadcasts/settings` | Change the brand's broadcast settings |
| POST | `/broadcasts/test` | Send a test of a broadcast to one address |
| GET | `/broadcasts/{broadcastId}` | Get a broadcast |
| PATCH | `/broadcasts/{broadcastId}` | Update a broadcast |
| DELETE | `/broadcasts/{broadcastId}` | Delete a draft broadcast |
| POST | `/broadcasts/{broadcastId}/cancel` | Cancel a broadcast |
| GET | `/broadcasts/{broadcastId}/recipients` | List a broadcast's recipients |
| POST | `/broadcasts/{broadcastId}/recipients` | Add recipients to a draft broadcast |
| POST | `/broadcasts/{broadcastId}/send` | Send, schedule, resume or retry a broadcast |

### Posts (28)

| Method | Path | What it does |
|---|---|---|
| GET | `/account-groups` | List account groups |
| POST | `/account-groups` | Save an account group |
| PATCH | `/account-groups/{groupId}` | Change an account group |
| DELETE | `/account-groups/{groupId}` | Delete an account group |
| GET | `/posts` | List posts, newest first |
| POST | `/posts` | Save a post draft |
| POST | `/posts/bulk` | Create up to 25 posts in one call |
| POST | `/posts/import` | Import posts from a CSV file |
| GET | `/posts/imports` | List CSV imports of posts |
| GET | `/posts/imports/{postImportId}` | Get a CSV import of posts |
| GET | `/posts/options` | Get an account's publishing facts or choices |
| POST | `/posts/sync` | Check a post made on the platform by its link or id |
| POST | `/posts/validate` | Check a post against each account before posting |
| GET | `/posts/{postId}` | Get a post and its result on each account |
| PATCH | `/posts/{postId}` | Change a post draft, or a live post's recycling or id |
| DELETE | `/posts/{postId}` | Delete a post that never published |
| POST | `/posts/{postId}/approve` | Approve a post waiting for approval |
| POST | `/posts/{postId}/cancel` | Cancel a scheduled post |
| PATCH | `/posts/{postId}/copy` | Correct a published copy's text, pin it, or change a video's details |
| POST | `/posts/{postId}/publish` | Publish a post now or at a time, or move a scheduled post |
| POST | `/posts/{postId}/reject` | Reject a post waiting for approval |
| POST | `/posts/{postId}/unpublish` | Take one published copy down from its platform |
| GET | `/queues` | List an account's posting queues |
| POST | `/queues` | Make a named posting queue |
| GET | `/queues/next-slot` | Get an account's next free queue time |
| PATCH | `/queues/{id}` | Change a posting queue or make it the default |
| DELETE | `/queues/{id}` | Delete a posting queue |
| GET | `/queues/{id}/preview` | Preview a queue's next free times |

### Comments (14)

| Method | Path | What it does |
|---|---|---|
| GET | `/inbox/comments` | List comments on the brand's posts |
| POST | `/inbox/comments/bulk` | Hide, unhide or delete several comments at once |
| GET | `/inbox/comments/moderation/log` | List what the AI comment moderation flagged and did |
| GET | `/inbox/comments/posts` | List posts with their comment counts |
| POST | `/inbox/comments/posts/{postId}` | Post a new comment on a post |
| POST | `/inbox/comments/posts/{postId}/like` | Like a post as a connected account |
| DELETE | `/inbox/comments/posts/{postId}/like` | Take a connected account's like off a post |
| GET | `/inbox/comments/{commentId}` | Get a comment and what can be done to it |
| PATCH | `/inbox/comments/{commentId}` | Update a comment |
| DELETE | `/inbox/comments/{commentId}` | Delete a comment from the platform |
| GET | `/inbox/comments/{commentId}/attachment` | A comment's picture, from our origin |
| POST | `/inbox/comments/{commentId}/like` | Like a comment as the brand |
| DELETE | `/inbox/comments/{commentId}/like` | Take the brand's like off a comment |
| POST | `/inbox/comments/{commentId}/reply` | Reply to a comment. Publicly, or privately as a direct message |

### On every channel

The same four jobs sit beside every channel's own endpoints.

| Method | Path | What it does |
|---|---|---|
| POST | `/connect/sessions` | Get the link where a brand member connects a channel, an app or a saved login |
| GET | `/connect/sessions/{sessionId}` | Where a connect link stands, or wait for it to finish |
| GET | `/connections` | List connections |
| POST | `/connections/{connectionId}/disconnect` | Disconnect one connection |
| GET | `/contacts` | List contacts |
| POST | `/contacts` | Create a contact |
| PATCH | `/contacts/{contactId}` | Update a contact |
| PATCH | `/contacts/{contactId}/consent` | Record a contact's marketing opt-in or opt-out |
| POST | `/files` | Add a file |
| GET | `/files/{fileId}` | Get a file |
| POST | `/webhooks/settings` | Register a webhook endpoint |
| POST | `/webhooks/test` | Send webhook_endpoint.tested to an endpoint |
| GET | `/webhooks/logs` | The webhook delivery log |

## What X takes

- **Message text.** Up to 9,999 characters.
- **Files.** Attachments to 25 MB each.
- **Reply window.** No time limit on replies.
- **Sends a day.** 600 a day for each mailbox.
- **Delivery status.** Sent only. The platform reports no delivery or read.
- **Post text.** Up to 25,000 characters. Over 280 depends on the account's plan with X.
- **Post rules.** Each account's own rules come back from GET /posts/options, and POST /posts/validate checks a post before it goes.
- **Comment reply.** Up to 280 characters.

## What every send carries

- **Consent checked.** Every send checks the contact's consent first. A refused send answers 409 with the reason.
- **Opt-outs hold.** A person who opted out is on the suppression list, and no call can message them.
- **No double sends.** Send an Idempotency-Key header and a retry is safe. The key is remembered for 24 hours.
- **One answer per customer.** A send takes the chat over from an automation in flight, so the customer never gets two replies.
- **Approval where you ask.** A send from an AI agent's key waits for a reviewer and answers 202 approval_required.
- **Every send recorded.** Each send lands in your activity feed, and validateOnly=true runs every check without sending.

## What comes back

POST /inbox/conversations/{conversationId}/messages answers:

- 200: Sent, a note or a scheduled message written, or, with validateOnly=true, the passed check
- 202: Accepted: it goes out shortly (status `queued`)
- 402: The brand has no active plan. Replies are paused
- 403: Your role cannot send replies
- 409: An automated reply is mid-send, this Idempotency-Key is in flight, or this person cannot be messaged here (`first_contact_not_allowed`, `suppressed`, `reconnect_required`)
- 429: Too many requests (`rate_limited`)

Event `message.received`:

```json
{
  "id": "evt_00000000008008000000000000",
  "type": "message.received",
  "apiVersion": "v1",
  "createdAt": "2026-10-09T09:30:00.000Z",
  "data": {
    "object": {
      "id": "msg_01j2jxbb4pex5vsknk084sn041",
      "conversationId": "cnv_01j2jxbb4pex5vsknk084sn03g",
      "channel": "x",
      "direction": "inbound",
      "role": "reply",
      "status": "received",
      "body": "Is the large box in stock?",
      "createdAt": "2026-11-18T09:30:00.000Z"
    }
  }
}
```

Event `message.sent`:

```json
{
  "id": "evt_00000000008008000000000000",
  "type": "message.sent",
  "apiVersion": "v1",
  "createdAt": "2026-10-09T09:30:00.000Z",
  "data": {
    "object": {
      "id": "msg_01j2jxbb4pex5vsknk084sn040",
      "conversationId": "cnv_01j2jxbb4pex5vsknk084sn03g",
      "channel": "x",
      "direction": "outbound",
      "role": "reply",
      "status": "delivered",
      "body": "Yes, the large box is in stock. Shall I keep one for you?",
      "createdAt": "2026-11-18T09:31:00.000Z"
    }
  }
}
```

A shortened sample from the API's own examples. The docs list every field.

```sh
# Register where the events go
curl https://app.otobiz.ai/api/v1/webhook-endpoints \
  -H "Authorization: Bearer $OTOBIZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "My server", "url": "https://example.com/otobiz", "events": ["message.received", "message.sent"] }'
```

## Let an AI app do it

The same operations are tools on the Otobiz MCP server, so an AI app can work X with no code.

You ask: "Which messages on X are waiting on us? Answer the oldest one."

Your AI calls: `list_inbox_conversations`, then `list_inbox_messages`, then `send_inbox_message`.

It lists the open chats, reads the oldest, and sends the reply as you. The send is recorded in Otobiz.

X MCP server: https://otobiz.ai/x-mcp.md

## No fee per call. You pay for your plan.

X comes with every plan. A call pays only for what it causes, such as a message sent. The API and the MCP server come with it. Plans: https://otobiz.ai/pricing

## Questions

### How do I send a X message with an API?

Make an Otobiz API key, connect X by link, then call POST /api/v1/conversations/{id}/messages with the key as a Bearer token.

### How do I connect X to the API?

Call POST /api/v1/connect-sessions with the kind x. The answer carries a link: open it, finish the steps, and the channel is connected.

### What are the X message limits?

Up to 9,999 characters. Replies have no time limit.

### Does the X API cost extra?

No. There is no fee per call. You pay for the Otobiz plan that opens X, and for what a call causes, such as a message sent.

### Can an AI app do this without code?

Yes. The Otobiz MCP server gives an AI app 83 X tools, the same operations as the API, and you sign in from the app.

What Otobiz does on X: https://otobiz.ai/connections/x

More: https://otobiz.ai/developers.md
