Refract docsBack to Refract

API reference

The Refract API lets your own scripts and apps read workspaces, accounts and posts, create drafts, schedule them and add files. It speaks JSON:API: requests and responses are JSON documents with data, attributes and errors.

https://refract.social/api/v1

Authentication

Every request carries an API token as a Bearer token:

curl https://refract.social/api/v1/workspaces \
  -H "Authorization: Bearer rf_live_…"

Admins create tokens in Settings › API and agents › For developers. A token is shown once; Refract keeps only a hash of it and its last four characters. Each token has:

  • A role: Editor, Contributor or Viewer (never Admin). The role decides what the token can do, exactly as it would for a person.
  • Workspaces: all of the organization's, or the ones you pick. Other workspaces answer 404, as if they didn't exist.
  • An expiry: 30 days, 90 days, a year or none. Whoever created it gets an email a week before it expires.

A revoked or expired token answers 401 from the next request on. A signed-in browser session never authenticates the API.

Role What the token can do
Editor Read everything, create drafts, schedule and publish, delete posts
Contributor Read everything, create drafts and send them for approval, delete its own drafts. Can't publish
Viewer Read workspaces, accounts, posts and files. Changes nothing (403)

Approval

Tokens follow the same approval rules as your team. Where a workspace has AI agents and tokens switched on under its approval settings, every post a token schedules becomes an approval request, whatever the token's role. GET /workspaces tells you per workspace with posts_need_approval.

Signing in with OAuth

