Publishing
Let an agent post to your social accounts through the vendor you connected, held for your approval by default, with every post recorded in the outcome ledger.
Publishing
Publishing lets an agent post to your social accounts through a publishing vendor you connect with your own account there. The first vendor is Ayrshare.
This feature is off unless the operator sets BR_PUBLISHING_ENABLED=1. With it off every endpoint below answers 404 with code publishing_disabled, and the MCP tools return the same error.
The Ayrshare adapter was written from Ayrshare's public documentation and has never been run against the real Ayrshare API. It is tested against stubbed responses only. Expect to find differences on the first real run; see What is unverified.
How it works
- You connect the vendor. You give BrainstormRouter your own Ayrshare API
key. It is checked against Ayrshare once, stored encrypted with the same key envelope as your provider keys, and never returned. BrainstormRouter has no Ayrshare key of its own: with nothing connected, posting answers not_connected.
- An agent asks to publish. One platform, the text, optional media and an
optional schedule time.
- You decide. By default (
publish_approval = required) the post is held
and nothing is sent. It appears with your other pending approvals in the dashboard. You approve it, edit and approve it, or reject it.
- It is recorded. The post is an action in the outcome ledger.
Your decision becomes approved, edited or rejected on that action; going live becomes published; comments reported by the vendor become comment.
Who can do what
| Action | Who |
|---|---|
| List accounts, request a post, read status, withdraw | Any key with tool.execute (OAuth scope tools) |
| Connect or disconnect the vendor | A key with config.write (admin or operator), or the dashboard |
| Approve or reject a post | A tenant owner or admin signed in to the dashboard. No key. |
Change publish_approval | A tenant owner or admin signed in to the dashboard. No key. |
| Delete a post that is already live | Under required: the dashboard owner or admin. Under auto: any key with tool.execute |
No API key can approve a post or switch approval off, whatever its role. The existing approval endpoints (POST /v1/approvals/{id}/approve, the br_approve_request tool) answer 403 owner_decision_required for a post, and there is no /v1 endpoint for the setting. No OAuth scope gained a permission for this feature.
Endpoints
| Step | REST | MCP tool | SDK |
|---|---|---|---|
| Connected accounts | GET /v1/publishing/accounts | br_publish_accounts | client.publishing.accounts |
| Publish / schedule | POST /v1/publishing/posts | br_publish_post | client.publishing.publish |
| One post's status | GET /v1/publishing/posts/{id} | br_publish_status | client.publishing.get |
| List posts | GET /v1/publishing/posts | br_publish_list | client.publishing.list |
| Withdraw / cancel | DELETE /v1/publishing/posts/{id} | br_publish_cancel | client.publishing.cancel |
| Connection state | GET /v1/publishing/connection | — | client.publishing.connection |
| Connect | PUT /v1/publishing/connection | — | client.publishing.connect |
| Disconnect | DELETE /v1/publishing/connection/{vendor} | — | client.publishing.disconnect |
| Vendor webhook | POST /v1/inbound/{vendor}/{tenantHookId} | — | — |
The owner's side is on the dashboard API (signed-in session, owner or admin): GET /auth/publishing, PUT /auth/publishing/settings, PUT /auth/publishing/connection, DELETE /auth/publishing/connection/{vendor}, POST /auth/publishing/posts/{id}/approve, .../reject, .../delete. The dashboard's existing approvals list (/auth/approvals/*) also shows held posts, with the full text and media URLs in the summary line, and its Approve and Reject buttons decide them. There is no dedicated publishing screen in the dashboard yet: connecting a vendor, changing the setting and editing a post before approving are API calls for now.
Connect
curl -X PUT https://api.brainstormrouter.com/v1/publishing/connection \
-H "Authorization: Bearer $BR_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{ "vendor": "ayrshare", "api_key": "YOUR-AYRSHARE-API-KEY" }'
{
"connection": {
"vendor": "ayrshare",
"connected": true,
"key_preview": "…9XQ2",
"has_profile_key": false
},
"accounts": [{ "platform": "linkedin", "display_name": "Acme", "username": "acme" }],
"inbound": {
"url": "https://api.brainstormrouter.com/v1/inbound/ayrshare/<hook id>",
"secret": "<signing secret>",
"note": "Shown once. …"
}
}
profile_key is optional, for Ayrshare accounts with more than one User Profile. The inbound block is shown once; see Inbound events. Connecting again replaces the key, the hook URL and the secret.
Publish
curl -X POST https://api.brainstormrouter.com/v1/publishing/posts \
-H "Authorization: Bearer $BR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platform": "linkedin",
"text": "We rebuilt onboarding. Setup now takes four minutes.",
"idempotency_key": "launch-post-1",
"request_ids": ["req_0193…"],
"campaign": "q4-launch"
}'
| Field | Notes |
|---|---|
platform | One platform from GET /v1/publishing/accounts. One post goes to one platform. |
text | Up to 3,000 characters. |
media_urls | Up to 10 public https:// URLs. |
schedule_at | ISO-8601 UTC, at least a minute ahead. Omit to publish now. |
idempotency_key | Required. The same key returns the same post and never sends twice. |
request_ids | BrainstormRouter request ids that wrote the post; the model is looked up from your usage records. |
campaign, task_type | Labels carried into the outcome ledger. |
Responses:
202withheld_for_approval: trueandapproval_id: the post is
waiting for the owner. Nothing has been sent. Poll the post's status.
201(only underpublish_approval = auto): sent.post.statusis
published, scheduled or submitted.
200withreplayed: true: this idempotency key was seen before.
A held post that nobody decides expires after 72 hours, unsent.
Post statuses
| Status | Meaning |
|---|---|
pending_approval | Waiting for the owner. Nothing sent. |
rejected | The owner said no. Nothing sent. |
expired | Nobody decided in 72 hours. Nothing sent. |
cancelled | Withdrawn before it went out. |
sending | Claimed for sending; the vendor call is in flight. |
submitted | The vendor accepted it and has not reported a final state. |
scheduled | The vendor holds it for a future time. |
published | The vendor reports it is live; post_url is set when known. |
failed | The vendor refused it or reported a failure; see error. |
deleted | It was live and was removed through the vendor. |
A post is handed to the vendor once. If the send fails it becomes failed; it is not retried, and repeating the request with the same key does not resend it. Use a new idempotency_key to try again. A post left in sending (the process stopped mid-call) is not resent automatically either.
Approve, edit, reject
In the dashboard, held posts are listed with the other pending approvals. Approving sends the post. Over the dashboard API:
# Approve, changing the text first
curl -X POST https://api.brainstormrouter.com/auth/publishing/posts/$POST_ID/approve \
-H "Authorization: Bearer $DASHBOARD_SESSION_JWT" \
-H "Content-Type: application/json" \
-d '{ "text": "We rebuilt onboarding. Setup takes four minutes." }'
schedule_at can be changed in the same call; null means publish as soon as it is approved. If the scheduled time has already passed, approval is refused with schedule_time_passed until you pick one of those.
To let agents publish without waiting:
curl -X PUT https://api.brainstormrouter.com/auth/publishing/settings \
-H "Authorization: Bearer $DASHBOARD_SESSION_JWT" \
-H "Content-Type: application/json" \
-d '{ "publish_approval": "auto" }'
What reaches the outcome ledger
| What happened | Outcome event | Changes routing? |
|---|---|---|
| Owner approved as written | approved | Yes, reward 1.0 |
| Owner edited, then approved | edited (ratio) + approved | Yes, reward 1 − edit ratio |
| Owner rejected | rejected | Yes, reward 0.0 |
| Vendor reports the post live | published | No |
| Vendor reports a comment on the post | comment | No |
| Withdrawn, expired, failed | — | No |
Sent under auto | published only | No: nobody judged the copy |
The edit ratio is the character edit distance between the requested text and the approved text, divided by the longer length. Rewards are applied by the outcome ledger, once per post and model, only when request_ids resolve to your usage records. post.outcome_action_id is the action; you can report more against it (replies, meetings, revenue) with POST /v1/outcomes/actions/{actionId}/events.
Inbound events
Register the inbound.url from the connect response at Ayrshare as a webhook (POST /hook/webhook, or their dashboard), with inbound.secret as its secret. Useful actions: scheduled, comments.
The receiver:
- has no API key; it is authenticated by the unguessable hook id in the URL
and the vendor's X-Authorization-Content-SHA256 signature (HMAC-SHA256 of the body with your secret), compared in constant time;
- accepts bodies up to 64 KB, is rate limited per IP and per hook, and ignores
an event it has already stored (it answers 200 again);
- for a post BrainstormRouter published: marks a scheduled post
publishedor
failed, and counts comments in the outcome ledger;
- stores and ignores everything else (direct messages, account events, events
about posts it did not publish). It keeps the event kind, platform and ids. It does not keep message or comment text, and no endpoint returns inbound content to an agent;
- never calls a model and never triggers an outbound action.
What is unverified
From Ayrshare's documentation as read on 2026-11-10; none of it has been exercised against the live service:
- Whether the webhook signature is hex or base64 (both are accepted), and
whether it covers exactly the raw body. If Ayrshare signs anything else, every delivery is answered 401 and inbound events are lost. Publishing is unaffected, and status still updates when you read a scheduled post.
- Whether every webhook carries an event id. When one does not, the event is
de-duplicated on a hash of its body.
- The response to a delete that only partly succeeds. Ayrshare documents that
Instagram and TikTok posts cannot be deleted through its API.
- Rate limits. A
429from the vendor is reported asvendor_rate_limited
and nothing is retried.
Posting to X is not offered: since 2026-03-31 Ayrshare requires your own X developer app credentials on each request, which this adapter does not send.
Not built yet
- A publishing screen in the dashboard (held posts do appear in the existing
approvals page).
- Posting one request to several platforms.
- Reading inbound comments or messages back.
- Editing a post after it is scheduled or live.
- A second vendor.