A site sends people from its own forms into your newsletter lists: a sign-up on the site becomes a subscriber in mailrust, with the same double opt-in as the list's own form.
Your lists
curl https://mail.example.com/api/v1/lists -H "Authorization: Bearer mr_..."
{
"ok": true,
"lists": [
{ "key": "37d85e995ab83f16be7f", "name": "Weekly news", "confirm": true, "subscribers": 20 }
]
}
key names the list in the requests below. confirm tells whether new people confirm by email first.
Add a subscriber
curl https://mail.example.com/api/v1/subscribers \
-H "Authorization: Bearer mr_..." \
-H "Content-Type: application/json" \
-d '{
"list": "37d85e995ab83f16be7f",
"email": "ben@example.com",
"name": "Ben",
"tags": ["website", "trial"],
"fields": { "plan": "trial" }
}'
| Field | What it is |
|---|---|
list (required) | The list's key |
email (required) | The address |
name | Up to 200 characters |
tags | A list of tags, or one string separated by spaces; up to 20 |
fields | Your own fields: up to 30, each a string, a number or true/false, used in the list's emails |
confirmed | true when the person already confirmed on your side; skips the confirmation email |
{ "ok": true, "status": "pending" }
| Status | Meaning |
|---|---|
pending | A confirmation email went out; the person joins once they press the link |
active | The person is on the list |
exists | The person was already on the list |
gone | The person unsubscribed earlier and is not added back without them |
suppressed | The address bounced or complained before |
A list takes up to 600 new people an hour through the API, because each of them gets an email. Import a ready base as a file in the list instead.
Unsubscribe
curl -X DELETE https://mail.example.com/api/v1/subscribers \
-H "Authorization: Bearer mr_..." \
-H "Content-Type: application/json" \
-d '{ "list": "37d85e995ab83f16be7f", "email": "ben@example.com" }'
{ "ok": true, "status": "unsubscribed" }
| Status | Meaning |
|---|---|
unsubscribed | Done |
gone | The person had already left |
absent | The address is not on the list |