> ## 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.

# Scripts and CI

> Use the CLI where nobody can log in from a browser.

Set `POSTINGER_API_KEY` to a key from **API Keys**. It's used instead of a saved login, and nothing is written to disk.

```bash theme={"system"}
export POSTINGER_API_KEY="pst_live_…"
postinger posts list --status scheduled --json
```

`POSTINGER_API_URL` (or `--api-url`) points the CLI at another server.

## GitHub Actions

Publish a post each time you tag a release:

```yaml .github/workflows/announce.yml theme={"system"}
name: Announce release
on:
  release:
    types: [published]

jobs:
  announce:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npm install -g postinger
      - run: |
          postinger posts create \
            --content "$RELEASE_NAME is out: $RELEASE_URL" \
            --account "$ACCOUNT_ID" \
            --now \
            --idempotency-key "release-$RELEASE_ID"
        env:
          POSTINGER_API_KEY: ${{ secrets.POSTINGER_API_KEY }}
          ACCOUNT_ID: ${{ vars.POSTINGER_ACCOUNT_ID }}
          RELEASE_NAME: ${{ github.event.release.name }}
          RELEASE_URL: ${{ github.event.release.html_url }}
          RELEASE_ID: ${{ github.event.release.id }}
```

> [!WARNING]
>
> Pass event fields through `env`, as above, and never write `${{ ... }}` straight into `run`. GitHub pastes those into the script before the shell runs it, so a release title with `$(...)` or backticks in it would run as a command.

`--idempotency-key` makes a re-run of the job within **24 hours** safe: the release isn't posted twice. Keys are kept for 24 hours, so a re-run after that posts it again. To guard against that too, record which release you've posted (a release asset, a repository variable) and check it first. See [Idempotency](https://docs.postinger.dev/api-reference/idempotency.md).

## In scripts

Use `--json` and read stdout; progress and errors go to stderr. Check the [exit code](https://docs.postinger.dev/cli/output.md#exit-codes):

```bash theme={"system"}
id=$(postinger media upload banner.jpg --json | jq -r '.[0].id')
postinger posts create --content "New banner" --account "$ACCOUNT_ID" --media "$id" --now
```


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