# Keys and permissions for the Accounts API

The Accounts API permissions and what each does, the three key types (read-only, read and write, AI agent), choosing permissions and limits when you generate a key, test and live keys, the rules for live keys (expiry, unused permissions, the responsible person), getting an access token from POST /oauth/token, and what each refusal means.

Source: https://dev.vezmo.com/docs/developers/accounts-api-keys


## Overview

An Accounts API call is made with an API key that holds Accounts API permissions. You choose them when you generate
the key; a key starts with no permissions at all. A key that holds only permissions ending in `.read` is a **read-only
key**.

The read permissions open once the Accounts API is on for your business; the others once sending with approval is on.
See [Get access to the Accounts API](/docs/developers/accounts-api-access).

## The read permissions

| Permission | In the key form | What it reads |
| --- | --- | --- |
| `accounts.read` | **Accounts and balances** | Your accounts, numbers masked to the last 4 digits, and each currency's balance. |
| `transactions.read` | **Transactions** | Every line booked on your balances. |
| `statements.read` | **Statements** | Monthly statements as JSON, CSV or PDF. |
| `events.read` | **Account events** | What happened on your accounts in the last 30 days. |

The names have a dot and end in `.read`, like the rest of Vezmo's permissions. Don't mix up `accounts.read` (the
Accounts API) with `account.read`, which reads your payment settings (3D Secure and payment methods) and sits under
**Account security** in the key form.

With sending with approval on, three more reads open: `recipients.read` (your recipients, masked), `fx.read`
(indicative rates) and `transfers.read` (transfers, payment requests and approvals).

## Permissions for sending with approval

| Permission | What it lets the key do |
| --- | --- |
| `recipients.write` | Add a recipient, which waits for a person's approval; archive one; change its nickname or metadata. |
| `quotes.write` | Price a payment. A price moves no money. |
| `transfers.request` | Ask for a payment, which waits for a person's approval, and cancel a request nobody has decided on. |

None of them can approve anything or send money on its own. See
[Approve API requests](/docs/developers/accounts-api-approvals).

A key that holds any of these holds Accounts API permissions only. Mixing them with VezmoPay permissions is refused
with `scopes_cant_mix`: use two keys.

## Key types

The permissions decide the key's type, and the type is in the key ID:

| Key type | Key ID starts with | What it is for |
| --- | --- | --- |
| **Read-only** | `vzm_live_ro_` · `vzm_test_ro_` | Reading only. |
| **Read and write** | `vzm_live_rq_` · `vzm_test_rq_` | Your own systems, such as your ERP, asking for payments and recipients. |
| **AI agent** | `vzm_live_ag_` · `vzm_test_ag_` | An AI agent preparing payments for a person to approve, with a shorter list of permissions and lower limits. See [AI agents and the Accounts API](/docs/developers/accounts-api-agents). |

## Generate a key with Accounts API permissions

1. **Open API keys**
Go to **Settings › Developers** (or **Payments › VezmoPay › Developers**). In **Test keys** or **Live keys**, select
**Generate key**.

2. **Name the key**
Name it after where it runs, like "ERP sync". The description is optional. A live key with Accounts API permissions
must expire: leave the date empty and it expires after 180 days, or pick a date up to 365 days ahead.

3. **Choose the permissions**
Under **Accounts API**, set each one you need. Choose only what the system needs: a statement exporter needs
`statements.read` and nothing else. The summary under the list says the key type and the start of the key ID it will
get. For an AI agent, choose **An AI agent** under **Who uses this key**.

4. **Set lower limits, if you want**
A key that can ask for payments can have limits lower than the standard ones. See
[Limits for sending with approval](/docs/developers/accounts-api-limits).

5. **Confirm it's you**
Select **Generate key**. We email you a code and ask for your passkey or authenticator app, because a key reaches your
money. The check names the key's permissions, its type and its limits.

6. **Save the key ID and the secret**
Both are shown once. Keep the secret in a secrets manager on your server, never in code, a web page or version
control. Then select **I've saved them — done**.

**The secret is shown once:**
We keep only a fingerprint of it. If you lose it, roll the key: you get a new secret, and the old one keeps working
for the time you choose.

## Test keys and live keys

| | Test key | Live key |
| --- | --- | --- |
| Reads | The sandbox: simulated accounts, no real money. See [Sandbox for the Accounts API](/docs/developers/accounts-api-sandbox). | Your real accounts. |
| Key ID starts with | `vzm_test_ro_`, `vzm_test_rq_` or `vzm_test_ag_` | `vzm_live_ro_`, `vzm_live_rq_` or `vzm_live_ag_` |
| Secret starts with | `vzs_test_` | `vzs_live_` |

A key's mode never changes. A test key never sees live data, and a live key never sees the sandbox.

**Before VezmoPay is active,** a live key can still be made once the Accounts API is on, holding only Accounts API
permissions. The key form then lists them first and shows the others as **Opens with VezmoPay**. A live key that asks
for any other permission is refused with `403` and the code `LIVE_KEYS_NEED_VEZMOPAY`.

