Show examples in:
JavascriptHTTP
Content Management API > Upload

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 basename attribute;
  • Upload a new version of the asset by passing a different path attribute;

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

replace_strategyenum

Strategy to use when replacing the asset file. If not specified, a new URL will be generated.

Example:"keep_url"
create_new_url

Generate a new URL for the asset (default behavior)

keep_url

Maintain the same URL by overwriting the file at the existing path

Body parameters

typestringRequired

Must be exactly "upload".

attributes.pathstringOptional

Upload path

Example:"/45/1496845848-digital-cats.jpg"
attributes.basenamestringOptional

Upload basename

Example:"digital-cats"
attributes.copyrightstring, nullOptional

Copyright

Example:"2020 DatoCMS"
attributes.authorstring, nullOptional

Author

Example:"Mark Smith"
attributes.notesstring, nullOptional

Notes

Example:"Nyan the cat"
attributes.tagsOptional

Tags

Type:Array<string>
Example:["cats"]
attributes.default_field_metadataobjectOptional

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.

altobjectOptional

Alternate text per locale

Example:{ en: "Alternate text" }
titleobjectOptional

Title per locale

Example:{ en: "Title" }
custom_dataobjectOptional

Object with arbitrary metadata, per locale

Example:{ en: { add_watermark: true } }
focal_pointobject, nullOptional

Focal point (only for image assets)

xnumberRequired

Horizontal position expressed as float between 0 and 1

Example:0.5
ynumberRequired

Vertical position expressed as float between 0 and 1

Example:0.5
poster_timenumber, nullOptional

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)

Example:12.5
relationships.creator.dataOptional

The entity (account/collaborator/access token) who created the asset

Type:<a href="/docs/content-management-api/resources/account">ResourceLinkage&#x3C;"account"></a>, <a href="/docs/content-management-api/resources/access_token">ResourceLinkage&#x3C;"access_token"></a>, <a href="/docs/content-management-api/resources/user">ResourceLinkage&#x3C;"user"></a>, <a href="/docs/content-management-api/resources/sso_user">ResourceLinkage&#x3C;"sso_user"></a>, <a href="/docs/content-management-api/resources/organization">ResourceLinkage&#x3C;"organization"></a>
relationships.upload_collection.dataOptional

Upload collection to which the asset belongs

Type:<a href="/docs/content-management-api/resources/upload_collection">ResourceLinkage&#x3C;"upload_collection"></a>, null

Returns

Returns a Job ID. You can then poll for thecompletion of the jobthat will eventually return a resource object of type upload

Other examples

PUT https://site-api.datocms.com/uploads/4124 HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Content-Type: application/vnd.api+json
{
"data": {
"id": "4124",
"type": "upload",
"attributes": {
"author": "Mark",
"copyright": "2020 DatoCMS",
"default_field_metadata": {
"alt": {
"en": "Nyan the cat"
},
"title": {
"en": "My cat"
},
"custom_data": {
"en": {}
}
}
}
}
}
Terminal window
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":{"alt":{"en":"Nyan the cat"},"title":{"en":"My cat"},"custom_data":{"en":{}}}}}}'
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: {
alt: { en: "Nyan the cat" },
title: { en: "My cat" },
custom_data: { en: {} },
},
},
},
}),
});
HTTP/1.1 202 Accepted
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-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": {
"alt": {
"en": "Nyan the cat"
},
"title": {
"en": "My cat"
},
"custom_data": {
"en": {}
}
}
}
}
}
PUT https://site-api.datocms.com/uploads/4124 HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Content-Type: application/vnd.api+json
{
"data": {
"id": "4124",
"type": "upload",
"attributes": {
"basename": "this-is-the-new-file-name"
}
}
}
Terminal window
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 Accepted
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 28
{
"data": {
"type": "job",
"id": "facf9248be977002c9bae231"
}
}
GET https://site-api.datocms.com/job-results/facf9248be977002c9bae231 HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Content-Type: application/vnd.api+json
Terminal window
curl -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 Accepted
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-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": {
"alt": {
"en": "Nyan the cat"
},
"title": {
"en": "My cat"
},
"custom_data": {
"en": {}
}
}
}
}
}
}
}
}