apithreadsmetapublishing

Threads API: how to post to Threads with code in 2026

By Published Updated

Facts checked against the official docs on

Short answer: the Threads API publishes in two steps. First POST /{threads-user-id}/threads creates a media container (text, an image, a video or a carousel), then POST /{threads-user-id}/threads_publish publishes it. You need a Meta app with the Threads use case, the threads_basic and threads_content_publish permissions, and a Threads user access token from Threads' own OAuth window. Meta lists no price; the limits are 250 published posts per profile per 24 hours and 500 characters per post.

This guide covers what Meta requires, the calls with real code, the same post through Ampost, and the limits and gotchas.

What the Threads API needs before you can post

The Threads API is separate from the Facebook Graph API. It has its own host (graph.threads.com, or the older graph.threads.net), its own authorization window, its own tokens and its own version, v1.0.

Requirement What it means
A Meta app with the Threads use case The app has two app IDs and secrets; the Threads API uses the Threads app ID and secret
Permissions threads_basic (every endpoint) and threads_content_publish (publishing). Replies need threads_manage_replies, deleting needs threads_delete, insights need threads_manage_insights
App Review Threads testers can grant permissions at any time. Anyone else can only after App Review approves each permission and your app is published
Threads testers Threads accounts you invite to your app; until App Review, your app can post only for them
A public media server Threads downloads every image and video from a public URL when you create the container
Price Meta lists no price for the Threads API

Permission grants last 90 days. For users with a public profile, refreshing a long-lived token extends the grant.

Post to Threads in 4 steps

1. Get an authorization code

Send the user to Threads' authorization window:

https://threads.com/oauth/authorize
  ?client_id=THREADS_APP_ID
  &redirect_uri=https://example.com/threads/callback
  &scope=threads_basic,threads_content_publish
  &response_type=code
  &state=RANDOM_STATE

Threads redirects back with ?code=...#_. Strip the #_: it is not part of the code. The code is valid for 1 hour and only once.

2. Exchange it for a long-lived token

On your server, exchange the code for a short-lived token (1 hour), then the short-lived token for a long-lived one (60 days):

curl -X POST https://graph.threads.com/oauth/access_token \
  -F client_id=$THREADS_APP_ID \
  -F client_secret=$THREADS_APP_SECRET \
  -F grant_type=authorization_code \
  -F redirect_uri=https://example.com/threads/callback \
  -F code=$CODE
# returns access_token (short-lived) and user_id

curl -G https://graph.threads.com/access_token \
  -d grant_type=th_exchange_token \
  -d client_secret=$THREADS_APP_SECRET \
  -d access_token=$SHORT_LIVED_TOKEN
# returns the long-lived access_token and expires_in (about 5,184,000 seconds)

Keep the user_id: it is the {threads-user-id} in every publishing call. Refresh the long-lived token before it expires with GET /refresh_access_token?grant_type=th_refresh_token; a token can be refreshed once it is 24 hours old.

3. Create a media container

A text post:

curl -X POST "https://graph.threads.com/v1.0/$THREADS_USER_ID/threads" \
  -H "Authorization: Bearer $TOKEN" \
  -d "media_type=TEXT" \
  --data-urlencode "text=Our API docs are live: https://example.com/docs"

An image post sets media_type=IMAGE and image_url; a video post sets media_type=VIDEO and video_url. Each returns {"id": "CONTAINER_ID"}.

4. Wait for the container, then publish it

Meta asks you to wait about 30 seconds before publishing so the upload is processed. More reliable is to read the container's status until it is FINISHED:

curl -G "https://graph.threads.com/v1.0/$CONTAINER_ID" \
  -H "Authorization: Bearer $TOKEN" \
  -d "fields=status,error_message"

curl -X POST "https://graph.threads.com/v1.0/$THREADS_USER_ID/threads_publish" \
  -H "Authorization: Bearer $TOKEN" \
  -d "creation_id=$CONTAINER_ID"

The publish call returns the post's media ID. The whole flow in Python:

import time
import requests

API = "https://graph.threads.com/v1.0"
headers = {"Authorization": f"Bearer {token}"}

container = requests.post(
    f"{API}/{threads_user_id}/threads",
    headers=headers,
    data={"media_type": "IMAGE", "image_url": "https://cdn.example.com/chart.png", "text": "This week in charts"},
).json()["id"]

for _ in range(60):
    status = requests.get(f"{API}/{container}", headers=headers, params={"fields": "status,error_message"}).json()
    if status["status"] == "FINISHED":
        break
    if status["status"] in ("ERROR", "EXPIRED"):
        raise RuntimeError(status.get("error_message", status["status"]))
    time.sleep(3)

post = requests.post(
    f"{API}/{threads_user_id}/threads_publish", headers=headers, data={"creation_id": container}
).json()
print(post["id"])

Carousels take one more step: create a container for each item with is_carousel_item=true, then a parent container with media_type=CAROUSEL and children set to the item IDs (2 to 20, images and videos mixed), then publish the parent.

The same post through Ampost

Everything above is yours to build and keep running when you integrate the Threads API directly: the Meta app and its review, the authorization window, token exchange and a refresh job that runs before 60 days pass, the container status loop, and the carousel steps. Ampost's Threads app has passed Meta's App Review. You connect the Threads account once in Ampost (from the dashboard or POST /api/accounts/connect), then send one request:

