Skip to content

Build a platform

Keep each customer's social accounts, posts, and events apart, and publish for them from inside your product.

You run a product, such as an AI content tool, and your customers want to post to their own social accounts from it. PubNio keeps each customer’s accounts, posts, and events apart, while your app talks to one API with one key.

This guide follows one customer, Trail Notes, from connecting an Instagram account to your app receiving the event that says their post went live.

Choose how to separate customers

One profile per customer (recommended) One workspace per customer
API keys One key for every customer One key per customer
Plan and bill One plan; the allowance is shared Each workspace has its own plan and bill
Team access Your team only Invite the customer’s own team
Webhooks One endpoint, or one per customer Endpoints per workspace
Best for Most platforms and AI tools Agencies whose clients log in to PubNio

A profile is a group of accounts inside a workspace. Give each profile an externalId set to your own customer ID, so every account, post, and event maps straight back to a row in your database. Connected accounts are $0 on every plan, so a customer who connects five accounts and rarely posts costs you nothing until they publish.

Your server makes every call in this guide with one workspace API key that has the publish scope. Registering the webhook endpoint in step 3 is one-time setup that needs the workspace owner’s sign-in, from the CLI’s pnio auth login or the web app.

1. Create a profile for the customer

const profile = await workspace.profiles.create({
  name: "Trail Notes",
  externalId: "cus_8421",
});
profile = workspace.profiles.create("Trail Notes", external_id="cus_8421")
curl -X POST "https://pubnio.com/api/v1/profiles?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Trail Notes","externalId":"cus_8421"}'
pnio profiles create --workspace "$WORKSPACE_ID" \
  --name "Trail Notes" --external-id cus_8421

Store profile.id next to your customer record. Creating the profile again with the same name and externalId returns the same profile, so a retried signup never makes a duplicate.

Create a connection for the customer’s profile and send them the returned URL, by email or as a button in your app. They open it in their own browser, with no PubNio account, approve the network’s consent screen, and land back on your redirectUrl. The new account joins the customer’s profile.

const launch = await workspace.accounts.prepareConnection("instagram", {
  profileId: profile.id,
  redirectUrl: "https://app.example.com/settings/social",
});
// Send launch.url to the customer. Later, confirm the result:
const result = await workspace.accounts.connectionStatus(launch.attemptId);
launch = workspace.accounts.connect(
    "instagram",
    profile_id=profile["id"],
    redirect_url="https://app.example.com/settings/social",
)
# Send launch["url"] to the customer. Later, confirm the result:
result = workspace.accounts.get_connection(launch["attemptId"])
curl -X POST "https://pubnio.com/api/v1/integrations/instagram/connect?workspaceId=$WORKSPACE_ID&profileId=$PROFILE_ID&redirectUrl=https%3A%2F%2Fapp.example.com%2Fsettings%2Fsocial" \
  -H "Authorization: Bearer $PUBNIO_API_KEY"

curl "https://pubnio.com/api/v1/integrations/attempts/$ATTEMPT_ID?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_API_KEY"
pnio integrations connect instagram --workspace "$WORKSPACE_ID" \
  --profile-id "$PROFILE_ID" \
  --redirect-url https://app.example.com/settings/social --no-browser
pnio integrations wait "$ATTEMPT_ID" --workspace "$WORKSPACE_ID"

What your customer sees. A short PubNio page names your workspace, or your brand, and the network, with a Continue button. Opening the link does not use it, so email scanners and link previews cannot spend it. Continue ties the link to that browser and opens the network’s consent screen. When they finish, PubNio sends them to redirectUrl with attemptId and status (connected, empty, denied, or failed) added to your query string. Without a redirectUrl, PubNio shows its own “Connected” page. For Bluesky, the page is a handle and app-password form instead.

The redirect alone is not proof. Confirm with the attempt, which returns status: "connected", the profileId, and the new account IDs, or with the account.connected webhook. Any key in the workspace can read the attempt.

