Attachment Upload¶
POST /api/v1/attachment/upload
Overview¶
Uploads an attachment to a workspace and returns the attachment identifier, which is used to associate the attachment with a subsequent Issue or Incident comment. This API only uploads files; it does not create comments automatically.
Before You Begin and Usage Steps¶
- Prepare the local file to attach and a workspace API Key with attachment upload permissions. The request uses multipart/form-data with the field name files.
- After a successful upload, save content.attachmentUuid, then put that identifier into the attachmentUuids array of the request body in Create Issue Reply. The upload itself does not append a comment.
- Upload only one file per request, up to 50 MiB. If a request times out, first check whether the attachment has already been created, then decide whether to retry.
Request Headers¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| DF-API-KEY | string | Y | AK identifier, AK uuid Example: <DF-API-KEY>How to obtain or fill in: Create or obtain a Key with permissions for this API in the API Key management of the target workspace. |
File Parameters (multipart/form-data)¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| files | file | Y | Attachment file Maximum size per file: 50M Maximum number of files: 1 Allowed file extensions: ['txt', 'json', 'mp4', 'mov', 'png', 'jpg', 'pdf', 'xls', 'xlsx'] Example: @/path/to/image.pngHow to obtain or fill in: Provide the path of the local file to upload. With curl, use -F and prefix the path with @. |
Additional Parameter Notes¶
- Use
multipart/form-datato upload the actual file binary; the file field name must befiles, and only one file is uploaded per request. - The file part must carry a filename, for example
Content-Disposition: form-data; name="files"; filename="image.png". - Provide
DF-API-KEYin the request headers. Use curl's-For the multipart builder of an HTTP client to generate the Content-Type and boundary automatically. - A single file must not exceed 50 MiB (50 × 1024 × 1024 bytes). For allowed file extensions, see the file parameter table; extension validation is case-insensitive.
- Lark
imageKeycannot be uploaded directly as a file; obtain the image binary first, then upload it with a filename ending in.pngor.jpg. - If the
filesfile is missing, thefilefield is used by mistake, or no filename is provided, HTTP 406 is returned witherrorCodeset toft.ParameterValidationFailed; requests are also rejected when the file extension, size, or count does not meet the requirements.
The content field of a successful response:
| Field | Type | Description |
|---|---|---|
| fileName | string | Original filename at upload time |
| attachmentUuid | string | Attachment identifier, used by subsequent APIs to associate the attachment; note the field name casing |
| fileSuffix | string | Extension of the original filename |
Request Example¶
curl --request POST 'https://openapi.guance.com/api/v1/attachment/upload' \
--header 'DF-API-KEY: <DF-API-KEY>' \
--form 'files=@/path/to/image.png'
Response¶
HTTP 200, application/json. A successful upload returns the attachment metadata. Repeated successful uploads may produce a new attachment identifier.
| Field | Type | Description |
|---|---|---|
| content.fileName | string | Original filename at upload time. |
| content.attachmentUuid | string | Attachment identifier, used in the attachmentUuids array of the Create Issue Reply request. |
| content.fileSuffix | string | File extension recorded by the server. |
{
"code": 200,
"content": {
"fileName": "image.png",
"attachmentUuid": "att_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"fileSuffix": "png"
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE_ID"
}
Error Response¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Handling |
|---|---|---|---|---|
| 406 | ft.ParameterValidationFailed | Missing files, incorrect field name, too many files, unsupported extension, or file over the limit | The message indicates the missing field or the violated rule, such as fileSuffix or limitSize. | Upload one supported file no larger than 50 MiB using the files field. |