Skip to main content
POST
/
api
/
v1
/
files
/
upload-url
Generate File Upload URL
curl --request POST \
  --url https://api.wordsmith.ai/api/v1/files/upload-url \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "file_name": "<string>",
  "content_type": "<string>"
}
'
{
  "upload_url": "https://s3.amazonaws.com/wordsmith-uploads/signed-url-here",
  "job_id": "123e4567-e89b-12d3-a456-426614174000",
  "content_type": "application/pdf"
}
Generates a presigned URL that can be used to upload files directly to Wordsmith’s storage. This is the first step when you want to include file attachments with your assistant questions.

Authentication

This endpoint requires a valid API key in the Authorization header.

Request Body

file_name
string
required
The name of the file to be uploaded, including the file extension
content_type
string
required
The MIME type of the file (e.g., “application/pdf”, “text/plain”, “application/vnd.openxmlformats-officedocument.wordprocessingml.document”, “image/png”, “audio/mp3”)

Supported File Types

Wordsmith supports a wide variety of file formats including:
  • Documents: PDF, DOC, DOCX, TXT, MD, HTML
  • Spreadsheets: XLS, XLSX, CSV, TSV
  • Presentations: PPT, PPTX
  • Images: PNG, JPEG, WebP, TIFF
  • Audio: MP3, MP4, M4A, MPEG, WAV, WebM
  • Archives: ZIP
curl -X POST "https://api.wordsmith.ai/api/v1/files/upload-url" \
  -H "Authorization: Bearer sk-ws-api1-your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "contract.pdf",
    "content_type": "application/pdf"
  }'

Response

upload_url
string
The presigned URL where you can upload your file using a PUT request.
job_id
string
The unique identifier for this upload job. Use this as the upload_job_id when creating assistant questions with file attachments.
content_type
string
The MIME type that was specified in the request.
{
  "upload_url": "https://s3.amazonaws.com/wordsmith-uploads/signed-url-here",
  "job_id": "123e4567-e89b-12d3-a456-426614174000",
  "content_type": "application/pdf"
}

Complete Upload Flow

After receiving the upload URL, you need to upload your file:
# Step 1: Get upload URL (shown above)
# Step 2: Upload the file
curl -X PUT "https://s3.amazonaws.com/wordsmith-uploads/signed-url-here" \
  -H "Content-Type: application/pdf" \
  --data-binary @contract.pdf

# Step 3: Use upload_job_id in your assistant question
curl -X POST "https://api.wordsmith.ai/api/v1/assistants/default/questions" \
  -H "Authorization: Bearer sk-ws-api1-your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "Please review this contract",
    "attachments": [
      {
        "upload_job_id": "123e4567-e89b-12d3-a456-426614174000"
      }
    ]
  }'

Error Responses

See the Errors page for the full error format reference.
{
  "error_code": "invalid_request_body",
  "ws_api_error_code": "invalid_request_body",
  "message": "Request body is invalid. Ensure it is valid JSON with 'file_name' and 'content_type' fields."
}

File Size Limits

  • Maximum file size: 50 MB per file
  • Maximum total attachments per question: 10 files
  • Files are automatically deleted after 30 days for security

Notes

  • Upload URLs expire after 1 hour
  • Files must be uploaded using a PUT request with the exact content type specified
  • The job_id from the response should be passed as upload_job_id when creating assistant questions