from line 1
1---
2title: Files
3url: https://platform.claude.com/docs/en/api/files
4---
5
61# Files
72
83## Upload File
94
10**post** `/v1/files`
5**POST** `/v1/files`
116
127Upload File
138
9### Body parameters (form-data)
10
11- `file: string`
12
13 The file to upload
14
15 format: binary
16
17- `expires_in_seconds: optional number`
18
19 Seconds from upload until the file expires and its bytes become permanently unavailable. Must be between 3600 (one hour) and 7776000 (ninety days).
20
21 minimum: 3600, maximum: 7776000
22
1423### Returns
1524
16- `FileMetadata object { id, created_at, filename, 5 more }`
25- `FileMetadata object`
1726
1827 - `id: string`
1928
from line 34
2534
2635 RFC 3339 datetime string representing when the file was created.
2736
37 format: date-time
38
2839 - `filename: string`
2940
3041 Original filename of the uploaded file.
3142
43 maxLength: 500, minLength: 1
44
3245 - `mime_type: string`
3346
3447 MIME type of the file.
3548
49 maxLength: 255, minLength: 1
50
3651 - `size_bytes: number`
3752
3853 Size of the file in bytes.
3954
55 minimum: 0
56
4057 - `type: "file"`
4158
4259 Object type.
from line 60
4360
4461 For files, this is always `"file"`.
4562
46 - `"file"`
47
4863 - `downloadable: optional boolean`
4964
5065 Whether the file can be downloaded.
5166
67 default: false
68
5269 - `expires_at: optional string or null`
5370
5471 RFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with `expires_in_seconds`, this is the upload time plus that value.
5572
73 format: date-time
74
5675### Example
5776
58```http
77```bash
5978curl https://api.anthropic.com/v1/files \
6079 -H 'Content-Type: multipart/form-data' \
6180 -H 'anthropic-version: 2023-06-01' \
from line 82
6382 -F 'file=@/path/to/file'
6483```
6584
66#### Response
85#### Response (200)
6786
6887```json
6988{
from line 99
8099
81100## List Files
82101
83**get** `/v1/files`
102**GET** `/v1/files`
84103
85104List Files
86105
87### Query Parameters
106### Query parameters
88107
89108- `ids: optional array of string`
90109
from line 115
96115
97116 Defaults to `20`. Ranges from `1` to `1000`.
98117
118 default: 20, maximum: 1000, minimum: 1
119
99120- `page: optional string`
100121
101122 Opaque page cursor returned in a prior list response's `next_page`. Prefixed `page_`.
from line 137
116137
117138 RFC 3339 datetime string representing when the file was created.
118139
140 format: date-time
141
119142 - `filename: string`
120143
121144 Original filename of the uploaded file.
122145
146 maxLength: 500, minLength: 1
147
123148 - `mime_type: string`
124149
125150 MIME type of the file.
126151
152 maxLength: 255, minLength: 1
153
127154 - `size_bytes: number`
128155
129156 Size of the file in bytes.
130157
158 minimum: 0
159
131160 - `type: "file"`
132161
133162 Object type.
from line 163
134163
135164 For files, this is always `"file"`.
136165
137 - `"file"`
138
139166 - `downloadable: optional boolean`
140167
141168 Whether the file can be downloaded.
142169
170 default: false
171
143172 - `expires_at: optional string or null`
144173
145174 RFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with `expires_in_seconds`, this is the upload time plus that value.
146175
176 format: date-time
177
147178- `next_page: optional string or null`
148179
149180 Opaque cursor for the next page. Supply as `?page=` to fetch the next page; null when there are no more results.
from line 181
150181
151182### Example
152183
153```http
184```bash
154185curl https://api.anthropic.com/v1/files \
155186 -H 'anthropic-version: 2023-06-01' \
156187 -H "X-Api-Key: $ANTHROPIC_API_KEY"
157188```
158189
159#### Response
190#### Response (200)
160191
161192```json
162193{
from line 209
178209
179210## Download File
180211
181**get** `/v1/files/{file_id}/content`
212**GET** `/v1/files/{file_id}/content`
182213
183214Download File
184215
185### Path Parameters
216### Path parameters
186217
187218- `file_id: string`
188219
from line 221
190221
191222### Example
192223
193```http
224```bash
194225curl https://api.anthropic.com/v1/files/$FILE_ID/content \
195226 -H 'anthropic-version: 2023-06-01' \
196227 -H "X-Api-Key: $ANTHROPIC_API_KEY"
from line 229
198229
199230## Get File Metadata
200231
201**get** `/v1/files/{file_id}`
232**GET** `/v1/files/{file_id}`
202233
203234Get File Metadata
204235
205### Path Parameters
236### Path parameters
206237
207238- `file_id: string`
208239
from line 241
210241
211242### Returns
212243
213- `FileMetadata object { id, created_at, filename, 5 more }`
244- `FileMetadata object`
214245
215246 - `id: string`
216247
from line 253
222253
223254 RFC 3339 datetime string representing when the file was created.
224255
256 format: date-time
257
225258 - `filename: string`
226259
227260 Original filename of the uploaded file.
228261
262 maxLength: 500, minLength: 1
263
229264 - `mime_type: string`
230265
231266 MIME type of the file.
232267
268 maxLength: 255, minLength: 1
269
233270 - `size_bytes: number`
234271
235272 Size of the file in bytes.
236273
274 minimum: 0
275
237276 - `type: "file"`
238277
239278 Object type.
from line 279
240279
241280 For files, this is always `"file"`.
242281
243 - `"file"`
244
245282 - `downloadable: optional boolean`
246283
247284 Whether the file can be downloaded.
248285
286 default: false
287
249288 - `expires_at: optional string or null`
250289
251290 RFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with `expires_in_seconds`, this is the upload time plus that value.
252291
292 format: date-time
293
253294### Example
254295
255```http
296```bash
256297curl https://api.anthropic.com/v1/files/$FILE_ID \
257298 -H 'anthropic-version: 2023-06-01' \
258299 -H "X-Api-Key: $ANTHROPIC_API_KEY"
259300```
260301
261#### Response
302#### Response (200)
262303
263304```json
264305{
from line 316
275316
276317## Delete File
277318
278**delete** `/v1/files/{file_id}`
319**DELETE** `/v1/files/{file_id}`
279320
280321Delete File
281322
282### Path Parameters
323### Path parameters
283324
284325- `file_id: string`
285326
from line 328
287328
288329### Returns
289330
290- `DeletedFile object { id, type }`
331- `DeletedFile object`
291332
292333 - `id: string`
293334
from line 340
299340
300341 For file deletion, this is always `"file_deleted"`.
301342
302 - `"file_deleted"`
343 default: file_deleted
303344
304345### Example
305346
306```http
347```bash
307348curl https://api.anthropic.com/v1/files/$FILE_ID \
308349 -X DELETE \
309350 -H 'anthropic-version: 2023-06-01' \
from line 351
310351 -H "X-Api-Key: $ANTHROPIC_API_KEY"
311352```
312353
313#### Response
354#### Response (200)
314355
315356```json
316357{
from line 360
319360}
320361```
321362
322## Domain Types
363## Domain types
323364
324365### Deleted File
325366
326- `DeletedFile object { id, type }`
367- `DeletedFile object`
327368
328369 - `id: string`
329370
from line 376
335376
336377 For file deletion, this is always `"file_deleted"`.
337378
338 - `"file_deleted"`
379 default: file_deleted
339380
340381### File Metadata
341382
342- `FileMetadata object { id, created_at, filename, 5 more }`
383- `FileMetadata object`
343384
344385 - `id: string`
345386
from line 392
351392
352393 RFC 3339 datetime string representing when the file was created.
353394
395 format: date-time
396
354397 - `filename: string`
355398
356399 Original filename of the uploaded file.
357400
401 maxLength: 500, minLength: 1
402
358403 - `mime_type: string`
359404
360405 MIME type of the file.
361406
407 maxLength: 255, minLength: 1
408
362409 - `size_bytes: number`
363410
364411 Size of the file in bytes.
365412
413 minimum: 0
414
366415 - `type: "file"`
367416
368417 Object type.
from line 418
369418
370419 For files, this is always `"file"`.
371420
372 - `"file"`
373
374421 - `downloadable: optional boolean`
375422
376423 Whether the file can be downloaded.
377424
425 default: false
426
378427 - `expires_at: optional string or null`
379428
380429 RFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with `expires_in_seconds`, this is the upload time plus that value.
430
431 format: date-time
381432
No line in this hunk matches that.