You're reading "Content Management API"

Upload

Every file you upload to DatoCMS will be retrievable from this endpoint.

The Upload object

A Upload object is returned as part of the response body of each successful Index, Show, Create, Update or Delete API call. The following table contains the list of all its fields along with their type, description and example values.

Object fields:
altstring

Alt

created_atstring

Date of upload

formatstring

Format

This attribute is required
heightinteger

Height of image

is_imageboolean

Is this upload an image?

This attribute is required
pathstring

Upload path

This attribute is required
sizeinteger

size of the upload

This attribute is required
titlestring

Upload title

urlstring

Upload URL

This attribute is required
widthinteger

Width of image

List all uploads

To list all uploads, send a GET request to the /uploads endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
GET https://site-api.datocms.com/uploads HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": [ { "type": "upload", "id": "666", "attributes": { "size": 444, "width": 30, "height": 30, "path": "/45/1496845848-digital-cats.jpg", "url": "https://www.datocms-assets.com/45/1496845848-digital-cats.jpg", "format": "jpg", "alt": "Nyan the cat", "title": "My cat", "is_image": true, "created_at": null } } ], "meta": { "total_count": 20, "uploaded_bytes": 20, "uploadable_bytes": 20 } }

Retrieve a upload

To retrieve a upload, send a GET request to the /uploads/:upload_id endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
GET https://site-api.datocms.com/uploads/:upload_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "upload", "id": "666", "attributes": { "size": 444, "width": 30, "height": 30, "path": "/45/1496845848-digital-cats.jpg", "url": "https://www.datocms-assets.com/45/1496845848-digital-cats.jpg", "format": "jpg", "alt": "Nyan the cat", "title": "My cat", "is_image": true, "created_at": null } } }

Create a new upload

To create a new upload, send a POST request to the /uploads endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
POST https://site-api.datocms.com/uploads HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "upload", "attributes": { "size": 444, "width": 30, "height": 30, "path": "/45/1496845848-digital-cats.jpg", "format": "jpg", "alt": "Nyan the cat", "title": "My cat" } } }
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "upload", "id": "666", "attributes": { "size": 444, "width": 30, "height": 30, "path": "/45/1496845848-digital-cats.jpg", "url": "https://www.datocms-assets.com/45/1496845848-digital-cats.jpg", "format": "jpg", "alt": "Nyan the cat", "title": "My cat", "is_image": true, "created_at": null } } }

Update a upload

To update a upload, send a PUT request to the /uploads/:upload_id endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
PUT https://site-api.datocms.com/uploads/:upload_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "upload", "id": "666", "attributes": { "path": "/45/1496845848-digital-cats.jpg", "size": 444, "width": 30, "height": 30, "format": "jpg", "alt": "Nyan the cat", "title": "My cat" } } }
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "upload", "id": "666", "attributes": { "size": 444, "width": 30, "height": 30, "path": "/45/1496845848-digital-cats.jpg", "url": "https://www.datocms-assets.com/45/1496845848-digital-cats.jpg", "format": "jpg", "alt": "Nyan the cat", "title": "My cat", "is_image": true, "created_at": null } } }

Delete a upload

To delete a upload, send a DELETE request to the /uploads/:upload_id endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
DELETE https://site-api.datocms.com/uploads/:upload_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "upload", "id": "666", "attributes": { "size": 444, "width": 30, "height": 30, "path": "/45/1496845848-digital-cats.jpg", "url": "https://www.datocms-assets.com/45/1496845848-digital-cats.jpg", "format": "jpg", "alt": "Nyan the cat", "title": "My cat", "is_image": true, "created_at": null } } }