2026-08-11 11:22:55 -04:00
---
# Code generated by make gen. DO NOT EDIT.
title : Files
---
<!-- DO NOT EDIT | GENERATED CONTENT -->
2023-01-03 19:21:10 +01:00
## Upload file
### Code samples
2026-07-15 14:07:09 -04:00
```sh
2023-01-03 19:21:10 +01:00
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/files \
-H 'Accept: application/json' \
-H 'Content-Type: application/x-tar' \
-H 'Coder-Session-Token: API_KEY'
```
2026-05-05 02:54:03 +05:00
`POST /api/v2/files`
2023-01-03 19:21:10 +01:00
> Body parameter
```yaml
file : string
2025-01-03 18:12:59 +05:00
2023-01-03 19:21:10 +01:00
```
### Parameters
2024-08-06 11:00:49 +04:00
| Name | In | Type | Required | Description |
2025-01-03 18:12:59 +05:00
|----------------|--------|--------|----------|------------------------------------------------------------------------------------------------|
2024-08-06 11:00:49 +04:00
| `Content-Type` | header | string | true | Content-Type must be `application/x-tar` or `application/zip` |
| `body` | body | object | true | |
| `» file` | body | binary | true | File to be uploaded. If using tar format, file must conform to ustar (pax may cause problems). |
2023-01-03 19:21:10 +01:00
### Example responses
2025-12-08 16:04:56 -06:00
> 200 Response
2023-01-03 19:21:10 +01:00
```json
{
2025-01-03 18:12:59 +05:00
"hash" : "19686d84-b10d-4f90-b18e-84fd3fa038fd"
2023-01-03 19:21:10 +01:00
}
```
### Responses
2026-08-18 12:54:45 -07:00
| Status | Meaning | Description | Schema |
|--------|-------------------------------------------------------------------------|--------------------------------------------------------------------------|--------------------------------------------------------------|
| 200 | [OK ](https://tools.ietf.org/html/rfc7231#section-6.3.1 ) | Returns existing file if duplicate | [codersdk.UploadResponse ](schemas.md#codersdkuploadresponse ) |
| 201 | [Created ](https://tools.ietf.org/html/rfc7231#section-6.3.2 ) | Returns newly created file | [codersdk.UploadResponse ](schemas.md#codersdkuploadresponse ) |
| 413 | [Payload Too Large ](https://tools.ietf.org/html/rfc7231#section-6.5.11 ) | Request body exceeds 100 MiB, or a .zip archive exceeds it once expanded | [codersdk.Response ](schemas.md#codersdkresponse ) |
2023-01-03 19:21:10 +01:00
2023-01-05 15:27:10 +01:00
To perform this operation, you must be authenticated. [Learn more ](authentication.md ).
2023-01-03 19:21:10 +01:00
## Get file by ID
### Code samples
2026-07-15 14:07:09 -04:00
```sh
2023-01-03 19:21:10 +01:00
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/files/{ fileID} \
-H 'Coder-Session-Token: API_KEY'
```
2026-05-05 02:54:03 +05:00
`GET /api/v2/files/{fileID}`
2023-01-03 19:21:10 +01:00
### Parameters
| Name | In | Type | Required | Description |
2025-01-03 18:12:59 +05:00
|----------|------|--------------|----------|-------------|
2023-01-03 19:21:10 +01:00
| `fileID` | path | string(uuid) | true | File ID |
### Responses
| Status | Meaning | Description | Schema |
2025-01-03 18:12:59 +05:00
|--------|---------------------------------------------------------|-------------|--------|
2023-01-03 19:21:10 +01:00
| 200 | [OK ](https://tools.ietf.org/html/rfc7231#section-6.3.1 ) | OK | |
2023-01-05 15:27:10 +01:00
To perform this operation, you must be authenticated. [Learn more ](authentication.md ).