# API keys

Create a key for uploads, notifications or both, then grant access to the channels your script uses.

## Choose a preset

| Preset | Artifacts | Restricted notifications |
| --- | --- | --- |
| Artifacts | Upload and manage | Read owner history |
| Notifications | None | Publish to selected channels |
| Both | Upload and manage | Read owner history and publish to selected channels |

Open the key settings from `pushbag auth login`. Personal is the default publish grant for Notifications and Both. Selecting a different set replaces that default. For `upload --notify`, choose Both and include the target channel.

## Set a credential

```sh
pushbag auth login
pushbag auth set YOUR_API_KEY
pushbag whoami
```

For automation, provide `PUSHBAG_API_KEY` through your environment. It takes precedence over the profile key. Remove a saved key with `pushbag auth logout`; revoke the key in the dashboard to stop other copies working.

## Register a receiver

A registered phone gets a separate receiver credential for history and device maintenance. Pairing a phone does not grant artifact access. Use a publisher key for scripts that send to restricted channels.

> **Note:** Existing artifact keys keep their original permissions. Issue a key with a publish grant to send notifications.

## Choose a credential for a job

| Job | Credential | Where to use it |
| --- | --- | --- |
| Post build status | Notifications key for the build channel | CI secret exposed as `PUSHBAG_API_KEY` |
| Share a private report without a notification | Artifacts key | Local CLI profile or job environment |
| Upload and notify Personal | Both key including Personal | `pushbag upload report.html --private --notify` |
| Read selected channels on a paired phone | Device receiver | Issued during device registration |
| Create keys or pairing codes | Owner's signed-in session | Dashboard settings |

A Notifications key granted only a non-Personal channel must name that channel in the command. If you need to send without learning a channel's history, give the job its ID directly. An empty `pushbag channels` result is compatible with a valid publish grant.

## Diagnose a credential mismatch

```sh
pushbag config show --json
pushbag whoami --json
```

The first command reports whether a key is set without printing it. The second verifies the identity and reports capabilities. If logout appears to have no effect, check the environment override. If you change the API host, the CLI only reuses a saved key when the deployment URL matches. Verify a replacement key with `auth set` before revoking the old one in the dashboard. See [CLI profiles](/docs/cli).
