Media upload with credit
POST /v1/media (and POST /v1/sites/{site}/media with a company key) uploads an image to the site’s library. This page covers what the Media reference does not detail: the file’s provenance and the credit and licence that travel with the image.
- Scope:
media:upload. Themedia:writepackage grantsmedia:uploadandmedia:delete(see API v2). - Body:
multipart/form-datawith a part namedfile. Another content type answers 400 with the messageexpected multipart/form-data body with a `file` field. - Metadata: all in the query string, never in the multipart body.
- Site: always the key’s (or the path
{site}checked against the key’s company). Asite_idin the query is ignored.
Query parameters
Section titled “Query parameters”All optional. A whitespace-only value counts as absent. Anything outside the contract is 400, answered before the file is read.
| Parameter | Limit | Notes |
|---|---|---|
alt_text |
up to 500 characters | The image’s text alternative. |
source |
upload, imported, ai or system |
Provenance. Omitted means upload. |
source_detail |
up to 200 characters | Free-form provenance detail (for example codex with source=ai, or a stock-photo id). |
credit_author |
up to 200 characters | Author name. |
credit_author_url |
up to 2048 characters, https | Author link. |
credit_license |
up to 200 characters | Licence name, for example CC BY 4.0. |
credit_license_url |
up to 2048 characters, https | Licence link. |
credit_caption |
up to 500 characters | Ready-to-display attribution text. |
Limits count characters, not bytes. Text fields reject control characters. URL fields accept only https:// with a host: no whitespace and no embedded credentials (https://user@host is rejected).
source and source_detail
Section titled “source and source_detail”upload: ordinary upload (default).imported: brought from another system.ai: AI-generated. Put the generator insource_detail, for examplesource=ai&source_detail=codex. Foraino credit field is required.system: created by a system routine.
unknown is not accepted: it is the value of files that predate provenance, not a choice for the sender.
Literal errors (400)
Section titled “Literal errors (400)”invalid query stringalt_text must have at most 500 characterssource must be one of: upload, imported, ai, systemsource_detail must have at most 200 characterscredit_author must have at most 200 characterscredit_license must have at most 200 characterscredit_caption must have at most 500 characterscredit_author_url must have at most 2048 characterscredit_license_url must have at most 2048 characterscredit_author must not contain control characterscredit_author_url must be an https:// URLcredit_author_url is not a valid https:// URLFor credit_license and credit_caption the same length and control-character messages apply; for credit_license_url, the length and https ones, swapping the field name. They come in the envelope { "error": { "code": "bad_request", "message": "..." } }.
Example
Section titled “Example”curl -X POST "https://api.canverly.com/v1/media?alt_text=Desk%20with%20laptop&source=imported&credit_author=Ana%20Souza&credit_author_url=https%3A%2F%2Fexample.com%2Fana&credit_license=CC%20BY%204.0&credit_license_url=https%3A%2F%2Fcreativecommons.org%2Flicenses%2Fby%2F4.0%2F&credit_caption=Photo%3A%20Ana%20Souza%20%2F%20CC%20BY%204.0" \ -H "Authorization: Bearer $CANVERLY_API_KEY" \ -F "file=@desk.jpg"For an AI-generated image, no credit:
curl -X POST "https://api.canverly.com/v1/media?alt_text=Illustration%20of%20a%20dashboard&source=ai&source_detail=codex" \ -H "Authorization: Bearer $CANVERLY_API_KEY" \ -F "file=@cover.png"Types and size
Section titled “Types and size”- Body: at most 8 MiB. Above that:
413(upload body too large). - Accepted types: PNG, JPEG, GIF, WebP, AVIF and SVG. The type is decided by the file’s bytes; the multipart part’s
Content-Typeis ignored. Any other type (BMP, TIFF, HEIC, PDF…) answers415. - SVG: up to 512 KiB, and it is stored sanitized. An SVG with active content (script, event handler,
javascript:URL,foreignObject) or that is not a servable SVG document is rejected with415. - Absurd dimensions: the image header declares an area or side above the safety ceiling:
413. - Missing
filepart:400missing file.
Response
Section titled “Response”Success is 202 (Accepted): the original is stored, variants are generated in the background.
{ "id": "…", "key": "…", "mime": "image/jpeg", "hash": "…", "primary_storage": "…", "bytes": 123456, "width": 1600, "height": 900, "filename": "desk.jpg", "status": "processing"}width and height may be null when the format does not allow reading dimensions. Track progress with GET /v1/media/{id}. The credit is not echoed in the upload response; it is stored on the asset and returned when the asset is read. Use the id as featured_image_id or in the post’s image blocks.
If the key has no company context, the upload answers 422 (this api key has no org context; re-create it in Configurações → Integrações API).
Where the credit appears
Section titled “Where the credit appears”The credit is stored with the asset (field credit, with provider equal to external and the keys author, author_url, license, license_url and caption) and returned by GET /v1/media/{id}.
See also Idempotency (the upload does not use Idempotency-Key), Rate limits (upload counts as a write) and Media.