curl -X POST https://api.ampost.io/api/posts \
  -H "Authorization: Bearer amp_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "targets": [{ "platforms": ["threads"] }],
    "text": "This week in charts",
    "media": [
      { "url": "https://cdn.example.com/one.png", "type": "image" },
      { "url": "https://cdn.example.com/two.mp4", "type": "video" }
    ],
    "publishNow": true
  }'

A text post with a reply chain, scheduled for later:

{
  "targets": [{ "platforms": ["threads"] }],
  "text": "We rebuilt our media pipeline. Here is what changed:",
  "thread": [
    { "text": "1. Videos are converted before they are published." },
    { "text": "2. Scheduled media is copied to our storage." }
  ],
  "scheduledFor": "2026-12-01T09:00:00Z"
}

What Ampost does with it, and where it saves work:

  • One request per post type. No media is a text post, one item an image or video post, and 2 to 20 items a carousel. Ampost creates the containers, waits for each one to be FINISHED and publishes.
  • Tokens stay alive. Ampost refreshes the 60-day token once it has less than 30 days left, including for accounts that have not posted in a while.
  • Replies and chains. thread publishes up to 25 follow-up posts, each a reply to the one before, and firstComment posts one reply. Both need threads_manage_replies, which Ampost asks for when the account connects.
  • Media is fitted to Threads' limits. Images and videos outside them are resized or re-encoded before the container is created.
  • The real URL. Ampost reads the post's permalink after publishing, so you get the threads.com link rather than a media ID.
  • Deletes. Deleting the post in Ampost deletes it on Threads (threads_delete).

The same POST /api/posts operation is also the posts_create tool on Ampost's MCP server, with the same arguments. Where Ampost does not save you work: it does not expose topic tags, polls, GIFs, reply_control or link_attachment. If you need those, call the Threads API directly. Request fields and errors are in the API docs; plans and limits are on pricing.

Limits and gotchas

Limit Value Source
Published posts 250 per profile per rolling 24 hours; a carousel counts as one Threads API overview
Replies 1,000 per profile per rolling 24 hours Threads API overview
Deletions 100 per profile per rolling 24 hours Threads API overview
API calls 4,800 × impressions (at least 10) per app and user pair, per rolling 24 hours Threads API overview
Text 500 characters; emojis count as their UTF-8 bytes Threads posts
Links 5 unique links per post Threads posts
Images JPEG or PNG, 8 MB, minimum width 320 px, aspect ratio up to 10:1 Threads posts
Videos MOV or MP4, H.264 or HEVC, up to 5 minutes and 1 GB, 23 to 60 fps, up to 1920 px wide Threads posts
Carousels 2 to 20 items Threads posts

The gotchas:

  • Publishing too early fails. A container that is still IN_PROGRESS cannot be published. In our experience this applies to text posts too: publishing a text container immediately can fail with error code 24, subcode 4279009 ("The requested resource does not exist"). Wait for FINISHED.
  • Containers expire. A container not published within 24 hours turns EXPIRED; create a new one.
  • Failed media has a reason. A container in ERROR has an error_message such as FAILED_DOWNLOADING_VIDEO. Meta suggests checking status once a minute for no more than 5 minutes.
  • Replying to a brand-new post can fail. A reply sent seconds after its parent was published can get the same code 24 error although the parent exists. Retry it after a short wait.
  • Rate limits are per profile, not per app. Check GET /{threads-user-id}/threads_publishing_limit?fields=quota_usage,config before a large scheduled batch, and enforce the 250-post limit in your scheduler.
  • The Threads app ID is not your Facebook app ID. Using the wrong ID or secret in the OAuth window or token exchange fails.

Related guides

Publishing to a Facebook Page uses the Graph API and Page access tokens instead. See the Facebook Graph API guide for its permissions, App Review and Reels flow.

FAQ

Frequently asked questions

Is the Threads API free?

Meta lists no price for the Threads API. Access is controlled by permissions instead: Threads testers can use your app right away, and everyone else only after App Review approves the permissions and your app is published.

How many posts can I publish with the Threads API per day?

250 API-published posts per Threads profile in a rolling 24-hour window; a carousel counts as one post. Replies have their own limit of 1,000 and deletions 100 in the same window. GET /{threads-user-id}/threads_publishing_limit returns the current usage.

Why does threads_publish fail right after I create a container?

The media is not processed yet. Meta recommends waiting about 30 seconds before publishing, or reading the container's status until it is FINISHED. A container that is not published within 24 hours expires.

How long do Threads access tokens last?

Short-lived tokens last 1 hour. Long-lived tokens last 60 days and can be refreshed once they are at least 24 hours old, for another 60 days. A token that is not refreshed in 60 days expires, and the user has to authorize your app again.

What is the character limit for a Threads API post?

500 characters. Emojis count as their length in UTF-8 bytes, so a post full of emojis reaches the limit sooner.

How many links can a Threads API post have?

Up to 5 unique links. Since December 22, 2025, a post with more than 5 fails with THREADS_API__LINK_LIMIT_EXCEEDED. A link preview set with link_attachment works only on text posts.