Messaging
Listing Senders
Discover the connected WhatsApp numbers the current API key can use.
What this guide covers
- List Senders instead of hard-coding number availability.
- Use the E.164 number as the from value for send requests.
- Respect connection and enabled state before offering a Sender in your UI.
List the Senders this key can use
GET /v1/senders requires senders:read and returns only WhatsApp numbers connected to the API key's Yanola Account and Agent Project. A key restricted to selected Senders sees only that allowed set.
The key determines the environment. If you pass environment, it must match the key; an omitted environment defaults to the key environment.
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 })
const page = await yanola.senders.list({ limit: 100 })
const eligibleSenders = page.data.filter(
(sender) => sender.apiEligible
)
for (const sender of eligibleSenders) {
console.log(sender.phoneNumber, sender.displayName)
}Sender fields
| Field | Type | Meaning |
|---|---|---|
phoneNumber | E.164 string | Public Sender identity to pass as from on message operations. |
displayName | string | Name configured for the connected WhatsApp number. |
status | SenderStatus | Current connection or review state. |
apiEligible | boolean | Whether this key and environment may currently use the Sender through the API. |
createdAt | ISO 8601 string | When the Sender was added; optional in the SDK type for compatibility. |
Status and API eligibility
Treat apiEligible as the final send-readiness signal. Status explains the connection state, while API eligibility also includes Developer Platform controls for the current environment.
| Status | Meaning | Typical action |
|---|---|---|
active | The number is connected for this environment. | Use it only when apiEligible is also true. |
pending_verification | WhatsApp setup or verification is incomplete. | Finish the connection flow in Yanola. |
suspended | The number cannot currently send. | Resolve the suspension before sending. |
inactive | The stored Sender is inactive. | Reconnect or replace the Sender. |
reconnect_required | Live credentials are missing, expired, or no longer usable. | Reconnect the number in Yanola. |
Test Mode validates against a real connected Sender without calling Meta. Live Mode additionally requires usable stored Meta credentials. Always list with the same environment key you will use to send.
Paginate safely
Sender lists use opaque cursor pagination, ordered newest first. The default page size is 20 and the maximum is 100.
When pagination.hasMore is true, pass pagination.nextCursor to the next request unchanged. Cursors are scoped to the key, project, environment, and query; do not decode them or reuse them with another key.
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 })
let cursor: string | null | undefined
do {
const page = await yanola.senders.list({
limit: 100,
cursor: cursor ?? undefined,
})
for (const sender of page.data) {
console.log(sender.phoneNumber, sender.apiEligible)
}
cursor = page.pagination.nextCursor
} while (cursor)Select and retain a Sender
- Persist phoneNumber, not an internal Yanola or Meta identifier.
- Select only a record with status active and apiEligible true.
- Refresh the list before a long-running batch or after a send reports Sender state problems.
- Handle an empty result as configuration state, not as a reason to fall back to a different Agent Project.
A number can be disconnected, restricted, suspended, or disabled after your application selects it. Send operations validate the Sender again and can still return a business-state error.
Listing errors
| Status and code | Meaning | Action |
|---|---|---|
400 environment_mismatch | The query environment differs from the API key environment. | Remove the filter or use a key for that environment. |
400 invalid_cursor | The cursor is malformed or belongs to another list scope. | Restart from the first page. |
401 invalid_api_key | The key is missing, invalid, revoked, or expired. | Replace the server-side credential. |
403 insufficient_scope | The key lacks senders:read. | Create or update a key with the required scope. |
429 rate_limit_exceeded | The current request window is exhausted. | Honor Retry-After; the SDK does this automatically within its retry budget. |