# Authentication and configuration

Use an application-scoped bearer key from trusted server-side code, a CI secret store, or your local agent environment.

## Endpoints and credentials

API base: `https://api.pijon.fyi/api/v1`. Send `Authorization: Bearer <key>` and `Accept: application/json`. JSON requests also need `Content-Type: application/json`. Image uploads use multipart and must let the HTTP client set the boundary.

Create the key inside the application's details in the [account app](https://app.pijon.fyi/applications). The secret is displayed only once. Its permissions must include `notifications:send` and the exact `application:<ULID>` scope; a generic `*` key cannot substitute for that application scope.

| Operation | Sending key | Account authentication |
| --- | --- | --- |
| Send notification / upload image | Supported for its application | Also supported by the app |
| Create applications / issue or rotate keys | Not supported | Required |
| List approved recipients | Not supported | Required |
| Read History, Inbox, or usage | Not supported | Required |
| Approve a subscription | Not supported | The recipient must approve |

Do not copy a login session or ask a user for their password to automate account setup. Use the app for these prerequisites.

## Environment variables

| Variable | Meaning |
| --- | --- |
| `PIJON_API_BASE_URL` | Full base including `/api/v1`; official default is above. |
| `PIJON_API_KEY` | Secret issued for the application. |
| `PIJON_APPLICATION_ID` | Application ULID matching that key. |
| `PIJON_RECIPIENT_ID` | Approved receiving user's ULID. |
| `PIJON_IDEMPOTENCY_KEY` | Stable value for one logical event; reuse for its retries. |

`test` and `live` are key labels. They do not select an isolated sandbox or disable delivery/accounting. There is no public dry-run endpoint. Local mock tests do not establish that credentials or delivery work in production.

## Storage and rotation

Keep keys out of browser bundles, screenshots, logs, prompts, repository history, and public configuration. Read them at runtime. A frontend should call your own authenticated backend, which sends to Pijon. Keep local secret files ignored and deploy with your host's secret manager.

Rotation immediately revokes the old key. Update the configured secret after rotating in the app, then verify one authorized test send. Diagnose `401` as missing/invalid/revoked credentials and `403` as scope, account, application, or subscription rejection. See [errors](/docs/troubleshooting).
