Create a size-limited TOS upload grant
curl --request POST \
--url https://api.creatok.ai/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content_type": "<string>",
"size": 123,
"filename": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({content_type: '<string>', size: 123, filename: '<string>'})
};
fetch('https://api.creatok.ai/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.creatok.ai/v1/files"
payload = {
"content_type": "<string>",
"size": 123,
"filename": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "file_upload",
"file_id": "<string>",
"upload_url": "<string>",
"upload_fields": {},
"expires_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}Files
Create a size-limited TOS upload grant
Upload with multipart/form-data POST, include every returned upload_fields entry, and put the file field last. TOS enforces the signed size limit: 10 MiB for image content types, 100 MiB otherwise. The grant expires after six hours. Finish uploading before referencing file_id or upload_fields.key in generation input. Upload success does not guarantee model compatibility; generation validates media type, dimensions, duration and model-specific limits.
POST
/
files
Create a size-limited TOS upload grant
curl --request POST \
--url https://api.creatok.ai/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content_type": "<string>",
"size": 123,
"filename": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({content_type: '<string>', size: 123, filename: '<string>'})
};
fetch('https://api.creatok.ai/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.creatok.ai/v1/files"
payload = {
"content_type": "<string>",
"size": 123,
"filename": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "file_upload",
"file_id": "<string>",
"upload_url": "<string>",
"upload_fields": {},
"expires_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Response
A signed TOS POST upload form and its object identifier.
Allowed value:
"file_upload"Show child attributes
Show child attributes
Pattern:
^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
