# Publish to Threads

> Publish a Threads post, carousel, or thread, with text, images, or video.

Canonical: <https://www.tryadeli.com/docs/api/posts/publish-threads>

`POST https://app.tryadeli.com/api/v1/posts`

Authorization: `Bearer <API key>` — see [Authentication](https://www.tryadeli.com/docs/authentication)

For local media, first [prepare direct uploads](https://www.tryadeli.com/docs/api/posts/create-media-uploads) with `platform: "threads"` and use `{ "upload_id": "..." }` media references. Threads fetches media by URL, so Adeli serves each file to Threads from its own storage while the post is published.

A Threads post is text, media, or both. One media item makes an image or video
post; 2 to 20 make a carousel. Send `thread` to publish several posts, each a
reply to the one before. The response is the finished post: a video can take a
few minutes while Threads processes it.

**Body**

| Name           | Type        | Required | Description                                                                                                                                                                                                                                                                         |
| -------------- | ----------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `platform`     | `"threads"` | Yes      |                                                                                                                                                                                                                                                                                     |
| `accountId`    | `uuid`      | Yes      | A connected Threads account in your organization.                                                                                                                                                                                                                                   |
| `profileId`    | `uuid`      |          | Optional, because accountId names its profile. If you pass both, they must agree.                                                                                                                                                                                                   |
| `text`         | `string`    | Yes      | Up to 500 characters, counted as Threads counts them: each emoji is its length in UTF-8 bytes, so most count as 4. At most 5 links. Send `""` for a media-only post. A text post's first link becomes a preview card.                                                               |
| `media`        | `object[]`  |          | Up to 20 items. Each is `{ upload_id }` (JPEG, PNG or WebP images up to 8 MB; MP4 or MOV video up to 1 GB and 5 minutes), an image as `{ content_type, base64 }`, or a video as `{ url }`, a public HTTPS MP4 or MOV. Any item takes an optional `altText`, up to 1,000 characters. |
| `replyControl` | `string`    |          | Who can reply to the first post: `everyone` (the default), `accounts_you_follow`, `followers_only`, `mentioned_only`, or `parent_post_author_only`.                                                                                                                                 |
| `topicTag`     | `string`    |          | One topic for the first post, 1 to 50 characters, without `.` or `&`.                                                                                                                                                                                                               |
| `thread`       | `object[]`  |          | Up to 24 further posts, each `{ text, media }` with the same rules, published in order as replies.                                                                                                                                                                                  |

`201` when every post is live. Images are re-encoded as JPEG, upright, before
Threads fetches them.

Threads can't publish a thread atomically. When a post after the first fails,
the posts before it are already live and stay live: the response is `207` with
`status: "partial"`, the failed post's `error`, and `not_attempted` for the
rest. Publish the remainder yourself as replies to the last `providerId` that
went live. A failure on the first post publishes nothing and is an ordinary
error.

Threads limits each account to 250 posts and 1,000 replies in any 24 hours; a
carousel is one post, and each later post in a thread is a reply. Past either,
the request answers `429 rate_limited`. A video Threads is still processing
after 4 minutes answers `504 media_processing_timeout`; retry the post later.

## Request examples

**cURL**

```bash
curl -X POST "https://app.tryadeli.com/api/v1/posts" \
  -H "Authorization: Bearer $ADELI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "platform": "threads",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "text": "Herons fish at dawn. A thread:",
  "topicTag": "Birds",
  "thread": [
    {
      "text": "They stand still for minutes at a time."
    }
  ]
}'
```

**JavaScript**

```javascript
const response = await fetch("https://app.tryadeli.com/api/v1/posts", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ADELI_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    platform: "threads",
    accountId: "00000000-0000-0000-0000-000000000000",
    text: "Herons fish at dawn. A thread:",
    topicTag: "Birds",
    thread: [
      {
        text: "They stand still for minutes at a time.",
      },
    ],
  }),
});
console.log(await response.json());
```

**Python**

```python
import os

import requests

response = requests.post(
    "https://app.tryadeli.com/api/v1/posts",
    headers={"Authorization": f"Bearer {os.environ['ADELI_API_KEY']}"},
    json={
        "platform": "threads",
        "accountId": "00000000-0000-0000-0000-000000000000",
        "text": "Herons fish at dawn. A thread:",
        "topicTag": "Birds",
        "thread": [
            {
                "text": "They stand still for minutes at a time.",
            },
        ],
    },
)
print(response.json())
```

## Responses

### 201

```json
{
  "id": "threads_post_00000000-0000-0000-0000-000000000000_18028000000000001",
  "platform": "threads",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "profileId": "00000000-0000-4000-8000-000000000001",
  "status": "published",
  "providerId": "18028000000000001",
  "permalink": "https://www.threads.com/@adeli/post/DAbCdEfGhIj",
  "posts": [
    { "index": 0, "status": "published", "providerId": "18028000000000001", "url": "https://www.threads.com/@adeli/post/DAbCdEfGhIj" },
    { "index": 1, "status": "published", "providerId": "18028000000000002", "url": "https://www.threads.com/@adeli/post/DAbCdEfGhIk" }
  ]
}
```

### 207

```json
{
  "status": "partial",
  "posts": [
    { "index": 0, "status": "published", "providerId": "18028000000000001", "url": "https://www.threads.com/@adeli/post/DAbCdEfGhIj" },
    { "index": 1, "status": "failed", "error": { "code": "rate_limited", "message": "Threads rate limit reached; retry later" } },
    { "index": 2, "status": "not_attempted" }
  ]
}
```

### 422

```json
{
  "error": {
    "code": "invalid_media",
    "message": "Threads could not process the media (INVALID_DURATION)"
  }
}
```