Apps that act for one person can sign them in instead of asking for a token. The Refract CLI does this: an OAuth 2.0 authorization code flow with PKCE, a loopback redirect (http://127.0.0.1:{any port}/callback) and the api scope. The person sees the same screen as Connect Claude, picks the workspaces and either Draft and send for approval (works like a Contributor) or Schedule and publish (works like an Editor, for 1, 7 or 30 days or until they change it, then like a Contributor), and the app gets an access token for a day and a refresh token for 90 days. The access token works like an API token with that role in those workspaces, approval rules included; GET /me gives the capability it has now. It appears under Connect other AI tools in Settings, where Remove ends it at once.

The Refract plugin for WordPress signs in the same way, after registering itself as a client. A client whose every redirect URI is a WordPress site's /wp-admin/admin.php?page=refract&refract_connect=1 (on https) gets the api scope. Its screen asks for one workspace, where the person can add accounts, and lists what the site will be able to do instead of a choice. Such a sign-in reaches only what the plugin uses: GET /me, DELETE /me/token, GET /networks, GET /workspaces and /workspaces/{workspace}, GET …/accounts, the WordPress site endpoints, the notes endpoints and the versions endpoints (including approve-all). Any other endpoint answers 403. On any of these screens, someone signed in who hasn't set up Refract yet goes through setup first, then comes back.

The Refract CLI

Post from your terminal. It signs in through the browser, so there's no token to paste.

npm install -g @refracthq/cli
refract login
refract post "Fresh Guji on the bar today." --to kolo-ig,kolo-fb --at "tomorrow 09:00"
Command What it does
refract login Opens the browser to sign in and pick workspaces and what the CLI can do. --no-browser prints the address instead
refract whoami Who you're signed in as, the organization, the workspaces and what the CLI can do there
refract accounts The accounts you can post to, with the name to use in --to
refract post "…" --to … Schedules with --at, adds to the queue without it, or saves a draft with --draft. --media attaches a file or a link
refract posts Scheduled posts and posts waiting for approval
refract logout Revokes this computer's sign-in on the server and forgets it

Accounts in --to are <workspace>-<network>: the workspace's slug or its first word (kolo, kolo-coffee) and one of ig fb x li th tt yt pin bsky masto tg gbp wp. A handle (@kolocoffee) works too. Anything that matches more than one account is refused with the choices. --at reads times in the workspace's time zone: tomorrow 09:00, today 17:30, Thu 13:30, 2026-10-15 09:00, in 2 hours or now.

Sign-ins are kept per server in ~/.config/refract/credentials.json, readable only by you, and renew themselves. --server (or REFRACT_SERVER) picks another Refract server. Every command has --help.

Endpoints

{workspace} is a workspace's id or its slug.

Method Path Role
GET /me any Who the token acts for, its organization and plan, its role or capability, and the AI credits the person can spend
DELETE /me/token any Sign out: revokes this OAuth access token and its refresh token (API tokens are revoked in Settings, 403 here)
GET /networks any The networks you can post to, with their limits and what Refract can do there
GET /workspaces any Workspaces the token can reach
GET /workspaces/{workspace} any One workspace
GET /workspaces/{workspace}/accounts any Its connected social accounts
POST /workspaces/{workspace}/accounts/wordpress Editor Connect a WordPress site (the Refract plugin)
DELETE /workspaces/{workspace}/accounts/wordpress/{account} Editor Remove a WordPress site
POST /workspaces/{workspace}/notes Contributor Start a draft from a blog post's note
PATCH /workspaces/{workspace}/notes/{post} Contributor Update that note after the blog post changed
POST /workspaces/{workspace}/notes/{post}/visibility Contributor Say whether that blog post is public; holds the post while it isn't
GET /workspaces/{workspace}/posts/{post}/versions any A post's versions, with their checks and status
POST /workspaces/{workspace}/posts/{post}/versions/{version}/approve Contributor Approve one version
POST /workspaces/{workspace}/posts/{post}/approve-all Contributor Approve every version and add the post to the queue, or send it for approval
GET /workspaces/{workspace}/posts any Its posts, newest first
GET /workspaces/{workspace}/posts/{post} any One post
POST /workspaces/{workspace}/posts Contributor Create a draft
POST /workspaces/{workspace}/posts/{post}/schedule Contributor Schedule it, or send it for approval
DELETE /workspaces/{workspace}/posts/{post} Contributor Delete it
POST /workspaces/{workspace}/media Contributor Upload a file, or add one from a link
GET /workspaces/{workspace}/media/{media} any One file

The WordPress, notes and versions endpoints take and return plain JSON (Content-Type: application/json), not JSON:API documents. Their errors are JSON:API error documents, like everywhere else.

Me

{
  "data": { "type": "users", "id": "0199e29f-…", "attributes": { "name": "Ana Kovač", "email": "ana@kolo.coffee" } },
  "meta": {
    "access": {
      "kind": "token", "name": "Website", "role": "editor",
      "organization": { "id": "0199e2a0-…", "name": "Kolo Coffee", "plan": "Business" }
    },
    "credits": { "left": 412, "refill_on": "2026-11-01", "own_key": false, "buy_url": "https://refract.socialw/kolo-coffee/settings/billing" }
  }
}

access is {"kind": "oauth", "client", "capability", "capability_label", "organization"} for an OAuth sign-in. credits.left is how many AI credits this person can spend now (their allowance included), refill_on when the monthly credits refill, and own_key whether the organization's own AI key pays for text.

Networks

{
  "data": [
    {
      "id": "x",
      "type": "networks",
      "attributes": {
        "key": "x",
        "label": "X",
        "mark_key": "x",
        "aliases": ["x"],
        "group": "social",
        "availability": "available",
        "capabilities": {
          "connect": "oauth", "destination": "account", "metrics": ["views", "engagements", "followers"],
          "supports_draft": false, "can_edit": false, "can_remove": false,
          "requires_media": false, "requires_title": false, "shares_numbers": true
        },
        "fields": {},
        "limits": { "text_max": 280, "media_max": 4 }
      }
    }
  ]
}

Every network, in Refract's order. key is the platform value accounts and posts use. aliases are the short names the Refract CLI accepts in --to (kolo-x). group is social, chat, blogs or local. availability is available, beta, soon (it can't be connected yet; accounts already connected on it keep posting), or internal for a network that's switched on only for your organization. capabilities says what Refract can do on the network (how it connects, what it reports, whether a published post can be edited or removed). fields lists the extra fields a post on the network uses (title, tags, community, canonical_url, as_draft, post_as) with their limits, such as {"tags": {"max_count": 4, "max_length": 30}}. limits.text_max and limits.media_max are null where the network sets none.

