Authentication
BlockWyre API uses Ed25519 JWT per-request signing for authentication. You generate an Ed25519 key pair locally, upload the public key in the BlockWyre Dashboard of your environment, and sign every API request with your private key. Your private key never leaves your server.
| Sandbox | Production | |
|---|---|---|
| Dashboard (create keys here) | https://dashboard-sandbox.blockwyre.com | https://dashboard.blockwyre.com |
| API base URL (send requests here) | https://api-sandbox.blockwyre.xyz | https://api.blockwyre.com |
A key works only in the environment it was created in. admin-sandbox.blockwyre.com and admin.blockwyre.com are BlockWyre staff consoles, not the dashboard: they answer "Unauthorized" to customers. See Environments.
Sign every request, on /v3/* and on /api/v2/*, with a single header:
Authorization: APIKey <signed-jwt>
The Key ID is the JWT sub claim; do not also send X-API-Key. On /v3/*, a signed JWT sent as Bearer is not accepted: the request answers 401.
Deprecated: /api/v2/* still accepts its original format, X-API-Key: <key id> with Authorization: Bearer <signed-jwt> (and the JWT in the Authorization query parameter on a WebSocket). It will be removed; move to Authorization: APIKey. See Deprecated v2 format.
Overview
| Concept | Detail |
|---|---|
| Algorithm | Ed25519 (EdDSA) |
| Transport | Authorization: APIKey <jwt> (scheme case-insensitive) |
| JWT lifetime | exp at most 35 seconds after iat; 30 seconds is the usual choice |
| Clock | exp is checked against the server clock with 5 seconds of leeway: keep your clock NTP-synced |
| Replay protection | Unique nonce per request, remembered per key |
| Body integrity | SHA-256 hash of request body |
| Body size | At most 1 MiB on /v3/* and 33 MiB on /api/v2/*; a larger body answers 413 body_too_large (401 in the deprecated v2 format) |
| Method matching | The request's method (GET, POST, etc.) |
| URI matching | Exact match (path + query params) |
| Key expiration | Maximum 1 year, mandatory |
| Permissions | Every key holds the fixed API Key role. See Key types and permissions. |
Key types and permissions
Every key is signed the same way. What differs is who it acts for:
| Workspace-scoped key | Account-scoped key | |
|---|---|---|
| Created | By a workspace user in Admin Access › API Keys, with Acts for left at Whole workspace | By a workspace user in Admin Access › API Keys, choosing the customer account under Acts for; or by the account's own user from API Keys in its portal |
accountId claim | Leave it out | Required: the key's account |
| Acts for | The whole workspace. Endpoints that act on one account's money name it: account_id on /v3/*, accountId on /api/v2/* | Its own account only. A request that names no account acts for it |
| The workspace's own operations: customers, KYC and KYB | Yes | No: 401 on /v3/*, 403 on /api/v2/* |
Webhook targets (/api/v2/* only; on /v3 they are managed in the dashboard) | Yes | No: 403 |
The API Key role
Every key, workspace-scoped or account-scoped, holds the same fixed set of permissions, the API Key role, from the moment it is created. There is no role to assign, and a key cannot be given another one. The role is listed, read-only, as API Key under Admin Access › Roles.
The role covers everything this reference documents:
- balances, bank accounts, banking and ACH pulls, bank counterparties, deposit instructions and withdrawals;
- crypto: wallets, counterparties (beneficiaries) and withdrawals;
- trade, cards and card purchases;
- transactions and reports;
- reading the workspace and its accounts;
- listing and creating customers (accounts), KYC and KYB, and webhook targets on
/api/v2/*: these take a workspace-scoped key, see below.
It never covers the following, which stay in the dashboard for a signed-in user: members and roles, API keys (a key never creates or manages keys), workspace settings, account lifecycle actions (re-enroll, block, freeze, unfreeze), chat integrations, PayPal invoices and the audit trail. Their endpoints refuse every key: on /v3/* they take only a dashboard session and answer a key 401; on /api/v2/* they answer 403. The dashboard's own routes, such as /v3/me, /v3/api-keys and /v3/branding, also answer 401 to any key.
Operations that need a workspace-scoped key
The workspace's own operations act on the workspace, not on one account, so they take a workspace-scoped key. An account-scoped key is refused: 401 on /v3/*, 403 on /api/v2/*.
| Operation | v3 | v2 |
|---|---|---|
| Listing, reading and creating customers | GET /v3/customers, GET /v3/customers/{customer_id}, POST /v3/customers | GET /api/v2/accounts, POST /api/v2/accounts |
| Individual verification (KYC) | /v3/customers/{customer_id}/kyc/… (Verification Flow) | /api/v2/kyc/banking-verification/…, /api/v2/kyc/card-verification/… |
| Business verification (KYB) | /v3/customers/{customer_id}/kyb/… | /api/v2/kyb/banking-verification/… |
| Webhook targets | Managed in the dashboard | /api/v2/webhooks/targets (Managing Webhook Targets) |
Account-scoped keys
An account-scoped key acts as one customer account: on /v3/* and /api/v2/* it calls the endpoints that act on an account's money and data, and only ever sees its own account.
- Signing. Add the
accountIdclaim (see the payload below, or setACCOUNT_IDin the Node.js example). A missing claim, or one naming any other account, is rejected with401. - Naming another account is rejected with
403: in the path or query on both versions, and on/api/v2/*also as anaccountId/account_idfield anywhere in a JSON body. Another account's resources read as404. - Enabling. Account keys are off by default; BlockWyre enables them per account. Until then, the Create API Key button in the account's portal is disabled, and a workspace user who chooses that account under Acts for is refused with
403 api_keys_disabled. A key also stops working (401) if the account's keys are turned off again, or if the account is not active (pending, closed) or is blocked. - What it cannot do. The workspace's own operations (above), and everything outside the API Key role.
- Managing the keys. An account user creates, freezes and deletes its account's keys from API Keys in its portal; workspace users manage keys from Admin Access › API Keys. There are no API routes for managing keys with a key.
401 or 403
| Answer | Means | What to do |
|---|---|---|
401 unauthorized | The request is not authenticated as a caller this endpoint takes: the key is unknown in this environment, frozen, expired or deleted; the signature or a claim failed (Verification Rules); or the endpoint does not take this kind of key (a dashboard-only /v3 endpoint, or a workspace operation called with an account-scoped key on /v3). | Check that you call the API of the environment the key was created in; that uri, method and bodyHash match the request exactly; that exp is fresh and your clock is synced; and that accountId is present for an account-scoped key and absent for a workspace-scoped one. For a workspace operation, use a workspace-scoped key. |
403 forbidden | The key authenticated, but may not make this call: the endpoint is outside the API Key role (on /api/v2/*), an account-scoped key called a workspace operation on /api/v2/*, or an account-scoped key named another account. | Do dashboard-only tasks in the dashboard. Use a workspace-scoped key for workspace operations. Name only the key's own account, or use a workspace-scoped key. |
The body says which, on /v3/* and /api/v2/* alike: {"code":401,"message":"unauthorized"} or {"code":403,"message":"forbidden"}. A 401 never says which check failed. See Error Handling.
Step 1: Generate an Ed25519 Key Pair
Generate your key pair locally using OpenSSL:
# Generate private key
openssl genpkey -algorithm Ed25519 -out private_key.pem
# Extract public key
openssl pkey -in private_key.pem -pubout -out public_key.pem
Your private key (private_key.pem) must never be shared, uploaded, or exposed. Only the public key is uploaded to BlockWyre.
Step 2: Upload the Public Key
Upload your public key (public_key.pem) in the BlockWyre Dashboard of your environment: https://dashboard-sandbox.blockwyre.com (sandbox) or https://dashboard.blockwyre.com (production), never an admin host.
- Navigate to the API keys page:
- Workspace users: Admin Access › API Keys
- Account users (customer portal): API Keys in the sidebar. The key is bound to your account; see Account-scoped keys.
- Click Create API Key
- Workspace users only: under Acts for, keep Whole workspace for a workspace-scoped key, or choose one customer account for an account-scoped key. An account whose keys BlockWyre has not enabled is refused (
403 api_keys_disabled). See Key types and permissions. - Enter a Name (e.g. "Production Server")
- Set Expires at (at most one year away)
- Upload your
public_key.pemfile under Public Key (PEM) - Click Create API Key
The key holds the API Key role as soon as it is created. The same page shows everything a request is signed with, each value copyable:
| Value | Where on the page | JWT claim |
|---|---|---|
Key ID (a UUID, e.g. 550e8400-e29b-41d4-a716-446655440000) | Key ID column of the keys table | sub |
| Workspace ID | Values to sign requests with | tenantId |
| Account ID (account-scoped keys only) | Account column of the keys table; in an account's portal, Values to sign requests with | accountId |
Step 3: Sign Every API Request
Each request must include:
| Header | Value |
|---|---|
Authorization | APIKey <signed-jwt> |
The JWT is signed with your private key and contains:
| Claim | Type | Description |
|---|---|---|
sub | string | Required. Your Key ID (raw UUID; its apk_… TypeID is accepted too). |
tenantId | string | Required. Your Workspace ID (raw UUID; its tnt_… TypeID is accepted too). |
accountId | string | Account-scoped keys only. Must equal the key's bound account (raw UUID or cst_… TypeID). Omit for workspace-scoped keys. |
uri | string | Required. The exact request path plus its query string, as sent (e.g. /v3/balances?account_id=cst_0123456789abcdef0123456789&coin=USD). |
method | string | Required. HTTP method in uppercase (e.g. GET, POST, DELETE). |
nonce | string | Required. A unique value per request (UUID v4 recommended). Prevents replay attacks. |
bodyHash | string | Required. SHA-256 hex digest of the exact body bytes you send. Use the hash of an empty string for requests without a body. |
iat | number | Required. Issued at (Unix timestamp). |
exp | number | Required. Expiration (Unix timestamp). At most 35 seconds after iat; use 30. |
JWT Structure
Header:
{
"alg": "EdDSA",
"typ": "JWT"
}
Payload for a workspace-scoped key (no accountId; the account is named in the query):
{
"sub": "550e8400-e29b-41d4-a716-446655440000",
"tenantId": "770a9c20-1234-5678-9abc-def012345678",
"uri": "/v3/balances?account_id=cst_0123456789abcdef0123456789&coin=USD",
"method": "GET",
"nonce": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"bodyHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"iat": 1708300000,
"exp": 1708300030
}
Payload for an account-scoped key — the same claims plus accountId, the account the key is bound to (raw UUID or cst_… TypeID). The request needs no account_id:
{
"sub": "550e8400-e29b-41d4-a716-446655440000",
"tenantId": "770a9c20-1234-5678-9abc-def012345678",
"accountId": "9b2f4c1e-7d3a-4e8b-a1c2-3d4e5f607182",
"uri": "/v3/balances",
"method": "GET",
"nonce": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"bodyHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"iat": 1708300000,
"exp": 1708300030
}
For requests without a body (GET, DELETE), bodyHash must be the SHA-256 of an empty string:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Lifetime, clock and body size
- Lifetime.
exp − iatmay be at most 35 seconds. Sign each request just before sending it, with a freshnonce; never reuse a JWT. - Clock. The server compares
expwith its own clock, allowing 5 seconds of leeway. With a 30-second lifetime, a client clock that runs more than about 35 seconds behind makes every fresh token look expired, and any lag eats into the time a token has to reach the server: keep your clock NTP-synced. - Nonce. A nonce is remembered per key for about 60 seconds; a second request from the same key with the same one is refused with
401. - Body size. The signed body is read whole to check
bodyHash: at most 1 MiB on/v3/*and 33 MiB on/api/v2/*. A larger one answers413 body_too_large; in the deprecated v2 format it answers401. - Hash what you send.
bodyHashmust be computed over the exact bytes of the body. Serialize the JSON once, hash that string, and send the same string.
Complete Node.js Example
Installation
npm install jose
Client Implementation
import crypto from "node:crypto";
import fs from "node:fs";
import { SignJWT, importPKCS8 } from "jose";
const API_KEY_ID = "550e8400-e29b-41d4-a716-446655440000";
const TENANT_ID = "770a9c20-1234-5678-9abc-def012345678";
// Account-scoped keys only: the account the key is bound to. Leave null for a workspace key.
const ACCOUNT_ID = null;
const BASE_URL =
process.env.BLOCKWYRE_BASE_URL ?? "https://api-sandbox.blockwyre.xyz"; // production: https://api.blockwyre.com
// Load your private key once at startup
const privateKeyPem = fs.readFileSync("private_key.pem", "utf-8");
const privateKey = await importPKCS8(privateKeyPem, "EdDSA");
/**
* Signs and sends an authenticated API request.
* `path` is the exact path and query string to send, already URL-encoded.
* Pass `idempotencyKey` on the writes that take an Idempotency-Key, and pass
* the same value again when you retry that same operation.
*/
async function apiRequest(method, path, body = null, { idempotencyKey } = {}) {
const bodyString = body ? JSON.stringify(body) : "";
const bodyHash = crypto
.createHash("sha256")
.update(bodyString)
.digest("hex");
const now = Math.floor(Date.now() / 1000);
const jwt = await new SignJWT({
tenantId: TENANT_ID,
...(ACCOUNT_ID && { accountId: ACCOUNT_ID }),
uri: path,
method: method.toUpperCase(),
nonce: crypto.randomUUID(),
bodyHash,
})
.setProtectedHeader({ alg: "EdDSA", typ: "JWT" })
.setSubject(API_KEY_ID)
.setIssuedAt(now)
.setExpirationTime(now + 30)
.sign(privateKey);
const response = await fetch(`${BASE_URL}${path}`, {
method,
headers: {
Authorization: `APIKey ${jwt}`,
...(body && { "Content-Type": "application/json" }),
...(idempotencyKey && { "Idempotency-Key": idempotencyKey }),
},
...(body && { body: bodyString }),
});
if (!response.ok) {
const error = await response.text();
throw new Error(`API error ${response.status}: ${error}`);
}
if (response.status === 204) {
return null;
}
return response.json();
}
Usage Examples
// GET request. An account-scoped key reads its own account; a workspace key
// names the account with account_id.
const balances = await apiRequest(
"GET",
"/v3/balances?account_id=cst_0123456789abcdef0123456789&coin=USD",
);
console.log(balances);
// A write that takes an Idempotency-Key (workspace-scoped key): create a customer.
// Generate the key once per customer you mean to create, store it with the
// operation, and send the same key on every retry of it.
const idempotencyKey = crypto.randomUUID();
const customer = await apiRequest(
"POST",
"/v3/customers",
{
customer_type: "individual",
name: "Samantha Reyes",
email: "samantha@example.com",
},
{ idempotencyKey },
);
console.log(customer.id);
// Request with a body
const renamed = await apiRequest("PATCH", "/v3/bank-accounts/bnk_0123456789abcdef0123456789", {
name: "Payroll",
});
console.log(renamed);
// DELETE request (answers 204 No Content)
await apiRequest("DELETE", "/v3/banking/pull-accounts/bpa_0123456789abcdef0123456789");
See Safe retries for which writes take the header and what a retry answers.
Verification Rules
The server validates every request against these rules, on /v3/* and /api/v2/* alike. If a check fails, the request is rejected with the status shown.
| Check | Rejection reason |
|---|---|
| API key not found / deleted (including a key from the other environment) | Unauthorized |
| API key is frozen | Unauthorized |
| API key has expired | Unauthorized |
| Account API keys disabled (account-scoped keys) | Unauthorized |
| Account not active (pending, closed) or blocked (account-scoped keys) | Unauthorized |
| Client IP not in allowlist (when configured) | Unauthorized |
| JWT signature invalid | Unauthorized |
JWT alg is not EdDSA | Unauthorized |
JWT sub does not match key id | Unauthorized |
JWT tenantId missing / mismatch | Unauthorized |
JWT accountId missing / mismatch (account-scoped key) | Unauthorized |
JWT accountId present on a workspace-scoped key | Unauthorized |
JWT exp in the past (5s leeway) | Unauthorized |
JWT iat or exp missing, or exp more than 35s after iat | Unauthorized |
JWT uri / method / bodyHash mismatch | Unauthorized |
JWT nonce already used by this key (≈60s window) | Unauthorized |
Signed body over 1 MiB on /v3/*, or over 33 MiB on /api/v2/* | 413 body_too_large (Unauthorized in the deprecated v2 format) |
| Workspace operation (customers, KYC/KYB, webhook targets) with an account-scoped key | Unauthorized on /v3/*, Forbidden on /api/v2/* |
| Endpoint outside the API Key role (members, roles, API keys, settings, …) | Unauthorized on /v3/*, Forbidden on /api/v2/* |
| Path / query names a foreign account (account-scoped key) | Forbidden |
JSON body names a foreign accountId / account_id on /api/v2/* (account-scoped key) | Forbidden |
| Resource id belongs to a foreign account (account-scoped key) | Not Found |
Deprecated v2 format
Before Authorization: APIKey, /api/v2/* was signed differently, and it still accepts that format while integrations move:
| Header | Value |
|---|---|
X-API-Key | Your Key ID (raw UUID). Must be the key that signed the JWT. |
Authorization | Bearer <signed-jwt> |
- The JWT carries the same claims, with one difference: it is signed without
accountId, and the account is the one the key is bound to. - A WebSocket client could instead put the JWT in the
Authorizationquery parameter.uriis then signed without that parameter: the path, plus the remaining query parameters sorted by name and URL-encoded (/api/v2/marketwhen there are none). - Every other rule above applies: key state, IP allowlist,
expat most 35 seconds afteriat, nonce, and the 33 MiB body limit.
A request in this format that fails answers 401 {"code":401,"message":"unauthorized"}, the same body as any other rejected key, whichever check failed. The usual causes:
X-API-Keyis sent without anAuthorization: Bearer <signed-jwt>header (Beareris case-sensitive here). This includesX-API-Keysent next toAuthorization: APIKey.- The JWT does not parse, or has no
tenantIdclaim. X-API-Keyis not the key that signed the JWT (sub), or any other check fails, including a body over 33 MiB.
This format will be removed. To move, keep signing the same JWT, add accountId for an account-scoped key, and send it as Authorization: APIKey <signed-jwt> with no X-API-Key. A WebSocket client sends the same header on the upgrade request.
Key Rotation
You can have multiple active API keys per workspace, enabling zero-downtime rotation:
- Create a new API key with a new key pair in the Dashboard
- Update your application to use the new key
- Verify the new key works in production
- Freeze or delete the old key from the Dashboard
Support and Resources
If you need assistance or have any questions, our support team is here to help. You can contact our support team at support@blockwyre.com.
Stay Updated
Stay up-to-date with the latest news, updates, and features from BlockWyre by following us on social media:
- Instagram: BlockWyre Instagram
- Twitter: BlockWyre Twitter
- Facebook: BlockWyre Facebook
- LinkedIn: BlockWyre LinkedIn
We are excited to have you on board and look forward to seeing how you leverage BlockWyre's powerful tools to enhance your financial operations. Happy integrating!