Guides & Tutorials

Create and update subscriber(s)

POST /api/contact.php

This endpoint can be used to create or update a single subscriber or multiple subscribers.

Note! This API endpoint does not trigger automation workflows.

Request parameters

Parameter Value
email Subscriber’s email address.

Required.
is_unsubscribed Subscriber’s subscription status.

0 - not unsubscribed, emails will be delivered;
1 - unsubscribed.
is_deleted Delete subscriber.

0 - subscriber is not deleted;
1 - subscriber is deleted from database.

Note! Does not affect unsubscribed status, custom data is purged.
... Custom field.

New fields will be automatically created and attached with subscriber data.

Response parameters

All possible response codes and their descriptions can be found in the “Response codes” page.

Parameter Value
code Response code.
message Human-readable response message.

Examples

Create a subscriber

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"email": "subscriber@domain.tld", "foo": "bar"}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/contact.php"

Bulk create subscribers

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '[{"email": "subscriber+1@domain.tld", "foo": "bar"}, {"email": "subscriber+2@domain.tld", "foo": "baz"}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/contact.php"

Update subscriber’s custom data

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"email": "subscriber@domain.tld", "foo": "baz"}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/contact.php"

Bulk update subscribers

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '[{"email": "subscriber+1@domain.tld", "name": "Andy"}, {"email": "subscriber+2@domain.tld", "name": "Mary"}]' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/contact.php"

Unsubscribe a subscriber

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{"email": "subscriber@domain.tld", "is_unsubscribed": 1}' \
  "https://${SUBDOMAIN}.sendsmaily.net/api/contact.php"

Delete a subscriber

$ curl -X POST -u "${USERNAME}:${PASSWORD}" \
-H "Content-Type: application/json" \
-d '{"email": "subscriber@domain.tld", "is_deleted": 1}' \
"https://${SUBDOMAIN}.sendsmaily.net/api/contact.php"

(JavaScript/JSON)

{
"code": 101,
"message": "OK"
}