Skip to Content

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
statusquerystringNoOne of active | rotating | revoked | expired.
modequerystringNoOne of sandbox | live.
pagequerynumberNoDefault: 1. At least 1.
limitquerynumberNoDefault: 20. Between 1 and 100.

Example request

bash
curl https://gp.useyona.com/a/v1/organizations/me/api-keys \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.

Request body

FieldTypeRequiredDescription
namestringYes1 to 100 characters.
modestringYesFixed for the life of the key: sk_test_ or sk_live_. One of sandbox | live.
presetstringNoDefault read_only. One of read_only | invoicing | payments_read | full_integration | full_integration_payments.
capabilitiesarray of stringNoEach 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.
expiresAtstring (date-time)NoISO-8601 instant with an offset, more than 1 hour and at most 2 years from now.

Example request

bash
curl -X POST https://gp.useyona.com/a/v1/organizations/me/api-keys \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ERP integration",
    "mode": "sandbox"
  }'

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
idpathstring (uuid)Yes

Example request

bash
curl https://gp.useyona.com/a/v1/organizations/me/api-keys/9f8e7d6c-5b4a-3210-fedc-ba9876543210 \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
idpathstring (uuid)Yes

Request body

FieldTypeRequiredDescription
namestringYes1 to 100 characters.

Example request

bash
curl -X PATCH https://gp.useyona.com/a/v1/organizations/me/api-keys/9f8e7d6c-5b4a-3210-fedc-ba9876543210 \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "string"
  }'

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.

Example request

bash
curl https://gp.useyona.com/a/v1/organizations/me/api-keys/summary \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
idpathstring (uuid)Yes

Example request

bash
curl https://gp.useyona.com/a/v1/organizations/me/api-keys/9f8e7d6c-5b4a-3210-fedc-ba9876543210/assignments \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
idpathstring (uuid)Yes
userIdpathstring (uuid)Yes

Example request

bash
curl -X PUT https://gp.useyona.com/a/v1/organizations/me/api-keys/9f8e7d6c-5b4a-3210-fedc-ba9876543210/assignments/d8b2e4f6-9a3c-5b7d-0e1f-2a3b4c5d6e7f \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
idpathstring (uuid)Yes
userIdpathstring (uuid)Yes

Example request

bash
curl -X DELETE https://gp.useyona.com/a/v1/organizations/me/api-keys/9f8e7d6c-5b4a-3210-fedc-ba9876543210/assignments/d8b2e4f6-9a3c-5b7d-0e1f-2a3b4c5d6e7f \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
idpathstring (uuid)Yes

Request body

FieldTypeRequiredDescription
capabilitiesarray of stringYesEach 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

bash
curl -X PUT https://gp.useyona.com/a/v1/organizations/me/api-keys/9f8e7d6c-5b4a-3210-fedc-ba9876543210/capabilities \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "capabilities": [
      "organization.read"
    ]
  }'

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
idpathstring (uuid)Yes

Example request

bash
curl https://gp.useyona.com/a/v1/organizations/me/api-keys/9f8e7d6c-5b4a-3210-fedc-ba9876543210/permissions \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
idpathstring (uuid)Yes

Example request

bash
curl -X PATCH https://gp.useyona.com/a/v1/organizations/me/api-keys/9f8e7d6c-5b4a-3210-fedc-ba9876543210/revoke \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN"

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

NameInTypeRequiredDescription
orgIdpathstringYesOrganization id — must equal the token’s organization — or me.
idpathstring (uuid)Yes

Request body

FieldTypeRequiredDescription
gracePeriodSecondsnumberNoSeconds 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

bash
curl -X POST https://gp.useyona.com/a/v1/organizations/me/api-keys/9f8e7d6c-5b4a-3210-fedc-ba9876543210/rotate \
  -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "gracePeriodSeconds": 1
  }'

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