python/resources/uploads/methods/cancel/index.md +0 −166 deleted
File Deleted View Diff
1## Cancel upload
2
3`uploads.cancel(strupload_id) -> Upload`
4
5**post** `/uploads/{upload_id}/cancel`
6
7Cancels the Upload. No Parts may be added after an Upload is cancelled.
8
9Returns the Upload object with status `cancelled`.
10
11### Parameters
12
13- `upload_id: str`
14
15### Returns
16
17- `class Upload: …`
18
19 The Upload object can accept byte chunks in the form of Parts.
20
21 - `id: str`
22
23 The Upload unique identifier, which can be referenced in API endpoints.
24
25 - `bytes: int`
26
27 The intended number of bytes to be uploaded.
28
29 - `created_at: int`
30
31 The Unix timestamp (in seconds) for when the Upload was created.
32
33 - `expires_at: int`
34
35 The Unix timestamp (in seconds) for when the Upload will expire.
36
37 - `filename: str`
38
39 The name of the file to be uploaded.
40
41 - `object: Literal["upload"]`
42
43 The object type, which is always "upload".
44
45 - `"upload"`
46
47 - `purpose: str`
48
49 The intended purpose of the file. [Please refer here](https://platform.openai.com/docs/api-reference/files/object#files/object-purpose) for acceptable values.
50
51 - `status: Literal["pending", "completed", "cancelled", "expired"]`
52
53 The status of the Upload.
54
55 - `"pending"`
56
57 - `"completed"`
58
59 - `"cancelled"`
60
61 - `"expired"`
62
63 - `file: Optional[FileObject]`
64
65 The `File` object represents a document that has been uploaded to OpenAI.
66
67 - `id: str`
68
69 The file identifier, which can be referenced in the API endpoints.
70
71 - `bytes: int`
72
73 The size of the file, in bytes.
74
75 - `created_at: int`
76
77 The Unix timestamp (in seconds) for when the file was created.
78
79 - `filename: str`
80
81 The name of the file.
82
83 - `object: Literal["file"]`
84
85 The object type, which is always `file`.
86
87 - `"file"`
88
89 - `purpose: Literal["assistants", "assistants_output", "batch", 5 more]`
90
91 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
92
93 - `"assistants"`
94
95 - `"assistants_output"`
96
97 - `"batch"`
98
99 - `"batch_output"`
100
101 - `"fine-tune"`
102
103 - `"fine-tune-results"`
104
105 - `"vision"`
106
107 - `"user_data"`
108
109 - `status: Literal["uploaded", "processed", "error"]`
110
111 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
112
113 - `"uploaded"`
114
115 - `"processed"`
116
117 - `"error"`
118
119 - `expires_at: Optional[int]`
120
121 The Unix timestamp (in seconds) for when the file will expire.
122
123 - `status_details: Optional[str]`
124
125 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.
126
127### Example
128
129```python
130import os
131from openai import OpenAI
132
133client = OpenAI(
134 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
135)
136upload = client.uploads.cancel(
137 "upload_abc123",
138)
139print(upload.id)
140```
141
142#### Response
143
144```json
145{
146 "id": "id",
147 "bytes": 0,
148 "created_at": 0,
149 "expires_at": 0,
150 "filename": "filename",
151 "object": "upload",
152 "purpose": "purpose",
153 "status": "pending",
154 "file": {
155 "id": "id",
156 "bytes": 0,
157 "created_at": 0,
158 "filename": "filename",
159 "object": "file",
160 "purpose": "assistants",
161 "status": "uploaded",
162 "expires_at": 0,
163 "status_details": "status_details"
164 }
165}
166```