Skip to main content
POST
/
kb
/
files
Associate file with knowledge base
curl --request POST \
  --url https://asteragents.com/api/kb/files \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "kbId": 123,
  "fileId": "550e8400-e29b-41d4-a716-446655440000",
  "fileName": "quarterly-report.pdf",
  "fileKey": "org_xxx/uploads/550e8400-e29b-41d4-a716-446655440000/quarterly-report.pdf",
  "contentKey": "org_xxx/contents/550e8400-e29b-41d4-a716-446655440000.md",
  "contentType": "application/pdf",
  "fileSize": 1048576
}
'
{
  "success": true,
  "file": {
    "id": 456,
    "knowledgeBaseId": 123,
    "fileId": "550e8400-e29b-41d4-a716-446655440000",
    "fileName": "quarterly-report.pdf",
    "fileKey": "org_xxx/uploads/550e8400-e29b-41d4-a716-446655440000/quarterly-report.pdf",
    "contentKey": "org_xxx/contents/550e8400-e29b-41d4-a716-446655440000.md",
    "contentType": "application/pdf",
    "processingStatus": "completed",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:35:00.000Z",
    "fileSize": 1048576,
    "processingError": null,
    "imageKeys": [
      "org_xxx/images/file-uuid/page-1.png",
      "org_xxx/images/file-uuid/page-2.png"
    ],
    "userMetadata": {},
    "extractedData": {}
  }
}

Authorizations

Authorization
string
header
required

JWT token from Clerk authentication.

Must be from a user with org:admin role.

Body

application/json
kbId
integer
required

The ID of the knowledge base to associate the file with

Example:

123

fileId
string<uuid>
required

The file UUID returned from the presigned upload endpoint

Example:

"550e8400-e29b-41d4-a716-446655440000"

fileName
string
required

Original filename

Example:

"quarterly-report.pdf"

fileKey
string
required

The storage key returned from the presigned upload endpoint

Example:

"org_xxx/uploads/550e8400-e29b-41d4-a716-446655440000/quarterly-report.pdf"

contentKey
string
required

The content key returned from the presigned upload endpoint

Example:

"org_xxx/contents/550e8400-e29b-41d4-a716-446655440000.md"

contentType
string
required

MIME type of the file

Example:

"application/pdf"

fileSize
integer

File size in bytes (optional but recommended)

Example:

1048576

Response

File associated and processing started

success
boolean
required
Example:

true

file
object
required