Workspaces

{
  "data": [
    {
      "id": "0199e2a4-6c1d-7b55-9a1e-3f0c2d1b4a77",
      "type": "workspaces",
      "attributes": {
        "name": "Kolo Coffee",
        "slug": "kolo-coffee",
        "timezone": "Europe/Ljubljana",
        "role": "editor",
        "posts_need_approval": true
      }
    }
  ]
}

role is the token's role in that workspace. Times in posts are in the workspace's timezone.

Accounts

{
  "id": "0199e2a5-0a33-7d1e-8c4f-5b2a9e7d1c10",
  "type": "accounts",
  "attributes": {
    "platform": "instagram",
    "name": "Kolo Coffee",
    "handle": "kolocoffee",
    "avatar_url": "https://…",
    "health": "connected",
    "label": "Instagram",
    "main": true,
    "availability": "available"
  }
}

health is connected, expiring_soon or needs_reconnect. label is the network's name, main whether it's the workspace's main channel, and availability whether the network is available, in beta or soon. A WordPress site's platform is wordpress. Account credentials never leave Refract.

WordPress sites

The Refract plugin connects its site with this endpoint; you don't need it unless you build something like it. It needs a person or token that can add accounts in the workspace (an Admin or Editor).

curl -X POST https://refract.social/api/v1/workspaces/kolo-coffee/accounts/wordpress \
  -H "Authorization: Bearer rf_live_…" \
  -H "Content-Type: application/json" \
  -d '{
    "site_url": "https://kolo.coffee",
    "site_name": "Kolo Coffee",
    "rest_url": "https://kolo.coffee/wp-json/",
    "plugin_version": "1.0.0",
    "wp_version": "7.1.3",
    "locale": "en_US",
    "timezone": "Europe/Ljubljana",
    "signing_secret": "…",
    "events_url": "https://kolo.coffee/wp-json/refract/v1/events"
  }'

Refract first checks the site with a signed request to its refract/v1/site route. It answers 201 for a new site, or 200 when the same site connects again in this workspace:

{ "account_id": "0199e2a6-…", "handle": "kolo.coffee", "workspace": { "id": "0199e2a4-…", "slug": "kolo-coffee", "name": "Kolo Coffee" } }

A site counts as one account on the plan. When it can't connect, the answer is 422 with one of these codes: site_unreachable, rest_blocked, not_https, or plan_full (with links.about, the plan page). The site gets the webhook events at events_url, signed with signing_secret.

DELETE /workspaces/{workspace}/accounts/wordpress/{account} answers 204. It removes the site like Disconnect on the Accounts page (scheduled posts that went only to it move to drafts), deletes its webhook endpoint and revokes the sign-in or token that connected it. Accounts that aren't WordPress sites answer 404.

Notes

Start a draft from a blog post. Refract writes a version for each account's network from the note, in the workspace's voice, for 1 AI credit each. Nothing is scheduled: every version waits for approval.

