Browse documentation

Messaging

Listing Senders

Discover the connected WhatsApp numbers the current API key can use.

DevelopersAdvancedAvailable

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.

List API-eligible Senders
ts
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

Sender response fields
FieldTypeMeaning
phoneNumberE.164 stringPublic Sender identity to pass as from on message operations.
displayNamestringName configured for the connected WhatsApp number.
statusSenderStatusCurrent connection or review state.
apiEligiblebooleanWhether this key and environment may currently use the Sender through the API.
createdAtISO 8601 stringWhen 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.

Sender status values
StatusMeaningTypical action
activeThe number is connected for this environment.Use it only when apiEligible is also true.
pending_verificationWhatsApp setup or verification is incomplete.Finish the connection flow in Yanola.
suspendedThe number cannot currently send.Resolve the suspension before sending.
inactiveThe stored Sender is inactive.Reconnect or replace the Sender.
reconnect_requiredLive credentials are missing, expired, or no longer usable.Reconnect the number in Yanola.

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.

Read every Sender page
ts
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

  1. Persist phoneNumber, not an internal Yanola or Meta identifier.
  2. Select only a record with status active and apiEligible true.
  3. Refresh the list before a long-running batch or after a send reports Sender state problems.
  4. Handle an empty result as configuration state, not as a reason to fall back to a different Agent Project.

Listing errors

Common Sender list errors
Status and codeMeaningAction
400 environment_mismatchThe query environment differs from the API key environment.Remove the filter or use a key for that environment.
400 invalid_cursorThe cursor is malformed or belongs to another list scope.Restart from the first page.
401 invalid_api_keyThe key is missing, invalid, revoked, or expired.Replace the server-side credential.
403 insufficient_scopeThe key lacks senders:read.Create or update a key with the required scope.
429 rate_limit_exceededThe current request window is exhausted.Honor Retry-After; the SDK does this automatically within its retry budget.