## Create or replace a transaction type (tenant:settings:write)

`PUT /api/trade/v1/sales/transaction-types/{code}`

Module: Trade · operationId: `upsertTransactionType` · Tag: Transaction types · Auth: access token (`Authorization: Bearer <accessToken>`)

The code comes from the path. All fields are replaced, including `isActive` and `sortOrder` (omitted values store `false` / `0`). `label` defaults to the code.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `code` | path | string | yes | Type code (upper-cased when stored). |

### Request body

`application/json` (required)

- `code` (string, read-only): Taken from the path on PUT.
- `createdAt` (string (date-time), read-only): When the type was created.
- `customerNo` (string, read-only): Customer number of the tenant.
- `direction` (string): Case-insensitive on input. (one of `IN`, `OUT`)
- `eInvoiceCode` (string): UNTDID 1001 document type code (BT-3) of e-invoices of this type, or empty; unique per tenant. Inbound e-invoices are filed under the IN type with their code.
- `isActive` (boolean): The type can be used for new documents.
- `label` (string): Display name of the type.
- `metadata` (object): Free-form metadata.
- `numberPrefix` (string): Prefix of the document numbers.
- `sortOrder` (integer): Sort order (ascending).
- `tenantName` (string, read-only): Name of the tenant.
- `updatedAt` (string (date-time), read-only): When the type was last changed.

Example:

```json
{
  "direction": "OUT",
  "eInvoiceCode": "",
  "isActive": true,
  "label": "Retoure",
  "numberPrefix": "RT",
  "sortOrder": 90
}
```

### Responses

- **200** Saved (`application/json`)
- **400** `direction` is not `IN`/`OUT` or `eInvoiceCode` is not one to three digits (`fields` names the field). (`application/json`)
- **401** No valid session or bearer token (no body).
- **403** Missing permission, no active tenant in the token, or a missing CSRF token on a cookie write. (`application/json`)
- **409** Another type of the tenant owns this e-invoice code. (`application/json`)

Fields of the 200 answer:

- `code` (string, read-only): Taken from the path on PUT.
- `createdAt` (string (date-time), read-only): When the type was created.
- `customerNo` (string, read-only): Customer number of the tenant.
- `direction` (string): Case-insensitive on input. (one of `IN`, `OUT`)
- `eInvoiceCode` (string): UNTDID 1001 document type code (BT-3) of e-invoices of this type, or empty; unique per tenant. Inbound e-invoices are filed under the IN type with their code.
- `isActive` (boolean): The type can be used for new documents.
- `label` (string): Display name of the type.
- `metadata` (object): Free-form metadata.
- `numberPrefix` (string): Prefix of the document numbers.
- `sortOrder` (integer): Sort order (ascending).
- `tenantName` (string, read-only): Name of the tenant.
- `updatedAt` (string (date-time), read-only): When the type was last changed.

Example 200 answer:

```json
{
  "code": "INBOUND_CREDIT_NOTE",
  "createdAt": "2026-09-01T07:00:00Z",
  "customerNo": "99999",
  "direction": "IN",
  "eInvoiceCode": "381",
  "isActive": true,
  "label": "Eingangsgutschrift",
  "metadata": {},
  "numberPrefix": "EG",
  "sortOrder": 75,
  "tenantName": "DEMO",
  "updatedAt": "2026-11-10T14:20:00Z"
}
```

### Example request

```bash
curl -X PUT 'https://api.mbcom.cloud/api/trade/v1/sales/transaction-types/RETURN' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"direction":"OUT","eInvoiceCode":"","isActive":true,"label":"Retoure","numberPrefix":"RT","sortOrder":90}'
```