curl -X POST https://refract.social/api/v1/workspaces/kolo-coffee/notes \
  -H "Authorization: Bearer rf_live_…" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: wp:1:123:456" \
  -d '{
    "source": { "type": "wordpress", "account_id": "0199e2a6-…", "external_id": "123", "url": "https://kolo.coffee/huila", "title": "Our autumn Huila is here", "excerpt": "…", "text": "…" },
    "start_from": "note",
    "note": { "point": "", "detail": "", "todo": "Read it: https://kolo.coffee/huila" },
    "accounts": ["0199e2a5-0a33-7d1e-8c4f-5b2a9e7d1c10"],
    "media": [{ "url": "https://kolo.coffee/wp-content/uploads/huila.jpg", "alt": "A bag of Huila beans", "role": "featured" }],
    "images": "crop",
    "write": true
  }'
  • source.account_id is a WordPress site connected to the workspace. accounts are the workspace's accounts to post to, never that site itself.
  • Empty note fields are filled from the blog post: the point from the excerpt or title, a detail from the text, and Read it: {url} as what to do.
  • start_from: note (default), or finished for the same text on every account, which costs nothing.
  • media: up to 10 files, downloaded into the library and cropped for each network. role is featured or content. When a network can't take every file, the ones that fit it best go to it and the rest are left off that network only (the post's skipped_media). A file no network can take is listed in media_skipped.
  • images: crop (default), or crop_or_make to make one image in Studio, for credits, for a network that no file fits. That image goes only to the network it was made for.
  • write: false saves the draft and its note without writing versions.

Idempotency-Key is required, up to 255 characters. Sending the same key again in the workspace returns the first answer, with the header Idempotent-Replayed: true, instead of making a second post. The answer is 202; the versions are written in the background:

{
  "post_id": "0199e2b0-…",
  "status": "draft",
  "start_from": "note",
  "versions": [{ "id": "0199e2b1-…", "account_id": "0199e2a5-…", "network": "instagram", "status": "writing" }],
  "credits_held": 1,
  "media_credits": 0,
  "media_skipped": [],
  "edit_url": "https://refract.socialw/kolo-coffee?compose=0199e2b0-…"
}

versions has one entry per account; accounts on one network share a version id, and id is null for a finished post. credits_held and media_credits are the credits set aside for versions and images.

When the credits aren't enough, nothing is created and the key isn't used up. The answer is 402, with what's needed and left:

{
  "errors": [{ "status": "402", "code": "out_of_credits", "title": "Out of AI credits", "detail": "You're out of AI credits for this post. It needs 4 and you have 1." }],
  "needed": 4,
  "left": 1,
  "refill_on": "2026-11-01",
  "buy_url": "https://refract.socialw/kolo-coffee/settings/billing"
}

PATCH /workspaces/{workspace}/notes/{post} takes source (the same site) and note after the blog post changed, with an optional Idempotency-Key. Refract saves the note and writes again the versions nobody edited; edited ones are kept and marked to check ("stale": "check"), and need approving again like the rewritten ones. When the post is scheduled or waiting for approval, the people who can approve are told. It answers 202 with the same body, 402 as above, or 409 once the post is going out (from a minute before its time) or went out. On 402 the note is still saved: the versions from the old note hold the post until someone writes them again or keeps them in Refract.

POST /workspaces/{workspace}/notes/{post}/visibility says whether the blog post is public, with account_id (the site the post came from) and status: publish, or why it isn't public (draft, pending, private, future, password, trash or deleted).

{ "account_id": "01JD8V3T6Q2M7K9B4N1C5X0WZE", "status": "private" }

Anything but publish holds the post: nothing goes out and it can't be scheduled, and when something was waiting to go out, everyone who can publish is told. publish ends the hold, and the versions need approving again; a post whose time has passed goes back to the drafts. The answer is 200:

{ "post_id": "01JD8V9ZK3R6T2W8Y5N7C4B1QA", "status": "scheduled", "public": false, "held": true, "needs_ok": false }

held is true when something waiting to go out is held now; needs_ok is true when a hold just ended. Another site's account_id or an unknown status is 422.

Versions

GET /workspaces/{workspace}/posts/{post}/versions returns the post's versions, one entry per account:

