# CLI reference

The `postlane` command wraps the [REST API](/docs/api): every command prints JSON and exits with a code a pipeline can gate on. It runs the same checks as the web app and the assistant tools — the same preflight, the same delivery guards, the same receipt. It is the console script of the A1 Lane STAGING Python package (also runnable as `python -m postlane`) and uses the Python standard library only.

## Configure

- `POSTLANE_URL` — the server to talk to (or `--url`).

- `POSTLANE_TOKEN` — a workspace API token (`plt_…`, scopes `read ⊂ write ⊂ publish`) for pipelines, or a session token (`ses_…`, printed by `postlane auth login`) for your own account actions (or `--token`).

- `POSTLANE_WORKSPACE` — the default workspace id (or `--workspace` / `-w`). `--pretty` indents the JSON.

```
export POSTLANE_URL=https://staging.a1lane.ai
postlane auth login --email you@example.com      # prints a session token
export POSTLANE_TOKEN=ses_…
postlane workspaces list
export POSTLANE_WORKSPACE=ws-…
postlane tokens create pipeline --scope read --scope write --scope publish   # shown once
export POSTLANE_TOKEN=plt_…                       # pipelines use the workspace token
postlane create --caption "Today's clip" --to acc_… --at 2026-11-07T09:00:00-08:00
postlane status post_… --wait                     # exit 0 only when every destination settled as asked
```

## Exit codes

| Code | Meaning |
| `0` | Done — every destination settled as asked. |
| `1` | Error — the request was refused or failed; the JSON says why. |
| `2` | Not done yet — destinations are still active. |
| `3` | Attention needed — a failed, uncertain or blocked destination, or an unhealthy account. |

## Commands

53 commands, read from the CLI's own argument parser on this request.

| Command | What it does | Usage |
| `seed-demo` | populate a demo workspace with the deterministic seeded dataset (fake connections, publish-disabled; --wipe removes exactly what the seed created) | `postlane seed-demo [-h] --email EMAIL [--password PASSWORD]
                          [--workspace-name WORKSPACE_NAME] [--wipe]` |
