---
title: "Create new attachment"
method: POST
path: "/attachments"
tags: ["Attachments"]
---

# Create new attachment

`POST /attachments`

Finalize new attachment creation after the initial call to generate_presigned_url.
The is the 3rd call made by the client in the creation flow 
(1st is generating a presigned URL, 2nd - uploading the object to storage using the presigned URL).

## Request body

- CreateAttachmentRequest
  - `extension` string, required — An Attachment extension (e.g. png, jpg)
  - `source` string, required — A source identifier (service_request)
  - `resourceId` integer, required — The id of a resource, to which the attachment is added
  - `resourceType` 'SR' | 'TEMPLATE' | 'AI_CHAT' | 'AI_DATASET', required — The resource type tells to which resource the attachment is attached to. All SR types are mapped to SR.
  - `subResourceId` integer, required — The id of a subresource, to which the attachment is added
  - `subResourceType` 'TEMP' | 'SR' | 'NOTE' | 'MESSAGE' | 'SOLUTION' | 'RESOLUTION' | 'DESCRIPTION' | 'AI_CHAT_MESSAGE' | 'AI_DATASET_REC', required
  - `sizeInBytes` integer, required — Size of the added attachment is bytes
  - `checksum` string, required — The checksum that will be used for detecting an identical image in the same ticket of the same type
  - `originalName` string, required — Attachment file name
  - `visibility` boolean — Defines whether the added attachment should be visible after creation
  - `path` string — Path under which the attachment will be stored (e.g. on S3)
  - `generatedFileName` string — Unique attachment file identifier

## Response `200`

Attachment successfully created

- CreateAttachmentResponse
  - `metadata` CreatedAttachmentMetadata, required
    - `extension` string, required — An Attachment extension (e.g. png, jpg)
    - `source` string, required — A source identifier (service_request)
    - `resourceId` integer, required — The id of a resource, to which the attachment is added
    - `resourceType` 'SR' | 'TEMPLATE' | 'AI_CHAT' | 'AI_DATASET', required — The resource type tells to which resource the attachment is attached to. All SR types are mapped to SR.
    - `subResourceId` integer, required — The id of a subresource, to which the attachment is added
    - `subResourceType` 'TEMP' | 'SR' | 'NOTE' | 'MESSAGE' | 'SOLUTION' | 'RESOLUTION' | 'DESCRIPTION' | 'AI_CHAT_MESSAGE' | 'AI_DATASET_REC', required
    - `originalName` string, required — Attachment file name
    - `visibility` boolean — Defines whether the added attachment should be visible after creation
    - `id` integer, required — Id of the created attachment
    - `createdDate` string, date-time, required — Attachment creation date and time
    - `userName` string, required — Username of the user, who has created the attachment
    - `fileId` integer, nullable — Id of the attachment file on the server filesystem (for backward compatibility with Classic environment)
  - `presignedUrl` string, uri, required

## Other responses

- `400` — The request was invalid or cannot be served
- `401` — Authentication information is missing or invalid

---

[API](https://skmtc.net/sysaid/apis/sysaid-public-api.md) · [All operations](https://skmtc.net/sysaid/apis/sysaid-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/sysaid/sysaid-public-api/revisions/38a43a1b2981/schema)