{
  "post_id": "0199e2b0-…",
  "post_status": "draft",
  "start_from": "note",
  "source": { "type": "wordpress", "account_id": "0199e2a6-…", "external_id": "123", "url": "https://kolo.coffee/huila", "title": "Our autumn Huila is here" },
  "can_publish": true,
  "approvers": [],
  "edit_url": "https://refract.socialw/kolo-coffee?compose=0199e2b0-…",
  "versions": [
    {
      "id": "0199e2b1-…",
      "account": { "id": "0199e2a5-…", "network": "instagram", "network_label": "Instagram", "name": "Kolo Coffee", "handle": "kolocoffee", "availability": "available", "main": true },
      "status": "needs_ok",
      "text": "Our autumn Huila is here …",
      "title": null,
      "media": [{ "url": "https://…", "thumb_url": "https://…", "width": 1080, "height": 1350, "alt": "A bag of Huila beans", "type": "image" }],
      "checks": [{ "level": "pass", "code": "pass", "message": "Instagram is ready" }],
      "rules_followed": [{ "id": "…", "text": "Up to 5 hashtags" }],
      "stale": null,
      "scheduled_for": null,
      "permalink": null,
      "short_link": null,
      "clicks": 0,
      "error": null,
      "approvable": true,
      "edit_url": "https://refract.socialw/kolo-coffee?compose=0199e2b0-…"
    }
  ]
}
  • status: writing, needs_ok, approved, edited, waiting_for_approval, scheduled, posted or failed. A scheduled post whose versions need an OK again after the note changed shows needs_ok; it doesn't go out until they're approved.
  • checks[].level is pass, warn or fail. A version with a fail check can't go out.
  • stale is old (written before the note changed), check (edited, then the note changed) or null.
  • error is {"message", "fix"} for a failed version.
  • title is the version's title on networks that have one (WordPress).
  • can_publish is false when the token can't publish, or the workspace asks for approval from it; approvers then names who can approve.

POST …/posts/{post}/versions/{version}/approve approves one version and answers 200 with the document. A version still being written, or that couldn't be written, answers 409.

POST …/posts/{post}/approve-all approves every version that needs an OK and passes its checks, then adds the post to the queue. Networks that a check blocks stay behind as a new draft. If the token can't publish, or the workspace asks for approval from it, the post is sent for approval instead. It answers 200 with the document plus:

{ "queued": true, "waiting_for": null, "skipped": ["0199e2b2-…"] }

waiting_for is "approval" when the post waits for approval, and skipped lists the versions not approved because of a failing check. Nothing is sent while a version is still being written; queued is false then.

Posts

The post resource

{
  "id": "0199e2b0-1f2e-7a3b-9c4d-5e6f7a8b9c0d",
  "type": "posts",
  "attributes": {
    "text": "Fresh Guji on the bar today.",
    "status": "scheduled",
    "source": "api",
    "scheduled_at": "2026-10-15T09:00:00+02:00",
    "published_at": null,
    "accounts": [
      { "id": "0199e2a5-…", "platform": "instagram", "handle": "kolocoffee", "status": "pending", "permalink": null, "error": null }
    ],
    "variants": { "x": "Fresh Guji on the bar today ☕" },
    "skipped_media": { "x": ["0199e2b4-…"] },
    "created_at": "2026-10-14T12:01:00+02:00",
    "updated_at": "2026-10-14T12:01:00+02:00"
  }
}
  • status: draft, awaiting_approval, scheduled, publishing, published or failed.
  • accounts[].status: pending, queued, uploading, processing, published, failed or removed, with permalink once published and error when it failed. Each account also has removed_at (when it was removed from the network from Refract), edits_count (edits the network took) and edit: the latest edit after publishing, {state, text, error} with state approving, applying, applied or failed, or null.
  • variants: per-platform text where it differs from the main text.
  • skipped_media: per platform, the ids of the post's files that platform leaves off; {} when every network posts every file.
  • Its files are the media relationship: add ?include=media to get them in included. Each network posts them in this order, without the ones it leaves off.

List posts

GET /workspaces/{workspace}/posts?filter[status]=draft,scheduled&page[number]=1&page[size]=25

page[size] is at most 100. The response has links (first, last, prev, next) and meta (current_page, total and more).

Create a draft

