# Transactions Service API

Base URL: `https://interact-uat.hsbc.com/yi-transactions-service/`

### POST /v1/test-transactions

**Add or replace a seeded transaction**

Adds a transaction to the in-memory test store. Supplying an existing `index` for the same customer and account replaces that entry in place. This endpoint is intended for development and testing only and does not require authentication.

#### Request body

Content type: `application/json`

| Field | Type | Description |
|---|---|---|
| `customerId` | string *(required)* | Customer identifier used to scope the seed store. |
| `accountId` | string *(required)* | Account identifier used to scope the seed store. |
| `currency` | string | Currency used to label mapped Amount.Currency values. |
| `index` | integer | Optional positive index. Reusing an index replaces that entry in place. |
| `transaction` | object *(required)* | Raw HSBCnet stmtTranList entry. It must contain crDbInd, amt, and either postDate or bosPostDt. |


#### Responses

- **200** — Transaction added or replaced successfully
- **400** — Invalid test-store request.
- **401** — Unauthorized — authentication credentials missing or invalid
- **403** — Forbidden — insufficient permissions for this resource
- **500** — Internal server error


#### Examples

```bash
curl -X POST "https://interact-uat.hsbc.com/yi-transactions-service/v1/test-transactions" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'
```

```javascript
const response = await fetch("https://interact-uat.hsbc.com/yi-transactions-service/v1/test-transactions", {
  method: "POST",
  headers: {
      "Authorization": "Bearer YOUR_TOKEN"
  },
  body: JSON.stringify({ /* ... */ }),
});

const data = await response.json();
```

```python
import requests

url = "https://interact-uat.hsbc.com/yi-transactions-service/v1/test-transactions"
headers = {
    "Authorization": "Bearer YOUR_TOKEN",
}

response = requests.post(url, headers=headers, json={
    # ...
})
print(response.json())
```

```java
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://interact-uat.hsbc.com/yi-transactions-service/v1/test-transactions"))
    .header("Authorization", "Bearer YOUR_TOKEN")
    .POST(HttpRequest.BodyPublishers.ofString("{ ... }"))
    .build();

HttpResponse<String> response = client.send(
    request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

#### Example response

```json
{
  "message": "Transaction added"
}
```