A link lasts one hour; pass expiresIn in seconds for up to 48 hours. It works once, in one browser. Revoking the key that created it stops its open links. If the network sends the customer back to a different browser, such as a phone’s native app, they see a page asking them to open the link again where they pressed Continue.

Brand your connect pages

On Platform and higher, the pages a link opens can carry your product’s name, logo, button color, and a help link. The page then reads “Trail Notes uses PubNio to connect your account.” It still ends with “Powered by PubNio”, and the network’s own consent screen is unchanged.

Every field is optional. Send null to clear one; a cleared name falls back to your workspace name. PubNio copies logoUrl once into its own storage, so send a public https: PNG, JPEG, or WebP of at most

1 MiB. An accentColor too light for white button text shows as PubNio’s dark default. Branding is workspace setup, so it needs the workspace owner’s sign-in, like the webhook endpoint in step 3. Owners can also edit it, with a live preview, under Settings → Connect pages.

await workspace.accounts.updateConnectBranding({
  displayName: "Trail Notes",
  logoUrl: "https://app.example.com/logo.png",
  accentColor: "#0b5fff",
  supportUrl: "mailto:help@example.com",
});

Branding needs a signed-in workspace owner, so the Python SDK, which authenticates with a workspace API key, does not set it. Use the console, the TypeScript SDK with a sign-in session, or the CLI.

curl -X PATCH "https://pubnio.com/api/v1/integrations/connect-branding?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"displayName":"Trail Notes","logoUrl":"https://app.example.com/logo.png","accentColor":"#0b5fff","supportUrl":"mailto:help@example.com"}'
echo '{"displayName":"Trail Notes","accentColor":"#0b5fff"}' |
  pnio integrations connect-branding update --workspace "$WORKSPACE_ID" --file -

On a plan without branded connect pages, the update returns plan_required with the plan that includes them. If the workspace later moves to such a plan, PubNio keeps your settings but shows the plain pages until you upgrade again.

3. Route events to the customer

Every event about an account in a profile carries that profileId. You have two ways to deliver it.

  • One endpoint for every customer. Subscribe once, then look up the customer by event.profileId. This is the simplest choice.
  • One endpoint per customer. Set profileId on the endpoint, and it only receives that customer’s events. Use this when each customer has their own receiving URL.
const created = await workspace.webhooks.create({
  name: "Trail Notes deliveries",
  url: "https://hooks.example.com/pubnio/cus_8421",
  eventTypes: [
    "account.connected",
    "post.delivery.published",
    "post.delivery.failed",
  ],
  profileId: profile.id,
});
// Save created.secret now; it is shown once.

Creating a webhook endpoint needs a signed-in workspace owner, so the Python SDK, which authenticates with a workspace API key, does not create endpoints. Use the console, the TypeScript SDK with a sign-in session, or the CLI.

curl -X POST "https://pubnio.com/api/v1/workspaces/$WORKSPACE_ID/webhook-endpoints" \
  -H "Authorization: Bearer $PUBNIO_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"name\":\"Trail Notes deliveries\",\"url\":\"https://hooks.example.com/pubnio/cus_8421\",\"eventTypes\":[\"account.connected\",\"post.delivery.published\",\"post.delivery.failed\"],\"profileId\":\"$PROFILE_ID\"}"
pnio webhooks create --workspace "$WORKSPACE_ID" \
  --name "Trail Notes deliveries" \
  --url https://hooks.example.com/pubnio/cus_8421 \
  --event account.connected \
  --event post.delivery.published \
  --event post.delivery.failed \
  --profile-id "$PROFILE_ID"

Workspace-wide events, such as billing, have no profileId and never reach an endpoint filtered to one profile. Keep one unfiltered endpoint for those.

4. Publish for the customer

List the customer’s ready accounts by profile, then publish to them. Keep every destination of a post inside one customer’s profile, so the post’s summary event carries that profileId too.

