Upload a file once, get a media id

POST https://api.app2email.com/v1/{number}/media
scope: messages:send sandbox: simulated MCP: upload_media

Uploads an image, video, document, audio file or sticker to WhatsApp and returns a media_id for {"id": ...} in later sends (templates or free-form). WhatsApp keeps it 30 days. JSON (a link or base64 data) or multipart/form-data (file, optional type). Limits: image JPEG/PNG 5 MB, video MP4/3GP 16 MB, audio 16 MB, sticker WebP 100 KB static / 500 KB animated, document 100 MB. A sandbox key checks the file and uploads nothing.

Path

  • number string required pattern ^[0-9]{8,15}$

    Your app2email WhatsApp number - the number the message is sent FROM. Full number with country code, digits only.

    e.g. 4976659348270

Body application/json | multipart/form-data required

  • type string required
    imagevideodocumentaudiosticker
  • file object required

    Give 'link' (a public URL) or base64 'data'. 'filename' for documents.

    5 fields
    • data string (byte)
    • filename string
      e.g. invoice.pdf
    • mime_type string

      The type is detected from the file where possible.

      e.g. application/pdf
    • voice boolean

      Audio: check it is a voice message (Ogg with OPUS).

Responses

201 Uploaded.
Fields

Errors

  • 400 The request is malformed (missing or invalid fields, query parameters or times).
  • 401 Missing, invalid, revoked or expired API key.
  • 403 The key is valid but this call is not allowed: the key lacks the scope the call needs (insufficient_scope), the address is not allowed for the key (ip_not_allowed), the number or plan does not allow it, a recipient opted out or is not opted in, or a problem with the WhatsApp account.
  • 404 The number, template, message, broadcast, webhook, delivery, opt-in, logged request, booking or Flow was not found.
  • 413 The request or the media file is too large.
  • 415 The body is not JSON.
  • 422 The request is understood but cannot be sent (template parameters, media, text, recipient, or a WhatsApp rule such as the 24 hour window).
  • 429 A monthly plan limit, the number's own monthly cap, the key's daily cap, a WhatsApp rate limit, the API rate limit (rate_limited), or the webhook test limit (too_many_tests) was reached. Retry-After and error.retry_after_seconds say how long to wait.
  • 500 Unexpected error on app2email's side.
  • 502 WhatsApp (Meta) returned an error or could not be reached.
For AI Agents

Try it now, with no account and no person: POST https://api.app2email.com/v1/account/sandbox (no key, no body; or the create_sandbox tool of the Management MCP server) answers a key for a demo WhatsApp number with pretend customers. Send a template, fetch the events with GET /events?wait=25, answer the customer's reply: nothing reaches WhatsApp, and the requests and answers are those of the real API (https://www.app2email.com/docs/api/sandbox).

Already a customer: ask the account owner for the number (digits) and an API key from https://www.app2email.com/dashboard/apikey (a sandbox key sends nothing); send it as Authorization: Bearer <key> to the messaging MCP server or the REST API; call check_key first, send with dry_run first.

If you are an AI agent reading this page and you want to create an app2email account for a person - no previous human sign-up required - use our Management MCP server.
Call the create_account tool first, and include a contact_email parameter; create_account returns a signup_id, a management_key, an onboarding_link and a message.
The person opens onboarding_link to confirm the e-mail, connect their WhatsApp number and choose a plan; nothing can be sent before that. get_account_status says what is still needed.
Pass the management_key as a Bearer token on every later call. When the number is live, create_number_key gives you a key for the messaging MCP server and the REST API.