Create files
import requests
url = "https://api.datagrid.com/v1/files"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "expires_after": "259200" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('expires_after', '259200');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.datagrid.com/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.datagrid.com/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form expires_after=259200{
"object": "file",
"id": "<string>",
"filename": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"media_type": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"credits": {
"consumed": 123
}
}{
"status_code": 123,
"error": "rate_limit_exceeded",
"message": "<string>",
"retryable": true,
"statusCode": 123,
"mitigation": "<string>",
"details": {
"reason": "<string>"
}
}Files
Create files
Create files which can be passed as input to agents. This endpoint consumes a flat credit charge per upload. The response includes a credits field with the amount consumed, or null if the billing write fails — the upload still succeeds in that case.
POST
/
files
Create files
import requests
url = "https://api.datagrid.com/v1/files"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "expires_after": "259200" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('expires_after', '259200');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.datagrid.com/v1/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.datagrid.com/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form expires_after=259200{
"object": "file",
"id": "<string>",
"filename": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"media_type": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"credits": {
"consumed": 123
}
}{
"status_code": 123,
"error": "rate_limit_exceeded",
"message": "<string>",
"retryable": true,
"statusCode": 123,
"mitigation": "<string>",
"details": {
"reason": "<string>"
}
}Authorizations
Body
multipart/form-data
Response
Successfully created file
The File object represents a document that has been uploaded to Datagrid.