# PaymentMessage

**Beta:**
Salaxy API v04 is in beta: it may change, and it is not used in production yet. Build on v03, the current version.

Payment messages (maksuaineisto) of the current company: create from invoices, list, download, mark sent, resend, mark paid and cancel. Every call is scoped to the account of the token. The channel's settings decide the actions: GET settings/{channel} returns them. Payment channels use the payment-channel endpoints instead.

Salaxy API v04 (beta), **Finland only**. 6 operations. Interactive version: [REST API reference](https://code.salaxy.com/reference/rest-api-v04.md). Machine-readable: [OpenAPI document](https://code.salaxy.com/openapi/salaxy-04.json).

**The reference wins:**
These pages are generated from the OpenAPI document. If a guide and this reference disagree about a field, follow the reference. Error responses are not in the document — see [Errors](https://code.salaxy.com/reference/errors.md).

## `GET /v04/api/payment-messages/settings/{channel}`

**The company's effective payment-message settings of a channel: the allowed actions, split, format and file name.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `channel` | path | PaymentChannel | yes | Payment channel key. |

Response: `PaymentMessageChannelInfo`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/paymentmessage/GET/v04/api/payment-messages/settings/{channel})

## `POST /v04/api/payment-messages`

**Creates payment messages from the company's unread invoices of one channel, one per split group of the channel's
splitBy, or resends a message with parentMessageId (a child over its unpaid payments). The messages stay new until
downloaded (PATCH status sent).**

Request body: `PaymentMessageCompanyCreateRequest` (required)

Response: `PaymentMessageCompanyCreateResult`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/paymentmessage/POST/v04/api/payment-messages)

## `GET /v04/api/payment-messages`

**The company's payment messages from the search index, newest first unless ordered: summary rows without batches, one
page at a time. The index follows the table about a second later; get, patch and the file read the table.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `channel` | query | PaymentChannel |  | Optional channel filter. |
| `status` | query | string |  | Optional status filter. The status set is open. |
| `$search` | query | string |  |  |
| `$filter` | query | string |  | Specifies the logic to pull back a subset of records. |
| `$orderby` | query | string |  | Specifies the values used to sort the collection of entries. |
| `$select` | query | string |  | The $select system query option allows the clients to requests a limited set of properties for each entry. |
| `$top` | query | number |  | Specifies the subset of entries by count. |
| `$skip` | query | number |  | Specifies the count of entries to skip. |
| `$count` | query | boolean |  | Indicates whether or not to include a total entry count. |

Response: `PageResultOfPaymentMessageListItem`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/paymentmessage/GET/v04/api/payment-messages)

## `GET /v04/api/payment-messages/{id}`

**A payment message with its batches and transaction ids.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Id of the payment message. |

Response: `PaymentMessage`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/paymentmessage/GET/v04/api/payment-messages/{id})

## `PATCH /v04/api/payment-messages/{id}`

**Changes the status: { "status": "sent" } after the company downloaded the file (only where the channel allows
download; its invoices become read), { "status": "cancellationRequested" }, or { "status": "executed" } to mark
it paid where the channel allows it (the invoices become paid). Writing the current status changes nothing.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Id of the payment message. |

Request body: `PaymentMessagePatch` (required)

Response: `PaymentMessage`

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/paymentmessage/PATCH/v04/api/payment-messages/{id})

## `GET /v04/api/payment-messages/{id}/sepa`

**Downloads the stored file under its stored file name. A read: it does not mark the message sent.**

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Id of the payment message. |
| `inline` | query | boolean |  | If true, returns the content inline; else as an attachment. |

Response: The payment message file as text/xml.

Try it: [interactive reference](https://code.salaxy.com/reference/rest-api-v04.md#tag/paymentmessage/GET/v04/api/payment-messages/{id}/sepa)
