Skip to content

Commit b1fa289

Browse files
update documentation for api/tx to include file attachments and multiple recipients (#1436)
1 parent acca61f commit b1fa289

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

docs/docs/content/apis/transactional.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@
66

77

88
## 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.
1010

1111

1212
##### 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` |
2325

2426

2527
##### Request
@@ -43,4 +45,17 @@ EOF
4345
}
4446
```
4547

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+
```
4661

0 commit comments

Comments
 (0)