const ready = await workspace.accounts.list({
  profileId: profile.id,
  ready: true,
});

const accepted = await workspace.posts.create({
  text: "Our spring trail guide is live. Ten loops under five miles.",
  accounts: ready.accounts.map((account) => account.accountId),
  idempotencyKey: "cus_8421-post-118",
});
ready = workspace.accounts.list(profile_id=profile["id"], ready=True)

accepted = workspace.posts.create(
    text="Our spring trail guide is live. Ten loops under five miles.",
    accounts=[account["id"] for account in ready["accounts"]],
    idempotency_key="cus_8421-post-118",
)
curl "https://pubnio.com/api/v1/integrations?workspaceId=$WORKSPACE_ID&profileId=$PROFILE_ID&ready=true" \
  -H "Authorization: Bearer $PUBNIO_API_KEY"

curl -X POST "https://pubnio.com/api/v1/posts?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: cus_8421-post-118" \
  -d "{\"text\":\"Our spring trail guide is live.\",\"accounts\":[\"$ACCOUNT_ID\"]}"
pnio posts create --workspace "$WORKSPACE_ID" \
  --text "Our spring trail guide is live." --account "$ACCOUNT_ID" \
  --idempotency-key cus_8421-post-118

Build the idempotency key from your own customer and post IDs, so a retry after a crash can never post twice. See Idempotency.

5. Receive the customer’s delivery event

When Instagram confirms the post, PubNio sends post.delivery.published to the endpoint. Verify the signature on the raw body, find the customer by profileId, and record the live URL.

{
  "id": "6f1c2a9e-…",
  "type": "post.delivery.published",
  "version": 1,
  "timestamp": "2026-12-04T17:02:11Z",
  "workspaceId": "…",
  "profileId": "…",
  "data": {
    "postId": "…",
    "targetId": "…",
    "attemptId": "…",
    "accountId": "…",
    "provider": "instagram",
    "placement": "feed",
    "revision": 1,
    "status": "published",
    "providerRef": { "id": "17895695668004550", "kind": "post" },
    "url": "https://www.instagram.com/p/…"
  }
}
import { verifyWebhookSignature } from "@pubnio/sdk";

export async function handle(request: Request) {
  const event = await verifyWebhookSignature({
    secret: process.env.PUBNIO_WEBHOOK_SECRET!,
    body: await request.text(),
    headers: request.headers,
  });
  if (await alreadyHandled(event.id))
    return new Response(null, { status: 200 });

  const customer = await customers.findByPubNioProfile(event.profileId);
  if (event.type === "post.delivery.published")
    await customer.markLive(event.data.postId, event.data.url);
  return new Response(null, { status: 200 });
}
import os

from pubnio import verify_webhook_signature

def handle(body: bytes, headers) -> int:
    event = verify_webhook_signature(os.environ["PUBNIO_WEBHOOK_SECRET"], body, headers)
    if already_handled(event["id"]):
        return 200
    customer = customers.find_by_pubnio_profile(event.get("profileId"))
    if event["type"] == "post.delivery.published":
        customer.mark_live(event["data"]["postId"], event["data"].get("url"))
    return 200

Deliveries arrive at least once and can arrive out of order, so deduplicate by event.id. Idempotent webhook handling shows the full pattern, and Webhooks lists every event.

Plan for scale

  • Billing: a workspace has one plan, and every customer’s confirmed publishes draw from its allowance. See Rate limits and plan limits.
  • Limits: one post takes up to 50 destinations and counts as one request against the rate limit, so publish a customer’s whole batch in one call.
  • Offboarding: move or disconnect a customer’s accounts, then archive the profile. Delivery history stays for your records.
  • Agents: if your product runs an agent, point it at the hosted MCP server with a workspace API key. It gets the same profiles, accounts, and posts. See Hosted MCP.

Type to search…

↑↓ navigate↵ selectEsc close