Skip to Content
Getting StartedAuthentication

Authentication

Every request carries an API key as a Bearer token:

Authorization: Bearer sk_test_your_key_here

Only that header is read. An x-api-key header is refused with 401 and AUTH040 on every operation, even beside a valid Authorization, and so is any scheme other than Bearer. Requests go to https://gp.useyona.com whichever key you use; the key decides whether you are on the sandbox or the live service.

Keys

  • Keys are created in the Yona app under API keys, by a signed-in user. A key can never create, rotate or revoke keys: those operations answer 403 with AUTH018.
  • The secret is shown once, at creation and at rotation. Store it then.
  • A key reads sk_test_<public id>_<secret> (sandbox) or sk_live_<public id>_<secret> (live). The public id is 16 characters of a to z and 2 to 7; it is not secret, and it is how the app and notifications name the key. The secret is 43 characters of letters, digits, _ and -. The environment is fixed for the life of the key.
  • A key may carry an expiry. An organization may hold up to 50 active keys.

What a key may do

Each key is granted a list of capabilities when it is created, from a preset or as an explicit list. 53 capabilities can be granted to a key; the capabilities field of Create an API key lists them. A preset becomes its list at creation, so a capability added to a preset later never joins an existing key. A preset you cannot fully hold yourself is refused with 403 and AUTH019, never narrowed.

PresetCapabilitiesCovers
read_only21Reading the organization, billing, invoices and their statistics, received invoices, buyers, items, the seller, reference data, the tax connection, webhook endpoints and deliveries, and the collection records
invoicing44Everything in read_only, plus creating, editing, finalising, validating, submitting, retrying, sending, sharing, downloading and recording payments on invoices; creating, editing, deleting and verifying buyers; creating, editing and archiving items; looking up tax IDs; opening collection accounts
full_integration49Everything in invoicing, plus cancelling invoices, sending test webhook events, redelivering, deactivating collection accounts and resolving collection exceptions
payments_read23read_only, plus bank_account.read and transfer.read
full_integration_payments51full_integration, plus bank_account.read and transfer.read

read_only is the default. A request that needs a capability the key lacks is answered 403 with AUTH019.

Exactly what each preset holds:

  • read_only: organization.read, billing.account.read, billing.usage.read, billing.ledger.read, billing.statement.read, billing.payment.read, billing.subscription.read, invoice.read, invoice.stats.read, invoice.inbound.read, buyer.read, item.read, seller.read, reference.read, tax_connection.read, webhook.endpoint.read, webhook.delivery.read, collection.account.read, collection.settlement_account.read, collection.payment.read, collection.exception.read.
  • invoicing: read_only, plus invoice.create, invoice.update_draft, invoice.delete_draft, invoice.finalise, invoice.validate, invoice.submit, invoice.retry, invoice.query_status, invoice.record_payment, invoice.send_to_buyer, invoice.download_pdf, invoice.download_authority_copy, invoice.reopen, invoice.share, buyer.create, buyer.update, buyer.delete, buyer.verify_tax_id, item.create, item.update, item.archive, tax_id.lookup, collection.account.create.
  • full_integration: invoicing, plus invoice.cancel, webhook.endpoint.test, webhook.delivery.redeliver, collection.account.deactivate, collection.exception.resolve.
  • payments_read and full_integration_payments: read_only and full_integration, each plus bank_account.read and transfer.read. Those two serve operations that are not in this reference yet.

full_integration is not every capability. It leaves out bank_account.read and transfer.read, and the two capabilities that no preset carries: organization.children.read (list the organization’s sub-organizations) and organization.children.create (create one, with a live key). Those two are added to a key on purpose, under Sub-organizations when the key is created. See Sub-organizations.

What a key may never do

These operations are for signed-in users and are done in the Yona app. With a key they answer 403 with AUTH018:

  • creating, rotating or revoking API keys;
  • connecting to the tax authority, refreshing the connection, installing the crypto key, or disconnecting;
  • creating, updating, deleting or rotating the secret of a webhook endpoint (a key can list and test them, and read deliveries);
  • buying credits;
  • changing invoice settings;
  • members, invitations and roles.

The API reference says, next to every operation, whether a key may call it.

How a key is checked

The gateway exchanges the key for a short-lived token, valid for at most ten minutes, and caches the result. You never handle that token. Revoking a key takes effect on its next request.

Rotating a key issues a new secret and keeps the old one working for a grace period, one day by default and seven at most, so you can switch without a gap.

Live keys

Creating a sk_live_ key needs three things, each with its own refusal:

NeedRefusal
The organization has been approved for live access403 BIZ006
Live mode is switched on for the organization403 BIZ005
The session creating the key has a second factor403 AUTH025

See Sandbox and live for the path to live access.

Errors

StatusCodeMeaning
401AUTH004No usable token on the request
401AUTH003The value after Bearer is not a well-formed key
401AUTH040The key was not sent as Authorization: Bearer: an x-api-key header, or another scheme
400VAL023Two Authorization headers, or one longer than 8,192 bytes
401AUTH021The key is not valid
401AUTH022The key has expired
401AUTH041The key was revoked
403AUTH018This operation is for signed-in users
403AUTH019The key lacks a capability the operation needs
403BIZ108The request names a mode the key cannot act in, such as a sk_live_ key reading the sandbox ledger

Keep keys safe

  • Keys are server-side only. Never ship one in a browser, a mobile app or a public repository.
  • Read keys from the environment, not from source control.
  • Give each integration its own key with the smallest preset that works, and name it after the system that holds it.
  • Rotate on a schedule, and revoke at once if a key may have leaked.