Skip to content
Peal
Esc
↑↓navigate↵open⌘Jpreview
On this page

API overview

How the Peal HTTP API is organised, how to authenticate to it, and where its OpenAPI document and reference are.

The web app, the command line and the MCP endpoint all run on the same HTTP API, so your own code can do anything they do. Here’s where requests go, how to authenticate, and what each group of endpoints holds.

What every endpoint shares is in API conventions: request ids, the error format and every error code, paging, idempotency, rate limits, and how the API changes over time.

One contract

The API is defined once, in the peal-contract package. The server implements that definition, the clients derive their types from it, and the API reference in these docs is generated from it. The three can’t drift apart.

Base URL

Requests go to the address you open Peal at, and every endpoint’s path starts with /api. The web app forwards /api/* to the server. In these docs, https://api.example.com stands for that address, so replace it with your own:

curl -i https://api.example.com/api/health

Authentication

Every endpoint needs a credential, except the health checks and the documents platforms read about Peal. There are four kinds:

Credential Sent as For What it may do
API key Authorization: Bearer peal_… Scripts and integrations It belongs to one workspace and holds some of the permissions of the member who created it, never more. A key without post:schedule neither schedules nor publishes. It may send 600 requests a minute, 60 on a billing account without a payment method (Rate limits).
Partner key Authorization: Bearer peal_partner_… A product that uses Peal for its own customers It belongs to a partner account. It creates and reads the workspaces that account owns under /api/v1/partner, and acts inside each of them, and in no other workspace, with the permissions it was given (Embedding Peal).
OAuth access token Authorization: Bearer … The command line and MCP clients, which obtain it when you sign them in It acts as you, limited to the scopes you agreed to (below).
Session cookie The web app’s cookie The web app itself A request that changes something with it must come from the web app’s own origin.

Members who may manage keys (owners and admins) create one with POST /api/v1/workspace/api-keys while signed in. The key appears only in that answer.

An OAuth token is limited to its scopes (What each permission allows):

Scope What it allows
workspace:read Reading.
workspace:write What your role allows, except what puts posts out, and who is in the workspace, which only Peal’s command line changes.
workspace:publish Scheduling and publishing. Every endpoint that needs post:schedule needs workspace:publish from an OAuth token, and answers 403 without it.
workspace:ads Nothing alone. With workspace:write it manages ad accounts, and with workspace:publish it spends on ads.

Check who you are

Any credential, keys and partner keys included, can ask GET /api/v1/credential who it is and what it may do. For an API key, that’s its name, workspace, permissions and expiry. For a partner key, it’s its partner, scopes and permissions. It never answers the key itself (SDKs).

import { PealClient } from "@peal-social/sdk";

const peal = new PealClient({ token: process.env.PEAL_API_KEY });

const credential = await peal.credential.get();
import os

from peal import Peal

peal = Peal(token=os.environ["PEAL_API_KEY"])

credential = peal.credential.get()
import (
	"context"
	"os"

	peal "github.com/peal-social/peal/packages/peal-sdk/go"
	"github.com/peal-social/peal/packages/peal-sdk/go/client"
	"github.com/peal-social/peal/packages/peal-sdk/go/option"
)

// The client is named `client`, so that `peal` stays the package of the
// request types.
client := client.NewClient(option.WithToken(os.Getenv("PEAL_API_KEY")))
ctx := context.Background()

credential, err := client.Credential.Get(ctx)
require "peal"

peal = Peal::Client.new(token: ENV.fetch("PEAL_API_KEY"))

credential = peal.credential.get
import social.peal.PealClient;
import social.peal.types.Credential;

PealClient peal = PealClient.builder()
    .token(System.getenv("PEAL_API_KEY"))
    .build();

Credential credential = peal.credential().get();
<?php
use Peal\PealClient;

$peal = new PealClient(token: getenv('PEAL_API_KEY'));

$credential = $peal->credential->get();
using Peal;

var peal = new PealClient(Environment.GetEnvironmentVariable("PEAL_API_KEY")!);

var credential = await peal.Credential.GetAsync();
use peal_sdk::prelude::*;

let peal = PealClient::new(ClientConfig {
    token: std::env::var("PEAL_API_KEY").ok(),
    ..Default::default()
})?;

let credential = peal.credential.get(None).await?;
curl https://api.example.com/api/v1/credential \
  -H "Authorization: Bearer $PEAL_API_KEY"

Workspaces

A workspace’s resources live under /api/v1/: posts, approvals, channels, media, inbox, automations, analytics, links, webhooks, assistant and workspace, which holds its members, API keys, billing, usage and activity. DELETE /api/v1/workspace deletes the workspace itself, with everything in it (Workspaces and your account). An API key, and an application bound to a workspace, act in their own workspace. Any other credential names the workspace in the Peal-Workspace header (The workspace of a request). Each endpoint’s reference names the permission it needs, such as post:schedule or channel:connect.

When the credential doesn’t get through, you’ll see one of these:

Status Meaning
401 No credentials, or credentials that no longer work.
403 The credentials work, but don’t allow this request, or the account is banned.
404 No such resource, or a workspace the caller doesn’t belong to.

These are the requests a script uses most:

Request What it does Shown in
POST /api/v1/posts Creates a post and sends it in one request, now or at an instant Posting from an AI agent
POST /api/v1/media/import Has the server fetch an image or a video from a public HTTPS address into the workspace’s media Posting from an AI agent
POST …/posts/validate Checks a post without making it Posting through the API
POST …/posts?wait=30, GET …/posts/{postId}/outcome Waits for the outcome of a post that goes out now Posting through the API
POST …/posts/bulk Sends up to 50 posts in one request Posting through the API
POST …/posts/import Imports posts from a CSV file Posting through the API
GET …/posts Lists posts with filters Posting through the API

Sending twice

With an Idempotency-Key header, you can send a create request again safely. Within 24 hours, the same key with the same body answers the post the first request made. Another body answers 409 IdempotencyKeyReused.

A post made in one call is refused with 409 DuplicatePost when its content already goes to one of its channels less than 23 hours from its time. Set allowDuplicate: true to send it anyway.

Errors and plan limits

Every error answers a JSON body in one format:

  • a stable code, such as post_content_invalid or connect_failed
  • _tag, the same name for clients generated from the contract (PostContentInvalid)
  • a message for people, and the requestId
  • the details the reference lists.

Errors describes the format, and Error codes lists every code. Some answers come from one feature:

Answer When
429 The writing assistant’s endpoints, once the workspace has used its requests for the day.
503 The writing assistant’s endpoints, when the instance has no AI provider.
502 The writing assistant’s endpoints, when the provider gave no answer the assistant could use.
402 PlanLimitReached On an instance that bills, connecting a channel, scheduling a post or starting an upload the workspace’s plan has no room for. It names the limit (channels, members, scheduledPosts, assistantRequests or mediaStorage, in bytes) and what the plan allowed (Plans and billing).

GET /api/v1/workspace/billing shows the plan, its allowances and the workspace’s usage. GET /api/v1/workspace/usage shows what it used day by day, in UTC days (Usage).

Partner accounts

A partner account owns one workspace for each customer of a product built on Peal. Embedding Peal walks through the whole flow. Three groups of endpoints serve it:

  • /api/v1/partner answers its partner keys only. GET /api/v1/partner reads the account and what it holds, and /api/v1/partner/workspaces creates, lists, finds by externalId, changes and deletes its workspaces.
  • A partner key then calls /api/v1/… for a workspace its account owns, naming it in the Peal-Workspace header, and gets 404 for any other.
  • POST /api/v1/channels/connect-links answers a hosted, single-use link. The owner of a social account connects it there without a Peal account.

What a channel takes

Each platform has its own rules: how long a post may be and how its length is counted, which images and videos it takes, and options of its own, such as a YouTube video’s title. Peal answers the rules it checks when a post is scheduled, so you don’t have to learn them from each platform’s documentation. There are two descriptions:

  • GET /api/v1/channels/capabilities describes every platform, whether or not the workspace has a channel there.
  • GET /api/v1/channels/{channelId}/capabilities describes one channel. You get its platform’s capabilities, and under account what the account itself narrows, read from the platform at that moment.

An account can narrow a lot. A TikTok account offers only some audiences, may have turned comments, Duets or Stitches off, and has a longest video. When the platform can’t be asked, account is unread with the reason, and you get the platform’s capabilities alone.

Both need channel:read, so an API key or an application you let read only may call them:

const capabilities = await peal.channels.capabilities.get({
  channelId,
});
capabilities = peal.channels.capabilities.get(channel_id=channel_id)
capabilities, err := client.Channels.Capabilities.Get(ctx, &channels.GetCapabilitiesRequest{
	ChannelID: channelID,
})
capabilities = peal.channels.capabilities.get(channel_id: channel_id)
import social.peal.types.ChannelCapabilities;

ChannelCapabilities capabilities = peal.channels().capabilities().get(channelId);
$capabilities = $peal->channels->capabilities->get($channelId);
var capabilities = await peal.Channels.Capabilities.GetAsync(new GetCapabilitiesRequest
{
    ChannelId = channelId,
});
let capabilities = peal
    .channels
    .capabilities
    .get(channel_id, None)
    .await?;
curl https://api.example.com/api/v1/channels/$CHANNEL_ID/capabilities \
  -H "Authorization: Bearer $PEAL_API_KEY"
peal channels capabilities <channel-id> --json

A description holds these fields:

Field What it says
version The version of the description, 1 today. It goes up when a field changes meaning or leaves. Fields, platforms, lookups and restrictions are added under the same version, so skip what you don’t know.
text Every limit on the text (limits: all apply, each maximum counted in its unit, the last one being Peal’s own), the most hashtags, mentions and different links, and the characters refused. peal-contract/post-text counts each unit as the server does.
media Whether a post needs an image or a video, how many it takes, whether images and videos go together, alt text, and for each file type its size, duration, pixels, sides and aspect ratio (width divided by height). formats is null where Peal knows none of the rules yet.
options The fields a draft’s options take on that platform: each one’s type, the values of a choice, whether it’s required to schedule, its maxLength, what the platform does when it’s left out (ifLeftOut), and the lookup that answers its values. Then constraints, the rules between two fields.
lookups What the platform tells about an account, for the options that refer to it (Lookups).
analytics Whether Peal reads the counts of each post published there (perPost), which ones (postCounts: likes, reposts, replies, and quotes, impressions, clicks, reach and saves where the platform gives them), and which numbers of the account it reads day by day (accountNumbers: followers, following, posts, views, reach).

A limit that’s null is one Peal doesn’t check. The platform may still apply it, and refuse the post when it goes out.

In analytics, a number that’s left out is one the platform doesn’t give. It’s never zero. A platform’s description says so when any of its channels has counts, and lists every lookup it has. A channel’s description says it for that channel. On LinkedIn, a company page has counts and the lookup of pages to mention, and a profile has neither. On X, only where the server’s operator turned its reads on.

Lookups

Some options take values only the account knows. A lookup asks the platform for them, with the channel’s token. There are two endpoints:

  • GET /api/v1/channels/{channelId}/lookups lists the lookups a channel has, with the input each takes and the options it fills.
  • POST /api/v1/channels/{channelId}/lookups/{name} runs one. It answers a page of items tagged by the lookup’s name (_tag). When nextCursor isn’t null, send it back as cursor for the next page.

This one lists YouTube’s video categories in France:

const categories = await peal.channels.lookups.run({
  channelId,
  name: "youtubeVideoCategories",
  regionCode: "FR",
});
categories = peal.channels.lookups.run(
    channel_id=channel_id,
    name="youtubeVideoCategories",
    region_code="FR",
)
categories, err := client.Channels.Lookups.Run(ctx, &channels.LookupInput{
	ChannelID:  channelID,
	Name:       "youtubeVideoCategories",
	RegionCode: peal.String("FR"),
})
categories = peal.channels.lookups.run(
  channel_id: channel_id,
  name: "youtubeVideoCategories",
  region_code: "FR"
)
import social.peal.resources.channels.lookups.requests.LookupInput;
import social.peal.types.LookupResult;

LookupResult categories = peal.channels().lookups().run(channelId, "youtubeVideoCategories",
    LookupInput.builder().regionCode("FR").build());
use Peal\Channels\Lookups\Requests\LookupInput;

$categories = $peal->channels->lookups->run($channelId, 'youtubeVideoCategories', new LookupInput([
    'regionCode' => 'FR',
]));
var categories = await peal.Channels.Lookups.RunAsync(new LookupInput
{
    ChannelId = channelId,
    Name = "youtubeVideoCategories",
    RegionCode = "FR",
});
let categories = peal
    .channels
    .lookups
    .run(
        channel_id,
        "youtubeVideoCategories",
        &LookupInput::builder().region_code("FR").build()?,
        None,
    )
    .await?;
curl -X POST https://api.example.com/api/v1/channels/$CHANNEL_ID/lookups/youtubeVideoCategories \
  -H "Authorization: Bearer $PEAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "regionCode": "FR" }'
peal channels lookup <channel-id> youtubeVideoCategories --region FR

Each platform has its own lookups:

Lookup Platform Input Items
youtubeVideoCategories YouTube regionCode (two capital letters, US when left out), language The categories a video can be filed under in that country: id, which the categoryId option takes, and title
youtubePlaylists YouTube limit (25 when left out, 50 at most), cursor The channel’s playlists: id, title and privacy
tiktokCreator TikTok none One item: the creator’s posting settings, whose privacyLevels the privacyLevel option takes
linkedinOrganizations LinkedIn (company page channels) vanityName (required), the name in the page’s address The page of that name, if any: name and urn, which an entry of the mentions option takes, and vanityName
pinterestBoards Pinterest limit (25 when left out, 50 at most), cursor The account’s boards: id, which the boardId option takes, name and privacy
pinterestBoardSections Pinterest boardId (required), limit, cursor The sections of that board: id, which the boardSectionId option takes, and name

A lookup changes nothing, and needs channel:read. Each run is a request to the platform, counted against what the platform allows this instance, so run one when a post needs it rather than on a timer. A page may come back empty and still name a next one.

How Peal paces lookups

Peal holds lookups back so they never spend what publishing needs:

  • A channel’s lookups reach its platform 30 times a minute at most. Past that, a run answers 429 PlatformRateLimited with retryAfterSeconds.
  • The same lookup with the same input on the same channel is answered from its last answer for a minute, without asking the platform again.
  • An instance’s lookups reach each platform a set number of times a day (UTC) for all its workspaces together. Past it, a lookup answers 429 PlatformRateLimited with retryAfterSeconds until the next day.
  • What a platform says of itself rather than of an account, such as YouTube’s video categories for a region and a language, is kept for a day.
Errors a lookup answers

A lookup can fail in these ways:

Status Error When
404 LookupNotFound A name the channel doesn’t have, because its platform or its kind of LinkedIn channel lacks it.
422 LookupInputInvalid An input the lookup doesn’t take, or one without a field it needs.
409 ChannelCannotPost The channel is turned off or must be reconnected.
502 PlatformUnreachable The platform doesn’t answer.
429 PlatformRateLimited The platform asks to slow down (with retryAfterSeconds when it said how long), or Peal’s pacing above holds the run back.

Webhooks

Peal can call your server when something happens in a workspace, so you don’t have to ask the API again and again: when a post went out or failed, a channel must be reconnected, or a file is ready.

Members who may manage webhooks (owners and admins), and API keys given that permission, add endpoints under /api/v1/webhooks. Webhooks lists every event with its schema, and explains how deliveries are signed, retried and verified.

The activity log

GET /api/v1/workspace/activity lists the requests that asked to change something in the workspace. Each entry says who asked, through which key or application, which operation, and how it was answered. It needs activity:read, which owners hold (The activity log).

Your account

Your account, your notifications and their preferences live under /api/me. Peal’s web app and command line call these endpoints for the person signed in. They aren’t part of the public API, so the OpenAPI document, the reference and the SDKs leave them out. They answer 403 to API keys, which belong to a workspace, and to OAuth tokens bound to one workspace, such as an MCP client’s. A program checks its own credential with GET /api/v1/credential (Check who you are).

Three of them answer only your own session in the web app: a copy of your data (GET /api/me/export), deleting your account (DELETE /api/me) and your connected applications (/api/me/connected-apps). API keys, OAuth tokens and staff acting as you get 403 (Workspaces and your account).

OpenAPI document

The OpenAPI 3.1 document of the API is public at /api/openapi.json, at the address you open Peal at, such as https://api.example.com/api/openapi.json. You can generate a client in another language from it, or import the API into an HTTP tool.

The server also answers it at /openapi.json on its own address, such as http://localhost:3000/openapi.json for a server running from source. The web app doesn’t forward that one.

The API catalogue at /.well-known/api-catalog (RFC 9727) points programs to that document, to the MCP endpoint and to where each gets a credential (Discovery). GET /api/changelog lists what each release of the API added (Changelog).

Reference

The API reference has a page for each endpoint, grouped by tag, with its parameters, request and response schemas, and code samples. The SDKs call them from eight languages.

Was this page helpful?