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

# Automate with the CLI

> Use structured output, JSON input, and stable retry keys.

## Read JSON output

```bash theme={null}
postinger accounts list --json
postinger posts list --limit 25 --json
postinger auth status --json
```

API commands return `{data, meta}`. Create and publish commands also return their idempotency key. Local authentication and diagnostic commands have their own result shapes. Errors go to stderr; `--json` makes them structured as well.

| Exit code | Meaning |
| - | - |
| `0` | Success |
| `1` | API, configuration, or transport failure |
| `2` | Invalid command or input |

## Create from a file

Save a JSON body as `post.json`, replacing the example UUIDs with your account and media IDs:

```json theme={null}
{
  "content": "A new update",
  "targets": [{ "socialAccountId": "11111111-1111-4111-8111-111111111111" }],
  "mediaIds": ["22222222-2222-4222-8222-222222222222"]
}
```

```bash theme={null}
postinger posts create --file post.json \
  --idempotency-key campaign-001 --json
```

`--file -` reads stdin. File input cannot be combined with individual content, account, media, or schedule flags. For edits, `posts update POST_ID --file patch.json` preserves omitted fields.

## Retry deliberately

Reuse the same idempotency key and unchanged payload for retries of one create or publish operation, for up to 24 hours. Use a new key for each new operation. Save the key before starting a job.

An uncertain upload, edit, or delete may already have succeeded. Inspect the resource before issuing another request. See [retries and errors](/guides/retries-and-errors).

## Command availability

The HTTP API supports `before` and `sort` on post lists. CLI 0.2.0 exposes forward pagination through `--after`; it does not expose `--before` or `--sort`. Use the HTTP API when you need those controls.


## Related topics

- [CLI authentication](/cli/authentication.md)
- [CLI quickstart](/cli/quickstart.md)
- [CLI command reference](/cli/commands.md)
- [Your first draft](/quickstart.md)
- [Upload media](/guides/media.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.