## Get an access token

Your server swaps the key for an access token with `POST /oauth/token`, the standard OAuth 2.0 client-credentials
request, so any OAuth library works:

- Send `grant_type=client_credentials`, form-encoded or as JSON.
- Send the key ID and the secret one way: HTTP Basic, or as `client_id` and `client_secret` in the body.
- To get a token that can do less than the key, send `scope` with the permissions you want, separated by spaces.

The answer has `access_token`, `token_type` (`Bearer`), `expires_in` (900 seconds, so 15 minutes) and `scope`. There
is no refresh token: when the token runs out, ask for a new one. A key can get 10 tokens a minute, so keep the token
and reuse it until it ends.

Requests and answers with examples: [Authentication in the Accounts API reference](https://user.vezmo.com/docs/v1/accounts-api#access-tokens).

## Rules for live keys with Accounts API permissions

These rules apply to live keys that hold any Accounts API permission. Test keys, and keys with only VezmoPay or
WooCommerce permissions, keep the rules on [API keys](/docs/developers/api-keys).

- **They expire.** 180 days after they are made unless you pick a date, and never more than 365 days ahead. **Change
  expiry** can move the date, up to 365 days ahead, but can't remove it. A key made before this rule keeps the expiry
  it had until you change it.
- **Unused power will lapse, once this rule is on.** It isn't on yet. When we switch it on, permissions that ask for
  payments or add recipients, unused for 60 days, will be taken off the key, which keeps reading, and a key not used at
  all for 90 days will be revoked. Everyone who can manage your API keys will get an email 7 days before either, and no
  key changes before 12 January 2027.
- **The responsible person must still be able to send.** A key that asks for payments needs its responsible person to
  hold **Send and convert money**; one that adds recipients needs them to hold **Manage recipients**. If they lose it,
  those calls are refused with `key_owner_cannot_send` and we tell you once. An admin can take the key over in
  **Settings › Developers**. If the responsible person leaves your team, the key stops until someone takes it over.

## Change, roll or stop a key

Everything on [API keys](/docs/developers/api-keys) applies to these keys too. In short:

- **Remove permissions** at any time. You can't add any: make a new key instead. Removing a sending permission cancels
  the payments or recipients the key asked for that still wait for approval.
- **Lower a key's limits** at any time. You can't raise them: make a new key instead.
- **Roll** a key to get a new secret; the old one keeps working for 1 hour, 24 hours or 7 days.
- **Allowed IP addresses**: a key that should run only from your servers can be limited to their addresses.
- **Revoke** a key in one click: it stops at once, and the payments and recipients it asked for that still wait for
  approval are canceled. The same happens when a key is switched off or deleted.
- **Found in public code.** If GitHub finds one of your secrets in public code, we tell every admin of your business. A
  live key is revoked at once. A test key can no longer make sandbox simulations, and the notice offers **Revoke it
  now**.

## When a call is refused

| Code | What happened | What to do |
| --- | --- | --- |
| `invalid_client` (from `/oauth/token`) | The key ID or secret is wrong, or the key is switched off, revoked or expired. | Check the key; roll it if the secret is lost. |
| `invalid_scope` (from `/oauth/token`) | You asked for a permission the key doesn't hold. | Leave it out, or make a key with it. |
| `token_expired` | The token is older than 15 minutes. | Get a new token. |
| `insufficient_scope` | The key, or the token you narrowed, lacks this endpoint's permission. `scopes` names it. | Make a key with it. |
| `api_access_not_enabled` | The Accounts API, or sending with approval, isn't on for your business. | [Ask for access](/docs/developers/accounts-api-access). |
| `ip_not_allowed` | The call came from an address the key doesn't allow. | Add the address to the key's list. |
| `key_owner_cannot_send` | The key's responsible person can no longer send money or manage recipients. | Give them the permission back, or take the key over. |

When you generate a key or change one, these refusals can come back:

| Code | What happened |
| --- | --- |
| `scope_not_available` | A permission isn't open for your business yet. |
| `scope_not_allowed_for_key_type` | An AI agent key can't hold that permission. |
| `scopes_cant_mix` | A key that asks for payments or adds recipients can't also hold VezmoPay permissions. |
| `expiry_too_long` | A live key with Accounts API permissions needs an expiry date at most 365 days ahead. |
| `limits_only_lower` | A key's limits can only go down. |

## Related

- [Accounts API](/docs/developers/accounts-api)
- [API keys](/docs/developers/api-keys)
- [AI agents and the Accounts API](/docs/developers/accounts-api-agents)
- [Limits for sending with approval](/docs/developers/accounts-api-limits)
- [Accounts API reference](https://user.vezmo.com/docs/v1/accounts-api)

Vezmo is a financial technology company, not a bank. Banking, stablecoin and card services are provided by regulated
partners.
