You're reading "Content Management API"

Upload permission

To upload a file in DatoCMS, first you need to obtain an upload permission through this API endpoint. The response will contain the S3 URL where you will be able to upload the file with a direct PUT request.

The Upload permission object

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

Object fields:
urlstring

The URL to use to upload the file with a direct PUT request

This attribute is required

Request a new upload

To request a new upload, send a POST request to the /upload-requests 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/upload-requests HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "upload_request", "attributes": { "filename": "image.png" } } }
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_request", "id": "/7/1455102967-image.png", "attributes": { "url": "https://dato-images.s3-eu-west-1.amazonaws.com/7/1455102967-image.png?X-Amz-Credential=AKIAJDTXTZHHDUCKAUMA%2F20160210" } } }