API keys and identity
Three values connect your code to an environment. All three are on the environment page once the environment is Active.
| Value | Looks like | Used by |
|---|---|---|
| Endpoint | https://e0123456789a.iad.cairnflow.cloud |
Everything that calls cairnflow: scripts, your backend, the chat proxy |
| API key | cf_… |
Sent as Authorization: Bearer <key> on every request to the endpoint |
| Identity key | publickeyv1_… |
Your service, in identityKeys, to check requests that come from the environment |
API keys authenticate you to the environment. The identity key works the other way round: it lets your service check that a request comes from your environment and not from someone who found its URL.
API keys
Section titled “API keys”Create a key on the environment page. Name it after where it will be used (ci, laptop,
billing-worker) so you know what breaks when you revoke it.
The secret is shown once, when the key is created. Cloud keeps only a hash and the key’s metadata; if you lose a secret, revoke the key and create a new one.
curl -X POST "$CAIRN_URL/invoke/Greeter/greet" \ -H "authorization: Bearer $CAIRN_KEY" \ -H "content-type: application/json" \ -d '"world"'A missing or wrong key gets 401; a key whose role does not allow the route gets 403.
| Role | For | Can |
|---|---|---|
| Admin (deploy and invoke) | CI, operators, your own scripts | Everything an Invoke key can, plus: register and remove deployments, move service revisions, read journals, logs, spans, usage, audit and archives, run SQL queries, hard-cancel, purge, resume, restart and migrate invocations. Signs in to the console |
| Invoke only | Clients that call your services: your backend, a chat proxy | Invoke handlers (/invoke, /send, workflows), read an invocation’s status and wait for it, resolve and reject durable promises and awakeables, send signals, cancel cooperatively, manage schedules, read the invocation’s own streams and artifacts |
An Invoke only key cannot read journals or state, and cannot register deployments. Give each client the smallest role that works: a browser-facing proxy needs Invoke only.
Revoking
Section titled “Revoking”Revoking a key refuses requests that use it within seconds, on every node. An event stream already open with the key is closed within about 30 seconds. It cannot be undone.
Keys do not belong to the person who created them: when a member leaves the organization, the keys they created keep working until someone revokes them.
Console sign-in
Section titled “Console sign-in”Open console on the environment page signs you in with your Cairnflow Cloud account; no key to paste. Your organization role decides what you can do there (see Cairnflow Cloud).
The console’s own sign-in page also accepts an Admin API key. The key is exchanged for a session cookie and is not stored in the browser. Signing out revokes the session on the server, so a copy of the cookie stops working too.
Identity key
Section titled “Identity key”Every request Cloud sends to your service carries a signed token. Pass the environment’s identity key to the SDK and it rejects anything not signed by your environment: wrong signature, wrong path, expired, or replayed for another request. The handler does not run.
await serve({ services: [greeter], port: Number(process.env.PORT ?? 9080), hostname: "0.0.0.0", identityKeys: ["publickeyv1_…"],});const handler = fetchHandler({ services: [greeter], identityKeys: ["publickeyv1_…"],});Cloud refuses to register an endpoint that does not check identity keys, because a function URL is public: without the check, anyone who knows the URL could call your handlers.
identityKeys is a list so that a key can be rotated without downtime: the new key is added to the
list before it starts signing, and the old one is removed after. You can also read the current keys
with an Admin key:
curl "$CAIRN_URL/identity" -H "authorization: Bearer $CAIRN_KEY"The answer is {tenant, signing, keys: [{generation, kid, active}]}; each kid is a
publickeyv1_… value for identityKeys.