API keys
List API keys
GET /a/v1/organizations/{orgId}/api-keys
A page of the organization’s API keys in every status. Metadata only, never a secret.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
status | query | string | No | One of active | rotating | revoked | expired. |
mode | query | string | No | One of sandbox | live. |
page | query | number | No | Default: 1. At least 1. |
limit | query | number | No | Default: 20. Between 1 and 100. |
Example request
Responses
Errors: 400, 401, 403, 404, 429, 500, 503
Create an API key
POST /a/v1/organizations/{orgId}/api-keys
Creates a sandbox or live key with a preset or an explicit list of capabilities (the read_only preset when neither is given). A live key also needs the live_mode.use capability. The response is the key’s metadata plus key, the full secret (sk_test_… or sk_live_…): it is shown in this response only and cannot be retrieved again.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | 1 to 100 characters. |
mode | string | Yes | Fixed for the life of the key: sk_test_ or sk_live_. One of sandbox | live. |
preset | string | No | Default read_only. One of read_only | invoicing | payments_read | full_integration | full_integration_payments. |
capabilities | array of string | No | Each item is one of organization.read | organization.children.read | organization.children.create | organization.children.onboard | billing.account.read | billing.usage.read | billing.ledger.read | billing.statement.read | billing.payment.read | billing.subscription.read | webhook.endpoint.read | webhook.endpoint.test | webhook.delivery.read | webhook.delivery.redeliver | collection.account.read | collection.account.create | collection.account.deactivate | collection.settlement_account.read | collection.payment.read | collection.exception.read | collection.exception.resolve | bank_account.read | transfer.read | invoice.read | invoice.stats.read | invoice.create | invoice.update_draft | invoice.delete_draft | invoice.finalise | invoice.validate | invoice.submit | invoice.retry | invoice.query_status | invoice.cancel | invoice.record_payment | invoice.send_to_buyer | invoice.download_pdf | invoice.download_authority_copy | invoice.reopen | invoice.share | invoice.inbound.read | reference.read | tax_id.lookup | buyer.read | buyer.create | buyer.update | buyer.delete | buyer.verify_tax_id | item.read | item.create | item.update | item.archive | seller.read | tax_connection.read. |
expiresAt | string (date-time) | No | ISO-8601 instant with an offset, more than 1 hour and at most 2 years from now. |
Example request
Responses
The key’s metadata and its plaintext key, shown once.
Errors: 400, 401, 403, 404, 413, 415, 429, 500, 503
Get an API key
GET /a/v1/organizations/{orgId}/api-keys/{id}
One API key’s metadata, never its secret.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
id | path | string (uuid) | Yes |
Example request
Responses
Errors: 400, 401, 403, 404, 429, 500, 503
Rename an API key
PATCH /a/v1/organizations/{orgId}/api-keys/{id}
Changes the key’s name only. Capabilities change through PUT …/api-keys/{id}/capabilities.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
id | path | string (uuid) | Yes |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | 1 to 100 characters. |
Example request
Responses
Errors: 400, 401, 403, 404, 409, 413, 415, 429, 500, 503
API keys at a glance, per mode
GET /a/v1/organizations/{orgId}/api-keys/summary
The organization’s keys counted per mode: by status, never used, expiring within 14 days, the next expiry and when a key was last exchanged for a token. Metadata only, never a secret.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
Example request
Responses
Errors: 400, 401, 403, 404, 429, 500, 503
List the members a key is assigned to
GET /a/v1/organizations/{orgId}/api-keys/{id}/assignments
The members a key is assigned to for the API playground, oldest first, each with effective — false, with the reason, when the member is no longer active in the organization or the key is no longer usable.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
id | path | string (uuid) | Yes |
Example request
Responses
Errors: 400, 401, 403, 404, 429, 500, 503
Assign a key to a member for the API playground
PUT /a/v1/organizations/{orgId}/api-keys/{id}/assignments/{userId}
Lets an active member use the key in the API playground even though they could not have created it. Only a caller who could have created the key may assign it (api_key.create and every capability of the key; for a live key also live_mode.use). Assigning twice answers the existing assignment.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
id | path | string (uuid) | Yes | |
userId | path | string (uuid) | Yes |
Example request
Responses
Errors: 400, 401, 403, 404, 409, 429, 500, 503
Remove a member’s assignment to a key
DELETE /a/v1/organizations/{orgId}/api-keys/{id}/assignments/{userId}
The member can no longer use the key in the API playground: their next mint is refused, and a token already minted lives out its few minutes. removed is false when there was nothing to remove.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
id | path | string (uuid) | Yes | |
userId | path | string (uuid) | Yes |
Example request
Responses
Errors: 400, 401, 403, 404, 429, 500, 503
Replace an API key’s capabilities
PUT /a/v1/organizations/{orgId}/api-keys/{id}/capabilities
The new list replaces the old one and may only name capabilities the caller holds. Access tokens already issued to the key stop working.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
id | path | string (uuid) | Yes |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
capabilities | array of string | Yes | Each item is one of organization.read | organization.children.read | organization.children.create | organization.children.onboard | billing.account.read | billing.usage.read | billing.ledger.read | billing.statement.read | billing.payment.read | billing.subscription.read | webhook.endpoint.read | webhook.endpoint.test | webhook.delivery.read | webhook.delivery.redeliver | collection.account.read | collection.account.create | collection.account.deactivate | collection.settlement_account.read | collection.payment.read | collection.exception.read | collection.exception.resolve | bank_account.read | transfer.read | invoice.read | invoice.stats.read | invoice.create | invoice.update_draft | invoice.delete_draft | invoice.finalise | invoice.validate | invoice.submit | invoice.retry | invoice.query_status | invoice.cancel | invoice.record_payment | invoice.send_to_buyer | invoice.download_pdf | invoice.download_authority_copy | invoice.reopen | invoice.share | invoice.inbound.read | reference.read | tax_id.lookup | buyer.read | buyer.create | buyer.update | buyer.delete | buyer.verify_tax_id | item.read | item.create | item.update | item.archive | seller.read | tax_connection.read. |
Example request
Responses
Errors: 400, 401, 403, 404, 409, 413, 415, 429, 500, 503
Get an API key’s capabilities
GET /a/v1/organizations/{orgId}/api-keys/{id}/permissions
What the key may do now, and which capabilities the caller could grant it.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
id | path | string (uuid) | Yes |
Example request
Responses
Errors: 400, 401, 403, 404, 429, 500, 503
Revoke an API key
PATCH /a/v1/organizations/{orgId}/api-keys/{id}/revoke
The key stops working at once.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
id | path | string (uuid) | Yes |
Example request
Responses
Errors: 400, 401, 403, 404, 409, 429, 500, 503
Rotate an API key
POST /a/v1/organizations/{orgId}/api-keys/{id}/rotate
Issues a new key with the same name, mode, capabilities and expiry. The old key keeps working for the grace period (gracePeriodSeconds) and is then retired. A live key also needs the live_mode.use capability, and the caller must hold every capability of the key. The new key’s full secret is returned once, in current.key.
Who can call it: Signed-in user only: do this in the Yona app.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
orgId | path | string | Yes | Organization id — must equal the token’s organization — or me. |
id | path | string (uuid) | Yes |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
gracePeriodSeconds | number | No | Seconds the old key keeps working after the rotation, from 0 to 604800 (7 days). Defaults to the configured grace period (86400 seconds, 24 hours, by default). Between 0 and 604800. |
Example request
Responses
The old key (previous, now rotating) and the new key (current) with its plaintext key, shown once.
Errors: 400, 401, 403, 404, 409, 413, 415, 429, 500, 503