Knowledge Sources - Upload File

Uploads a file to a File knowledge source for processing and indexing.

POST {endpoint}/knowledgesources('{sourceName}')/files?api-version=2026-05-01-preview

URI Parameters

Name In Required Type Description
endpoint
path True

string (uri)

The endpoint URL of the search service.

sourceName
path True

string

The name of the knowledge source.

api-version
query True

string

minLength: 1

The API version to use for this operation.

Request Header

Media Types: "application/octet-stream"

Name Required Type Description
Content-Disposition True

string

The Content-Disposition header specifying the filename of the uploaded file. Must follow the format: attachment; filename="<filename>". For example: attachment; filename="installation-guide.pdf".

x-ms-client-request-id

string (uuid)

An opaque, globally-unique, client-generated string identifier for the request.

Request Body

Media Types: "application/octet-stream"

Name Type Description
file

string (binary)

The file content to upload.

Responses

Name Type Description
201 Created

KnowledgeSourceFile

The request has succeeded and a new resource has been created as a result.

Other Status Codes

ErrorResponse

An unexpected error response.

Security

api-key

Type: apiKey
In: header

OAuth2Auth

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/v2.0/authorize

Scopes

Name Description
https://search.azure.com/.default

Examples

SearchServiceUploadKnowledgeSourceFile

Sample request

POST https://previewexampleservice.search.windows.net/knowledgesources('ks-file-test')/files?api-version=2026-05-01-preview



"dGVzdCBmaWxlIGNvbnRlbnQ="

Sample response

{
  "fileId": "00000000-0000-0000-0000-000000000001",
  "fileName": "example.pdf",
  "fileSizeBytes": 12345,
  "createdAt": "2026-01-01T00:00:00Z",
  "lastUpdatedAt": "2026-01-01T00:00:00Z",
  "errorMessage": null
}

Definitions

Name Description
ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).

KnowledgeSourceFile

Metadata for a file uploaded to a File knowledge source.

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

searchservice.knowledgesources.uploadfile

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).

Name Type Description
error

ErrorDetail

The error object.

KnowledgeSourceFile

Metadata for a file uploaded to a File knowledge source.

Name Type Description
createdAt

string (date-time)

The timestamp when the file was created.

errorMessage

string

The error message if file processing failed, null otherwise.

fileId

string

The unique identifier for the file.

fileName

string

The original file name.

fileSizeBytes

integer (int64)

The file size in bytes.

lastUpdatedAt

string (date-time)

The timestamp when the file was last updated.