Users and audienceEarly accessDesigned and in development. No results yet. See what's left on the roadmap.
Users, external IDs and tags
Early access · launching soon. This page describes the SDK kit 1.0.1 and the REST API that early-access projects use today.
Oricato keeps one subscription for each installation of your app. Your own idea of a user, the account someone signs in to, is separate. This guide shows how to connect the two with an external user ID, how to make sure nobody can claim someone else’s ID, how to describe people with tags, and how to send to exactly the people you mean: push notification segmentation by tag, by user ID or by installation.
Subscriptions and users
| Subscription | Your user | |
|---|---|---|
| What it is | One installation of your app on one device | The person, as your app or backend knows them |
| Who creates the ID | The Oricato SDK, on first launch (a UUID) | You |
| How long it lives | Survives app updates. A reinstall, or a phone restored from a backup, gets a new subscription | As long as the account exists |
| How many | One per device | One person can have several subscriptions (phone, tablet, reinstall) |
| How to read it | getSubscriptionId() |
Your own code |
The SDK stores the subscription ID in storage the OS never backs up or transfers, so two devices never share one. The dashboard calls it the Subscriber ID.
Read it in each SDK:
import com.oricato.push.Oricato
val subscriptionId: String? = Oricato.getSubscriptionId() // null before the first initialize
import OricatoPush
let subscriptionId: String = Oricato.getSubscriptionId() // same as Oricato.subscriptionId
import 'package:oricato_push/oricato_push.dart';
final String? subscriptionId = await Oricato.getSubscriptionId(); // null before the first initialize
A debug screen that shows this ID makes it easy to mark your own phone as a test device later.
Prerequisites
- The Oricato SDK is installed and
initializeruns on every app start. If not, follow the Android, iOS or Flutter quickstart first. - An ID for each of your users that is opaque and pseudonymous, for example
u_9f2b1c03. See Choose a safe external user ID. - For external ID verification: a backend that can compute an HMAC, and the admin role in the project.
- For targeting from your servers: a REST API key. See REST API quickstart.
Choose a safe external user ID
The SDK sends the external user ID from the device, which is not an authenticated environment. Anyone who can run your app can send any ID. Pick IDs that are worthless to someone who reads or guesses them:
- Do use a random or derived identifier, such as
u_9f2b1c03or a UUID, stored next to the account in your database. - Don’t use an email address, a phone number, a name, or a sequential or guessable account number (
10442). - Keep it 1 to 128 characters.
The Android SDK logs a warning when an ID looks like an email address or a phone number. To stop people from claiming each other’s IDs, turn on external ID verification.
Step 1. Set the external user ID on login and clear it on logout
Call setExternalUserId after the person signs in, and again on every app start while they stay signed in. The call
is idempotent: when nothing changed, the SDK sends nothing. Pass null (nil in Swift) when they sign out, so the
device stops receiving messages meant for that account.
The second argument is the verification hash. Leave it out until you turn on verification in Step 2.
Android (Kotlin)
import com.oricato.push.Oricato
fun onSignedIn(oricatoUserId: String, oricatoIdHash: String?) {
// oricatoUserId: "u_9f2b1c03". oricatoIdHash: from your backend, or null without verification.
Oricato.setExternalUserId(oricatoUserId, oricatoIdHash)
}
fun onSignedOut() {
Oricato.setExternalUserId(null)
}
The signature is Oricato.setExternalUserId(id: String?, hash: String? = null). From Java, both
Oricato.setExternalUserId("u_9f2b1c03") and Oricato.setExternalUserId("u_9f2b1c03", hash) work. Calls made
before initialize are queued and applied once it runs.
iOS (Swift)
import OricatoPush
func onSignedIn(oricatoUserId: String, oricatoIdHash: String?) {
Oricato.setExternalUserId(oricatoUserId, hash: oricatoIdHash)
}
func onSignedOut() {
Oricato.setExternalUserId(nil) // clears the id and the hash
}
The signature is Oricato.setExternalUserId(_ id: String?, hash: String? = nil).
Flutter (Dart)
import 'package:oricato_push/oricato_push.dart';
Future<void> onSignedIn(String oricatoUserId, String? oricatoIdHash) async {
await Oricato.setExternalUserId(oricatoUserId, hash: oricatoIdHash);
}
Future<void> onSignedOut() async {
await Oricato.setExternalUserId(null);
}
The signature is static Future<void> setExternalUserId(String? id, {String? hash}). Await
Oricato.initialize(...) first. A call made while initialize is still running waits for it, and on later
launches the SDK loads the saved settings. On the very first launch, calls made before initialize are logged
(setExternalUserId called before Oricato.initialize(); ignored) and ignored.
Step 2 (optional). Verify external IDs on your server
With verification on, Oricato saves an external user ID only when it arrives with a matching signature that your backend computed. A copy of your app, or a script, can no longer claim someone else’s ID.
How it works
- Your project has an external-ID secret: 48 characters, shown once.
- When a person signs in, your backend computes
external_user_id_hash = lowercase hex( HMAC-SHA256( key = secret, message = external_user_id ) ). The key is the UTF-8 bytes of the 48-character secret exactly as the dashboard shows it. Don’t base64-decode or trim it. The message is the UTF-8 bytes of the external user ID. - Your backend returns the hash to the app with the session. The app passes it as the second argument of
setExternalUserId. - On every registration the server recomputes the HMAC and compares it in constant time. If the hash is missing or
wrong, the server stores the external user ID as null and returns the warning
external_user_id_unverified. The SDK logs it asServer warning: external_user_id_unverified. The subscription itself keeps working.
Never put the secret in your app. Anyone can extract a secret from an app binary.
Turn it on
- In the dashboard, open your project, then Settings → App protection.
- Under External user ID verification, click Create secret. Copy it now. You won’t see it again.
Store it in your server’s secret manager, for example as
ORICATO_EXTERNAL_ID_SECRET. (The button callsPOST /admin/v1/projects/{project_id}/external-id-secret, which needs the admin role.) - Deploy the backend change (below) and an app release that passes the hash.
- Switch on Verify external user IDs. The switch stays disabled until a secret exists.
- Click Save changes in the bar at the bottom of the page. The settings sections share one draft, so verification stays off until you save.
Turn verification on only after most of your users run the app version that sends hashes. Every registration without a valid hash after that point clears the external user ID on that device. The SDK registers again whenever the app starts or returns to the foreground and the last registration is more than an hour old, so devices on older app versions lose their IDs soon after you switch it on.
Compute the hash on your backend
All three examples use only the standard library.
// Node.js
import crypto from 'node:crypto';
const secret = process.env.ORICATO_EXTERNAL_ID_SECRET; // the 48-character secret
export function oricatoIdHash(externalUserId) {
return crypto.createHmac('sha256', secret).update(externalUserId, 'utf8').digest('hex');
}
# Python 3
import hashlib
import hmac
import os
SECRET = os.environ["ORICATO_EXTERNAL_ID_SECRET"] # the 48-character secret
def oricato_id_hash(external_user_id: str) -> str:
return hmac.new(
SECRET.encode("utf-8"), external_user_id.encode("utf-8"), hashlib.sha256
).hexdigest()
// Go
package oricatoid
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
)
// Hash returns lowercase hex(HMAC-SHA256(secret, externalUserID)).
func Hash(secret, externalUserID string) string {
m := hmac.New(sha256.New, []byte(secret))
m.Write([]byte(externalUserID))
return hex.EncodeToString(m.Sum(nil))
}
Check your code against this test vector. The secret is an example only, never use it:
| Input | Value |
|---|---|
| Secret | Xq7Lm2Rp9Tz4Vb8Nc1Hd6Kf3Wg5Ys0Ja2Pe7Qu4Ti9Ro1MnZ |
| External user ID | u_9f2b1c03 |
| Expected hash | 55e50ffc669e0986f9d7847ff0172cc0512f59911312b38ca2e77be27284c77d |
The hash is always 64 hexadecimal characters. The SDKs lowercase it. They differ on a malformed hash:
- Android drops a hash that isn’t 64 hex characters and logs
setExternalUserId: ignoring a hash that is not 64 lowercase hex characters. - iOS keeps it (lowercased) and logs
external_user_id_hash is not 64 hex characters; the server will not verify it. - Flutter keeps any hash after lowercasing it, with no check and no log.
In every case the server then stores the external user ID as null.
Rotate the secret
Clicking Rotate secret opens a Rotate the secret? confirmation. After you confirm, the new secret is shown once in a Your new secret dialog. It replaces the old secret at once, and the old one stops working. Devices that still hold a hash made with the old secret lose their external user ID at their next registration, until the app receives a new hash. Update your backend first, and have the app fetch a fresh hash on each sign-in or session refresh.
Step 3. Set tags when something meaningful changes
Tags are string key-value pairs stored on the subscription. Use them for facts you want to target on, such as a plan, a skill level or a favorite topic.
setTagsmerges into the tags already stored on the device, then sends the full map.- A
nullor""value removes that key. - At most 50 keys per subscription. Keys match
^[A-Za-z0-9_.-]{1,64}$. Values are strings of at most 256 characters. - The SDK checks every entry before sending. It logs and skips an invalid key, a value that is too long, or a new key past the 50th. The valid entries are still saved.
Set tags when the fact changes (an upgrade, a finished level, a settings change), not on every screen.
import com.oricato.push.Oricato
Oricato.setTags(mapOf("plan" to "pro", "level" to "intermediate", "favorite_topic" to "astronomy"))
// Later: remove one key, keep the others
Oricato.setTags(mapOf("favorite_topic" to null))
import OricatoPush
Oricato.setTags(["plan": "pro", "level": "intermediate", "favorite_topic": "astronomy"])
// Later: remove one key, keep the others
Oricato.setTags(["favorite_topic": nil])
import 'package:oricato_push/oricato_push.dart';
await Oricato.setTags({'plan': 'pro', 'level': 'intermediate', 'favorite_topic': 'astronomy'});
// Later: remove one key, keep the others
await Oricato.setTags({'favorite_topic': null});
Tags belong to the installation, not to the account. When someone signs out, also remove the tags that describe
them, for example setTags with "plan" set to null.
Values are compared as exact, case-sensitive strings. There are no numeric comparisons, so store a bucket you can
match ("level": "intermediate") rather than a number you would want to compare.
Don’t put personal data in tags. The same rule as for external IDs applies.
Opt in and opt out inside your app
optIn() and optOut() are an app-level switch, separate from the phone’s notification permission. Use them for an
in-app “Notifications” setting. After optOut(), the server stops sending to that installation until optIn().
New installations start opted in.
Oricato.optOut() // Swift: Oricato.optOut() Dart: await Oricato.optOut();
Oricato.optIn() // Swift: Oricato.optIn() Dart: await Oricato.optIn();
The dashboard shows this as Switched on in the app in the subscriber details.
Track conversions
trackEvent(name) records a conversion, such as a purchase or a finished workout. Names match ^[a-z0-9_]{1,40}$.
The SDK logs and ignores any other name. The server attributes a conversion to the person’s latest notification
open in the 24 hours before it. Conversions without an open still count in project totals.
Oricato.trackEvent("purchase")
Oricato.trackEvent("started_workout")
await Oricato.trackEvent('exported_pdf');
A project keeps at most 100 distinct conversion names. Newer names are still stored but counted under (other) in
reports, so pick a short, stable list.
Step 4. Target people
Every message has an audience (an AudienceSpec). An empty audience means everyone who is subscribed on the message’s platforms.
AudienceSpec fields
The audience fields covered here:
| Field | What it matches | Limits |
|---|---|---|
tags |
A list of conditions, all of which must match. Each one is key, relation (eq, neq, exists, not_exists) and value (required for eq and neq, not allowed for exists and not_exists) |
At most 20 conditions. neq also matches people who don’t have the key at all |
external_user_ids |
Every subscribed device with one of these external user IDs | At most 10,000 IDs, each 1 to 128 characters |
subscription_ids |
Exactly these installations | At most 10,000 UUIDs |
test_only |
Only devices marked as test devices | true or false (default) |
engagement_levels |
Nightly levels: champion, active, light, sleeping, new |
Any subset |
Use at most one of external_user_ids and subscription_ids in a message. Country, language, app version and
activity filters are also available. The REST API quickstart lists them all.
Count an audience before you send
POST /api/v1/audience/estimate returns how many subscribed devices match. This example counts Pro subscribers who
like astronomy and haven’t finished onboarding:
curl -X POST "<ORICATO_API_ADDRESS>/api/v1/audience/estimate" \
-H "Authorization: Bearer $ORICATO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platforms": ["android", "ios"],
"audience": {
"tags": [
{ "key": "plan", "relation": "eq", "value": "pro" },
{ "key": "favorite_topic", "relation": "eq", "value": "astronomy" },
{ "key": "onboarding_done", "relation": "not_exists" }
]
}
}'
{
"count": 4812,
"exact": true,
"method": "query",
"as_of": "2026-10-16T09:30:00Z",
"by_platform": { "android": 3120, "ios": 1692 },
"by_language": [ { "language": "en", "count": 2950 }, { "language": "es", "count": 1104 } ],
"by_country": [ { "country": "US", "count": 1830 }, { "country": "BR", "count": 702 } ]
}
platforms is optional and defaults to the project’s platforms. Tag filters are counted with a database query
(method: "query"). If that query takes too long, you get the count of the filters the live counters can answer,
with exact: false. Sending always evaluates every filter per person.
Send to specific users
Put the same audience into a message. This sends right away to every device linked to two external user IDs:
curl -X POST "<ORICATO_API_ADDRESS>/api/v1/messages" \
-H "Authorization: Bearer $ORICATO_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-shipped-7c41e2" \
-d '{
"name": "Order shipped",
"content": {
"default_language": "en",
"translations": [
{ "language": "en", "title": "Your order is on its way", "body": "Track it in the app." }
]
},
"audience": { "external_user_ids": ["u_9f2b1c03", "u_4d8e2a71"] }
}'
REST requests are decoded strictly: a misspelled field returns 400 validation_failed instead of being ignored.
Target in the dashboard
In the message composer, open Who, choose Only some people, then click Add a filter:
- Tags: add conditions with equals, doesn’t equal, exists or doesn’t exist. All conditions must match.
- Specific people: choose External user IDs or Subscriber IDs and paste one ID per line, up to 10,000.
The composer shows the live estimate as you edit.
Find people on the Audience page
Open your project’s Audience page.
- Search: paste a full Subscriber ID or an exact external user ID into the search box and press Enter. The search is an exact match, not a prefix search.
- Subscriber details: click a row to see the external user ID (“Not set — your app can set it to link this phone to a user” when there is none), the tags, language, time zone, permission and Switched on in the app. Recent opens are on the Opens tab.
- Mark as test device (editor role): give the phone a name your team recognizes. Test devices receive test
sends and match
test_only: true. A project can have up to 100 test devices. - Delete this person’s data (admin role): use this when a person asks you to delete their data. It deletes the
subscription with its opens and conversions. Report totals stay. The Notification ID is then blocked for good: if
the app is still installed, that device gets no more Oricato notifications until the app is reinstalled. The API
call is
DELETE /admin/v1/projects/{project_id}/subscriptions/{subscription_id}.
Verify it works
- Turn on debug logs (
Oricato.setLogLevel(OricatoLogLevel.DEBUG)on Android,.debugon iOS and Flutter), sign in on a test phone, and set an external user ID and a tag. - On the Audience page, search for the external user ID. The subscriber details should show the ID under External user ID and your keys under Tags.
- With verification on, check the device log. No
Server warning: external_user_id_unverifiedline should appear. - Call
POST /api/v1/audience/estimatewith the body{"audience": {"external_user_ids": ["<your test id>"]}}, or a tag condition insideaudience. Thecountshould be at least 1. A field outsideaudiencereturns400. - Sign out in the app. The external user ID should disappear from the subscriber details.
Troubleshooting
| Symptom | Likely cause and fix |
|---|---|
The dashboard shows External user ID “Not set” after setExternalUserId |
Verification is on and the hash is missing or wrong. Look for Server warning: external_user_id_unverified in the log. Check that the backend hashes the exact ID string the app sends, uses the 48-character secret as-is (UTF-8, not base64-decoded), outputs hex (not base64), and uses the current secret after a rotation. Compare your output with the test vector above. |
Android logs ignoring a hash that is not 64 lowercase hex characters, or iOS logs external_user_id_hash is not 64 hex characters |
The backend returns base64 or a truncated value. Return the 64-character hex digest. Flutter doesn’t log this, so compare the hash with the test vector. |
Android: setExternalUserId ignored: the id must be 1-128 characters. iOS: Ignoring setExternalUserId: the id must be 1–128 characters. Flutter: setExternalUserId: ids must be 1–128 characters |
The ID is too long, or (Android and Flutter) empty. To clear the ID, pass null (nil). On iOS an empty string also clears it. |
| A tag never shows up | The SDK skipped it on the device, so the upload itself doesn’t fail. Keys must match ^[A-Za-z0-9_.-]{1,64}$, values are at most 256 characters, and a subscription holds at most 50 tags. Look for these logs. Android: setTags: ignoring key '<key>'. iOS: Ignoring tag "<key>": keys must match ..., ... values must be at most 256 characters or ... at most 50 tags are allowed. Flutter: setTags: ignoring invalid tag key "<key>", setTags: value of "<key>" is longer than 256 characters; ignored or setTags: more than 50 tags; "<key>" ignored. |
400 validation_failed on an estimate or a message |
Check details.fields[]. Common ones: audience.tags[0].key with invalid_format, a missing value for eq or neq, a value sent with exists or not_exists (not_allowed), more than 20 tag conditions (too_many), or both external_user_ids and subscription_ids (conflict). |
| A tag filter matches fewer people than expected | Values are exact and case-sensitive (Pro isn’t pro). People who installed before you shipped the setTags call don’t have the tag until they open the updated app. |
neq matches more people than expected |
neq also matches everyone without that key. Add an exists condition on the same key to exclude them. |
Flutter logs setTags called before Oricato.initialize(); ignored |
Await Oricato.initialize(...) before calling the setters. |
| Changes made while offline don’t appear | They aren’t lost. The SDK saves them on the device and retries with backoff, and also when the app returns to the foreground. They appear after the next successful registration. |
| A user who reinstalled has no external ID or tags | A reinstall, or a phone restored from a backup, creates a new subscription with no ID and no tags. Call setExternalUserId and setTags again on app start whenever the person is signed in. Targeting by external user ID then reaches the new subscription. |
| A message to one external user ID reached several devices | That’s expected. Every subscribed device linked to the ID receives it. Target subscription_ids to reach one installation. |
Next steps
- Languages and localized messages: report the language your app shows and send each person the right translation.
- REST API quickstart: create, schedule and cancel messages from your servers.
- API keys and App Check: keep API keys and the external-ID secret on your servers, and protect SDK traffic.