curl -X POST https://refract.social/api/v1/workspaces/kolo-coffee/posts \
  -H "Authorization: Bearer rf_live_…" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
    "data": {
      "type": "posts",
      "attributes": {
        "text": "Fresh Guji on the bar today.",
        "accounts": ["0199e2a5-0a33-7d1e-8c4f-5b2a9e7d1c10"],
        "media": [],
        "variants": { "x": "Fresh Guji on the bar today ☕" }
      }
    }
  }'

Answers 201 with the post and a Location header. accounts and media must belong to the workspace. A variant is a platform's text, or {"text": "…", "settings": {…}, "skipped_media": […]} for platforms with settings (a Pinterest board, a YouTube title) or files it leaves off. The post is saved with "source": "api".

Post fields

Some networks take extra fields in a variant's settings. GET /networks lists each network's fields and their limits.

Field Value
title Text. Required on some networks; the most each takes is in GET /networks.
tags A list of tags without the # (a leading # and spaces are removed).
community_id The community the post goes to: its id on the account's server, or its address (coffee@lemmy.world). Refract looks it up through the post's account to show its name; when the server can't find it, the post shows the id and the check runs when it publishes.
canonical_url The full link (https://…) to where the post first appeared, so search engines credit it.
as_draft true sends the post to the network's drafts instead of publishing it.
post_as {"name": "…", "avatar_media_id": "…"}: the name and a picture from the workspace's library the post goes out under. Leave either out to use the account's default, else the workspace's name and logo.
privacy_level TikTok only, and required before a TikTok post can be scheduled: who can view it, PUBLIC_TO_EVERYONE, MUTUAL_FOLLOW_FRIENDS, FOLLOWER_OF_CREATOR or SELF_ONLY. TikTok requires the person who posts to choose it, with no preset, so ask them. A choice the post's TikTok account doesn't offer answers 422, with the choices it does.
"variants": {
  "dev": { "text": "…", "settings": { "title": "How we roast for filter", "tags": ["coffee", "roasting"], "canonical_url": "https://kolo.coffee/blog/huila" } }
}

A field the network doesn't take answers 422, with the field in the error's source.pointer (for example /data/attributes/variants/telegram/settings/tags). Limits such as the longest title or the most tags are checked when you schedule, like the text: a post over them is blocked.

Files per network

Every network posts all of the post's media unless its variant leaves some off. skipped_media lists the ids of the files that network leaves off, for example when it takes fewer files than the post has:

"variants": {
  "x": { "skipped_media": ["0199e2b4-…"] }
}

Each id must be one of the post's media; any other answers 422 with the pointer /data/attributes/variants/x/skipped_media/0. The checks when you schedule look at each network's own files.

A picture in a format the network doesn't take (WebP or PNG) goes to it as a JPEG copy, so it isn't blocked for its format or file size. The file in your library stays as it is.

Schedule

curl -X POST https://refract.social/api/v1/workspaces/kolo-coffee/posts/{post}/schedule \
  -H "Authorization: Bearer rf_live_…" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{ "data": { "type": "posts", "attributes": { "when": "at", "at": "2026-10-15T09:00:00+02:00" } } }'
when
queue (default) The next free posting time of its accounts
at The time in at (ISO 8601, in the future)
now Publish right away to all its accounts

The same checks as the composer run first. If a platform blocks the post (text too long, an account signed out), the answer is 422 with one error per problem ("code": "blocked", the platform in meta), and nothing is scheduled. Pass "skip_platforms": ["x"] to leave the blocked platforms behind as a new draft (meta.draft_id) and schedule the rest.

Contributor tokens, and every token where the workspace asks for approval from AI agents and tokens, send the post for approval instead: it answers 200 with "status": "awaiting_approval", at the time asked for or the next free time. meta.message says what happened in plain words.

Delete

DELETE /workspaces/{workspace}/posts/{post} answers 204. A post that is publishing right now answers 409. Published posts leave Refract but stay on the platforms. Contributor tokens can delete only their own drafts and posts waiting for approval.

Edit after publishing

curl -X POST https://refract.social/api/v1/workspaces/kolo-coffee/posts/{post}/accounts/{account}/edit \
  -H "Authorization: Bearer rf_live_…" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{ "data": { "type": "posts", "attributes": { "text": "Fresh Guji on the bar today. Until 18:00." } } }'

Changes one account's published copy on its network. text is required: the whole new text, or null for none where the network takes a post without text; settings takes the same names as a variant's (title, tags, community_id, canonical_url, as_draft, post_as) for networks that use them. Settings you leave out keep their values from the post, so you can send text alone. The network's checks run first: a problem answers 422. The answer is the post with meta.message and meta.state: applying (it's being saved to the network) or approving (the workspace asks for approval from AI agents and tokens, so someone on the team approves it first). The result arrives in the account's edit and the post.edited webhook.

