# Add attachment

### Description

This service allows an authenticated operator to upload and attach files to a specific case instance.

***

### Request

#### Restrictions

* Authentication: Requires a successful operator login.
* Content-Type: The request must be sent as `multipart/form-data`.

#### Endpoint

```
POST https://<server-url>/api/v4/cases/{caseInstanceId}/files
```

#### Path Parameters

| **Parameter**    | **Type** | **Description**                                                        |
| ---------------- | -------- | ---------------------------------------------------------------------- |
| `caseInstanceId` | Integer  | The unique ID of the case instance to which the file will be attached. |

#### Parameters

| **Parameter** | **Location**   | **Description**                                                                    |
| ------------- | -------------- | ---------------------------------------------------------------------------------- |
| `touchpoint`  | Query / Header | The identifier for the touchpoint. Use `Thalamus-Touchpoint` for the header.       |
| `token`       | Query / Header | The authentication token for the API session. Use `Thalamus-Token` for the header. |

#### Form Parameters

| **Parameter** | **Type**      | **Description**                                                    |
| ------------- | ------------- | ------------------------------------------------------------------ |
| `file`        | multipartFile | Required. The binary file to be uploaded and attached to the case. |

#### Full URL Example

```
https://<server-url>/api/v4/cases/1/files?touchpoint=test&token=...
```

***

### Response

#### ✅ Successful Response: `200 OK`

Returns the session `context` and an object containing the updated list of `attachments` (including the newly uploaded file).

JSON

```
{  
   "context": {  
      "simpleProfile": {  
         "firstname": "test",
         "lastname": "test",
         "email": "test@test.com"
      }
   },
  "attachments": {
    "attachements": [
      {
        "id": 1,
        "url": "https://thalamus-files.s3.amazonaws.com/Env/Cust/cases/file1.txt"
      },
      {
        "id": 2,
        "url": "https://thalamus-files.s3.amazonaws.com/Env/Cust/cases/file2.csv"
      }
    ]
  }
}
```

#### ❌ Unsuccessful Response: `200 OK` (Logical Failure)

In certain failure scenarios, the API may still return an HTTP 200 status but with a simple text body indicating the failure.

Text

```
FAILED
```
