Command line
Get the peal command line, sign in or use an API key, choose the workspace, and read its answers as JSON.
With peal, you work with a Peal instance from a terminal. You sign in once, in a browser, and every command then acts with your role in each of your workspaces. A script or an agent that nobody attends runs it with a workspace’s API key instead, and reads its answers as JSON.
From the command line you can:
- write and discard drafts, and upload and import media;
- schedule, publish, move and cancel posts, and follow up on those that went out;
- read analytics, billing, members and invitations, and invite people;
- save a copy of your data.
You connect channels and change roles in the web app.
Get it
There are no released builds yet. You build it from a clone of the repository, with Bun installed:
bun install --frozen-lockfile
bun nx run peal-cli:build
packages/peal-cli/dist/peal --help
packages/peal-cli/dist/peal is a single file with Bun inside. Copy it anywhere on your PATH.
Choose the instance
Point peal at the address you open Peal at, such as https://peal.example.com. Give it with --api-url or PEAL_API_URL, and the flag wins if you set both. Without either, peal uses http://localhost:3000, a server running from source. It never sends an API key there unless you name that address yourself (Run it with an API key).
export PEAL_API_URL=https://peal.example.com
peal health
peal health tells you whether the instance answers, so a script can wait for it. It exits with one of these codes:
| Exit code | When |
|---|---|
| 0 | The instance answers |
| 1 | It’s unreachable (after 5 seconds), or it answers with an error |
peal health --json prints what it measured, such as {"healthy": true, "milliseconds": 12, "url": "https://peal.example.com"}. To check the rest of your setup, run peal doctor.
Sign in
To sign in, run:
peal login
It prints an address and a code of eight letters and digits:
To sign in to https://peal.example.com, open https://peal.example.com/device in a browser and enter the code WDJB-MJHT.
Or open https://peal.example.com/device?user_code=WDJBMJHT, where the code is filled in.
Waiting for you to approve the sign-in (the code works for 10m)…
Open the address
Sign in to Peal there if you haven’t yet.
Check the code and allow
Check that the code matches the one in your terminal, then click Allow.
Go back to the terminal
peal login tells you where it saved the sign-in.
The code works for 10 minutes. If you click Deny, the sign-in is refused and peal login stops.
peal asks to do what your role allows in your workspaces, to schedule and publish posts, and to stay signed in. It saves the sign-in for that instance in credentials.json, which only you can read. The file goes in the first of these folders that’s set:
| Folder | Used when |
|---|---|
PEAL_CONFIG_DIR |
It’s set |
$XDG_CONFIG_HOME/peal |
XDG_CONFIG_HOME is set |
%APPDATA%\peal |
On Windows |
~/.config/peal |
Otherwise |
Each instance has its own sign-in, keyed by its address, so you can be signed in to several. peal renews its access by itself, and it never prints its tokens.
Two-step verification
When your account has two-step verification on, the browser asks for the code from your authenticator app, or a recovery code, as you sign in there. The command stays the same.
A workspace can require it. If yours does and your account doesn’t have it on, every command is refused, and says why. Turn it on in the web app’s account settings, then run the command again with the same sign-in. peal doctor names such a workspace.
No command manages two-step verification. With PEAL_API_KEY nothing changes, because keys aren’t concerned.
A sign-in made before publishing was asked for
A sign-in made before peal asked for publishing doesn’t hold it. The commands that put posts out tell you so, and ask you to run peal login again and approve it.
Who am I
To see who you’re signed in as, run:
peal whoami
Signed in to https://peal.example.com as Sam Example <[email protected]>.
Workspaces:
Studio (owner) studio 7c9e6679-7425-40de-944b-e07fc1f90ae7
Clients (editor) clients 3f2b8a41-5d6c-4e7f-8a9b-0c1d2e3f4a5b
Each workspace comes with its slug and its id, and --workspace takes either.
A key isn’t a person. With an API key, peal whoami tells you which key it is instead, through GET /api/v1/credential. You get its name, its workspace’s name and id, its permissions and when it expires, but never the key:
The API key in PEAL_API_KEY is "nightly" (peal_AbCd…), of the workspace Studio (7c9e6679-7425-40de-944b-e07fc1f90ae7), on https://peal.example.com.
Permissions: channel:read, post:read, post:create.
It never expires.
When the sign-in stops working, because it was revoked or your account was banned, peal whoami says so and asks you to run peal login again. Before you’ve signed in at all, it tells you you’re not signed in.
Sign out
To sign out, run:
peal logout
peal logout tells the instance to revoke the sign-in, then forgets it. It forgets it even when the instance doesn’t answer within 5 seconds.
Run it with an API key
For a run nobody attends, such as a scheduled job or an agent on a server, set PEAL_API_KEY to a workspace’s API key. The key acts in its own workspace, so the run needs nothing else:
export PEAL_API_URL=https://peal.example.com
export PEAL_API_KEY=peal_…
peal doctor
peal drafts list --json
peal reads the key from the environment only. There’s no flag for it, because a flag lands in your shell’s history and in the list of processes. peal never prints it. While PEAL_API_KEY is set, it wins over a saved sign-in, and a blank value counts as no key.
With a key, --api-url or PEAL_API_URL must name the instance the key was made on. A key goes to no default address, so without either the command stops with api_url_required and sends nothing.
A key acts in the workspace it belongs to, so you don’t need --workspace or PEAL_WORKSPACE. peal whoami and peal doctor say which workspace that is. If you name one, give its id, not its slug, because a key can’t look workspaces up. A slug stops the command with workspace_id_required, and the instance refuses another workspace’s id (forbidden). A blank PEAL_WORKSPACE names no workspace.
With the key alone, each command first asks the instance whose key it is, and that request counts toward the rate limit. Setting PEAL_WORKSPACE to the key’s workspace id, which peal whoami prints, saves one request per command.
A partner key belongs to no workspace. Name one of its partner’s workspaces by its id, or the command stops with workspace_id_required.
The key does what its permissions allow, and no more. Without post:schedule, for example, it can write drafts but not schedule them. A refusal comes in the server’s words, with the permission the key lacks.
The key fails in two other ways:
- What only a person does is refused before any request (
person_required):peal login,peal account exportandpeal account apps,peal members list, and everypeal invitationscommand. - A key the server no longer accepts (revoked, expired or another server’s) is reported as such (
api_key_refused), not as a sign-in to renew.
Check the setup
peal doctor checks what a run would use, and changes nothing. Run it first, before a script or an agent does anything else:
peal doctor
peal doctor --workspace studio --json
ok api-url https://peal.example.com, from PEAL_API_URL.
ok health The server answers.
ok ready The server and its database both answer.
ok changelog The API's latest release is of 2026-11-09: The API as the SDKs' release 0.3.0 calls it: 49 operations. Later entries list what each release adds to it.
ok credential The sign-in saved for https://peal.example.com. PEAL_API_KEY is not set.
ok access Signed in as Sam Example <[email protected]>, in 2 workspaces: Studio (studio, 7c9e6679-7425-40de-944b-e07fc1f90ae7, owner); Clients (clients, 3f2b8a41-5d6c-4e7f-8a9b-0c1d2e3f4a5b, editor).
ok publish-scope The sign-in has workspace:publish: it can schedule and publish, where your role allows it.
ok workspace Commands act in Studio (studio, 7c9e6679-7425-40de-944b-e07fc1f90ae7, owner), from --workspace.
ok mcp MCP clients connect to https://peal.example.com/api/mcp: peal mcp shows how.
It runs these checks, in this order:
| Check | What it looks at |
|---|---|
api-url |
The instance’s address, and whether it came from --api-url, PEAL_API_URL or the default. It fails for plain HTTP beyond this machine, unless --insecure-http allows it, and for the default while PEAL_API_KEY is set. |
health |
That the server answers within 5 seconds. |
ready |
That the server reaches its database. |
changelog |
That it answers GET /api/changelog with the API’s latest release (Changelog). A server that doesn’t is older, or isn’t a Peal server. |
credential |
Which credential a run uses: the key in PEAL_API_KEY, or the saved sign-in. It’s never printed. |
access |
That the credential works: who’s signed in and where, or, for a key, that it can read the workspace’s channels. |
publish-scope |
Whether the sign-in can schedule and publish. It’s skipped for a key, which has permissions rather than a scope. A sign-in without it is ok: it writes drafts, and that isn’t something to work around. |
workspace |
Which workspace commands act in, and where that choice came from. |
mcp |
The address MCP clients connect to. |
Each check is ok, failing or skipped. A check is skipped when it can’t be made, for example when the server doesn’t answer, or when it doesn’t apply. A failing check tells you what to do, on a line that starts with To do:. If any check fails, peal doctor exits with 1.
With --json, it prints {"checks": [{"name", "status", "detail", "fix"}], "ok"} on stdout, with fix only where there’s something to do. When a check fails, it also prints the failure checks_failed on stderr, with the names of the failing checks in failed.
Connect an MCP client
To get what an MCP client needs, run:
peal mcp
It prints the instance’s MCP endpoint and a configuration most MCP clients accept. It also warns you when the instance doesn’t let MCP clients register themselves. Connect an MCP client explains the rest.
Choose the workspace
Every command below acts in one workspace. Name it with --workspace (or -w), by its slug or its id, or set PEAL_WORKSPACE once for the commands that follow:
export PEAL_WORKSPACE=studio
peal drafts list
peal drafts list --workspace clients
If you belong to one workspace only, peal takes it. If you belong to several and name none, it lists their slugs and stops. With an API key, peal takes the key’s own workspace, and you name one only by its id.
Each command does what your role allows there, as the web app does. A viewer reads. An editor writes, schedules, publishes and follows up. An owner or an admin also invites.
When the instance refuses, peal says why (your role, the post’s status, the plan) and exits with 1. The refusal ends with the request’s id and the error’s code, such as Request 019a7b2f-9a04-7b61-8c3d-2e5f7a1b4c68 (forbidden). Quote that id when you ask for help (Requests and answers).
Output for scripts
With --json, a command prints the API’s answer as one JSON document on stdout, and nothing else there. Instants are in ISO 8601, in UTC. Every command that reads or changes something through the API takes it, and so do peal health and peal doctor. peal login, peal logout and peal mcp don’t.
peal post "Spring catalogue is out" --channel <channel-id> --now --json
peal posts show <post-id> --json
What the document holds depends on the command:
- Most print the answer of the endpoint they call, as the API reference describes it: a post, a page with
itemsandnextCursor, or an array. - A command whose endpoint answers without a body, such as
peal drafts discard,peal invitations revokeorpeal webhooks delete, printsnull. peal billing --jsonholds the two answers it reads, underbillingandstanding.peal health --jsonandpeal doctor --jsonprint documents of their own (Choose the instance, Check the setup).
Failures
Under --json, a failure is one JSON document too. It goes to stderr, the exit code is 1, and stdout stays empty:
{
"error": {
"code": "forbidden",
"message": "This API key does not have the permission post:schedule. An owner or an admin of the workspace gives it to the key, or creates a key that has it.",
"permission": "post:schedule",
"reason": "missingPermission",
"requestId": "019a7b2f-9a04-7b61-8c3d-2e5f7a1b4c68"
}
}
When the API refuses, error is the error as the server sent it: its code, its message, the requestId and its own fields. Error codes lists every code. Branch on code, never on message.
The command line has codes of its own for what stops it before, or instead of, an answer from the API:
| Code | When |
|---|---|
invalid_usage |
The arguments can’t be read: an unknown flag, or a missing argument. |
unreachable |
No answer came from the instance: a refused connection, an unknown host, or a timeout. |
unhealthy |
peal health got an answer that isn’t a healthy one. |
unexpected_answer |
The instance answered something the API’s contract doesn’t describe. It may be older, or not a Peal server. |
not_signed_in |
No sign-in is saved for the instance, and PEAL_API_KEY isn’t set. |
sign_in_expired |
The saved sign-in no longer works. Run peal login again. |
api_key_refused |
The instance refused the key in PEAL_API_KEY: it’s revoked, expired, or another server’s. |
person_required |
The command is for a person who’s signed in, and PEAL_API_KEY is set. |
api_url_required |
PEAL_API_KEY is set, and neither --api-url nor PEAL_API_URL names the instance. |
workspace_id_required |
With an API key, the workspace is named by something other than its id. Or a partner key, or an application’s token bound to no workspace, names none. |
workspace_required |
You belong to several workspaces and named none. |
workspace_unknown |
You belong to no workspace with that slug or id. |
no_workspace |
You don’t belong to any workspace yet. |
credential_store_failed |
The sign-in couldn’t be read from, or saved to, credentials.json. |
checks_failed |
peal doctor found failing checks, named in failed. |
refused, failed |
Anything else the command line refuses or fails at, with the reason in message. |
An answer with an error status that carries no API error gets the API’s general code for that status, such as internal_error, and the requestId when the server gave one.
An agent that runs commands rather than MCP tools works the same way (Posting from an AI agent).