Areev
Areev / Developers

Authentication & API keys

Create a scoped credential for your integration, keep it secure and revoke it when access is no longer needed.

1. Start with an organisation administrator

Sign in to the Areev Desk as an owner or administrator of the organisation that owns the deployment. Ask Areev for assisted key creation if you do not have administrator access. The steps below use the authentication API; they do not depend on an API-key screen in the Desk.

Production control API: https://api.areev.ai. Staging control API: https://staging-api.areev.ai. Use the matching signed-in Desk and environment. For background integrations, use a scoped API key; a browser session or short-lived cell token is not a permanent integration credential.

2. Get your organisation ID and create a key

An administrator can run this JavaScript from the trusted, signed-in Desk origin allowed by the control API. GET /v1/auth/me returns the organisations and the caller’s roles. Choose the correct organisation, then replace ORG_ID below. Do not run it from the Store, an unrelated page or a public code playground.

POST /v1/orgs/{org}/api-keys creates the credential. Request only the scopes your integration needs: jobs:submit to start work and jobs:read to inspect jobs and evidence. This example expires the key after 90 days. Creation returns the token once; store it in your secret manager immediately. Listing keys never reveals the secret again.

const api = "https://api.areev.ai";
const meResponse = await fetch(api + "/v1/auth/me", {
  credentials: "include"
});
if (!meResponse.ok) throw new Error("Sign in to the matching Desk first");
const me = await meResponse.json(); // inspect me.orgs for id and role

const response = await fetch(api + "/v1/orgs/ORG_ID/api-keys", {
  method: "POST",
  credentials: "include",
  headers: {
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID()
  },
  body: JSON.stringify({
    name: "Finance integration",
    scopes: ["jobs:submit", "jobs:read"],
    expires_in_days: 90
  })
});
if (!response.ok) throw new Error("Key creation failed: " + response.status);
const credential = await response.json();
// Save credential.token securely now; do not log or commit it.

3. Authenticate each request

Send the returned token as Authorization: Bearer <API_KEY>. Its format is ak_<prefix>.<secret>. Store it on your server or in an approved client’s credential storage, never in browser-delivered application code, a product URL or a repository.

Use GET /v1/auth/credential to verify a machine credential and its scopes. GET /v1/auth/me is for a signed-in person. An API key cannot approve human decisions, even if a requested scope mentions responding to a run.

curl --fail-with-body https://api.areev.ai/v1/auth/credential \
  -H "Authorization: Bearer $AREEV_API_KEY"

4. Rotate or revoke access

An organisation administrator can list key metadata with GET /v1/orgs/{org}/api-keys and revoke a key with DELETE /v1/orgs/{org}/api-keys/{id}. Use the key ID returned at creation, not the secret. To rotate, create a replacement, update the integration, verify it works and revoke the old key.

A 401 response usually means authentication is missing or invalid; a 403 means the credential lacks access or a required scope. Verify the organisation, environment and deployment as well as the key. Do not solve an access error by granting every scope.