API for publishing to social networks
Use one API to connect accounts, choose recipients, publish content, and check the result.
Sections
1. Get an API key
Create a OnePost account and request an API key. You can request access on any plan.
After approval, open Integrations → API and create a dedicated key for your integration. Choose its permissions and projects. The secret is shown once. Store it on your server or in your personal CLI. Keep it out of distributed websites and iOS or Android clients.
The publishing examples require posts:publish and posts:read. Setup requires profiles:read and connections:read. Connecting accounts requires connections:write. Creating a project requires profiles:write and access to all projects. Uploading files requires media:write. Reading the plan requires subscription:read. A key does not extend your plan limits.
Use this server's exact origin as the base URL. Send Authorization: Bearer YOUR_POST_KEY with every protected request. A revoked key returns 401. Insufficient permissions or a suspended account returns 403. API access is available on every plan and shares its publishing allowance with the website and MCP.
Plan and permissions
curl --fail-with-body 'https://onepost.cc/api/capabilities' -H 'Authorization: Bearer YOUR_POST_KEY'2. Set up a project and connection
Use GET /api/profiles or create a project. GET /api/platforms returns the available networks, authorization methods, fields, and instructions for each platform.
Create a project
curl --fail-with-body 'https://onepost.cc/api/profiles' -H 'Authorization: Bearer YOUR_POST_KEY' -H 'Idempotency-Key: create-profile-000001' -H 'Content-Type: application/json' --data '{"name":"My brand"}'For OAuth, send platform, profileId, and the oauthForm fields in parameters. Open authorizeUrl in the user's browser. The user does not need to sign in to OnePost. The single-use link expires after five minutes. Keep the key on your server.
Start OAuth
curl --fail-with-body 'https://onepost.cc/api/connections/sessions' -H 'Authorization: Bearer YOUR_POST_KEY' -H 'Idempotency-Key: connect-youtube-000001' -H 'Content-Type: application/json' --data '{"platform":"youtube","profileId":"PROFILE_ID","parameters":{}}'Save a random operation key before the first POST. If the result is unknown, retry with the same key and unchanged parameters. Generate a new key for each new connection; the example key is for demonstration. If you did not receive a session ID, look up the session by its original key. Retrieving an existing link preserves its original expiration and session.
Find an existing OAuth session
curl --fail-with-body 'https://onepost.cc/api/connections/sessions?operationKey=connect-youtube-000001' -H 'Authorization: Bearer YOUR_POST_KEY'Retrieve an unused authorization link
curl --fail-with-body 'https://onepost.cc/api/connections/sessions/SESSION_ID/authorize-url' -H 'Authorization: Bearer YOUR_POST_KEY' -H 'Content-Type: application/json' --data '{}'After the user confirms, cancel the unfinished operation using the original key, project, and platform. Cancellation works without a session ID and prevents the same operation from creating a connection later. An already connected account returns 409. Disconnect it separately.
Cancel an OAuth operation after confirmation
curl --fail-with-body 'https://onepost.cc/api/connections/sessions' -H 'Authorization: Bearer YOUR_POST_KEY' -X DELETE -H 'Content-Type: application/json' --data '{"operationKey":"connect-youtube-000001","profileId":"PROFILE_ID","platform":"youtube","confirm":true}'To reauthorize an active account, check actions.reauthorizeConnection in GET /api/capabilities. If true, send reconnectConnectionId from GET /api/connections and the current project. OnePost verifies that you chose the same external account, channel, or page before saving. Use a new key for this separate operation.
Reauthorize the original account
curl --fail-with-body 'https://onepost.cc/api/connections/sessions' -H 'Authorization: Bearer YOUR_POST_KEY' -H 'Idempotency-Key: reauthorize-youtube-000001' -H 'Content-Type: application/json' --data '{"platform":"youtube","profileId":"PROFILE_ID","parameters":{},"reconnectConnectionId":"CONNECTION_ID"}'After authorization, call GET /api/connections/sessions/SESSION_ID. If the status is selection_required, retrieve the choices through GET /api/connections/youtube/selection/SELECTION_ID or facebook/selection/SELECTION_ID, then POST channelId or pageId. For a direct bot, webhook, or token connection, POST the connectionForm fields and profileId to /api/connections/PLATFORM. Nostr uses a challenge and a signed event. The private key stays with the signer.
POST /api/connections/lemmy takes instance, username, password, and optional totp. OnePost does not store the password or 2FA code. The response contains selectionId and choices. GET /api/connections/lemmy/selection/SELECTION_ID?name=community searches by name, and POST with choiceId completes the connection. The selection expires after 10 minutes and requires the original access. You do not need to enter a token or community ID manually.
GET /api/connections returns ID, platform, profileIds, and version. Secrets are omitted. PATCH /api/connections/ID with profileId and linked adds or removes the account from the project. DELETE on the same path disconnects the account entirely. A restricted key cannot disconnect an account used by a project it cannot access.
Get accounts and versions
curl --fail-with-body 'https://onepost.cc/api/connections' -H 'Authorization: Bearer YOUR_POST_KEY'3. Send a post
Save this JSON as publication.json. Replace PROFILE_ID and CONNECTION_ID with your own values. Get CONNECTION_VERSION from GET /api/connections. The example publishes text immediately to the selected Telegram account. For multiple recipients, list them in recipients and list each distinct network in platforms.
publication.json
{
"profileId": "PROFILE_ID",
"title": "My post",
"text": "Text you want to publish",
"format": "text",
"platforms": [
"telegram"
],
"recipients": [
{
"id": "CONNECTION_ID",
"platform": "telegram",
"version": "CONNECTION_VERSION"
}
],
"mediaIds": [],
"timezone": "Europe/Warsaw",
"plannedAt": null
}Common fields are title, text, format, mediaIds or mediaUrls, and timezone. platformContent holds platform-specific title and text variants and options. To use the default project account for each platform, pass connectionVersions keyed by platform ID. Use recipients to specify the exact destinations.
Set plannedAt as an ISO UTC timestamp with seconds or milliseconds, up to 30 days ahead. timezone sets the IANA time zone. Scheduling is available on every plan. addToQueue uses the selected project accounts' schedules in place of plannedAt. Multiple accounts need a shared available slot. background: true submits the content for background processing. Nostr requires signing at send time, so it supports neither background publishing nor scheduling.
Assign each post a stable Idempotency-Key of 16–128 letters, digits, underscores, or hyphens. Store it with the original JSON and publication.id. Retrying the same request with the same key returns the previous result. If the content changes, use a new key for the new post.
4. Copy an example
Set POST_BASE_URL (the exact origin), POST_API_KEY, POST_REQUEST_ID (the stable key for this post), and POST_PAYLOAD_FILE (the path to your reviewed publication.json). The JavaScript, Python, Swift, and Kotlin examples create a post and read its status once. They do not retry automatically. If processing continues, save the ID for a later status check.
Create a post
# Run in Bash; require an origin, never a path or credentials.
if ! [[ "$POST_BASE_URL" =~ ^https://[^/@?#[:space:]]+/?$ ||
"$POST_BASE_URL" =~ ^http://(localhost|127[.]0[.]0[.]1)(:[0-9]+)?/?$ ]]; then
printf '%s\n' 'POST_BASE_URL must be an HTTPS origin (HTTP only on localhost)' >&2
exit 1
fi
POST_BASE_URL="${POST_BASE_URL%/}"
# POST_PAYLOAD_FILE points to the reviewed publication.json below.
# Reuse POST_REQUEST_ID for this material; do not generate it on each retry.
curl --fail-with-body --max-time 120 \
"$POST_BASE_URL/api/publications" \
-H "Authorization: Bearer $POST_API_KEY" \
-H "Idempotency-Key: $POST_REQUEST_ID" \
-H 'Content-Type: application/json' \
--data-binary "@$POST_PAYLOAD_FILE"
# Save publication.id from the response, then read its individual results:
curl --fail-with-body --max-time 30 \
"$POST_BASE_URL/api/publications/PUBLICATION_ID" \
-H "Authorization: Bearer $POST_API_KEY"The Swift example is for a server or a local CLI with Swift 6.2+ and Foundation. The Kotlin main-kts example requires Kotlin 2.4+, JDK 11+, and the official kotlinx.serialization-json 1.11.0 dependency declared in the example. These examples have not been run.
Media and drafts
POST /api/media accepts raw JPEG, PNG, MP4, or PDF data. Send Content-Type and X-File-Name, with the filename encoded using encodeURIComponent. You can provide a stable Idempotency-Key for the file. A restricted key can set ?profileId=ID explicitly. Use the returned media.id in mediaIds.
Upload a photo
curl --fail-with-body 'https://onepost.cc/api/media?profileId=PROFILE_ID' -H 'Authorization: Bearer YOUR_POST_KEY' -H 'Content-Type: image/png' -H 'X-File-Name: photo.png' -H 'Idempotency-Key: upload-photo-000001' --data-binary @photo.pngStandard limits are 10 MB per photo, 50 MB per video or PDF, and 500 MB of storage per account. Platforms may apply stricter limits. Short-video mode with X-Post-Shorts: 1 accepts compatible MP4, MOV, or WebM up to 100 MB. GET /api/media returns pages of up to 100 with cursor. DELETE /api/media/ID deletes only unused files.
Use mediaUrls to import direct public HTTPS links for up to 10 photos or one video or PDF, without mediaIds. For short videos, set shortVideo: true. Set the first comment through firstComment or platformContent. Availability depends on the platform and the OAuth application's permissions.
POST /api/posts saves a draft without publishing. PATCH /api/posts/ID replaces fields. Include all values you need to keep, since omitted attachments or variants may be cleared. To publish a draft directly with POST /api/posts/ID/publish, send Idempotency-Key, If-Match with version in double quotes, and X-Connection-Version. Use /api/publications to publish to multiple networks.
Results, errors, and limits
The website, API, and MCP share one allowance. Each successful delivery to one recipient consumes one post credit. A confirmed deletion returns the credit if requested through OnePost within 15 minutes of post. GET /api/capabilities shows used, temporarily reserved, and remaining credits.
If the response from POST /api/publications was lost and the post ID is unknown, call GET /api/publications?operationKey=ORIGINAL_KEY with the original key. This requires posts:read and access to the original project. The lookup does not create deliveries or consume a credit. After a 404, the original request may still be processing. In MCP, use recover_publication with the original idempotencyKey.
Recover a post after an unknown result
curl --fail-with-body 'https://onepost.cc/api/publications?operationKey=publish-example-000001' -H 'Authorization: Bearer YOUR_POST_KEY'GET /api/publications/ID returns the result for each recipient. HTTP 2xx confirms that the API request was processed. Check each recipient for the publishing result. published means the platform confirmed delivery, sending means in progress, failed means rejected, and uncertain means the result is unknown and should be verified before retrying. completed means processing is finished for every recipient, including any failures.
POST /api/publications/ID/check/PLATFORM checks processing on the platform. POST /api/publications/ID/resume/PLATFORM explicitly continues a supported workflow. Neither operation creates a new post. PATCH /api/publications/ID edits a scheduled post. DELETE cancels it before sending starts. If-Match can protect the schedule revision. GET /api/deliveries returns delivery history with filters and a cursor.
400: invalid fields. 401: key required or invalid. 403: permissions or plan. 404: resource unavailable. 409: conflict or connection state. 410: expired session. 412: version changed. 413: size limit. A 429 with Retry-After and code=publication_quota_exceeded means the monthly allowance was reached. schedule_quota_exceeded means the queue is full. rate_limited or concurrency_limited indicates a technical limit. 503 server_busy means the server is busy. Keep the same Idempotency-Key after a network error.
Each separate account delivery uses one credit. Publishing to three accounts uses three credits. Every plan can schedule up to 30 days ahead. The queue limit applies across all projects. GET /api/capabilities provides scheduleQuota.limit and the remaining slots. One post with multiple recipients uses one slot. The website, REST API, and MCP share one monthly allowance. GET /api/capabilities shows the remaining credits and reset date. Technical per-minute and concurrency limits are the same for every plan. JSON is usually limited to 16 KiB, drafts to 128 KiB, and posts to 512 KiB.
Platforms and formats
Connection status shows whether the platform is publicly available. Formats depend on the platform and publishing method.
| Platform | Publishing formats | Public connection |
|---|---|---|
| photo, video, carousel | Unavailable | |
| TikTok | photo, video | Unavailable |
| YouTube | video | Available |
| text, document, photo, video | Available | |
| text, photo, video | Unavailable | |
| Threads | text, photo, video | Unavailable |
| photo, video | Unavailable | |
| Bluesky | text, photo, video | Available |
| Discord | text, photo, video | Available |
| Telegram | text, photo, video | Available |
| Mastodon | text, photo, video | Available |
| Nostr | text | Available |
| Lemmy | text | Available |
| Dev.to | text | Unavailable |
| Hashnode | text | Available |
| Whop | text | Unavailable |
| Listmonk | text | Available |
| text | Unavailable |