# Postiefy

> Postiefy publishes and schedules posts to X, LinkedIn (profiles and Pages), Instagram, Facebook Pages, TikTok, YouTube and Pinterest. Agents use it through a remote MCP server or the REST API; both run the same rules.

A workspace connects its social accounts in the dashboard. An agent then acts through one connection, which has a mode and, optionally, a list of accounts it may use:

- `drafts_only`: everything the agent creates is a draft a person sends out.
- `needs_approval`: posts the agent sends out wait for a person to approve them in the dashboard. An agent never edits a post that is waiting for approval.
- `publish`: posts go out at their time. A publish connection can also send a post to a client for approval by link (`create_approval_link`): the client approves or asks for changes without an account, and any later edit needs a new link.

Whatever the mode, a post an agent sends out with a TikTok direct post (`overrides.mode: direct_post`, the default) or a Pinterest Pin waits in `needs_approval` until a person approves it in the dashboard: both platforms require a person to choose each post. A TikTok `inbox_draft` is exempt, because the creator finishes it in TikTok. Each target's `confirmation` records who approved which `revision`; an agent's edit of such a post sends it back for approval.

## MCP server

- Endpoint: https://api.postiefy.com/mcp (Streamable HTTP, stateless; MCP 2026-07-28 and 2025-era clients).
- Sign-in: OAuth 2.1. Discovery starts at https://api.postiefy.com/.well-known/oauth-protected-resource/mcp. Client ID Metadata Documents and Dynamic Client Registration are supported. The person picks the workspace, mode and accounts on the consent page.
- Without OAuth: send an API key from the dashboard as `Authorization: Bearer pfy_...`.
- Every tool call counts as one API call against the plan.
- Failures are tool results with `isError: true` and `structuredContent.error`: `{code, message, hint, details}`. For a post its platform would refuse, `details.targets[].issues[]` names each field with its own hint.

### Tools

- `list_accounts`: Lists the social accounts this connection may post to, with each one’s platform, health and brand.
- `list_brands`: Lists the workspace’s brands: the clients an agency posts for, each with its name, colour, timezone and the accounts this connection may use.
- `get_account_options`: Returns the values one account accepts right now, fetched from its platform: TikTok privacy levels and limits, Pinterest boards, the YouTube upload allowance left today and the like.
- `get_platform_constraints`: Returns each platform’s fixed limits (text length, media count, sizes, durations, aspect ratios) and the JSON Schema of the `overrides` it accepts.
- `validate_post`: Dry run of create_post: returns, per account, every issue its platform would raise (code, field, message, hint).
- `create_post`: Creates one post for one or more accounts.
- `create_posts`: Creates up to 50 posts in one call, each exactly as create_post would (same fields, same mode rules, one quota slot per post sent out).
- `update_post`: Replaces content, disclosure, timezone or the whole `targets` list of a post that has not started publishing.
- `schedule_post`: Gives a post its time (`scheduledAt`, ISO 8601 with offset) or sends it now (`publishNow: true`).
- `cancel_post`: Stops every account of a post that has not started publishing.
- `retry_post`: Publishes again the accounts of a post whose error is retryable now (each target’s `error.retryable`).
- `resolve_post_target`: For a failed account whose `error.mayBeLive` is true (the platform may already hold the post): if you found the post live on the account, give its `externalUrl` (on the platform’s own site, such as x.com for X) and `externalPostId` if known; the account becomes published.
- `get_post`: Returns a post with each account’s status, the live post URL once published (`externalUrl`) and the error with its hint when one failed.
- `list_posts`: Lists the workspace’s posts, 20 per page by default.
- `wait_for_post`: Waits up to `timeoutSeconds` (at most 25) for a post to stop changing, then returns it.
- `create_approval_link`: Makes a link a client opens without an account to approve the post or ask for changes.
- `revoke_approval_link`: Closes an approval link nobody has answered, so it no longer opens.
- `get_post_approvals`: Returns a post’s approval links with their state, and its approval record oldest first: every link made or revoked, each approval or request for changes (by whom, with any comment) and each reset by an edit, with the post revision it applies to.
- `import_media`: Copies an image, video or PDF from a public URL into the media library and returns its `id` for `content.mediaIds`.
- `create_media_upload`: For a file the agent holds locally: returns a presigned URL.
- `complete_media_upload`: Call after the PUT to create_media_upload’s URL succeeded.
- `list_media`: Lists the workspace’s uploaded and imported files, newest first, 20 per page by default, so a file already there can be reused by its `id` in `content.mediaIds` instead of uploaded again.
- `get_post_metrics`: Returns the metric snapshots of each published account of one post, taken 24 h, 72 h, 7 days and 30 days after publishing (X: 7 days only, because X bills every read).
- `list_metrics`: Lists published accounts of every post with their metric snapshots, newest first, 20 per page by default (at most 100).
- `get_usage`: Returns this month’s counters against the plan: posts sent out, X credits and API calls (each MCP tool call counts as one), and the media storage in use.

