Get Upload URL
Use this endpoint to get an AWS S3 signed upload url to upload your file to, store the returned key to use after file is uploaded successfully.
Javascript example of how to upload file to the URL you receive from this endpoint:
try {
// Get the S3 URL to upload file to.
const authToken = '<Your Cody AI API Key>'
const response = await fetch('https://getcody.ai/api/v1/uploads/signed-url', {
method: 'POST',
headers: {
'Authorization': `Bearer ${authToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
content_type: 'text/plain',
file_name: 'knowledge.txt'
})
})
const { key, url } = (await response.json()).data
// Upload the File object to S3
await fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'text/plain',
},
body: file, // File object from Web API
})
// File is uploaded, now you can use the `key` you got from this endpoint.
} catch {
// Handle file upload failure.
}
Body
-
file_name string
Original file name you want to upload, must contain the file extension.
-
content_type string
MIME content type of the file.
POST /uploads/signed-url
curl \
-X POST https://getcody.ai/api/v1/uploads/signed-url \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"file_name":"banana_shake.pdf","content_type":"application/pdf"}'
Request example
{
"file_name": "banana_shake.pdf",
"content_type": "application/pdf"
}
Response examples (200)
{
"url": "https://example.com",
"key": "string"
}