# Security and privacy

> What a private Opush server stores, what the push gateway sees, and how encryption and access controls protect your data.

This page explains where data lives in a private deployment, what leaves your infrastructure, and the controls you can turn on.

## What's stored where [#whats-stored-where]

| Where | What |
|---|---|
| Your Opush server (your Cloudflare D1) | Accounts, devices and their push tokens, follows, monitors and their history, integrations, status pages, channels, notification channels, phone numbers, and sign-in links. Secrets are stored as SHA-256 hashes where the server only needs to check them |
| Your users' devices | The Inbox. Push history lives on the device, not on the server |
| Official push gateway | Nothing from your pushes. It forwards each push and keeps a monthly push count per license |
| Apple and Google | The push while they deliver it, like any push notification |

The server doesn't keep custom push content after it sends it. Some pushes are kept for a while: [scheduled pushes](/docs/push/schedule) until they are sent, pushes for Android phones without Google services until the phone picks them up (up to 7 days), and alerts that escalate, which keep the message and its SMS text so the next step can be sent. Alerts are deleted 7 days after they are sent.

On iPhone, people can turn on **Sync Inbox with iCloud**. Messages are then end-to-end encrypted in their own iCloud account. Accounts can also link across a person's devices through iCloud Keychain.

### Secrets on your server [#secrets-on-your-server]

| Secret | How it's stored |
|---|---|
| Device secret and account secret (used by the apps) | SHA-256 hash only |
| MCP tokens and OAuth tokens | Hash only |
| Device key (the push URL) | Plain. It works like a password, so people can change their push URL in the app if it leaks |
| Integration signing secrets, webhook channel secrets | Plain, because the server needs them to sign or check requests |
| Slack and Discord webhook URLs, Telegram bot tokens | Plain. The API never returns them, only a short hint |
| Server encryption keys | On the server. For end-to-end encryption, only the public key |

### Automatic cleanup [#automatic-cleanup]

Your server cleans up by itself on a schedule:

- Devices whose push token has been invalid for over 90 days are deleted.
- Devices that haven't used the API for 365 days are deleted. The app checks in when it opens.
- An account without a sign-in method is deleted when its last device is removed. An account with a sign-in method stays until it hasn't been used for a year.

## What the push gateway sees [#what-the-push-gateway-sees]

The gateway receives the device's push token, the platform, delivery settings, and the notification payload. See [the full list](/docs/enterprise#what-the-gateway-sees).

The payload is the part to think about. Choose how much of it you want the gateway, Apple, and Google to read:

| What you send | Your server sees | The gateway, Apple, Google see |
|---|---|---|
| Plain text | Content | Content |
| Plain text, device has **Server encryption** on | Content, when it arrives | Ciphertext |
| Encrypted in your script (`ciphertext` or `sealed`) | Ciphertext | Ciphertext |

With end-to-end encryption (HPKE), your script seals the push with the device's public key. Only the device can open it. Not your server, not the gateway, not Apple or Google. See [Encryption](/docs/push/encryption) for how to set it up.

Some fields always stay outside the encryption, because the server needs them to deliver the push: for example `level`, `id`, `group`, `sound`, and `badge`.

<Callout type="warn" title="Notifications your server creates">
  Server encryption applies to pushes sent to a push URL. Notifications your server writes itself, like monitor alerts, new releases, and integration events, are sent in plain text. The gateway and Apple or Google can read their title and body.
</Callout>

## Gateway authentication [#gateway-authentication]

Your server signs in to the gateway with your license key:

```http
POST https://opu.sh/gateway/v1/push
Authorization: Bearer ent_...
```

- Keep the key in a Worker secret (`ENTERPRISE_LICENSE`). Never put it in a variable or in source control.
- The gateway stores only a hash of the key.
- A key can have an expiry date and a monthly push limit. An expired or revoked key gets `401`. Over the monthly limit gets `429`.
- All traffic between your server and the gateway uses HTTPS.

If the key leaks, contact [support@allright.dev](mailto:support@allright.dev) to revoke it and get a new one.

## Who can create accounts [#who-can-create-accounts]

By default, anyone who can reach your server can create an account. To close sign-ups, set `REGISTRATION_TOKEN`. Then:

- The app needs the token, which comes from the [setup link](/docs/enterprise#connect-apps-to-your-server).
- The web sign-up page asks for it as the **Registration code**.
- Adding another device to an existing account doesn't need it. That uses the account's own secret.

`GET {base}/v1/server` shows `"registration": "token"` when sign-ups are closed. Sign-ups are also rate limited per IP address.

## Basic Auth [#basic-auth]

Set `BASIC_AUTH` to `user:password` to protect the endpoints that send pushes:

- Push URLs: `{base}/YOUR_KEY/...` and `{base}/push`
- [Team channel](/docs/teams/channels) push URLs: `{base}/c/...`
- Creating a question for an [AI agent](/docs/agents/ask): `POST {base}/ask`
- [MCP](/docs/agents/mcp) requests without an MCP token

The app API (`/v1`), heartbeat URLs, and public status pages don't use Basic Auth. They have their own keys or are public by design.

```bash
curl -u "ops:YOUR_PASSWORD" "https://push.example.com/YOUR_KEY?title=Deploy&body=Done"
```

Tools that only take a URL can usually put the credentials in it: `https://ops:YOUR_PASSWORD@push.example.com/YOUR_KEY`.

## AI agents and MCP on your server [#ai-agents-and-mcp-on-your-server]

MCP works on your server the same way it does on `opu.sh`, with your server's address:

- `{base}/mcp` needs a sign-in. MCP clients use OAuth 2.1 with PKCE. People approve the connection in your web console. Access tokens last 1 hour. Refresh tokens last 90 days and change on every use.
- People can also create named tokens in **AI agents** in the web console, or a device token in the app's settings. Tokens are shown once and stored as hashes. Each can be revoked.
- `{base}/mcp/YOUR_KEY` works without signing in, like a push URL. It can send pushes and ask questions, but can't read the account.

If you turned on Basic Auth, send the MCP token in the `X-Opush-Token` header instead of `Authorization`. A valid token skips Basic Auth.

## Web console sessions [#web-console-sessions]

The web console uses an `HttpOnly`, `SameSite=Lax` session cookie. Sessions expire after 30 days without use. The cookie is `Secure` when your server runs on HTTPS. Every request from the console must also carry the `X-Opush-Console` header, which blocks cross-site request forgery. People can see their signed-in browsers and sign them out from the app or the console.

## Public endpoints [#public-endpoints]

These answer without any sign-in:

| Endpoint | Shows |
|---|---|
| `GET {base}/v1/server` | Server name, features, limits, and whether sign-ups need a token |
| `GET {base}/info` | Server version and the number of registered devices |
| `GET {base}/ping`, `GET {base}/healthz` | That the server is up |

If you don't want them reachable from the internet, put your server behind your own access rules in Cloudflare. Keep in mind that devices and the services that send webhooks must still reach the push, API, and webhook URLs.