### A typical run

1. `list_accounts`, then `get_platform_constraints` and `get_account_options` for the accounts you will post to.
2. Media: `import_media` for a public URL, or `create_media_upload` then `complete_media_upload` for a local file.
3. `validate_post` until `valid` is true, then `create_post` with an `idempotencyKey` and `scheduledAt` or `publishNow`.
4. `wait_for_post` until `settled`. Each target carries `externalUrl` once published, or an `error` with `retryable` and a hint. An error with `needsReconnect` becomes retryable once a person reconnects the account; then `retry_post`. An error with `mayBeLive` means the platform may already hold the post: check the account; if the post is live, `resolve_post_target` with its URL, otherwise ask a person to settle it in the dashboard.

## REST API

Base URL https://api.postiefy.com/v1, `Authorization: Bearer <API key>`. Answers are `{success, data, meta}`; errors `{success: false, error: {code, message, details}}`. Request and response fields match the MCP tools.

- `GET /v1/channels`: connected accounts, `?brandId=` for one brand (MCP: list_accounts)
- `GET /v1/brands, GET /v1/brands/{id}`: brands (clients) and their accounts (list_brands)
- `GET /v1/channels/{id}/options`: live per-account options (get_account_options)
- `GET /v1/providers`: platform limits (get_platform_constraints)
- `POST /v1/posts/validate`: dry run (validate_post)
- `POST /v1/posts`: create; send `Idempotency-Key` to make retries safe (create_post)
- `POST /v1/posts/batch`: up to 50 posts in one call, `{posts: [...]}` each with its own `idempotencyKey`; one result per item, not all-or-nothing; counts one API call per post (create_posts)
- `PATCH /v1/posts/{id}`: edit before it goes out (update_post)
- `POST /v1/posts/{id}/schedule`: schedule, publish now, or move the time (schedule_post)
- `POST /v1/posts/{id}/cancel`: cancel (cancel_post)
- `POST /v1/posts/{id}/retry`: retry failed targets (retry_post)
- `POST /v1/posts/{id}/targets/{targetId}/resolve`: settle a target in doubt (`mayBeLive`): a key reports the live post it found, with its platform URL (resolve_post_target); only a person marks it not published
- `GET /v1/posts, GET /v1/posts/{id}`: read (list_posts, get_post); the list takes `status=a,b`, `scheduledFrom`, `scheduledTo`, `updatedFrom`, `channelId`, `brandId`, `sourceKind`, `sourceId`, `sort`
- `GET /v1/posts/{id}/metrics`: raw metric snapshots of one post, with `normalized` views, likes, comments, shares (get_post_metrics)
- `GET /v1/metrics`: snapshots across posts, newest published first; `from`, `to`, `channelId`, `brandId`, `snapshot`, `page`, `limit` (list_metrics)
- `POST /v1/media/import`: import from a URL, with an optional `filename` and `brandId` (import_media)
- `GET /v1/media`: the media library: `type`, `brandId`, `q` (file name), `unused`, each with `usageCount` (list_media)
- `PATCH /v1/media/{id}, DELETE /v1/media/{id}, POST /v1/media/delete-unused`: rename or re-brand a file; delete one, or the unused ones of a list (people and publish keys)
- `POST /v1/media/uploads, POST /v1/media/{id}/complete`: presigned upload (create_media_upload)
- `GET /v1/usage`: this month against the plan (get_usage)
- `POST /v1/webhooks`: signed events: post.published, post.failed

## Error codes

- `VALIDATION_ERROR`: Fix what details names and call again. validate_post checks a post without saving it.
- `UNAUTHORIZED`: This connection is no longer valid. Reconnect Postiefy in the client.
- `PAYMENT_REQUIRED`: The workspace subscription lapsed: it can read and cancel, nothing else. A person renews it in the dashboard.
- `PLAN_LIMIT_REACHED`: The plan’s monthly allowance is used up. get_usage shows the counters. A person upgrades the plan, or it resets next month.
- `STORAGE_LIMIT_REACHED`: The plan’s media storage is full (details: limitBytes, usedBytes, fileBytes). list_media with unused: true finds files no post uses; a person deletes them in the dashboard’s media library (or a publish key calls POST /v1/media/delete-unused), or upgrades the plan.
- `FORBIDDEN`: This connection’s mode or account list does not allow it. Save a draft instead, or ask a person to reconnect with a wider mode.
- `NOT_FOUND`: Check the id. list_posts and list_accounts return the ids this connection can use.
- `CONFLICT`: The post is not in a state that allows this. Call get_post to see where it is.
- `RATE_LIMIT_EXCEEDED`: Too many calls. Wait a minute, then call again.
- `INTERNAL_ERROR`: Something failed on Postiefy’s side. Retry once; if it fails again, tell the user.
- `DATABASE_ERROR`: Something failed on Postiefy’s side. Retry once; if it fails again, tell the user.
- `EXTERNAL_SERVICE_ERROR`: The platform did not answer. Retry in a minute.
