Add or update a subscriber
On this page
POST
/v1/subscribersupsert_subscriber| Risk | write |
| Authentication | API key or OAuth access token |
| Scopes | subscribers:write |
| Idempotency | supported: send an Idempotency-Key header to make retries safe |
| Dry run | yes: add dry_run=true to the query |
| Success status | 200 |
| Response type | application/json |
What it does#
- Use when: A reader signs up on your site or store; double_opt_in is the default.
- Do not use when: the reader unsubscribed or bounced (it cannot be re-added), or you add many (call bulk_upsert_subscribers).
- Side effects: Creates the subscriber; Queues one confirmation email unless already_confirmed.
- Reversible: Yes, call unsubscribe_subscriber.
- Required scope: subscribers:write.
- Idempotency: supported (Idempotency-Key header).
- Typical next step: call get_subscriber or add_subscriber_tags.
Scopes#
subscribers:write: Add subscribers with double opt-in, update them, unsubscribe them, and change their lists and tags.
Side effects#
- Creates the subscriber
- Queues one confirmation email unless already_confirmed
Request#
Path parameters#
None.
Query parameters#
None.
Every mutation also accepts dry_run=true: it runs every check and returns {"dry_run": true, "would": {...}} without writing anything.
Body (application/json)#
| Field | Type | Required | Description |
|---|---|---|---|
email | string, max 254 characters | yes | |
name | string, max 400 characters | no | |
confirmation | one of "double_opt_in", "already_confirmed", default "double_opt_in" | no | |
consent | object | no | |
consent.collected_at | string (date-time) | yes | |
consent.method | one of "signup_form", "reader_magnet", "store_or_checkout", "in_person", "other" | yes | |
consent.source_url | string (uri), max 2048 characters | no | |
consent.notice_text | string, max 1000 characters | no | |
lists | array of string, max 100 characters, max 50 items | no | |
tags | array of string, max 50 characters, max 20 items | no |
Response#
| Field | Type | Required | Description |
|---|---|---|---|
status | one of "added_pending", "confirmation_resent", "added_confirmed", "updated", "already_subscribed", "already_pending", "cannot_resubscribe", "invalid", "plan_limit", "daily_limit", "unavailable" | yes | |
email | string | yes | |
message | string | yes | |
code | string | no | |
subscriber_id | string | no |
Examples#
double opt-in#
Request:
curl -X POST 'https://api.seemly.com/v1/subscribers' \
-H "Authorization: Bearer $SEEMLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"name": "Sam Reader",
"lists": [
"Main list"
],
"tags": [
"store-buyer"
]
}'const response = await fetch("https://api.seemly.com/v1/subscribers", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SEEMLY_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"email": "[email protected]",
"name": "Sam Reader",
"lists": [
"Main list"
],
"tags": [
"store-buyer"
]
}),
});
const result = await response.json();
console.log(response.status, result);import os
import requests
response = requests.post(
"https://api.seemly.com/v1/subscribers",
headers={
"Authorization": f"Bearer {os.environ['SEEMLY_API_KEY']}",
},
json={
"email": "[email protected]",
"name": "Sam Reader",
"lists": [
"Main list",
],
"tags": [
"store-buyer",
],
},
)
print(response.status_code, response.json())Response: 200:
{
"status": "added_pending",
"email": "[email protected]",
"message": "Added. A confirmation email is on its way. They stay pending until they click it.",
"subscriber_id": "sub_0123456789abcdefghjkmnpq"
}Errors#
Every error is an application/problem+json body with a code, a fix sentence and next_actions. See reading a problem response.