Get Upload URL

POST /uploads/signed-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.
}
application/json

Body

  • Original file name you want to upload, must contain the file extension.

  • MIME content type of the file.

Responses

  • 200 application/json

    OK

    Hide response attributes Show response attributes object
    • url string(uri)

      AWS S3 signed upload URL, you can make a put request to upload the file.

    • key string

      Key you can use for endpoints that require file uploads.

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"
}