6.4.Upload an attachment — POST /v1/ats/posts/:post_id/attachments

6.4.Upload an attachment — POST /v1/ats/posts/:post_id/attachments

Uploads a new file and attaches it to the specified post. Unlike other write endpoints, this endpoint uses multipart/form-data encoding rather than JSON, because it must transport a binary file payload.

Form fields:

file (file, required)

The file to upload. The server validates the file against the allowed MIME types and maximum size configured in the ATS component options.

post_id (integer, required unless in URL)

ID of the post to attach the file to. When using the nested route (/v1/ats/posts/:post_id/attachments) the value is taken from the URL segment and this form field is optional.

Note

Do not set a Content-Type: application/json header on this request. The Content-Type must be multipart/form-data (including the boundary parameter) so that the server can parse the file part correctly.

Example request:

POST /api/index.php/v1/ats/posts/101/attachmentsAuthorization: Bearer <token>Accept: application/vnd.api+jsonContent-Type: multipart/form-data; boundary=----Boundary7MA4YWxkTrZu0gW------Boundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name="post_id"101------Boundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name="file"; filename="screenshot.png"Content-Type: image/png<binary file data>------Boundary7MA4YWxkTrZu0gW--

HTTP codes:

200 OK

File uploaded successfully. Returns the newly created attachment resource (the response format is the same as GET /v1/ats/attachments/:id).

400 Bad Request

No file was received in the request, or the upload failed (e.g. the file type is not allowed, or the file exceeds the maximum size).

{  "errors": [    {      "title": "No file was uploaded.",      "detail": "",      "status": "400"    }  ]}
403 Forbidden

The API user does not have attachment upload permission on the post's ticket category, or the post does not exist.