Register upload
POST
/upload/register
const url = 'https://api.colourbox.com/upload/register';const options = { method: 'POST', headers: { Authorization: 'CBX-SIMPLE-TOKEN Token=<token>', 'Content-Type': 'application/json' }, body: '{"folder":1337,"redirectURL":"http://www.myservice.com/upload-done"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.colourbox.com/upload/register \ --header 'Authorization: CBX-SIMPLE-TOKEN Token=<token>' \ --header 'Content-Type: application/json' \ --data '{ "folder": 1337, "redirectURL": "http://www.myservice.com/upload-done" }'Register an upload with the API
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”Media typeapplication/json
object
folder
integer
Example
1337redirectURL
string
Example
http://www.myservice.com/upload-doneResponses
Section titled “Responses”The resource returns a JSON document with all the information needed to upload the actual file. It contains the endpoint to post the file to, the encoding type of the POST request and the POST parameters that should be posted along with the file itself. The file itself should be posted in the file field.
The JSON documents is a direct representation of an HTML form.
Full Example, with truncated values:
{
"action" : "https://colourbox-upload.s3-eu-west-1.amazonaws.com",
"enctype" : "multipart/form-data",
"method" : "POST",
"fields" : [
{
"name" : "success_action_redirect",
"value" : "http://api.colourbox.com/upload/done?redirect=http%3A%2F%2Fwww.myservice.com%2Fupload-done",
"type" : "hidden"
},
{
"type" : "hidden",
"value" : "upload/777/33/${filename}",
"name" : "key"
},
{
"value" : "REDUCED_REDUNDANCY",
"type" : "hidden",
"name" : "X-Amz-Storage-Class"
},
{
"value" : "AKIAJFHN67ZGNWA...",
"type" : "hidden",
"name" : "X-Amz-Credential"
},
{
"name" : "X-Amz-Algorithm",
"type" : "hidden",
"value" : "AWS4-HMAC-SHA256"
},
{
"value" : "20170601T080641Z",
"type" : "hidden",
"name" : "X-Amz-Date"
},
{
"type" : "hidden",
"value" : "eyJleHBpcmF0aW9uI...",
"name" : "Policy"
},
{
"name" : "X-Amz-Signature",
"value" : "cb56a851d7321e8fa90f...",
"type" : "hidden"
},
{
"type" : "file",
"name" : "file"
}
]
}
Media typeapplication/json
object
action
string
enctype
string
method
string
fields
Array<object>
object
name
string
value
string
type
string
Example
{ "action": "https://colourbox-upload.s3-eu-west-1.amazonaws.com", "enctype": "multipart/form-data", "method": "POST"}