| `sessions-audit` | C.409: signed-in session census (offline; aggregates only, never a token, label or user id); --purge-expired also deletes sessions past expiry | `postlane sessions-audit [-h] [--purge-expired]` |
| `oauth-client-policy` | row 224: show or set one OAuth client's refresh policy (offline; operator-only — no client can choose its own). Existing grants keep the policy they were issued under | `postlane oauth-client-policy [-h] --client-id CLIENT_ID
                                    [--set {ROTATE_REUSE_REVOKE,STABLE_CONFIDENTIAL}]` |
| `oauth-client-create` | Lane F: create a pre-registered CONFIDENTIAL OAuth client (Microsoft, Muse) and print its secret ONCE (offline; operator-only — DCR and CIMD stay public). Only the secret's hash is stored; PKCE stays required | `postlane oauth-client-create [-h] --name NAME --redirect-uri
                                    REDIRECT_URIS
                                    [--auth-method {client_secret_basic,client_secret_post}]` |
| `oauth-client-list` | row 806: list every registered OAuth client (DCR, metadata-document and confidential) with live / total grants and the last grant (offline; operator-only; ids and names only) | `postlane oauth-client-list [-h]` |
| `oauth-client-delete` | row 806: delete one idle PUBLIC OAuth client (offline; operator-only). Refuses a confidential client and any client that still holds a live grant | `postlane oauth-client-delete [-h] --client-id CLIENT_ID` |
| `oauth-client-secret` | Lane F: rotate a confidential OAuth client's secret and print the new one ONCE (offline; operator-only) | `postlane oauth-client-secret [-h] --client-id CLIENT_ID --rotate
                                    [--grace-hours GRACE_HOURS]` |
| `stripe-id-sweep` | C.446: find stored Stripe customer/subscription ids the configured key no longer knows (offline, GET-only dry run); --apply clears them and reads back | `postlane stripe-id-sweep [-h] [--apply]` |
| `credential-consolidate` | Q-CRB2: find duplicate shared-credential records for the same (billing account, platform, channel) and plan merging their references onto one survivor (offline dry run); --apply performs the merge and reports references moved | `postlane credential-consolidate [-h] [--apply]` |
| `credential-split` | de-share 1113: find grant-platform credential records still shared across workspaces and plan splitting them (the earliest account's workspace keeps the record; every other row is detached to Needs reconnecting, never deleted) (offline dry run); --apply performs the split | `postlane credential-split [-h] [--apply]` |
| `vault-aad-census` | row 596: count platform credentials that open only through the vault's legacy no-AAD fallback (offline, read-only; ids and counts, never a secret). Row 936: a bounded walk — one read session, the directory in pages, a progress line per page on stderr. Exit 0 only when every workspace was read and none remain | `postlane vault-aad-census [-h] [--page-size PAGE_SIZE]
                                 [--max-sessions MAX_SESSIONS]
                                 [--resume-after RESUME_AFTER]` |
| `activation-funnel` | activation funnel for a signup range (offline): signup -> workspace created -> first connect -> first draft -> first verified delivery -> week-2 repeat publish, per-step counts + conversion; --json prints the report dict | `postlane activation-funnel [-h] [--days DAYS] [--since SINCE]
                                  [--until UNTIL] [--json]
                                  [--by {source,landing,segment}]
                                  [--include-internal | --only-internal]` |
| `platforms` |  | `postlane platforms [-h]` |
| `auth` | sign up / log in as an ordinary user; prints a session token |  |
| `auth signup` |  | `postlane auth signup [-h] --email EMAIL [--name NAME]
                            [--password PASSWORD] [--code CODE] --agree` |
| `auth login` |  | `postlane auth login [-h] --email EMAIL [--name NAME]
                           [--password PASSWORD] [--code CODE]` |
| `auth logout` |  | `postlane auth logout [-h]` |
| `auth me` |  | `postlane auth me [-h]` |
| `workspaces list` |  | `postlane workspaces list [-h]` |
| `workspaces create` |  | `postlane workspaces create [-h] name` |
| `workspaces delete` |  | `postlane workspaces delete [-h] id` |
| `workspaces settings` | key=value (require_approval=true, late_policy=hold, …) | `postlane workspaces settings [-h] [fields ...]` |
| `tokens` | workspace API tokens (session token required) |  |
| `tokens list` |  | `postlane tokens list [-h]` |
| `tokens create` |  | `postlane tokens create [-h] [--scope SCOPE] name` |
| `tokens revoke` |  | `postlane tokens revoke [-h] id` |
| `members list` |  | `postlane members list [-h]` |
| `members invite` |  | `postlane members invite [-h] [--role ROLE] email` |
| `batch` | A-4: submit many posts from a JSON file; print the roll-up | `postlane batch [-h] [--wait] [--timeout TIMEOUT] source` |
| `approval` | request | approve | reject | `postlane approval [-h] [--note NOTE] id {request,approve,reject}` |
| `release` | G-4: release a post held for same-asset confirmation | `postlane release [-h] id` |
| `handoff` | print the handoff pack(s) for a post | `postlane handoff [-h] id` |
| `accounts list` |  | `postlane accounts list [-h]` |
| `accounts connect` |  | `postlane accounts connect [-h] [--reconnect RECONNECT]
                                 [--from-file FROM_FILE]
                                 platform [fields ...]` |
| `accounts probe` |  | `postlane accounts probe [-h] id` |
| `accounts disconnect` |  | `postlane accounts disconnect [-h] id` |
| `accounts show` |  | `postlane accounts show [-h] id` |
| `accounts settings` |  | `postlane accounts settings [-h] id [fields ...]` |
| `media add` |  | `postlane media add [-h] source` |
| `media list` |  | `postlane media list [-h]` |
| `media delete` |  | `postlane media delete [-h] id` |
| `create` | create a post | `postlane create [-h] [--caption CAPTION] [--media MEDIA] [--to TO]
                       [--at AT] [--draft] [--label LABEL] [--json JSON]
                       [--wait] [--timeout TIMEOUT]` |
| `status` |  | `postlane status [-h] [--receipts] [--wait] [--timeout TIMEOUT] id` |
| `list` |  | `postlane list [-h] [--status STATUS] [--limit LIMIT] [--offset OFFSET]` |
| `attention` |  | `postlane attention [-h]` |
| `retry` |  | `postlane retry [-h] [--force] [--acknowledge]
                      [--destination DESTINATION]
                      id` |
| `cancel` |  | `postlane cancel [-h] id` |
| `delete` |  | `postlane delete [-h] id` |
| `duplicate` |  | `postlane duplicate [-h] id` |
| `publish` | queue a draft | `postlane publish [-h] [--at AT] id` |
| `resolve` | run the A-3 probe for an uncertain destination | `postlane resolve [-h] post destination` |
| `events` |  | `postlane events [-h] [--after AFTER] [--limit LIMIT] [--follow]` |
| `export` |  | `postlane export [-h]` |

## Self-hosted operator commands

These act on a deployment's own data directory or its admin token. They are for people running their own server, not for the hosted service.

| Command | What it does | Usage |
| `serve` | run the engine + API in this process | `postlane serve [-h]` |
| `seed-reviewer` | R-29: create/refresh the reviewer test workspace offline (2FA-exempt, no live platform) | `postlane seed-reviewer [-h] --email EMAIL --password PASSWORD
                              [--workspace-name WORKSPACE_NAME]` |
| `backup` | snapshot every database (SQLite backup API) + sync media/logs append-only to POSTLANE_BACKUP_TARGET | `postlane backup [-h] [--target TARGET]` |
| `backup-drill` | restore the newest snapshot into a scratch dir, integrity-check it and compare receipt counts | `postlane backup-drill [-h] [--target TARGET] [--from-remote]
                             [--scratch SCRATCH]` |
| `restore` | restore a snapshot + the newer journal into the data dir (engine stopped); the next start quarantines | `postlane restore [-h] [--snapshot SNAPSHOT] [--target TARGET]
                        [--no-journal] [--from-remote] [--scratch SCRATCH]` |
| `restore-boot` | container boot: empty data dir + a backup set on POSTLANE_BACKUP_TARGET -> restore snapshot + journal (staged, verified, promoted); fails closed | `postlane restore-boot [-h]` |
| `cutover` | P0-1 D2: the guarded SQLite -> Postgres cutover steps (reports only; never flips the configuration) | `postlane cutover [-h] [--stats STATS] [--rehearsal]
                        {preflight,backfill,verify,smoke,rollback,run}` |
| `mfa-reset` | operator recovery: turn off a user's 2FA and revoke their sessions (offline; no email path exists) | `postlane mfa-reset [-h] --email EMAIL` |
| `deletion-records` | Q-Del-5: list platform data-deletion (and deauthorize) records past 12-month retention (offline); --purge deletes them | `postlane deletion-records [-h] [--purge]` |
| `token` | show where the API token lives | `postlane token [-h] [--reveal]` |
| `health` |  | `postlane health [-h]` |

---
HTML version: https://staging.a1lane.ai/docs/cli
Tool surface: v1.12, generated from the running server
