Update an upload
Depending on the attributes that you pass, you can use this endpoint to:
- Update regular attributes like
author,notes,copyright,default_field_metadata, etc.; - Rename the asset by passing a different
basenameattribute; - Upload a new version of the asset by passing a different
pathattribute;
Just like POST /uploads endpoint, an asyncronous job ID might be returned instead of the regular response. See the Create a new upload section for more details.
We strongly recommend to use our JS or Ruby client to upload new assets, as they provide helper methods that take care of all the details for you.
Query parameters
Strategy to use when replacing the asset file. If not specified, a new URL will be generated.
"keep_url"
Generate a new URL for the asset (default behavior)
Maintain the same URL by overwriting the file at the existing path
Body parameters
Must be exactly "upload".
Upload path
"/45/1496845848-digital-cats.jpg"
Upload basename
"digital-cats"
Copyright
"2020 DatoCMS"
Author
"Mark Smith"
Notes
"Nyan the cat"
Tags
["cats"]
Patch the asset's default metadata. Send any subset of alt/title/custom_data/focal_point/poster_time — missing keys preserve their stored values. See the response shape for the full structure and per-key semantics.
Alternate text per locale
{ en: "Alternate text" }
Title per locale
{ en: "Title" }
Object with arbitrary metadata, per locale
{ en: { add_watermark: true } }
Focal point (only for image assets)
Horizontal position expressed as float between 0 and 1
0.5
Vertical position expressed as float between 0 and 1
0.5
Poster time in seconds (only for video assets). Float seconds into the video used to generate the thumbnail; null uses Mux's default (middle of the video)
12.5
The entity (account/collaborator/access token) who created the asset
Upload collection to which the asset belongs
Returns
Returns a Job ID. You can then poll for the completion of the job that will eventually return a resource object of type upload
Other examples
PUT https://site-api.datocms.com/uploads/4124 HTTP/1.1Authorization: Bearer YOUR-API-TOKENAccept: application/jsonX-Api-Version: 3Content-Type: application/vnd.api+json
{ "data": { "id": "4124", "type": "upload", "attributes": { "author": "Mark", "copyright": "2020 DatoCMS", "default_field_metadata": { "en": { "alt": "Nyan the cat", "title": "My cat", "custom_data": {} } } } }}curl -g 'https://site-api.datocms.com/uploads/4124' \ -X PUT \ -H "Authorization: Bearer YOUR-API-TOKEN" \ -H "Accept: application/json" \ -H "X-Api-Version: 3" \ -H "Content-Type: application/vnd.api+json" \ --data-binary '{"data":{"id":"4124","type":"upload","attributes":{"author":"Mark","copyright":"2020 DatoCMS","default_field_metadata":{"en":{"alt":"Nyan the cat","title":"My cat","custom_data":{}}}}}}'await fetch("https://site-api.datocms.com/uploads/4124", { method: "PUT", headers: { Authorization: "Bearer YOUR-API-TOKEN", Accept: "application/json", "X-Api-Version": "3", "Content-Type": "application/vnd.api+json", }, body: JSON.stringify({ data: { id: "4124", type: "upload", attributes: { author: "Mark", copyright: "2020 DatoCMS", default_field_metadata: { en: { alt: "Nyan the cat", title: "My cat", custom_data: {} }, }, }, }, }),});HTTP/1.1 202 AcceptedContent-Type: application/jsonCache-Control: cache-control: max-age=0, private, must-revalidateX-RateLimit-Limit: 30X-RateLimit-Remaining: 28
{ "data": { "type": "upload", "id": "666", "attributes": { "size": 444, "width": 30, "height": 30, "path": "/205/1565776891-image.png", "url": "https://www.datocms-assets.com/205/1565776891-image.png", "basename": "image", "format": "jpg", "alt": "Nyan the cat", "title": "My cat", "is_image": true, "author": "Mark", "copyright": "2020 DatoCMS", "default_field_metadata": { "en": { "alt": "Nyan the cat", "title": "My cat", "custom_data": {} } } } }}PUT https://site-api.datocms.com/uploads/4124 HTTP/1.1Authorization: Bearer YOUR-API-TOKENAccept: application/jsonX-Api-Version: 3Content-Type: application/vnd.api+json
{ "data": { "id": "4124", "type": "upload", "attributes": { "basename": "this-is-the-new-file-name" } }}curl -g 'https://site-api.datocms.com/uploads/4124' \ -X PUT \ -H "Authorization: Bearer YOUR-API-TOKEN" \ -H "Accept: application/json" \ -H "X-Api-Version: 3" \ -H "Content-Type: application/vnd.api+json" \ --data-binary '{"data":{"id":"4124","type":"upload","attributes":{"basename":"this-is-the-new-file-name"}}}'await fetch("https://site-api.datocms.com/uploads/4124", { method: "PUT", headers: { Authorization: "Bearer YOUR-API-TOKEN", Accept: "application/json", "X-Api-Version": "3", "Content-Type": "application/vnd.api+json", }, body: JSON.stringify({ data: { id: "4124", type: "upload", attributes: { basename: "this-is-the-new-file-name" }, }, }),});HTTP/1.1 202 AcceptedContent-Type: application/jsonCache-Control: cache-control: max-age=0, private, must-revalidateX-RateLimit-Limit: 30X-RateLimit-Remaining: 28
{ "data": { "type": "job", "id": "facf9248be977002c9bae231" }}GET https://site-api.datocms.com/job-results/facf9248be977002c9bae231 HTTP/1.1Authorization: Bearer YOUR-API-TOKENAccept: application/jsonX-Api-Version: 3Content-Type: application/vnd.api+jsoncurl -g 'https://site-api.datocms.com/job-results/facf9248be977002c9bae231' \ \ -H "Authorization: Bearer YOUR-API-TOKEN" \ -H "Accept: application/json" \ -H "X-Api-Version: 3" \ -H "Content-Type: application/vnd.api+json"await fetch( "https://site-api.datocms.com/job-results/facf9248be977002c9bae231", { headers: { Authorization: "Bearer YOUR-API-TOKEN", Accept: "application/json", "X-Api-Version": "3", "Content-Type": "application/vnd.api+json", }, },);HTTP/1.1 202 AcceptedContent-Type: application/jsonCache-Control: cache-control: max-age=0, private, must-revalidateX-RateLimit-Limit: 30X-RateLimit-Remaining: 28
{ "data": { "type": "job-result", "id": "facf9248be977002c9bae231", "attributes": { "status": 200, "payload": { "data": { "type": "upload", "id": "666", "attributes": { "size": 444, "width": 30, "height": 30, "path": "/160228/1745427779-image.png", "url": "https://www.datocms-assets.com/160228/1745427779-image.png", "basename": "image", "format": "jpg", "alt": "Nyan the cat", "title": "My cat", "is_image": true, "author": "Mark", "copyright": "2020 DatoCMS", "default_field_metadata": { "en": { "alt": "Nyan the cat", "title": "My cat", "custom_data": {} } } } } } } }}