Project keys
Each project has a public key for sending events. It goes in your client code; it cannot read anything.
Key types
| Prefix | Use | Where it may appear |
|---|---|---|
pk_live_ | sending events from your live site or app | client code, public |
pk_test_ | development: also accepts localhost, 127.0.0.1 and Expo Go | client code, public |
rk_ | a read key: opens your workspace's dashboard | never in client code |
datacub_mcp_ | connecting an AI tool through MCP | never in client code |
A pk_ key can only send events, and only from the places you allow. That is why it is safe to ship. The SDKs refuse a key that starts with sk_ in any environment: a secret in a browser or app is a leaked credential.
Find the key in Settings, Integrations, under Write keys.
Allowed websites and apps
datacub accepts events only from:
- sites on the project's list: a domain such as
shop.example.sa, or*.example.safor every subdomain (not the bare domain: add it too if it serves pages) - apps whose bundle ID or package name is on the project's list, such as
sa.example.shop
Both lists are in Settings, General, under Where data may come from. Government, education, health and military sites are reviewed by datacub before any of their events are stored.
A request from anywhere else is refused with 403 origin_not_allowed or 403 app_not_allowed, and the SDK stops sending for that page or launch. These checks stop your key being used on someone else's site by accident. They are not a secret: anyone can still send requests that claim to be your site, so treat incoming events as data, not proof.
Test and live
Use a pk_test_ key while you build, ideally in a separate project, so test traffic never mixes with real users. datacub accepts events from localhost, 127.0.0.1 and Expo Go only with a test key; a live key is refused there. Every new project comes with a test key, marked Test in Settings, Integrations; New test key makes another.
Put the test key in development builds and the live key in production. With Vite, write datacub.init('%VITE_DATACUB_KEY%') in the snippet in index.html and set VITE_DATACUB_KEY in .env.development and .env.production.
Changing keys
A project can have two keys at once, so you can switch without a gap: in Settings, Integrations, create a new key, ship it, then revoke the old one. A revoked key stops working within 15 seconds.
A pk_ key is public by design, so a copy is not a breach. Switch keys if someone sends junk with it.