curl --request POST \
--url https://www.asteragents.com/api/upload/presigned \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "quarterly-report.pdf",
"contentType": "application/pdf"
}
'{
"url": "https://account-id.r2.cloudflarestorage.com/bucket/org_xxx/uploads/file-uuid/report.pdf?X-Amz-Algorithm=...",
"method": "PUT",
"fileId": "550e8400-e29b-41d4-a716-446655440000",
"key": "org_xxx/uploads/550e8400-e29b-41d4-a716-446655440000/report.pdf",
"contentKey": "org_xxx/contents/550e8400-e29b-41d4-a716-446655440000.md",
"metadata": {
"contentType": "application/pdf",
"orgId": "org_xxx",
"userId": "user_xxx"
}
}{
"error": "User is not part of any organization"
}{
"error": "Unauthorized"
}{
"error": "Internal Server Error"
}Get presigned upload URL
Get a presigned URL for uploading a file. This is the first step in a two-step upload flow.
Upload Flow:
- Call this endpoint to get a presigned URL and metadata
- PUT the file to the returned URL with the required headers
The presigned URL is signed with specific metadata headers. You must include these headers when uploading or the request will fail with SignatureDoesNotMatch.
Required headers for the PUT request:
Content-Type: Usemetadata.contentTypefrom the responsex-amz-meta-file-type: Usemetadata.contentTypefrom the responsex-amz-meta-org-id: Usemetadata.orgIdfrom the responsex-amz-meta-user-id: Usemetadata.userIdfrom the response
Presigned URLs expire after 10 minutes.
curl --request POST \
--url https://www.asteragents.com/api/upload/presigned \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "quarterly-report.pdf",
"contentType": "application/pdf"
}
'{
"url": "https://account-id.r2.cloudflarestorage.com/bucket/org_xxx/uploads/file-uuid/report.pdf?X-Amz-Algorithm=...",
"method": "PUT",
"fileId": "550e8400-e29b-41d4-a716-446655440000",
"key": "org_xxx/uploads/550e8400-e29b-41d4-a716-446655440000/report.pdf",
"contentKey": "org_xxx/contents/550e8400-e29b-41d4-a716-446655440000.md",
"metadata": {
"contentType": "application/pdf",
"orgId": "org_xxx",
"userId": "user_xxx"
}
}{
"error": "User is not part of any organization"
}{
"error": "Unauthorized"
}{
"error": "Internal Server Error"
}Authorizations
JWT token from Clerk authentication.
Must be from a user with org:admin role.
Body
Response
Presigned URL generated successfully
The presigned URL to upload the file to
"https://account-id.r2.cloudflarestorage.com/bucket/..."
The HTTP method to use (always PUT)
PUT "PUT"
Unique identifier for the uploaded file
"550e8400-e29b-41d4-a716-446655440000"
The storage key/path where the file will be stored
"org_xxx/uploads/550e8400-e29b-41d4-a716-446655440000/report.pdf"
The storage key for extracted text content (for documents)
"org_xxx/contents/550e8400-e29b-41d4-a716-446655440000.md"
Values that MUST be included as headers when uploading to the presigned URL
Show child attributes
Show child attributes