SecurityEarly accessDesigned and in development. No results yet. See what's left on the roadmap.
API key security: create, store and rotate keys
Early access · launching soon.
Oricato has three kinds of secrets, and each one lives in a different place:
| Secret | Who uses it | Where it belongs | Covered in |
|---|---|---|---|
| REST API key | Your servers, schedulers and integrations | A secret manager or a server environment variable | Part A |
| Firebase App Check token | Your app on a real phone, sent automatically by the SDK | Nowhere: Firebase issues short-lived tokens on the device | Part B |
| Firebase service-account key | The Oricato server, to send through your Firebase project | Uploaded once to the dashboard, then deleted from your computer | Part C |
Your apps never hold a secret. The SDKs only take a Project ID, which is public by design; App Check is how
you prove that the requests carrying it come from your real app. The examples use a neutral app called
Lingora (package com.lingora.app).
How Oricato protects API keys
- Only a hash is stored. A key is a 44-character secret of random letters and digits (base62). The server stores only its SHA-256 hash and the first 12 characters so you can recognize it. Nobody, including the Oricato Team, can show you a key again after it is created.
- The key decides the project. A key belongs to exactly one project. There is no project ID in REST paths, so a key can never act on another project.
- Every key has a daily limit. Each key may create at most
max_messages_per_daymessages per UTC day (default 500). This guards against a runaway script; the limit counts REST and OneSignal-compatible creates, drafts included. - Keys never bypass the daily cap. The project’s per-person daily cap still applies to every message a key creates. Only an admin in the dashboard can override it; an API key cannot.
- Guessing is slowed down. Each client address (IPv4 /32 or IPv6 /64) may fail authentication 30 times a minute.
After that, it gets
429 rate_limitedbefore any key is looked up. - Unusual use raises an alert. Oricato remembers where each key is used from, per IPv4 /24 or IPv6 /48 network and country. A key used from a network or country it has not used in 30 days raises a “used from a new place” event, and a key that creates far more messages than usual (80% of its daily limit, or at least 20 messages in an hour and 3 times its busiest hour of the week before) raises a “used more than usual” alert. Many requests with unknown or revoked keys raise “Many requests with a wrong API key”.
- Authentication is cached for 5 seconds. This keeps the API fast. It is also why a revoke reaches every server within 5 seconds (see step 6).
Who can do what
| Action | Viewer | Editor | Admin | Owner |
|---|---|---|---|---|
| See the key list (name, prefix, last used, used today) | ✓ | ✓ | ✓ | ✓ |
| Create or revoke API keys | ✓ | ✓ | ||
| Change App protection (App Check) settings | ✓ | ✓ | ||
| Upload or replace the Firebase key | ✓ | ✓ |
Viewers and editors never see a secret. Every create and revoke is recorded in the activity log with who did it, the key’s name and its prefix.
Prerequisites
- A dashboard login with the admin or owner role in the project. Oricato is in early access; if you don’t have a login yet, request access.
- A project with a Firebase key uploaded. See Firebase and APNs credentials.
- For Part A: a server, scheduler or CI system that can read secrets from a secret manager or environment variables.
- For Part B: your app on Oricato SDK 1.0.1 (Android, iOS or Flutter), with the Firebase App Check library added and an attestation provider registered in the Firebase console (Play Integrity on Android, App Attest or DeviceCheck on iOS). Follow Firebase’s own App Check setup guide for that part; the Oricato SDKs do not depend on the App Check libraries.
Part A: API keys
1. Create one key per server or integration
- In the dashboard, open your project and go to Project settings → API keys.
- Select Create API key.
- Enter a Name (1 to 80 characters) that says where the key will live, for example
Scheduler (eu-west)orBilling service. - Set Messages per day (1 to 100,000, default 500). Pick a little above what that server really sends. A month of daily messages is about 90 to 150, so a scheduler that imports a month at once fits in the default.
- Select Create key.
Give every server, script or integration its own key. When one of them is compromised or retired, you revoke just that key and nothing else stops working.
The same call through the admin API (admin role, dashboard session):
POST /admin/v1/projects/{project_id}/api-keys
Content-Type: application/json
{ "name": "Scheduler (eu-west)", "max_messages_per_day": 500 }
HTTP/1.1 201 Created
Cache-Control: no-store
Content-Type: application/json
{
"api_key": {
"id": "0192f0c4-7d2e-7b41-a3c9-5e8f1a2b3c4d",
"name": "Scheduler (eu-west)",
"prefix": "<KEY_PREFIX>",
"created_at": "2026-10-16T09:12:44Z",
"created_by": { "id": "0192f0c4-0000-7000-8000-000000000001", "display_name": "Alex Morgan" },
"last_used_at": null,
"last_used_ip": null,
"revoked": false,
"revoked_at": null,
"max_messages_per_day": 500,
"messages_today": 0
},
"secret": "<ORICATO_API_KEY>"
}
The response carries Cache-Control: no-store. A name over 80 characters or a limit outside 1 to 100,000 answers
400 validation_failed.
2. Copy the secret once, straight into a secret store
The dialog shows the full key exactly once: “Copy your key now — you won’t be able to see it again.” Copy it directly into one of these:
- your cloud’s secret manager (for example AWS Secrets Manager, Google Secret Manager or Azure Key Vault),
- your CI or hosting platform’s encrypted secrets,
- an environment variable on the server, set by your deployment tooling.
Never put an API key in:
- a mobile app, desktop app or website (anyone can extract it; apps use the SDK and the Project ID instead),
- a Git repository, including private ones,
.envfiles that are committed, or Docker images, - chat messages, tickets, email or screenshots,
- logs. Make sure your HTTP client does not log the
Authorizationheader.
If you lose the secret, you cannot recover it. Create a new key and revoke the old one.
3. Read the key from the environment
Load the key at runtime instead of writing it into code:
# Set by your secret manager or deployment tooling, never typed into a shared shell history
export ORICATO_API_KEY="<ORICATO_API_KEY>"
curl https://api.oricato.com/api/v1/me \
-H "Authorization: Bearer $ORICATO_API_KEY"
// Node.js: fail fast when the key is missing instead of sending unauthenticated requests
const apiKey = process.env.ORICATO_API_KEY;
if (!apiKey) throw new Error("ORICATO_API_KEY is not set");
const res = await fetch("https://api.oricato.com/api/v1/me", {
headers: { Authorization: `Bearer ${apiKey}` },
});
console.log(res.status); // never log the key or the request headers
# Python
import os
import requests
api_key = os.environ["ORICATO_API_KEY"]
r = requests.get(
"https://api.oricato.com/api/v1/me",
headers={"Authorization": f"Bearer {api_key}"},
timeout=20,
)
print(r.status_code)
The Authorization header accepts Bearer <ORICATO_API_KEY>, Key <ORICATO_API_KEY> or Basic <ORICATO_API_KEY>. All three take the raw key
(not base64), and the scheme name is not case-sensitive. Use your own API address if the dashboard’s
Send from your server card shows a different one.
4. Watch each key’s use
The API keys table shows, per key:
| Column | What it shows |
|---|---|
| Name | The name you gave it and when it was created |
| Key | Only the start of the key, for example <KEY_PREFIX>… (that is all that is stored for display) |
| Used today | Messages created with this key today (UTC), out of its daily limit |
| Last used | When the key last authenticated, and from which IP address (hover to see it). Updated at most once a minute |
| Status | Active or Revoked |
A key that should be idle but shows a recent Last used, or an address you don’t recognize, is a reason to rotate it now.
5. Rotate a key
Rotate on a schedule that suits your team (for example every 90 days), whenever someone with access to the secret leaves, and at once if you think the key leaked. Rotation never interrupts sending if you follow this order:
- Create a new key for the same server (step 1). Use a name that tells the two apart, for example
Scheduler (eu-west) 2026-10. - Deploy the new key. Put it in your secret store and restart or redeploy the server so it reads the new value.
- Confirm the new key is in use. In Project settings → API keys, check that the new key’s Last used shows a recent time and the old key’s Last used stops moving. Allow a few minutes: Last used updates at most once a minute per key.
- Revoke the old key (step 6).
Keys cannot be edited after they are created. To change a key’s Messages per day limit, rotate to a new key with the new limit.
6. Revoke a key you no longer need
- In Project settings → API keys, select the revoke icon at the end of the key’s row (its tooltip reads Revoke followed by the key’s name).
- Type the key’s name to confirm, then select Revoke key.
Revoking takes effect at once on the API server that handled it and within 5 seconds on all others. After that,
every request with the key on /api/v1/messages and the other REST endpoints answers 401 unauthorized with details.reason set to
revoked, and every OneSignal-compatible request answers 403 with an errors array (see
REST vs OneSignal-compatible error shapes). Revoking cannot be
undone, and the key stays in the list as Revoked for your records. Revoking is also allowed on an archived
project, because it only removes access.
DELETE /admin/v1/projects/{project_id}/api-keys/{key_id}
The response is the key with "revoked": true and revoked_at set. Revoking a key that is already revoked returns
it unchanged.
If a key leaked: revoke it first, then create and deploy a replacement. A few minutes of failed sends from your own server cost far less than a stranger sending to your audience. Then check Messages for anything the key created that you did not expect, and cancel it.
7. Handle the per-key daily limit
When a key reaches its limit, POST /api/v1/messages answers 429 key_quota_exceeded in the Oricato error
envelope:
{
"error": {
"code": "key_quota_exceeded",
"message": "This API key already created 500 messages today (UTC); the limit is 500.",
"details": { "limit": 500, "resets_at": "2026-10-17T00:00:00Z" },
"request_id": "0192f0c5-1e9a-7f03-b6d2-8c4e7a9f1b20"
}
}
The Retry-After header holds the seconds until midnight UTC. Do not retry in a loop; wait for resets_at, or
rotate to a key with a higher limit if the volume is real. A message that would give someone more than the
project’s daily cap answers 409 daily_cap_exceeded instead, and no API key can override it.
POST /api/v1/notifications (OneSignal-compatible) counts against the same limit but answers in OneSignal’s
shape, with the same Retry-After header and no code or details:
{ "errors": ["Daily message quota for this API key reached"] }
REST vs OneSignal-compatible error shapes
| Situation | REST (/api/v1/messages) |
OneSignal-compatible (/api/v1/notifications) |
|---|---|---|
| Missing, malformed, unknown or revoked key | 401 unauthorized with details.reason |
403 {"errors": ["Please include a case-sensitive header of Authorization: Key <key> with a valid REST API key."]} |
| Archived project | 403 project_archived |
403 {"errors": ["This app is archived in Oricato."]} |
| Per-key daily limit reached | 429 key_quota_exceeded with details.limit and resets_at |
429 {"errors": ["Daily message quota for this API key reached"]} |
| Project daily cap would be exceeded | 409 daily_cap_exceeded |
400 {"errors": [...]} |
The compatible endpoint never returns details.reason, so check the key on GET /api/v1/me when you need to
know why it is refused. See Migrate from OneSignal.
Part B: Firebase App Check
Your Project ID is in every copy of your app, so anyone can read it. Without App Check, a script could use it to
register fake devices. With App Check, the SDK attaches a short-lived Firebase token
(X-Firebase-AppCheck header) that proves the request comes from your real app on a real device.
App Check has three modes, set in Project settings → App protection:
| Mode | What happens | Use it when |
|---|---|---|
| Off | Tokens aren’t checked. Any copy of your app can register phones. | You haven’t shipped an app version with App Check yet |
| Monitor | Tokens are checked and failures are counted, but nothing is blocked. | Your new app version is rolling out |
| Enforce | Registrations and config requests without a valid token get 401 app_check_failed. |
Almost every request already has a valid token |
Delivered and opened receipts never need a token. The iOS Notification Service Extension and background
receivers cannot get App Check tokens, so these receipts are protected by a per-message signed receipt key instead.
They are accepted in every mode and are not counted in the App Check numbers. Conversion events
(trackEvent) do need a valid token under Enforce.
1. Add the token provider before initialize
Set the provider once, before you call Oricato.initialize. The SDK caches each token until 5 minutes before it
expires, and asks for a fresh one if the server rejects it.
Android (Kotlin). In Application.onCreate. The provider is called on a background thread, so it may block
for a few seconds.
package com.lingora.app
import android.app.Application
import com.google.android.gms.tasks.Tasks
import com.google.firebase.appcheck.FirebaseAppCheck
import com.oricato.push.Oricato
import java.util.concurrent.TimeUnit
class App : Application() {
override fun onCreate() {
super.onCreate()
// Register Firebase's App Check provider (Play Integrity) here first, as in Firebase's guide.
Oricato.setAppCheckTokenProvider { forceRefresh ->
Tasks.await(FirebaseAppCheck.getInstance().getAppCheckToken(forceRefresh), 5, TimeUnit.SECONDS).token
}
Oricato.initialize(this, "<ORICATO_PROJECT_ID>", "<ORICATO_API_ADDRESS>")
}
}
The provider implements OricatoAppCheckTokenProvider, a fun interface with
fun getToken(forceRefresh: Boolean): String?. Return null when no token is available.
iOS (Swift). In application(_:didFinishLaunchingWithOptions:). The provider is called on the main thread.
import UIKit
import FirebaseCore
import FirebaseAppCheck
import OricatoPush
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Set Firebase's App Check provider factory (App Attest or DeviceCheck) before FirebaseApp.configure().
FirebaseApp.configure()
Oricato.setAppCheckTokenProvider { forcingRefresh, completion in
AppCheck.appCheck().token(forcingRefresh: forcingRefresh) { token, _ in completion(token?.token) }
}
Oricato.initialize(projectId: "<ORICATO_PROJECT_ID>", apiBaseURL: "<ORICATO_API_ADDRESS>")
return true
}
OricatoAppCheckTokenProvider is (_ forcingRefresh: Bool, _ completion: @escaping (_ token: String?) -> Void) -> Void.
Call completion(nil) when no token is available. Passing nil to setAppCheckTokenProvider removes the provider.
Flutter (Dart). In main(), after Firebase.initializeApp and Firebase App Check activation.
import 'package:firebase_app_check/firebase_app_check.dart';
import 'package:oricato_push/oricato_push.dart';
Future<void> setUpOricato() async {
Oricato.setAppCheckTokenProvider((force) => FirebaseAppCheck.instance.getToken(force));
await Oricato.initialize(
'<ORICATO_PROJECT_ID>',
'<ORICATO_API_ADDRESS>',
);
}
OricatoAppCheckTokenProvider is Future<String?> Function(bool forceRefresh). Return null when no token is
available.
Ship this app version before you go further. Older versions keep working under Off and Monitor.
2. Turn on Monitor
- In the Firebase console, open Project settings → General and copy the Project number (digits, not the project name).
- In the dashboard, open Project settings → App protection.
- Paste it into Firebase project number. Monitor and Enforce need it.
- Optional: add your Firebase app ids (Firebase console → Project settings → General → Your apps → App
ID, for example
1:512398765012:android:4f2a9c1e3b7d5a60). When set, tokens must come from one of these apps. You can list up to 20. - Select Monitor and save.
3. Watch the unattested share
The App traffic, last 24 hours card counts every app request App Check applies to (registrations, config fetches and conversion events), per outcome:
| Card label | Field in app_check_24h |
Meaning |
|---|---|---|
| Valid token | verified |
Token checked and valid |
| Invalid token | invalid |
Token present but rejected (expired, wrong project, bad signature) |
| No token | missing |
No X-Firebase-AppCheck header, usually an app version without the provider |
| Not checked | unchecked |
Token present while the mode is Off |
The project’s app_check_24h also carries unattested_share = (invalid + missing) / requests. While you are
in Monitor, the dashboard tells you how many requests Enforce would block. Wait until most people have updated to
the version from step 1 and the unattested share is close to zero.
4. Switch to Enforce
- In Project settings → App protection, select Enforce. The dashboard shows the current unattested share as a last check.
- Save, then keep an eye on the card for a day. Requests without a valid token now count as blocked.
If a large group of users is still on an old app version, go back to Monitor; nothing is lost while you wait.
Where should I store my Oricato API key?
On your server only: in your cloud’s secret manager, your CI or hosting platform’s encrypted secrets, or an environment variable set by your deployment tooling. Never in a mobile app, website, Git repository or log. Apps use the SDK with the public Project ID, protected by Firebase App Check (Part B).
Part C: Service-account hygiene
The Firebase service-account key is the most powerful secret in your setup: it lets anyone send to your app’s devices through Firebase. Firebase and APNs credentials walks through every step; the rules are:
- Use a dedicated service account with one role. Grant only Firebase Cloud Messaging API Admin
(
roles/firebasecloudmessaging.admin). Don’t upload the defaultfirebase-adminsdk-…account: it can do far more than send messages. - Upload it once, then delete the file. In Project settings → Firebase key, upload the JSON. Oricato checks it with Google, encrypts it and never returns it: no dashboard screen or API response shows the private key, only its metadata (Firebase project, service account email, key id). Then delete the JSON from your computer and never email or chat it.
- Rotate by uploading a new key. Create a new JSON key for the same service account in the Google Cloud Console, select Replace key, upload it, and delete the old key in Service Accounts → your account → Keys. The new key is checked with Google before it replaces the current one.
- Keep the external user ID secret on your server. If you turn on Verify external user IDs, the secret is shown once and belongs on your server only, which signs each ID with it. Rotating it invalidates the old secret at once. See Users, external IDs and tags.
Verify it works
-
The new key works. Call
GET /api/v1/mewith it:curl -i https://api.oricato.com/api/v1/me \ -H "Authorization: Bearer $ORICATO_API_KEY"You should see
200with your project and the key’s name and prefix:{ "project": { "id": "0192f0c3-9b8a-7e65-8f4d-1a2b3c4d5e6f", "name": "Lingora", "platforms": ["android", "ios"], "accent_color": "#E8622C", "icon_emoji": null, "archived": false }, "api_key": { "id": "0192f0c4-5a1d-7c22-8d3e-6f7a8b9c0d1e", "name": "Scheduler (eu-west) 2026-10", "prefix": "<KEY_PREFIX>" } } -
The old key is dead. More than 5 seconds after revoking, call the same endpoint with the old key. You should see
401with"code": "unauthorized"and"details": { "reason": "revoked" }. (On the OneSignal-compatiblePOST /api/v1/notifications, the old key gets403with anerrorsarray instead.) -
App Check is verified. After the new app version is out, the App traffic, last 24 hours card shows mostly Valid token, and
app_check_24h.verifiedgrows whilemissingshrinks.
Troubleshooting
401 unauthorized (REST endpoints). Check details.reason:
missing: noAuthorizationheader. The environment variable may be empty; print its length, not its value.invalid: the key is malformed or unknown. Look for a typo, a missing first character, a quote character or other stray non-space character copied with it, or a base64-encoded key withBasic(send the raw key). Spaces and newlines around the key are trimmed, so they are not the cause. An unknown scheme such asTokenis alsoinvalid; useBearer,KeyorBasic.revoked: the key was revoked. Deploy the current key; the old one cannot be restored.
A key from an archived project answers 403 project_archived instead.
403 with an errors array on POST /api/v1/notifications. The OneSignal-compatible endpoint answers every
missing, malformed, unknown or revoked key with 403 and “Please include a case-sensitive header of
Authorization: Key <key> with a valid REST API key.”, and an archived project with “This app is archived in
Oricato.” There is no details.reason; call GET /api/v1/me with the same key to see which 401 reason applies.
429 rate_limited after a series of failures from one server. That address made more than 30 failed
authentications in a minute, so it is refused before any key lookup. Stop the retries, fix the key, wait for
Retry-After, then try once. A common cause is a server still using a revoked key after a rotation; the
“Many requests with a wrong API key” alert points to it.
429 rate_limited from a working key. That is the per-key request rate (20 requests per second, 5 creates per
second, or more than 8 creates of one key running or waiting at once). Wait for Retry-After, with jitter.
429 key_quota_exceeded. The key reached its Messages per day limit. See
Part A, step 7.
Apps get 401 app_check_failed under Enforce. The SDK fetches a fresh token, retries once, then backs off.
The SDK log shows the reason, worded per platform:
- Android:
app_check_failed <reason>. - iOS: a warning,
App Check token rejected (<reason>); retrying once with a fresh token, or, when no provider is set, an error:The project enforces Firebase App Check but no token provider is set (Oricato.setAppCheckTokenProvider). - Flutter: an info line,
App Check rejected (<details>); retrying once with a fresh token.
The reasons:
missing: the app version has no provider, or the provider returnsnullbecause Firebase App Check is not set up. On debug builds, a common cause is Firebase’s debug provider with a debug token that is not registered in the Firebase console (App Check → Apps → Manage debug tokens): Firebase issues no token, so none is sent. Register it, or test on a release build. IfsetAppCheckTokenProviderruns afterinitialize, only the first requests go without a token; the SDKs read the provider on each request, but set it first anyway (Part B, step 1).invalid: a token was sent but its signature or format was rejected.wrong_project: the Firebase project number in App protection belongs to another Firebase project, or the app’s ID is missing from Firebase app ids.expired: the device clock is far off or a stale token was reused; the SDK refreshes on retry.
Until fixed, switch back to Monitor so those devices can keep registering.
503 service_unavailable with details.reason app_check_unavailable. Under Enforce, the server could not
fetch Google’s App Check keys and had none cached. It is not a problem with your app. The SDK waits for
Retry-After (30 seconds) plus jitter and retries; Monitor accepts these requests.
The App traffic card shows “No app requests in the last 24 hours.” No app version has registered or fetched config in the last day. Open the app on a test device and refresh the page.
Notifications stopped after rotating the Firebase key. The new key may lack the Firebase Cloud Messaging API Admin role or belong to another Firebase project. Select Check again on the Firebase key card, and see Firebase and APNs credentials.