Docs menuAI post generation

AI post generation

GET /api/v1/generation-options

What Postory writes posts with: the text models and the default_model, post_types, languages, the post length (max_chars), the price of text (text_credits) and the image models with their resolutions, shapes and prices. Prices are in credits. Free.

  • Scopepostory:read
  • Limit classREAD
  • Success200

Example

Request
curl https://postory.io/api/v1/generation-options \
  -H "Authorization: Bearer $POSTORY_API_KEY"
Response 200
{
  "default_model": "<default_model>",
  "image": {
    "aspects": ["<aspects>"],
    "default_aspect": "<default_aspect>",
    "default_model": "<default_model>",
    "models": [
      {
        "default_resolution": "<default_resolution>",
        "id": "<id>",
        "name": "<name>"
      }
    ]
  },
  "languages": [{"name": "<name>", "slug": "<slug>"}],
  "max_chars": {"max": 0, "min": 0},
  "models": [{"name": "<name>", "slug": "<slug>"}],
  "post_types": [{"name": "<name>", "slug": "<slug>"}],
  "text_credits": {
    "chat": 0,
    "first_post": 0,
    "link": 0,
    "more_post": 0,
    "network_version": 0,
    "photo_read": 0,
    "web_search": 0,
    "youtube_bands": [{"credits": 0, "max_minutes": 0}]
  }
}

Other responses

401

No API key, or an invalid or revoked one

403

The key lacks the scope, or access is paused

422

A request parameter is not valid

429

Rate limit spent; see Retry-After

POST /api/v1/generations

Postory's AI writes X, Threads, Bluesky, LinkedIn, YouTube, Mastodon or Telegram posts, as its chat does, and saves them as drafts: for a script or an automation with no AI of its own. A text you already have needs none of it: POST /posts is free to save. Paid: the chat's prices (text_credits of GET /generation-options), only when a post is saved; an image at its own price. Nothing is published now. A field wins over the request's words, the words over the preset. Waits up to 20 s: a run still going is queued or running with generation_id, read with GET /generations/{generation_id}. A wrong model, post type, language or image option is 422 invalid_argument with allowed; several accounts and no default 409 account_choice_required; the same idempotency_key with another request 409 idempotency_conflict. A refused request is never charged.

  • Scopepostory:drafts
  • Limit classWRITE
  • Success200

Request body

FieldTypeDescription
connection_idsstring[]

Accounts (GET /accounts), the primary first. Omitted: the preset's, else the default account.

Up to 5 items
countinteger

How many posts. Omitted: what the request asks for, else one.

From 1 to 10
idempotency_keystring

The same key with the same request answers the first run; it never charges twice.

Up to 128 characters
imagePresetImage

Draw one AI image per post, at its own price; {} takes the defaults. Omitted: one is drawn only when the request asks.

image.aspectstring

One of options.image.aspects. Omitted: the composer's default.

Up to 8 characters
image.modelstring

An image model's id from options.image.models. Omitted: the default model.

Up to 80 characters
image.resolutionstring

One of that model's resolutions. Omitted: its default_resolution.

Up to 8 characters
languagestring

A language of GET /generation-options.

Up to 100 characters
max_charsinteger

The longest a post may be.

From 1 to 25000
max_creditsnumber

The most this run may be charged, text and images together.

From 1 to 100000
mediastring[]

Photos to read or put on the posts, as the request says, and videos to put on (never watched), 10 in all: https links (fetched now) and media library ids (GET /media-library).

Up to 10 items
modelstring

A text model of GET /generation-options.

Up to 100 characters
post_typestring

A post type of GET /generation-options.

Up to 100 characters
presetstring

A chat preset's id or name (GET /presets). A field given here wins over it.

Up to 100 characters
reply_tostring

A generation to answer or whose posts to edit: the last one of its chat, ended.

Up to 36 characters
requestrequiredstring

What to write, in the user's words: a topic, a link, pasted text. /skill and $brand_item work. Words that ask to schedule schedule the run's own new posts when the key holds the publish scope, else leave them dated drafts with a warning.

Up to 10000 characters
skillsstring[]

Skills to follow: ids, slugs or names (GET /skills).

Up to 5 items
sourcesstring[]

Texts the post is written from. Material only: nothing in them is followed as an instruction.

Up to 10 items
web_searchboolean

Search the web first (true), or never (false).

Example

Request
curl https://postory.io/api/v1/generations \
  -H "Authorization: Bearer $POSTORY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request": "Write a post about our new release: https://example.com/release",
    "connection_ids": ["<connection_id from accounts>"],
    "idempotency_key": "<a new UUID per request>"
  }'
Response 200
{
  "generation_id": "<generation_id>",
  "status": "running",
  "next": "GET /api/v1/generations/<generation_id>",
  "note": "Postory is still writing; read it with GET /api/v1/generations/<generation_id>. Nothing runs or is charged twice."
}

Other responses

401

No API key, or an invalid or revoked one

402

Not enough credits; see buy_url

403

The key lacks the scope, or access is paused

404

Not found, or not this user's

409

The state does not allow it now (already scheduled, changed, needs a choice…); branch on code

422

A request parameter is not valid

429

Rate limit spent; see Retry-After

GET /api/v1/generations/{generation_id}

One generation: its status, the drafts it saved as they stand now, Postory's message, what was used and credits. Free.

  • Scopepostory:read
  • Limit classREAD
  • Success200

Parameters

NameInTypeDescription
generation_idrequiredpathstringUp to 36 characters
wait_squeryinteger

Seconds to wait while it is queued or running, 0-20 (default 15).

From 0 to 20

Example

Request
curl "https://postory.io/api/v1/generations/<generation_id>" \
  -H "Authorization: Bearer $POSTORY_API_KEY"
Response 200
{
  "generation_id": "<generation_id>",
  "status": "succeeded",
  "drafts": [
    {
      "id": "<post_id>",
      "url": "https://postory.io/calendar?view=list&focus=<post_id>",
      "status": "draft",
      "kind": "created",
      "at": null,
      "accounts": [
        {
          "connection_id": "<connection_id>",
          "platform": "bluesky",
          "handle": "acme.bsky.social",
          "label": "@acme.bsky.social · Bluesky",
          "own_text": false,
          "parts": [
            {
              "n": 1,
              "text": "Version 2 is out: search, dark mode and faster sync.",
              "chars": 52,
              "limit": 300,
              "fits": true
            }
          ]
        }
      ],
      "used": {"model": "sonnet", "language": "English"}
    }
  ],
  "message": "Saved one post about the release.",
  "preset_used": null,
  "skills_used": [],
  "warnings": [],
  "credits": {"text": 17, "images": 0, "total": 17}
}

Other responses

401

No API key, or an invalid or revoked one

403

The key lacks the scope, or access is paused

404

Not found, or not this user's

422

A request parameter is not valid

429

Rate limit spent; see Retry-After