-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update documentation for api/tx to include file attachments and multi…
…ple recipients (#1436)
- Loading branch information
1 parent
acca61f
commit b1fa289
Showing
1 changed file
with
26 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,20 +6,22 @@ | |
|
||
|
||
## POST /api/tx | ||
Send a transactional message to a subscriber using a predefined transactional template. | ||
Send a transactional message to one or multiple subscribers using a predefined transactional template. | ||
|
||
|
||
##### Parameters | ||
| Name | Data Type | Optional | Description | | ||
|:-------------------|:----------|:---------|:----------------------------------------------------------------------------------| | ||
| `subscriber_email` | String | Optional | E-mail of the subscriber. Either this or `subscriber_id` should be passed. | | ||
| `subscriber_id` | Number | Optional | ID of the subscriber. Either this or `subscriber_email` should be passed. | | ||
| `template_id` | Number | Required | ID of the transactional template to use in the message. | | ||
| `from_email` | String | Optional | Optional `from` email. eg: `Company <[email protected]>` | | ||
| `data` | Map | Optional | Optional data in `{}` nested map. Available in the template as `{{ .Tx.Data.* }}` | | ||
| `headers` | []Map | Optional | Optional array of mail headers. `[{"key": "value"}, {"key": "value"}]` | | ||
| `messenger` | String | Optional | Messenger to use to send the message. Default value is `email`. | | ||
| `content_type` | String | Optional | `html`, `markdown`, `plain` | | ||
| Name | Data Type | Optional | Description | | ||
|:--------------------|:----------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `subscriber_email` | String | Optional | E-mail of the subscriber. Either this or `subscriber_id` should be passed. | | ||
| `subscriber_id` | Number | Optional | ID of the subscriber. Either this or `subscriber_email` should be passed. | | ||
| `subscriber_emails` | []String | Optional | E-mails of the subscribers. This is an alternative to `subscriber_email` for multiple recipients. `["[email protected]", "[email protected]"]` | | ||
| `subscriber_ids` | []Number | Optional | IDs of the subscribers. This is an alternative to `subscriber_id` for multiple recipients. `[1,2,3]` | | ||
| `template_id` | Number | Required | ID of the transactional template to use in the message. | | ||
| `from_email` | String | Optional | Optional `from` email. eg: `Company <[email protected]>` | | ||
| `data` | Map | Optional | Optional data in `{}` nested map. Available in the template as `{{ .Tx.Data.* }}` | | ||
| `headers` | []Map | Optional | Optional array of mail headers. `[{"key": "value"}, {"key": "value"}]` | | ||
| `messenger` | String | Optional | Messenger to use to send the message. Default value is `email`. | | ||
| `content_type` | String | Optional | `html`, `markdown`, `plain` | | ||
|
||
|
||
##### Request | ||
|
@@ -43,4 +45,17 @@ EOF | |
} | ||
``` | ||
|
||
### File Attachments | ||
To include file attachments in a transactional message, use Content-Type `multipart/form-data`. | ||
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. | ||
|
||
```shell | ||
curl -u "username:password" "http://localhost:9000/api/tx" -X POST \ | ||
-F 'data=\"{ | ||
\"subscriber_email\": \"[email protected]\", | ||
\"template_id\": 4 | ||
}"' \ | ||
-F 'file=@"/path/to/attachment.pdf"' \ | ||
-F 'file=@"/path/to/attachment2.pdf"' | ||
``` | ||
|