Start here
Authentication and API keys
Understand Agent Project scope, Test and Live key prefixes, secure storage, rotation, and revocation.
What this guide covers
- Authenticate each request with a Yanola API key, never a Meta access token.
- Treat yalo_test_ and yalo_live_ keys as secrets with different environments.
- Rotate or revoke keys from the Agent Project API settings.
API key anatomy
Every public request is scoped by the API key to one Yanola Account, one Agent Project, one environment, a set of permissions, and optionally selected Senders. You do not pass an agent ID in public API paths.
| Prefix | Environment | Effect |
|---|---|---|
yalo_test_ | Test Mode | Validates requests and creates synthetic records without provider delivery or balance usage. |
yalo_live_ | Live Mode | Can deliver through connected Senders and consume Yanola Balance. |
apk_ | Key ID | Stable public identifier embedded in the credential and shown in lifecycle history. |
Yanola shows the complete credential only when a key is created or rotated. Later dashboard views show a preview, not the recoverable secret.
Authenticate with the SDK
WhatsAppClient adds the Bearer Authorization header to every request. Pass the credential through YANOLA_API_KEY rather than constructing headers yourself.
import { WhatsAppClient } from "@yanola/whatsapp"
const apiKey = process.env.YANOLA_API_KEY
if (!apiKey) {
throw new Error("Missing YANOLA_API_KEY")
}
const yanola = new WhatsAppClient({ apiKey })Authenticate with REST
For direct HTTP integrations, send the same credential using the Bearer scheme. The production API begins at https://api.yanola.ai/v1.
curl "https://api.yanola.ai/v1/senders" \
--header "Authorization: Bearer $YANOLA_API_KEY" \
--header "Accept: application/json"Choose least-privilege scopes
Scopes are selected in the Agent Project dashboard. The default preset excludes webhooks:write so a key cannot replay deliveries unless you explicitly grant that capability.
| Scope | Allows |
|---|---|
messages:write | Send messages and mark inbound messages as read. |
messages:read | Read message records and delivery state. |
senders:read | List connected WhatsApp Senders. |
templates:read | List approved templates for a Sender. |
webhooks:read | Inspect webhook delivery attempts. |
webhooks:write | Replay existing webhook deliveries. |
events:read | Read normalized Developer Platform events. |
usage:read | Read usage records and billable state. |
Restrict Sender access
A key can be allowed to use every eligible Sender in its Agent Project or only selected connected numbers. Sender restrictions apply in addition to scopes; messages:write does not grant access to a number outside the key's allowed set.
Use separate narrowly scoped keys for independent services instead of sharing one broad production credential.
Store credentials safely
- Use YANOLA_API_KEY in a local ignored file for development and a secret manager in deployed environments.
- Create different credentials for development, staging, and production services.
- Do not log the key, place it in client-side state, commit it, send it in job payloads, or expose it through browser-prefixed variables.
- Rotate immediately if a credential may have been copied to an unsafe location.
.env
.env.local
.env.*.localLifecycle management
API key lifecycle operations are dashboard-only in v1. A public API key cannot create or modify other credentials.
- Create a key in either the Test Mode or Live Mode tab and copy its secret once.
- Rename it to identify the owning service and environment.
- Adjust scopes, expiration, and allowed Senders as access needs change.
- Rotate to replace the secret immediately while keeping the key ID and access settings.
- Revoke to permanently disable the key; revoked keys cannot be rotated back into service.
- Review last-used metadata and audit events when investigating credential activity.
Authentication failures
| Status | Meaning | Action |
|---|---|---|
401 | The key is missing, malformed, invalid, revoked, or expired. | Load the intended YANOLA_API_KEY or create/rotate a dashboard key. |
403 | The key is valid but lacks a required scope, Sender permission, or entitlement. | Change dashboard access or use a correctly scoped key. |
402 | A Live Mode usage-billed action cannot reserve enough Yanola Balance. | Top up the account balance; do not replace the key. |
Use the prefix only to recognize Test versus Live Mode. Do not parse key IDs or secret segments to make authorization decisions in your application.