Remove after publishing

POST /workspaces/{workspace}/posts/{post}/accounts/{account}/remove takes the account's copy down from its network. It stays in Refract with status removed; the post's other accounts keep it. The answer is the post with meta.state removing (or removed when it already was). Asking again while the removal is on its way answers removing too and sends nothing more to the network. The post.removed webhook follows.

Both need an Editor or Admin token (403 otherwise). A copy that can't be changed now answers 409 with the reason: it isn't published, the network doesn't let apps edit or remove posts, the network's time limit passed (X edits within 30 minutes, 5 times; Telegram removes within 48 hours), an edit is being saved (no remove) or it's being removed (no edit). See Edit and remove after publishing.

Media

Upload a file as multipart/form-data:

curl -X POST https://refract.social/api/v1/workspaces/kolo-coffee/media \
  -H "Authorization: Bearer rf_live_…" \
  -F "file=@latte.jpg"

Or let Refract download it from a public link, with optional alt text:

curl -X POST https://refract.social/api/v1/workspaces/kolo-coffee/media \
  -H "Authorization: Bearer rf_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/latte.jpg", "alt": "A latte on the bar" }'

The JSON:API form, {"data": {"type": "media", "attributes": {"url": "…", "alt": "…"}}}, works too. Links must be public http or https addresses on the standard ports; private, local and reserved addresses answer 422. Refract follows at most three redirects. Files are checked by their content: images up to 50 MB and videos up to 1 GB, within the platforms' limits. The answer is 201 with the file:

{
  "id": "0199e2c1-…",
  "type": "media",
  "attributes": {
    "kind": "image", "filename": "latte.jpg", "mime_type": "image/jpeg", "size_bytes": 482113,
    "width": 1080, "height": 1350, "duration_ms": null, "alt_text": null,
    "url": "https://…", "created_at": "2026-10-14T12:03:00+02:00"
  }
}

url works for a limited time. Use the file's id in a draft's media.

Errors

Every error is a JSON:API error document:

{
  "errors": [
    {
      "status": "422",
      "code": "invalid",
      "title": "Invalid attribute",
      "detail": "One of the accounts isn't in this workspace any more.",
      "source": { "pointer": "/data/attributes/accounts/0" }
    }
  ]
}
Status code
401 unauthenticated No token, or it is revoked or expired
402 out_of_credits Not enough AI credits (notes)
403 forbidden The token's role doesn't allow it in this workspace
404 not_found It doesn't exist, or the token can't reach it
409 conflict Not possible right now (e.g. the post is publishing)
422 invalid, blocked, site_unreachable, rest_blocked, not_https, plan_full An attribute isn't valid (source.pointer, or source.parameter for query parameters), a platform blocks the post, or a WordPress site can't connect
429 too_many_requests See Rate limits

Cookies

Refract uses the cookies it needs to work. If you allow it, we also use marketing cookies: one so a partner who sent you here gets credit for your sign-up, and the TikTok and OpenAI pixels on our website, to measure our ads on TikTok and in ChatGPT. See the Cookie policy.