Put media on an AI attachment from links
POST/v1/agents/:agentId/attachments/:attachmentId/media/import
x-scope: "attachments:write"
x-rate-limit-per-minute: 10
Mojeeb downloads the attachment's media from https links and stores it as an upload
would, replacing whatever was stored: one link for a photo, video or document, or up to
10 for an album's images, in order. For a client that can't send files, such as an AI
assistant. A link can also be the url of a Mojeeb upload of this agent (createUpload),
read from Mojeeb's storage instead of downloaded. Each link must answer 200 with the file itself within 20 seconds:
redirects aren't followed, and a link to an address that isn't public is refused. A link
that fails is 422 attachment_media_url_invalid; a file that arrives but isn't what the
type takes is 422 invalid_media, with the same types and sizes as
uploadAttachmentMedia. Nothing stored changes until every file passes. A video is
re-encoded, so 503 media_processing_busy can answer here too. It shares the budget of
10 requests a minute per key with uploadAttachmentMedia.
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 request body is larger than 1 MB.
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.