Upload an AI attachment's media
PUT/v1/agents/:agentId/attachments/:attachmentId/media
x-scope: "attachments:write"
x-rate-limit-per-minute: 10
The attachment's media as multipart/form-data, replacing whatever was stored: one file
in file for a photo, video or document, or an album's images in files (up to 10, kept
in order). Each file is checked by what it is, not by the type it is sent with:
- photo, and each album image: JPEG, PNG or WebP, up to 5 MB (WhatsApp's limit for images, so a photo never uploads and then fails when the AI sends it);
- video: MP4 or MOV, up to 16 MB. Every video is re-encoded on the server to the format WhatsApp plays (H.264, AAC, MP4) at up to 720p and 30 fps; one still over 16 MB after that, or one that takes longer than 150 seconds to re-encode, is refused;
- document: PDF or DOCX, up to 20 MB.
A refused file is 422 invalid_media and changes nothing stored. The files stored before
are removed, so messages the AI already sent with them no longer open their media in the
conversation. This is the one
endpoint whose body may be larger than 1 MB: up to 51 MB, a full album. Videos are
re-encoded a few at a time across Mojeeb: when the server is busy for longer than 30
seconds, the answer is 503 media_processing_busy with Retry-After, and the same
upload can be sent again. It shares the budget of 10 requests a minute per key with
importAttachmentMedia and the other endpoints that have one. Uploading media doesn't
switch the attachment on.
Request
Responses
- 200
- 401
- 403
- 404
- 413
- 422
- 429
- 500
- 503
The attachment with its new media.
Response Headers
Correlation id for this request — paste into support tickets.
Authentication failed. Single code (invalid_api_key) covers every
sub-case: missing header, wrong scheme, malformed, unknown, revoked or
expired key. The message field disambiguates for humans debugging.
One exception: when the key could not be checked because of a server-side
fault, the status is still 401 but type is internal_error and code
is internal_server_error; retry with backoff.
Response Headers
Correlation id for this request — paste into support tickets.
Authenticated, but not allowed: insufficient_scope (the key lacks the scope in this
operation's x-scope) or agent_not_authorized (the key is limited to other agents).
Response Headers
Correlation id for this request — paste into support tickets.
agent_not_found when the agent is not one of your company's agents
(the API never confirms whether another company's agent exists);
not_found when the attachment is not one of this agent's;
endpoint_not_found for a path or method no endpoint serves, including
an id that is not a UUID.
Response Headers
Correlation id for this request — paste into support tickets.
The upload is larger than 51 MB, a full album of 10 images of 5 MB and the form around them.
Response Headers
Correlation id for this request — paste into support tickets.
invalid_media: no file, too many files for the type, an empty or too large file, or a
file that isn't a kind the type takes (checked by its content, not the type it was sent
with); the message names the file. attachment_media_url_invalid (import only): a link
that isn't https, points at an address that isn't public, can't be reached, answers
anything but 200 with a file in time, or sends a file too large for the type; param
is urls. invalid_request_body when the body isn't valid JSON or breaks a limit in its
schema. Nothing stored was changed.
Response Headers
Correlation id for this request — paste into support tickets.
Per-key rate limit hit. Default is 60/min/key; an endpoint with an
x-rate-limit-per-minute of its own counts in a budget of its own
(today the WhatsApp template endpoints, sendBroadcast, retryBroadcast, inviteMember,
resendInvitation, uploadAttachmentMedia, importAttachmentMedia, createUpload and
importSavedReplyMedia, which share one that allows 10/min/key,
sendConversationMessage, which allows 20/min/key; putUploadContent takes no key and
allows the default 60/min per IP address), and its 429
reports that limit in X-RateLimit-Limit. Retry-After tells you when to retry;
X-RateLimit-Reset is the Unix timestamp of the next window.
Per-success-response
X-RateLimit-*headers are a known gap; on 2xx responses these headers are NOT currently emitted. Customers should rely on 429 +Retry-Afterfor backoff signals.
Response Headers
Correlation id for this request — paste into support tickets.
Seconds to wait before retrying.
The per-minute request limit of the endpoint called. Every key has the same limits today.
Remaining requests in the current window. 0 on rejection.
Unix timestamp at which the current window resets.
Unexpected server-side failure. Retry with exponential backoff. If
the failure persists, send us the correlation_id.
Response Headers
Correlation id for this request — paste into support tickets.
A temporary fault; nothing stored was changed, so retry. media_processing_busy: every
video re-encoding slot stayed busy for 30 seconds; send the same request again after
Retry-After. access_unavailable: Mojeeb couldn't check this key's access.
Response Headers
Correlation id for this request — paste into support tickets.
Seconds to wait before retrying.