Attachment Upload¶
POST /api/v1/attachment/upload
Overview¶
Uploads an attachment to the workspace and returns the attachment identifier, which can be used to associate the attachment with a subsequent Issue or Incident comment. This endpoint only uploads the file; it does not create a comment 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 add the identifier to the attachmentUUIDs array in the request of Add Incident Comment. The upload itself does not append a comment.
- Upload only one file per request, up to 50 MiB. If the request times out, first check whether the attachment was already created before deciding to upload again.
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 endpoint 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: Enter 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 may be uploaded per request. - The file part must include a file name, for example
Content-Disposition: form-data; name="files"; filename="image.png". - Provide
DF-API-KEYin the request headers. Use curl-For the multipart builder of your HTTP client to generate the Content-Type and boundary automatically. - A single file must not exceed 50 MiB (50 × 1024 × 1024 bytes). Allowed file extensions are listed in the file parameter table; extension validation is case-insensitive.
- A Lark
imageKeycannot be uploaded directly as a file; first obtain the image binary, then upload it with a file name ending in.pngor.jpg. - If the
filesfile is missing, thefilefield is used by mistake, or no file name 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.
content field of a successful response:
| Field | Type | Description |
|---|---|---|
| fileName | string | Original file name at upload time |
| attachmentUuid | string | Attachment identifier, used by subsequent endpoints to associate the attachment; note the field name casing |
| fileSuffix | string | Suffix of the original file name |
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. Repeating a successful upload may produce a new attachment identifier.
| Field | Type | Description |
|---|---|---|
| content.fileName | string | Original file name at upload time. |
| content.attachmentUuid | string | Attachment identifier, used in the attachmentUUIDs array of the Add Incident Comment request. |
| content.fileSuffix | string | File suffix 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. |