> For the complete documentation index, see [llms.txt](https://docs.nexos.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexos.ai/gateway-api/files.md).

# Files

Upload and manage files used by other endpoints.

## List files

> Return the list of files that have been uploaded.

```json
{"openapi":"3.0.0","info":{"title":"Nexos AI Public API Production","version":"1.0.0"},"tags":[{"name":"Files","description":"Upload and manage files used by other endpoints."}],"servers":[{"url":"https://api.nexos.ai"}],"security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"},"apiKeyHeader":{"type":"apiKey","in":"header","name":"X-Api-Key","description":"Authenticate by sending your nexos API key in the `X-Api-Key` header (e.g. `X-Api-Key: nexos-...` for a user key or `X-Api-Key: nexos-team-...` for a team key). This is an alternative to the `Authorization: Bearer` scheme. If both `X-Nexos-Key` and `X-Api-Key` are sent, `X-Nexos-Key` takes precedence."}},"schemas":{"FilePurposeType":{"type":"string","description":"The intended purpose of the file. Only \"batch\" is supported — uploaded files may only be used as input for the Batch API.","enum":["batch"]},"ListFilesResponse":{"type":"object","description":"A list of uploaded files.","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/FileResponse"}},"object":{"type":"string","description":"The object type, which is always list.","enum":["list"]},"hasMore":{"type":"boolean","description":"Indicates if there are more items to be fetched."},"firstId":{"type":"string","description":"The ID of the first item in the list."},"lastId":{"type":"string","description":"The ID of the last item in the list."}},"required":["data","object"]},"FileResponse":{"type":"object","description":"A document that has been uploaded and can be referenced by other endpoints.","properties":{"bytes":{"type":"integer","description":"The size of the file, in bytes."},"created_at":{"type":"integer","description":"The Unix timestamp (in seconds) for when the file was created."},"expires_at":{"type":"integer","description":"The Unix timestamp (in seconds) for when the file will expire."},"filename":{"type":"string","description":"The name of the file."},"id":{"type":"string","description":"The file identifier, which can be referenced in the API endpoints."},"object":{"type":"string","description":"The object type, which is always \"file\".","enum":["file"]},"purpose":{"$ref":"#/components/schemas/FilePurposeType"},"status":{"type":"string","description":"Deprecated. The current status of the file.","deprecated":true,"enum":["uploaded","processed","error"]}}}}},"paths":{"/v1/files":{"get":{"operationId":"get-files-v1","summary":"List files","tags":["Files"],"description":"Return the list of files that have been uploaded.","parameters":[{"name":"after","in":"query","description":"A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"A limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000.","required":false,"schema":{"type":"integer","format":"uint32","minimum":1,"default":10000}},{"name":"order","in":"query","description":"Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.","required":false,"schema":{"type":"string","enum":["asc","desc"],"default":"desc"}},{"name":"purpose","in":"query","description":"Only return files with the given purpose.","required":false,"schema":{"$ref":"#/components/schemas/FilePurposeType"}}],"responses":{"200":{"description":"Successful response with list of files","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListFilesResponse"}}}},"500":{"description":"Server error."},"4XX":{"description":"Client error."}}}}}}
```

## Upload file

> Upload a file that other endpoints can reference, such as the request file consumed by the Batch API.

```json
{"openapi":"3.0.0","info":{"title":"Nexos AI Public API Production","version":"1.0.0"},"tags":[{"name":"Files","description":"Upload and manage files used by other endpoints."}],"servers":[{"url":"https://api.nexos.ai"}],"security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"},"apiKeyHeader":{"type":"apiKey","in":"header","name":"X-Api-Key","description":"Authenticate by sending your nexos API key in the `X-Api-Key` header (e.g. `X-Api-Key: nexos-...` for a user key or `X-Api-Key: nexos-team-...` for a team key). This is an alternative to the `Authorization: Bearer` scheme. If both `X-Nexos-Key` and `X-Api-Key` are sent, `X-Nexos-Key` takes precedence."}},"schemas":{"UploadFileRequest":{"type":"object","additionalProperties":false,"properties":{"file":{"description":"The File object (not file name) to be uploaded.\n","type":"string","format":"binary"},"purpose":{"$ref":"#/components/schemas/FilePurposeType"}},"required":["file","purpose"]},"FilePurposeType":{"type":"string","description":"The intended purpose of the file. Only \"batch\" is supported — uploaded files may only be used as input for the Batch API.","enum":["batch"]},"FileResponse":{"type":"object","description":"A document that has been uploaded and can be referenced by other endpoints.","properties":{"bytes":{"type":"integer","description":"The size of the file, in bytes."},"created_at":{"type":"integer","description":"The Unix timestamp (in seconds) for when the file was created."},"expires_at":{"type":"integer","description":"The Unix timestamp (in seconds) for when the file will expire."},"filename":{"type":"string","description":"The name of the file."},"id":{"type":"string","description":"The file identifier, which can be referenced in the API endpoints."},"object":{"type":"string","description":"The object type, which is always \"file\".","enum":["file"]},"purpose":{"$ref":"#/components/schemas/FilePurposeType"},"status":{"type":"string","description":"Deprecated. The current status of the file.","deprecated":true,"enum":["uploaded","processed","error"]}}}}},"paths":{"/v1/files":{"post":{"operationId":"post-files-v1","summary":"Upload file","tags":["Files"],"description":"Upload a file that other endpoints can reference, such as the request file consumed by the Batch API.","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/UploadFileRequest"}}}},"responses":{"200":{"description":"Successful response with file upload details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileResponse"}}}},"400":{"description":"Invalid request data."},"500":{"description":"Server error."}}}}}}
```

## Get file

> Return the metadata for a single file by its ID.

```json
{"openapi":"3.0.0","info":{"title":"Nexos AI Public API Production","version":"1.0.0"},"tags":[{"name":"Files","description":"Upload and manage files used by other endpoints."}],"servers":[{"url":"https://api.nexos.ai"}],"security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"},"apiKeyHeader":{"type":"apiKey","in":"header","name":"X-Api-Key","description":"Authenticate by sending your nexos API key in the `X-Api-Key` header (e.g. `X-Api-Key: nexos-...` for a user key or `X-Api-Key: nexos-team-...` for a team key). This is an alternative to the `Authorization: Bearer` scheme. If both `X-Nexos-Key` and `X-Api-Key` are sent, `X-Nexos-Key` takes precedence."}},"schemas":{"FileResponse":{"type":"object","description":"A document that has been uploaded and can be referenced by other endpoints.","properties":{"bytes":{"type":"integer","description":"The size of the file, in bytes."},"created_at":{"type":"integer","description":"The Unix timestamp (in seconds) for when the file was created."},"expires_at":{"type":"integer","description":"The Unix timestamp (in seconds) for when the file will expire."},"filename":{"type":"string","description":"The name of the file."},"id":{"type":"string","description":"The file identifier, which can be referenced in the API endpoints."},"object":{"type":"string","description":"The object type, which is always \"file\".","enum":["file"]},"purpose":{"$ref":"#/components/schemas/FilePurposeType"},"status":{"type":"string","description":"Deprecated. The current status of the file.","deprecated":true,"enum":["uploaded","processed","error"]}}},"FilePurposeType":{"type":"string","description":"The intended purpose of the file. Only \"batch\" is supported — uploaded files may only be used as input for the Batch API.","enum":["batch"]}}},"paths":{"/v1/files/{file_id}":{"get":{"operationId":"get-file-v1","summary":"Get file","tags":["Files"],"description":"Return the metadata for a single file by its ID.","parameters":[{"name":"file_id","description":"The ID of the file to use for this request.","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response with file details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileResponse"}}}},"404":{"description":"File not found."},"500":{"description":"Server error."}}}}}}
```

## Delete file

> Permanently delete a single file by its ID.

```json
{"openapi":"3.0.0","info":{"title":"Nexos AI Public API Production","version":"1.0.0"},"tags":[{"name":"Files","description":"Upload and manage files used by other endpoints."}],"servers":[{"url":"https://api.nexos.ai"}],"security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"},"apiKeyHeader":{"type":"apiKey","in":"header","name":"X-Api-Key","description":"Authenticate by sending your nexos API key in the `X-Api-Key` header (e.g. `X-Api-Key: nexos-...` for a user key or `X-Api-Key: nexos-team-...` for a team key). This is an alternative to the `Authorization: Bearer` scheme. If both `X-Nexos-Key` and `X-Api-Key` are sent, `X-Nexos-Key` takes precedence."}},"schemas":{"DeletionStatusResponse":{"type":"object","description":"The status of a file deletion.","properties":{"id":{"type":"string","description":"The file identifier."},"object":{"type":"string","description":"The object type, which is always file.","enum":["file"]},"deleted":{"type":"boolean","description":"Indicates whether the file has been deleted."}},"required":["id","object","deleted"]}}},"paths":{"/v1/files/{file_id}":{"delete":{"operationId":"delete-file-v1","summary":"Delete file","tags":["Files"],"description":"Permanently delete a single file by its ID.","parameters":[{"name":"file_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response with deletion status.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeletionStatusResponse"}}}},"404":{"description":"File not found."},"500":{"description":"Server error."}}}}}}
```

## Get file contents

> Download the raw contents of a single file by its ID.

```json
{"openapi":"3.0.0","info":{"title":"Nexos AI Public API Production","version":"1.0.0"},"tags":[{"name":"Files","description":"Upload and manage files used by other endpoints."}],"servers":[{"url":"https://api.nexos.ai"}],"security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"},"apiKeyHeader":{"type":"apiKey","in":"header","name":"X-Api-Key","description":"Authenticate by sending your nexos API key in the `X-Api-Key` header (e.g. `X-Api-Key: nexos-...` for a user key or `X-Api-Key: nexos-team-...` for a team key). This is an alternative to the `Authorization: Bearer` scheme. If both `X-Nexos-Key` and `X-Api-Key` are sent, `X-Nexos-Key` takes precedence."}}},"paths":{"/v1/files/{file_id}/content":{"get":{"operationId":"get-file-contents-v1","summary":"Get file contents","tags":["Files"],"description":"Download the raw contents of a single file by its ID.","parameters":[{"name":"file_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response with file contents","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"404":{"description":"File not found."},"500":{"description":"Server error."}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nexos.ai/gateway-api/files.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
