Third crossposting target on the ADR-065 loop (ADR-069). Text posts get a link preview, 1 image posts as IMAGE and 2-4 as a CAROUSEL (Meta fetches them from /media/), with alt text and the first tag as topic_tag. Posts are shortened to 500 characters, counting non-ASCII as UTF-8 bytes. Edits don't follow (the API has no edit); unpublish and delete remove the post. Retried creates check for an existing post first. The 60-day token is refreshed daily from the worker loop and kept in DATA_PATH/threads_token.json under a file lock; a new configured token replaces it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.7 KiB
2.7 KiB
ADR-069: Crossposting to Threads
Status
Accepted (v2.6.0, 2026-10-31)
Context
ADR-065 and ADR-066 crosspost notes to GoToSocial and Bluesky. Threads (Meta) has a publishing API, so it can be a third target on the same loop.
Decision
- Third client, same loop.
ThreadsClientis target idthreadsbehind thesyndicationstable and reconcile loop from ADR-065. - Auth. A long-lived Threads user token (
THREADS_ACCESS_TOKEN) withthreads_basic,threads_content_publishandthreads_delete. These tokens expire after 60 days, so StarPunk refreshes the token about once a day (th_refresh_token) from the worker loop, even when nothing is being posted. The current token is kept inDATA_PATH/threads_token.json(mode 0600) with a hash of the configured token. A different configured token replaces the saved one. A file lock stops gunicorn workers from refreshing at the same time. The file avoids a migration for one value. - Posting. Create a container, poll its status until
FINISHED, thenthreads_publish. Text-only notes areTEXTposts with the permalink aslink_attachment. One image is anIMAGEpost and 2–4 images are aCAROUSEL. Meta fetches images from their public/media/URL. Only JPEG and PNG up to 8 MB are allowed, so GIF and WebP images are left off. Alt text goes inalt_text. - Content. Plain text (as for Bluesky), then the permalink, shortened
to 500 characters. Non-ASCII characters are counted as UTF-8 bytes,
because Threads counts emoji that way. Threads allows one tag per post,
so the note's first tag is sent as
topic_tagand no hashtags are added to the text. - Edits don't follow. The API has no way to edit a post. As with Bluesky, the post stays as first sent, and unpublishing, unticking the target or deleting the note removes it.
- Likes and reposts (ADR-068). The API can't like or repost outside content, so likes are not crossposted. Reposts are text posts with "🔁 title" and the URL, plus the comment if there is one, and the reposted page as the link preview.
- No double posts. A retried create first looks for a recent post that already contains the permalink.
Consequences
- Meta limits accounts to 250 posts and 100 deletes per day. Rate-limit errors (Graph codes 4, 17, 32, 613) are retried.
- If StarPunk is down for more than 60 days, the token expires and a new one is needed.
- Getting the first token requires a Meta developer app with the Threads
use case. See the setup notes in
docs/design/v2.6.0/. - Notes with more than five links fail on Threads (a Meta limit). The error is shown in the editor.