|
6 | 6 |
|
7 | 7 |
|
8 | 8 | ## POST /api/tx
|
9 |
| -Send a transactional message to a subscriber using a predefined transactional template. |
| 9 | +Send a transactional message to one or multiple subscribers using a predefined transactional template. |
10 | 10 |
|
11 | 11 |
|
12 | 12 | ##### Parameters
|
13 |
| -| Name | Data Type | Optional | Description | |
14 |
| -|:-------------------|:----------|:---------|:----------------------------------------------------------------------------------| |
15 |
| -| `subscriber_email` | String | Optional | E-mail of the subscriber. Either this or `subscriber_id` should be passed. | |
16 |
| -| `subscriber_id` | Number | Optional | ID of the subscriber. Either this or `subscriber_email` should be passed. | |
17 |
| -| `template_id` | Number | Required | ID of the transactional template to use in the message. | |
18 |
| -| `from_email` | String | Optional | Optional `from` email. eg: `Company <[email protected]>` | |
19 |
| -| `data` | Map | Optional | Optional data in `{}` nested map. Available in the template as `{{ .Tx.Data.* }}` | |
20 |
| -| `headers` | []Map | Optional | Optional array of mail headers. `[{"key": "value"}, {"key": "value"}]` | |
21 |
| -| `messenger` | String | Optional | Messenger to use to send the message. Default value is `email`. | |
22 |
| -| `content_type` | String | Optional | `html`, `markdown`, `plain` | |
| 13 | +| Name | Data Type | Optional | Description | |
| 14 | +|:--------------------|:----------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------| |
| 15 | +| `subscriber_email` | String | Optional | E-mail of the subscriber. Either this or `subscriber_id` should be passed. | |
| 16 | +| `subscriber_id` | Number | Optional | ID of the subscriber. Either this or `subscriber_email` should be passed. | |
| 17 | +| `subscriber_emails` | []String | Optional | E-mails of the subscribers. This is an alternative to `subscriber_email` for multiple recipients. `["[email protected]", "[email protected]"]` | |
| 18 | +| `subscriber_ids` | []Number | Optional | IDs of the subscribers. This is an alternative to `subscriber_id` for multiple recipients. `[1,2,3]` | |
| 19 | +| `template_id` | Number | Required | ID of the transactional template to use in the message. | |
| 20 | +| `from_email` | String | Optional | Optional `from` email. eg: `Company <[email protected]>` | |
| 21 | +| `data` | Map | Optional | Optional data in `{}` nested map. Available in the template as `{{ .Tx.Data.* }}` | |
| 22 | +| `headers` | []Map | Optional | Optional array of mail headers. `[{"key": "value"}, {"key": "value"}]` | |
| 23 | +| `messenger` | String | Optional | Messenger to use to send the message. Default value is `email`. | |
| 24 | +| `content_type` | String | Optional | `html`, `markdown`, `plain` | |
23 | 25 |
|
24 | 26 |
|
25 | 27 | ##### Request
|
|
43 | 45 | }
|
44 | 46 | ```
|
45 | 47 |
|
| 48 | +### File Attachments |
| 49 | +To include file attachments in a transactional message, use Content-Type `multipart/form-data`. |
| 50 | +Use the parameters described above as a JSON object via the `data` form key and include an arbitrary number of attachments via the `file` key. |
| 51 | + |
| 52 | +```shell |
| 53 | +curl -u "username:password" "http://localhost:9000/api/tx" -X POST \ |
| 54 | +-F 'data=\"{ |
| 55 | + \"subscriber_email\": \"[email protected]\", |
| 56 | + \"template_id\": 4 |
| 57 | +}"' \ |
| 58 | +-F 'file=@"/path/to/attachment.pdf"' \ |
| 59 | +-F 'file=@"/path/to/attachment2.pdf"' |
| 60 | +``` |
46 | 61 |
|
0 commit comments