Skip to content

Mint a data-plane API key (scopes capped to the partner ceiling)

POST
/v1/partner/tenants/{id}/api-keys
curl --request POST \
--url https://api.emite.cr/v1/partner/tenants/example/api-keys \
--header 'Content-Type: application/json' \
--data '{ "environment": "sandbox", "name": "pos-cloud production", "scopes": [ "example" ], "revokeExisting": false }'

The raw key is returned exactly once. Rotation = mint new + revoke old — or, in one call, revokeExisting: true: the other live keys this partner minted for the tenant in the same environment are revoked in the same transaction (the name can be reused), with a 5-minute grace during which they still verify. Answers 201 with the key; rawKey, the value to send as x-api-key on the data plane, is in this response only and cannot be retrieved later.

id
required
string
x-partner-key
string

Partner app credential (ecp_*)

Media typeapplication/json
object
environment
required

Environment the key is bound to, for good: sandbox (an ec_test_* key) or production (ec_live_*). A production key needs the partner app to have production access (403 PARTNER_PRODUCTION_NOT_ENABLED).

string
Allowed values: sandbox production
name
required

Label of the key. Two active keys of one company's environment cannot share it (409 API_KEY_NAME_TAKEN); with revokeExisting: true it can be reused in the same call.

string
Example
pos-cloud production
scopes

The key's scopes, within the partner ceiling: invoices:read, invoices:write, invoices:sign, invoices:submit, invoices:void, invoices:export, parties:read, parties:write, items:read, items:write, documents:read, documents:accept, branches:read, terminals:read, sequences:read, economic_activities:read, tenant:read, fx:read. Omitted or empty, the key gets the whole ceiling; anything outside it answers 400 PARTNER_SCOPE_NOT_GRANTABLE.

Array<string>
revokeExisting

Rotation in one call: every other live key this partner minted for the company in the same environment is revoked in the same transaction (so the name can be reused) and keeps working for a 5-minute grace. If the mint fails, nothing is revoked.

boolean
Media typeapplication/json
object
id
required

Identifier of the key — also the middle segment of the raw key (<prefix>_<id>_<secret>). Use it to rotate or revoke the key.

string
name
required

The label given at creation, kept by a rotation. Unique among the active keys of the environment: a revoked key frees its name.

string
prefix
required

Prefix segment of the raw key. ec_test_* for sandbox keys, ec_live_* for production keys (Stripe-style). The secret segment is never returned after creation (the middle segment is the key's id).

string
environment
required

Environment the key is bound to. A sandbox key authenticates against sandbox data only; a production key against production data only. Immutable after creation — to switch environments, create a new key.

string
Allowed values: sandbox production
lastFour
required

Last 4 chars of the key id. Useful for visual reconciliation in the UI and in audit logs ("the key ending in …a3b4"). NEVER exposes secret bytes.

string
scopes
required

The scopes stored on the key, as chosen at creation (a rotation keeps them). * grants every scope an API key may hold — never the session-only ones (members, API keys, billing, credentials, ownership).

Array<string>
status
required

Derived, never stored: revoked once revokedAt has passed (it wins over an expiry), expired once expiresAt has passed, otherwise active — also during the grace window of a rotation, while revokedAt is still in the future.

string
Allowed values: active revoked expired
createdAt
required

When the key was created (a rotation creates a new key).

string format: date-time
lastUsedAt
required

Last verified use (best-effort, populated on guard verify).

string format: date-time
nullable
expiresAt
required

When the key stops authenticating on its own, as set at creation (a rotation keeps it). null = it never expires.

string format: date-time
nullable
revokedAt
required

When the key was revoked; null if it never was. A rotation sets it in the future — the grace window — and the old key keeps working until then.

string format: date-time
nullable
createdByName
required

Display name of the user who created the key. null if the user was deleted.

string
nullable
createdByUserId
required

User who created the key.

string format: uuid
nullable
rawKey
required

Plaintext API key. Returned once only. Use as the x-api-key header value. Cannot be recovered after this response.

string
Example
{
"environment": "sandbox",
"status": "active",
"rawKey": "ec_test_01a00c73-5c07-7bb5-8b9e-d20f16537e42_aBcDeF..."
}