Skip to main content
POST
Upload reference media and receive a public URL immediately, without polling. Retention tiers are 3, 7, 15, and 30 days. The 3-day tier is free within your account allowance; overage and longer retention require paid uploads. Check your actual free allowance and available tiers in the console.
The documentation Playground does not support file uploads. Use the cURL, Python, or JavaScript examples below. The JavaScript example requires an <input type="file"> with a file selected on the page.

Authentication

string
required
Use a valid, enabled, unexpired APIMart API Key as Bearer <token>, with an account that is not suspended. The account balance must be positive. Paid uploads also require enough account balance and remaining API Key spending allowance to cover the upload. The free file allowance and the Key’s spending limit are separate limits. Get a Key from API Key management.

Request parameters

integer
Optional: 3, 7, 15, or 30 days. An explicit value overrides the account default; when omitted, the currently effective console default applies, which is not necessarily 3 days. Only URL query parameters are accepted; a form field with this name has no effect. See the console for available tiers.
file
required
Send one file, including its filename, in the file field of a multipart/form-data request. Do not substitute JSON, a base64 string, or a file URL for the file part. Other form fields are ignored; if multiple file parts are sent, only the first is processed.Supported formats: JPEG (.jpg, .jpeg), PNG (.png), GIF (.gif), WebP (.webp)Default maximum file size: 30MB. File size limits can be configured. The active service configuration and size-limit error message take precedence.
With cURL --form, Python files, or JavaScript FormData, let the client generate the Content-Type header with its boundary. Do not set this header manually.

File validation

The file type is detected from its content, not its extension or the MIME type supplied by the client. The content must match the endpoint; renaming a file does not convert it. A type mismatch returns HTTP 400. Images must fully decode, with at most 40MP total and no side exceeding 32768 pixels. GIF files may contain at most 500 frames.

Retention and paid upload settings

Open the console overview to view your allowance and current prices, enable paid uploads, confirm prices, and choose a default retention tier. Prices are shown in the console; charges depend on actual file size (1 GB = 1024³ bytes). Failed uploads are refunded. A price increase requires confirmation before using that tier again; a decrease does not. Disabling paid uploads stops new upload charges and resets default retention to 3 days. Re-enabling requires confirmation of current prices. If a configured long-retention tier becomes unavailable, the effective default falls back to 3 days; check the console.
If your default is 7, 15, or 30 days, uploads without retention_days are charged individually even when free slots remain. Set retention_days=3 to use the 3-day rules for a specific upload. All request examples above explicitly select 3 days.
This example selects 7 days and requires paid uploads to be enabled with that tier’s price confirmed:

Successful response

HTTP 200 returns file metadata. url is at the JSON root, without a data wrapper or a generation task ID. The response example shows file metadata and omits optional quota and overage objects. Their return conditions are described below.
string
Public file URL. Pass it to the appropriate reference-media parameter of the target generation API. Each model still has its own format, size, count, and duration limits; a successful upload does not guarantee model compatibility.
string
Original filename.
string
MIME type detected by the server from the file content, not the client’s declared value.
string
File category. This endpoint returns image.
integer
Actual file size in bytes.
integer
Upload time as a Unix timestamp in seconds.
integer
Retention tier actually used for this file, in days: 3, 7, 15, or 30.
integer
File expiration time as a Unix timestamp in seconds. Use this value to determine URL validity.
object
Returned only for charged uploads: 3-day overage or any 7 / 15 / 30-day upload. charged indicates whether a charge was made; bytes is the billed file size; cost_usd is the charge in USD; price_per_gb_usd is the tier price per GB; retention_days is the billed tier. Free uploads omit this object.
object
Optional shared free-allowance information for the account. Returned for the 3-day tier; longer tiers do not consume free slots and omit this object. See below for unlimited accounts or unavailable statistics.

Shared quota and request rate limits

Images, videos, and audio share one account free allowance. Multiple API Keys do not add allowances. The window rolls on the hour and normally counts successful 3-day uploads over approximately the past 71–72 hours. Longer tiers do not consume free slots. Invalid files, oversized files, and storage failures do not consume slots. Use the console or returned quota.limit for your allowance. Ordinary quota-limited 3-day responses include X-Upload-Quota-Limit, X-Upload-Quota-Remaining, and X-Upload-Quota-Reset, corresponding to limit, remaining, and reset_at; Reset is in Unix seconds. Unlimited accounts receive quota: {"unlimited": true} without these headers. Successful responses may omit quota when statistics are temporarily unavailable; longer tiers also omit it. Do not interpret its absence as zero or unlimited, or re-upload solely because it is absent. After the 3-day free allowance is exhausted, uploads can continue with charges if paid uploads are enabled and the tier price is confirmed. Otherwise, handle 429 as described below. A separate limit of 1000 requests per Key per 60 seconds uses rate_limit_error and is independent of the free file allowance.

Error handling

Errors use a root-level error object. Inspect the HTTP status, error.type / error.code, and root-level overage fields instead of relying only on localized error.message text. Error overage differs from the successful billing object: it may contain available, enabled, needs_reconfirm, retention_days, price_per_gb_usd, optional settings_url, and reason. Enable paid uploads or reconfirm prices in the console.

Using URLs and retaining files

The 72-hour free-allowance window is separate from file retention. Files expire according to the selected tier; use the returned expires_at for the actual expiration time. Expired URLs return 404. Keep original files and do not assume URLs are permanent. For large upload volumes, consider your own object storage (OSS). If the model accepts public file URLs, use your own storage URLs directly to reduce repeated uploads and storage costs.

Other upload endpoints