Upload a media binary to Meta and get a re-usable `mediaId`
POST/numbers/{numberId}/media
Accepts the binary as base64 to avoid bringing in a multipart parser. The route forwards the bytes to POST /{phoneNumberId}/media on the Meta Cloud API and returns the resulting mediaId (~30-day TTL).
The mediaId is then passed in the message payload: { type: "media", payload: { kind: "image", media: { id: "<mediaId>" } } }.
For files of any size, prefer POST /numbers/{numberId}/media/binary: base64 inflates the payload by 33% on the wire. This endpoint streams the decoded bytes straight to disk, so it no longer holds the file in memory — but the upload is still 33% larger to send.
Parâmetros
| Campo | Onde | Tipo | Descrição |
|---|---|---|---|
numberIdobrigatório | caminho | string |
Corpo da requisiçãoapplication/json
| Campo | Tipo | Descrição |
|---|---|---|
filenameobrigatório | string | |
mimeTypeobrigatório | string | |
dataBase64obrigatório | string | Base64-encoded binary, capped at 140,000,000 characters (~105 MB of binary). Line breaks and whitespace inside the value are ignored, so base64 wrapped at 76 columns is accepted. |
Exemplo completo do corpo
{ "filename": "string", "mimeType": "image/jpeg", "dataBase64": "string"}
Respostas
201Default ResponseCampos e exemplo da resposta
Campo Tipo Descrição mediaIdobrigatóriostringkindobrigatóriostringValores: imageaudiovideodocumentstickermimeTypeobrigatóriostringfilenameobrigatóriostringsizeobrigatóriointegersha256obrigatóriostringvoiceopcionalbooleanPresent and truewhen the binary is OGG/Opus mono and can be sent as a WhatsApp voice note. Pass it back verbatim inpayload.media.voiceso the recipient's phone downloads it automatically instead of showing a manual download button.JSON{ "mediaId": "string", "kind": "image", "mimeType": "string", "filename": "string", "size": 0, "sha256": "string", "voice": true}
400RFC 7807 problem details for BAD_REQUEST (400).401RFC 7807 problem details for UNAUTHORIZED (401).403RFC 7807 problem details for FORBIDDEN (403).404RFC 7807 problem details for NOT_FOUND (404).413RFC 7807 problem details for BAD_REQUEST (400).415RFC 7807 problem details for BAD_REQUEST (400).422RFC 7807 problem details for VALIDATION_ERROR (422).502RFC 7807 problem details for DEPENDENCY_FAILED (502).
As respostas de erro seguem o formato RFC 7807 (application/problem+json), com um código estável no campo code. Ver os códigos de erro
Exemplo em curl
curl -X POST 'https://api.messages.ccxcompany.co/numbers/<numberId>/media' \ -H "Authorization: Bearer $CCX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "filename": "string", "mimeType": "image/jpeg", "dataBase64": "string" }'