---
title: "CLI"
description: "Use the PubNio command line for auth, posts, drafts, publishing, and media."
---

> Documentation Index
> Fetch the complete documentation index at: https://pubnio.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

The CLI binary is `pnio`. In this repository, run it with `bun run cli`; the
commands below use `pnio` for brevity.

## Sign in

```sh
pnio auth login
pnio auth status
```

For unattended work, set `PUBNIO_API_KEY` to a workspace API key. The CLI uses
the key instead of the browser session.

## Common commands

```sh
pnio workspaces list
pnio workspaces create --name "Studio" --default-timezone America/New_York
pnio workspaces update "$WORKSPACE_ID" --default-timezone Asia/Tokyo
pnio integrations list --workspace "$WORKSPACE_ID"
pnio media list --workspace "$WORKSPACE_ID"
pnio media upload ./launch.mp4 --workspace "$WORKSPACE_ID"
pnio media import "https://cdn.example.com/launch.mp4" --workspace "$WORKSPACE_ID"
pnio media wait "$MEDIA_ID" --workspace "$WORKSPACE_ID" --timeout 30
pnio posts create --workspace "$WORKSPACE_ID" \
  --text "Launch day" --platform x
pnio posts get --workspace "$WORKSPACE_ID" "$POST_ID"
pnio posts status --workspace "$WORKSPACE_ID" "$POST_ID"

# Advanced: save and publish a reviewed draft
pnio posts create --draft --workspace "$WORKSPACE_ID" --file draft.json
pnio posts update --workspace "$WORKSPACE_ID" "$POST_ID" --text "Launch day" --revision 1
pnio posts validate --workspace "$WORKSPACE_ID" "$POST_ID"
pnio posts publish --workspace "$WORKSPACE_ID" "$POST_ID" \
  --revision 1 --idempotency-key "$(uuidgen)"
```

`pnio posts create --draft --file -` reads the draft JSON from stdin. Use
`--text` for a text-only draft. `pnio posts delete` archives a draft or post. `pnio media upload`, `import`, `status`, and `wait`
print the same `{ mediaId, status, asset?, issue? }` intake result.

## Schedule and manage deliveries

```sh
pnio posts publish --workspace "$WORKSPACE_ID" "$POST_ID" \
  --revision 1 --idempotency-key "$(uuidgen)" \
  --at "2026-12-02T15:00:00-08:00"

pnio posts reschedule --workspace "$WORKSPACE_ID" "$POST_ID" "$TARGET_ID" \
  --attempt "$ATTEMPT_ID" --at "2026-12-02T16:00:00-08:00"

pnio posts cancel --workspace "$WORKSPACE_ID" "$POST_ID" "$TARGET_ID" \
  --attempt "$ATTEMPT_ID"
```

## Weekly queues

A queue belongs to one connected account. Create it with the account ID and
repeat `--slot DAY:HH:mm` (0 is Sunday). Times use the queue's IANA zone, or
the workspace default when `--timezone` is omitted; changing the workspace
default never moves an existing queue. The first active queue is always the
default. Use `--default` to promote another queue and `--no-default` to demote
a non-default queue.

```sh
pnio queues create --workspace "$WORKSPACE_ID" --account "$ACCOUNT_ID" \
  --name "Brand queue" --timezone America/New_York \
  --slot 1:09:00 --slot 3:13:00 --slot 5:17:00

pnio queues create --workspace "$WORKSPACE_ID" --account "$ACCOUNT_ID" \
  --name "Stories queue" --timezone America/New_York \
  --slot 2:12:00 --default
pnio queues update --workspace "$WORKSPACE_ID" "$QUEUE_ID" \
  --version 2 --default

pnio queues preview --workspace "$WORKSPACE_ID" "$QUEUE_ID" --count 10
pnio posts publish --workspace "$WORKSPACE_ID" "$POST_ID" \
  --revision 1 --idempotency-key "$(uuidgen)" --queue "$QUEUE_ID"
pnio posts reschedule --workspace "$WORKSPACE_ID" "$POST_ID" "$TARGET_ID" \
  --attempt "$ATTEMPT_ID" --queue "$QUEUE_ID"
```

Use `--at` instead of `--queue` to detach a destination from its queue. Add
`--slot` and `--date` to a queue reschedule to pin one occurrence.

Move a queue-assigned destination to the next free occurrence after its
current time without choosing a slot:

```sh
pnio schedule skip-to-next --workspace "$WORKSPACE_ID" \
  --post-id "$POST_ID" --target-id "$TARGET_ID"
```

It reads the target's queue and attempt by default; pass `--queue-id` or
`--expected-attempt-id` to override them. The JSON result is
`{ skipped: true, result }` or, when the queue horizon is full,
`{ skipped: false, horizonEndsAt }`.

Read the calendar with an inclusive ISO range of at most 90 days:

```sh
pnio schedule list --from 2026-12-01T00:00:00Z --to 2026-12-31T23:59:59Z \
  --account-id "$ACCOUNT_ID"
pnio schedule list --from 2026-12-01T00:00:00Z --to 2026-12-31T23:59:59Z \
  --queue-id "$QUEUE_ID"
```

Each row reports the post, target, and attempt IDs plus the scheduled instant,
derived `scheduled` or `queued` status, and a short text preview. Queue-assigned
rows also carry the queue name, slot, assignment, occurrence date, and local
date and time.

Skip one occurrence or block a date range without moving scheduled work:

```sh
pnio queues skips --workspace "$WORKSPACE_ID" "$QUEUE_ID"
pnio queues skip --workspace "$WORKSPACE_ID" "$QUEUE_ID" \
  --slot-id "$SLOT_ID" --occurrence-date 2026-12-07
pnio queues unskip --workspace "$WORKSPACE_ID" "$QUEUE_ID" --skip-id "$SKIP_ID"
pnio queues blackout --workspace "$WORKSPACE_ID" "$QUEUE_ID" \
  --starts-on 2026-12-24 --ends-on 2026-12-26 --reason "Holiday"
pnio queues blackouts --workspace "$WORKSPACE_ID" "$QUEUE_ID"
pnio queues unblackout --workspace "$WORKSPACE_ID" "$QUEUE_ID" \
  --blackout-id "$BLACKOUT_ID"
```

## Output and errors

Commands print JSON by default, which makes them easy to pipe into an agent or
another tool. SDK and API errors are JSON on stderr with a stable `kind`,
`status`, `type`, and request ID when available.

> **Tip**
>
> Read the [API reference](https://pubnio.com/api/v1/docs) for every flag and
> response field.

Source: https://pubnio.com/docs/cli/index.mdx
