PyAI Whats App API

WhatsApp Business Calling: register a WhatsApp Business number, enable calling, and let an Omni agent answer (and, with the user's permission, place) WhatsApp voice calls. Requires the `telephony:manage` scope.

GitHub OpenAPI

Operations 12

GET /v1/whatsapp/numbers List your WhatsApp numbers #
POST /v1/whatsapp/numbers Register a WhatsApp Business number #
GET /v1/whatsapp/numbers/{id} Get a WhatsApp number #
DELETE /v1/whatsapp/numbers/{id} Release a WhatsApp number #
POST /v1/whatsapp/numbers/{id}/assign Route a WhatsApp number to an agent #
POST /v1/whatsapp/numbers/{id}/calling Enable or disable calling on a WhatsApp number #
GET /v1/whatsapp/call-permissions Check call permission for a user #
POST /v1/whatsapp/call-permissions Ask a user for permission to call them #
GET /v1/whatsapp/calls List WhatsApp calls #
POST /v1/whatsapp/calls Place a WhatsApp call #
GET /v1/whatsapp/calls/{id} Get a WhatsApp call #
POST /v1/whatsapp/calls/{id}/terminate Hang up a WhatsApp call #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/pyai-com:pyai-com-whats-app-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

pyai-com-whats-app-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: PyAI WhatsApp API
  version: 2.14.0
  description: 'Telephony-native Voice AI behind one bearer key:


    - **Hear**, speech-to-text · `POST /v1/audio/transcriptions` (streaming + batch)

    - **Speak**, text-to-speech · `POST /v1/audio/speech`, `GET /v1/voices`

    - **Clone**, custom voices from a short clip · `/v1/voice/clones`

    - **Cast**, auto-directed expressive voiceovers · `/v1/cast`

    - **Dub**, asynchronous audio and video dubbing · `POST /v1/dub` (guide)

    - **Cue configuration frames (reserved)**; Hear streams skip knowledge-base retrieval by default

    - **Omni**, full-duplex agentic voice (speech-to-speech, grounded in your knowledge bases + tools) · `/v1/omni`

    - **Knowledge Bases**, hosted grounding for Omni: create bases, add documents (file, URL, or text), crawl a public website, bind to agents or org defaults · `/v1/knowledgebases`

    - **AMD API**, answering-machine detection: know *who or what* answered a call (human, voicemail, IVR, iPhone/Google screening, dead number) with the reason it decided · `wss …/v1/amd/stream` (Twilio Media Streams drop-in), `POST /v1/amd/config`, `GET /v1/amd/calls/{id}`

    - **Agents Beta**, the live console feature to create, configure, test, and connect Omni voice agents without code. Beta features and limits may change. ## Identity, billing and authentication

    - Before any generation or transcription, call GET /v1/me (MCP: whoami). Verify org_id, project_id, environment, scopes, limits and billing/credit context against the intended project. Do not infer identity or free usage from a key prefix or tool name. Stop on a mismatch or unknown budget; never switch to a live project automatically. - Test usage has enforced limits; live usage is billed. Current meters and rates: https://pyai.com/pricing. Agree a bounded input/request count before generating, and do not retry uncertain billable submissions blindly. Create a key in the console (it is shown once) and send it as a bearer token:


    ```

    Authorization: Bearer pyai_live_... ```


    Keys are environment-scoped: `pyai_live_...` (production) and `pyai_test_...` (sandbox). `POST /v1/sandbox/keys` creates an instant, short-lived test key without login or billing. Account signup also creates a sandbox key. Live keys consume prepaid credit; phone verification may unlock promotional credit under graduated-signup rules, but credit is not guaranteed at signup. Keys are self-validating signed tokens: they work on every PyAI surface the instant they are created, no activation or propagation delay. Treat them as opaque strings (up to 512 chars) and never parse their contents. Keep long-lived keys on trusted servers. For Omni browsers, mint an origin-locked short-lived token on your backend with POST /v1/omni/sessions; never expose a live or test API key in browser code. Offer the protocol marker and session token:


    ```

    Sec-WebSocket-Protocol: pyai.v1, pyai-key. ```


    (server-side clients may instead append `?api_key=...` to the URL). Your key is authenticated on the upgrade and never reaches the model. ## Quickstart, Hear (speech-to-text)


    ```

    curl https://api.pyai.com/v1/audio/transcriptions \

    -H "Authorization: Bearer $PYAI_API_KEY" \

    -F file=@audio.wav -F model=pyai-hear

    # -> { "text": "..." }

    ```


    ## Quickstart, Speak (text-to-speech)


    ```

    curl https://api.pyai.com/v1/audio/speech \

    -H "Authorization: Bearer $PYAI_API_KEY" \

    -H "Content-Type: application/json" \

    -d ''{"model":"pyai-speak","input":"Hello from PyAI.","voice":"voice_abc"}'' \

    --output speech.wav

    ```


    `voice` is a stock voice id from `GET /v1/voices` (the curated prebuilt catalog with personas and avatars) or a cloned voice id from `/v1/voice/clones`. Omit it to use the platform default voice (`stock_dorit_en_us`).'
  contact:
    name: PyAI
    url: https://pyai.com
servers:
- url: https://api.pyai.com
  description: Production
security:
- apiKey: []
- xApiKey: []
tags:
- name: Whats App
  description: 'WhatsApp Business Calling: register a WhatsApp Business number, enable calling, and let an Omni agent answer (and, with the user''s permission, place) WhatsApp voice calls. Requires the `telephony:manage` scope.'
paths:
  /v1/whatsapp/numbers:
    get:
      tags:
      - Whats App
      summary: List your WhatsApp numbers
      description: WhatsApp Business numbers registered to your org, newest first. Active only unless `include_released=true`. Requires the `telephony:manage` scope.
      operationId: listWhatsAppNumbers
      parameters:
      - name: include_released
        in: query
        required: false
        schema:
          type: boolean
          default: false
      responses:
        '200':
          description: Your WhatsApp numbers
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    example: list
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/WhatsAppNumber'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: WhatsApp calling is not enabled for this deployment.
    post:
      tags:
      - Whats App
      summary: Register a WhatsApp Business number
      description: Attach a WhatsApp Business number you already own on Meta's Cloud API to your org so an Omni agent can answer its calls. You bring the WhatsApp Business Account id, the number's `phone_number_id`, and a system-user access token with `whatsapp_business_messaging`; PyAI stores the token encrypted and never returns it. Point your Meta app's `calls` and `messages` webhooks at `https://api.pyai.com/public/whatsapp/webhook`. Calling stays off until you enable it with `POST /v1/whatsapp/numbers/{id}/calling`. Requires the `telephony:manage` scope.
      operationId: registerWhatsAppNumber
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WhatsAppRegisterNumberRequest'
      responses:
        '201':
          description: Registered
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppNumber'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          description: 'That phone_number_id is already registered (`code: number_in_use`).'
        '503':
          description: 'WhatsApp calling is not enabled on this deployment (`code: whatsapp_disabled`).'
  /v1/whatsapp/numbers/{id}:
    get:
      tags:
      - Whats App
      summary: Get a WhatsApp number
      operationId: getWhatsAppNumber
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: The number
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppNumber'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      tags:
      - Whats App
      summary: Release a WhatsApp number
      description: Detach the number from your org. Inbound WhatsApp calls to it are rejected from then on; nothing changes on Meta's side. Requires the `telephony:manage` scope.
      operationId: releaseWhatsAppNumber
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Released
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppNumber'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /v1/whatsapp/numbers/{id}/assign:
    post:
      tags:
      - Whats App
      summary: Route a WhatsApp number to an agent
      description: 'Bind (or unbind with `agent_id: null`) the Omni agent that answers inbound WhatsApp calls to this number and is the default for outbound calls from it. Requires the `telephony:manage` scope.'
      operationId: assignWhatsAppNumber
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WhatsAppAssignRequest'
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppNumber'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /v1/whatsapp/numbers/{id}/calling:
    post:
      tags:
      - Whats App
      summary: Enable or disable calling on a WhatsApp number
      description: 'Pushes Meta''s calling configuration for the number (`POST /{phone_number_id}/settings`): turns the call button on or off, and whether a user calling you automatically grants a 7-day call-back permission. Meta requires the number to have a messaging limit of at least 2,000 conversations per day before calling can be enabled. Requires the `telephony:manage` scope.'
      operationId: configureWhatsAppCalling
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WhatsAppCallingSettingsRequest'
      responses:
        '200':
          description: Settings applied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppNumber'
        '400':
          description: 'Meta rejected the settings (`code: meta_graph_error`).'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '502':
          description: 'Meta''s API was unreachable or refused the token (`code: meta_graph_error`).'
  /v1/whatsapp/call-permissions:
    get:
      tags:
      - Whats App
      summary: Check call permission for a user
      description: Whether you may place a business-initiated call to `user` from `number_id`. Temporary permissions last 7 days; permanent ones until the user revokes them. Served from PyAI's cache when live, otherwise refreshed from Meta (`refresh=true` forces it). Requires the `telephony:manage` scope.
      operationId: getWhatsAppCallPermission
      parameters:
      - name: number_id
        in: query
        required: true
        schema:
          type: string
      - name: user
        in: query
        required: true
        schema:
          type: string
        description: The user's WhatsApp number (E.164).
      - name: refresh
        in: query
        required: false
        schema:
          type: boolean
          default: false
      responses:
        '200':
          description: Permission state
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppCallPermission'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      tags:
      - Whats App
      summary: Ask a user for permission to call them
      description: Sends Meta's interactive `call_permission_request` message from `number_id` to `user` with your `text`. Meta limits this to 1 request per 24 hours and 2 per 7 days per user; the user's reply is recorded from the webhook and gates `POST /v1/whatsapp/calls`. Requires the `telephony:manage` scope.
      operationId: requestWhatsAppCallPermission
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WhatsAppPermissionRequest'
      responses:
        '202':
          description: Request sent
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    example: whatsapp.call_permission_request
                  number_id:
                    type: string
                  user:
                    type: string
                  message_id:
                    type: string
                    nullable: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /v1/whatsapp/calls:
    get:
      tags:
      - Whats App
      summary: List WhatsApp calls
      operationId: listWhatsAppCalls
      parameters:
      - name: limit
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 200
          default: 50
      responses:
        '200':
          description: Calls, newest first
          content:
            application/json:
              schema:
                type: object
                properties:
                  object:
                    type: string
                    example: list
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/WhatsAppCall'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      tags:
      - Whats App
      summary: Place a WhatsApp call
      description: Business-initiated WhatsApp call from `number_id` to `to`, answered by `agent_id` (defaults to the number's agent). Fails with 403 `call_permission_required` unless the user has a live call permission. Not available in every country (Meta blocks business-initiated calls in the US, Canada, Egypt, Vietnam and Nigeria at the time of writing). Requires an `Idempotency-Key` and the `telephony:manage` scope.
      operationId: createWhatsAppCall
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          maxLength: 255
        description: Safe retry key. Reusing it with the same input replays the original call; different input returns 409 `idempotency_conflict`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WhatsAppCallCreateRequest'
      responses:
        '201':
          description: Call placed (ringing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppCall'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: 'No live call permission from the user (`code: call_permission_required`).'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: 'Calling is disabled on the number (`code: calling_disabled`) or the Idempotency-Key was reused with different input.'
        '502':
          description: Meta refused the call or the media edge was unavailable.
  /v1/whatsapp/calls/{id}:
    get:
      tags:
      - Whats App
      summary: Get a WhatsApp call
      operationId: getWhatsAppCall
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: The call
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppCall'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /v1/whatsapp/calls/{id}/terminate:
    post:
      tags:
      - Whats App
      summary: Hang up a WhatsApp call
      operationId: terminateWhatsAppCall
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Terminated (idempotent on already-ended calls)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WhatsAppCall'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    WhatsAppCall:
      type: object
      properties:
        object:
          type: string
          example: whatsapp.call
        id:
          type: string
          example: wac_...
        number_id:
          type: string
        wa_call_id:
          type: string
          nullable: true
          description: Meta's call id (wacid...).
        direction:
          type: string
          enum:
          - inbound
          - outbound
        user:
          type: string
          example: '+919876543210'
        agent_id:
          type: string
          nullable: true
        status:
          type: string
          enum:
          - ringing
          - accepted
          - connected
          - completed
          - failed
          - rejected
          - no_answer
          - terminated
        failure_reason:
          type: string
          nullable: true
        started_at:
          type: integer
          nullable: true
          description: Unix ms.
        connected_at:
          type: integer
          nullable: true
          description: Unix ms.
        ended_at:
          type: integer
          nullable: true
          description: Unix ms.
        duration_seconds:
          type: integer
          nullable: true
        created_at:
          type: integer
        updated_at:
          type: integer
    ErrorCode:
      type: string
      description: Stable, machine-readable error code. Branch on this rather than the human `message`.
      enum:
      - invalid_request_error
      - invalid_session_label
      - unauthorized
      - forbidden
      - origin_not_allowed
      - credit_exhausted
      - key_budget_exceeded
      - child_budget_exceeded
      - insufficient_quota
      - rate_limit_exceeded
      - concurrency_limit_exceeded
      - daily_cap_exceeded
    WhatsAppCallPermission:
      type: object
      properties:
        object:
          type: string
          example: whatsapp.call_permission
        number_id:
          type: string
        user:
          type: string
          example: '+919876543210'
        status:
          type: string
          enum:
          - temporary
          - permanent
          - rejected
          - none
        source:
          type: string
          nullable: true
          description: user_action | automatic | api
        expires_at:
          type: integer
          nullable: true
          description: Unix ms (temporary only).
        updated_at:
          type: integer
    WhatsAppCallingSettingsRequest:
      type: object
      properties:
        enabled:
          type: boolean
          default: true
          description: Meta `calling.status`.
        call_icon_visibility:
          type: string
          enum:
          - DEFAULT
          - DISABLE_ALL
          default: DEFAULT
        callback_permission:
          type: boolean
          default: true
          description: A user calling you grants a 7-day call-back permission automatically.
    WhatsAppAssignRequest:
      type: object
      properties:
        agent_id:
          type: string
          nullable: true
          description: Agent to bind, or null to unassign.
    WhatsAppCallCreateRequest:
      type: object
      required:
      - number_id
      - to
      properties:
        number_id:
          type: string
        to:
          type: string
          example: '+919876543210'
          description: The user's WhatsApp number (E.164).
        agent_id:
          type: string
          nullable: true
          description: Defaults to the number's agent.
    WhatsAppRegisterNumberRequest:
      type: object
      required:
      - waba_id
      - phone_number_id
      - display_phone_number
      - access_token
      properties:
        waba_id:
          type: string
        phone_number_id:
          type: string
        display_phone_number:
          type: string
          example: '+14155550123'
          description: The number in E.164.
        access_token:
          type: string
          description: Meta system-user token with `whatsapp_business_messaging`. Stored encrypted, never returned.
        app_id:
          type: string
          nullable: true
          description: Meta app that owns the webhook subscription.
        agent_id:
          type: string
          nullable: true
          description: Optional agent to route inbound calls to.
    Problem:
      type: object
      description: RFC 7807 problem+json returned by the control plane (request-validation and resource errors such as 400/404/409). The stable code is the last path segment of `type`.
      required:
      - title
      - status
      properties:
        type:
          type: string
          description: Problem type URI; ends with the stable code.
        title:
          type: string
        status:
          type: integer
        detail:
          type: string
        request_id:
          type: string
    WhatsAppPermissionRequest:
      type: object
      required:
      - number_id
      - to
      - text
      properties:
        number_id:
          type: string
        to:
          type: string
          example: '+919876543210'
          description: The user's WhatsApp number (E.164).
        text:
          type: string
          maxLength: 1024
          description: Why you want to call, shown in the permission prompt.
    Error:
      type: object
      description: OpenAI-compatible error envelope returned by the gateway data plane (401/402/403/429). Control-plane request/resource errors use Problem (application/problem+json) instead.
      required:
      - error
      properties:
        error:
          type: object
          required:
          - message
          properties:
            message:
              type: string
              description: Human-readable explanation.
            type:
              type: string
              description: Error category, e.g. rate_limit_error.
            code:
              $ref: '#/components/schemas/ErrorCode'
            param:
              type: string
              nullable: true
              description: Offending parameter when applicable, else null.
    WhatsAppNumber:
      type: object
      properties:
        object:
          type: string
          example: whatsapp.number
        id:
          type: string
          example: wan_...
        waba_id:
          type: string
          description: WhatsApp Business Account id.
        phone_number_id:
          type: string
          description: Meta's id for the business number (what the webhook carries).
        phone_number:
          type: string
          example: '+14155550123'
          description: E.164.
        app_id:
          type: string
          nullable: true
        agent_id:
          type: string
          nullable: true
          description: Agent that answers inbound WhatsApp calls.
        calling_enabled:
          type: boolean
        calling_settings:
          type: object
          additionalProperties: true
          description: Last calling settings pushed to Meta.
        status:
          type: string
          enum:
          - active
          - released
        created_at:
          type: integer
          description: Unix ms.
        updated_at:
          type: integer
          description: Unix ms.
        released_at:
          type: integer
          nullable: true
          description: Unix ms.
  responses:
    BadRequest:
      description: Invalid request (bad field, unsupported value)
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    NotFound:
      description: 'Resource not found (`code: not_found`)'
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    Unauthorized:
      description: 'Missing or invalid API key (`code: unauthorized`)'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    interpretationUpload:
      type: http
      scheme: bearer
      description: Short-lived write-only upload_capability returned by POST /v1/audio/interpretations/recordings. Never use it for reads.
    sessionCookie:
      type: apiKey
      in: cookie
      name: pyai_session
      description: Console session cookie. PyAI-admin routes also require the configured platform-admin email allowlist.
    apiKey:
      type: http
      scheme: bearer
      description: 'Use `Authorization: Bearer pyai_live_...` (or `pyai_test_...`).'
    xApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Header alias for bearer auth on HTTP endpoints. WebSocket auth uses the subprotocol pair `pyai.v1, pyai-key.<API_KEY>`.
x-pyai-agent-notes:
  guide: https://pyai.com/agents/speech-calling.md
  omni_frames: https://api.pyai.com/omni-frames.json
  discovery: Inspect live operation schemas; preserve IDs and required Idempotency-Key headers. SDK-first for realtime. Never infer a simulated PSTN call endpoint.