Files
StarPunk/docs/decisions/ADR-069-threads-syndication.md
T
PhilandClaude Opus 5.5 fade75fd2d fix: Let Threads build the link preview itself (v2.6.2)
An explicit link_attachment for a URL Meta hasn't fetched yet fails at
threads_publish with "Invalid Link Attachment" (subcode 4279047), which
is every new note; it only went out on the retry. Tested live with fresh
URLs: with link_attachment it fails, without it it publishes first time
and Threads still sets link_attachment_url from the first link in the
text. Reposts likewise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 21:38:00 -06:00

2.9 KiB
Raw Permalink Blame History

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

  1. Third client, same loop. ThreadsClient is target id threads behind the syndications table and reconcile loop from ADR-065.
  2. Auth. A long-lived Threads user token (THREADS_ACCESS_TOKEN) with threads_basic, threads_content_publish and threads_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 in DATA_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.
  3. Posting. Create a container, poll its status until FINISHED, then threads_publish. Text-only notes are TEXT posts. Threads previews the first link in the text (the permalink) by itself. An explicit link_attachment is not sent, because Meta rejects one for a page it hasn't fetched yet ("Invalid Link Attachment", subcode 4279047), which is always the case for a new note (v2.6.2). One image is an IMAGE post and 2–4 images are a CAROUSEL. 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 in alt_text.
  4. 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_tag and no hashtags are added to the text.
  5. 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.
  6. 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.
  7. 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.