---
title: "Upload a WhatsApp file"
canonical: "https://bird.com/docs/api/reference/create-whatsapp-file"
---

# Upload a WhatsApp file

`POST /v1/whatsapp/files`

Stores a file for the workspace's WhatsApp messages, hands it to WhatsApp for one of the workspace's
numbers, and returns it. Send the file as `multipart/form-data` with `from`, the connected E.164 number
the file is uploaded with, before `file`, at most 100 MB; a larger one returns `413`. A missing, unknown
or not yet connected `from` returns `422`. The name is `name`, else the uploaded filename; a request that
yields none returns `422`. The media type is `mime_type`, else the type we detect from the contents; send
`mime_type` for a type detection cannot tell apart, such as an Office document or AAC, AMR, M4A or 3GPP
media. WhatsApp carries JPEG and PNG images; WebP stickers; MP4 and 3GPP video; AAC, AMR, MP3, M4A and
Ogg audio; and PDF, plain text and Office documents. Any other type is refused with `422`, as is a file
whose contents do not match its media type, such as a JPEG declared as a PDF. A `mime_type` of
`application/octet-stream` is read as none given. A JPEG or PNG image is stored re-encoded from its
pixels, upright and without its metadata, as the asset library stores images, so it must decode, fit
5 MB and have at most 25 megapixels and 20,000 pixels per side; every other file is stored as sent.

The file is uploaded to WhatsApp before the request answers, with the number's own credential. A file
WhatsApp refuses returns `422` whose `vendor_code` is WhatsApp's own error code; no file is created, so
there is no id to read or send, and the private copy Bird staged for the hand-over, which nothing can
read, is deleted with the 30-day expiry. A WhatsApp outage or rate limit returns `503`, which can be
retried with the same `Idempotency-Key`. A number whose credential WhatsApp no longer accepts returns the
same `422` as a `from` that is not connected, with WhatsApp's error code as `vendor_code`; the number
may still read `connected`: disconnect it and connect it again through WhatsApp Embedded Signup, then
upload again.

Send the file by passing its `id` as `file_id` on a free-form media send, or on a template's media header
parameter (`header_file_id` in `template.parameters`), from the same `from`; a send from another number is
refused with `422`. The file is kept for 30 days after it is uploaded and then
returns `404`; a send within 24 hours of that time is refused with `422`. WhatsApp keeps its copy for the
same 30 days; should it drop the copy earlier, a send of the file fails after acceptance with a media
failure (a `failed` message, `media_rejected` when WhatsApp reports a media error) and the file must be
uploaded again. Media you reuse and are happy to host publicly,
such as a logo, can live in the asset library (`/v1/assets`), whose public URL a
message's media takes as `url`; asset URLs stay reachable after the asset is deleted, and the library
takes smaller files and fewer types than WhatsApp. Anything else, such as a private document or a video,
is uploaded here or sent from a URL you host.

Each request stores a new file; retry with the same `Idempotency-Key` to receive the first result
without uploading the file to WhatsApp again.

## Servers

- `https://{region}.platform.bird.com`: Regional API endpoint. Use the host for the region your organization is hosted in. Official Bird SDKs and the CLI select it automatically from your API key, so you rarely need to set it by hand.
  - `region`: `us1`, `eu1`. Default: `us1`. The region your organization's data is hosted in.

## Authentication

Use one authentication option:

- `BearerAuth`: HTTP bearer authentication. Pass the API key as a bearer token in the `Authorization` header. Workspace
keys use `bk_{region}_*`; organization master keys use `bm_{region}_*`.
The prefix identifies the region and selects the
API endpoint. Official Bird SDKs and the CLI derive the region from the key.

## Code samples

**TypeScript**

```ts
import { readFile } from "node:fs/promises";

const file = await bird.whatsapp.files.create({
  from: "+13124495648",
  file: new Blob([await readFile("invoice-4821.pdf")]),
  name: "invoice-4821.pdf",
});
// Send it from the same number as document.file_id.
console.log(file.id, file.mime_type, file.expires_at);
```

Examples: [TypeScript](/docs/api/reference/create-whatsapp-file.ts.md) · [Python](/docs/api/reference/create-whatsapp-file.py.md) · [Go](/docs/api/reference/create-whatsapp-file.go.md) · [PHP](/docs/api/reference/create-whatsapp-file.php.md) · [CLI](/docs/api/reference/create-whatsapp-file.cli.md) · [cURL](/docs/api/reference/create-whatsapp-file.curl.md)

## Example response `201`

```json
{
  "id": "waf_01krdgeqcxet5s7t44vh8rt9mg",
  "from": "+13124495648",
  "name": "receipt.pdf",
  "mime_type": "application/pdf",
  "size": 48213,
  "created_at": "2026-12-03T12:00:00Z",
  "expires_at": "2027-01-02T12:00:00Z"
}
```

## Header parameters

- `Idempotency-Key` (string, required): Required client-supplied deduplication key for this write. Reuse it for retries of the same intent. Successful results replay within the configured idempotency window (three hours by default); selected connected-app writes also replay uncertain-write conflicts. Use a new key only after confirming the prior result and beginning a different action.
- `X-Workspace-Id` (string, optional): Workspace context for the request. Required for dashboard authentication and master keys. Workspace keys and access tokens already identify their workspace; send that workspace or omit the header. A different one is rejected.
- `X-Organization-Id` (string, optional): Organization context for the request. Required for dashboard authentication. An API key or access token carries its own organization, so send either that organization or no header at all; a different one is rejected.

## Response body

- `id` (string, required): ID of the stored file, which a free-form media send or a template's media header accepts as `file_id`.
- `from` (string, required): The E.164 number the file was uploaded to WhatsApp with; only a message from this number can send it.
- `name` (string, required): Display filename.
- `mime_type` (string, required): Media type of the file.
- `size` (integer, required): File size in bytes.
- `created_at` (string, required): When the file was stored.
- `expires_at` (string, required): When the file is removed, 30 days after it was stored. A send within 24 hours of this time is refused.

## Related resources

- [Should I use a Bird SDK or call the API directly?](/explained/platform/should-i-use-an-sdk-or-call-the-api-directly) (answer)
- [Build your first integration](/learn/paths/integration) (course)
- [Send your first email](/docs/get-started/send-your-first-email) (docs)

[Get an implementation brief](/learn/workspace?topic=api-basics)
