Use the Subscribers API to manage subscriptions. With this API, you can programmatically subscribe and unsubscribe users from subscriptions.
Make a call to this endpoint to opt-in a user to a subscription.
Notes:
A legal disclosure is required when a user is opted-in programmatically.
For marketing messages, required legal language must be included.
For transactional messages, you must include a transactional opt-in unit.
By default, if a subscription already exists, it will try and record the attempt to create the subscription again. For TEXT subscriptions, this will result in a message being sent to the person indicating that they are already subscribed.
Requests to opt-in subscribers must either contain a) a sign-up source id or b) both a locale and a subscription type.
The unique identifier of a sign-up source can be found in the Sign-up Units tab of the Attentive platform in the ID column. If this value is provided in the request, then this sign-up unit will be used for opting in the user in the request.
Callers of this endpoint have the option to omit signUpSourceId
and, instead, provide both a locale
and a subscriptionType
(see below for field details).
Given the locale and subscription type, Attentive will resolve any matching API opt-in units. To opt-in a user to a subscription without a signUpSourceId
and exclusively based on locale and subscription type,
there must be exactly one API sign-up unit that matches the provided locale and subscription type. Conversely, requests that contain a locale and a subscription type
that do not have a corresponding sign-up unit or that have multiple matching sign-up units will receive a 400
response and will not opt a user into a subscription.
Phone numbers must be submitted in e164 format.
+19148440001
, +442071838750
, +551155256325
19148440001
, +1---914---844---0001
, 1 () 914 844 0001
subscriptions:write
) required | object (UserDto1) User associated with the action. Note that this is a visitor to the site and does not need to be actively subscribed to Attentive. |
signUpSourceId | string The unique identifier of the sign-up source. This can be found in the Sign-up Units tab of the Attentive platform in the ID column for any API sign-up method. This field is required if locale is not present. Or, you can contact our White Glove team (whiteglove@attentivemobile.com) or your Client Strategy Manager at Attentive to request a sign-up source for either marketing or transactional opt-ins. Our team will review API opt-in units with compliance in mind. |
object (NewExternalIdentifierDto) External Identifiers for a user | |
object (LocaleDto) | |
subscriptionType | string Enum: "MARKETING" "TRANSACTIONAL" |
singleOptIn | boolean Opt in subscriber silently (do not send a Reply Y to subscribe text). NOTE: This property is disabled by default. We strongly recommend maintaining the double opt-in flow. The double opt in serves a couple of important purposes from a legal/compliance perspective. Contact your dedicated Client Strategy Manager (CSM) or our whiteglove@attentivemobile.com team to enable it. If wanting to skip legal/reply y language, set this to be true. We will not send reply y message or legal message to subscribers added with this flag set to true. |
Accepted a create subscription(s) request. The response body will contain info about which subscription(s) already exist, and which subscription(s) will be created (asynchronously).
Invalid parameter in request query or body
Unauthorized
Access Denied
The specified resource was not found
The user has sent too many requests in a given amount of time
Internal Server Error
{- "user": {
- "phone": "+13115552368",
- "email": "test@gmail.com"
}, - "signUpSourceId": "string",
- "externalIdentifiers": {
- "clientUserId": "string",
- "shopifyId": "string",
- "klaviyoId": "string",
- "customIdentifiers": [
- {
- "name": "string",
- "value": "string"
}
]
}, - "locale": {
- "language": "en",
- "country": "US"
}, - "subscriptionType": "MARKETING",
- "singleOptIn": true
}
{- "user": {
- "phone": "+13115552368",
- "email": "test@gmail.com"
}, - "externalIdentifiers": {
- "clientUserId": "string",
- "shopifyId": "string",
- "klaviyoId": "string",
- "customIdentifiers": [
- {
- "name": "string",
- "value": "string"
}
]
}, - "subscriptionResponses": [
- {
- "subscription": {
- "type": "MARKETING",
- "channel": "TEXT"
}, - "subscriptionCreationStatus": "NEWLY_CREATED"
}
]
}
Make a call to this endpoint to list all subscription types and channels a user is subscribed to. You can query for a subscriber using either their phone number or email. One of the query parameters is required in order to look up a subscriber. As an example, you can use this endpoint to check if a subscriber is eligible to receive SMS or email campaigns, and then send them a message based on that eligibility.
subscriptions:write
) Successfully accepted get subscriptions request
Invalid parameter in request query or body
Unauthorized
Access Denied
The specified resource was not found
The user has sent too many requests in a given amount of time
Internal Server Error
curl -i -X GET \ 'https://api.attentivemobile.com/v1/subscriptions?phone=%2B13115552368&email=test%40gmail.com' \ -H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
{- "subscriptionEligibilities": [
- {
- "subscription": {
- "type": "MARKETING",
- "channel": "TEXT"
}, - "eligibility": {
- "isEligible": true
}
}
]
}
Make a call to this endpoint to unsubscribe a user from a subscription type or channel. If no subscriptions are present in the request, the user is unsubscribed from all subscriptions. If subscriptions are present in the request, the user is unsubscribed from the requested type or channel combination. By default, if a subscription exists, but the user is already unsubscribed, it records the attempt to unsubscribe the subscription again. For TEXT subscriptions, a message is sent to the person indicating that they are unsubscribed.
For the user object, the email data point determines which email subscriptions a user has and the phone data point determines which text (or sms) subscriptions a user has. Passing in an email does not locate, nor unsubscribe, a user from any sms subscriptions. Similarly, passing in a phone does not locate, nor unsubscribe, a user from any email subscriptions.
subscriptions:write
) required | object (UserDto1) User associated with the action. Note that this is a visitor to the site and does not need to be actively subscribed to Attentive. |
Array of objects (SubscriptionDto) | |
object (NotificationConfigDto) Optional notification properties to override |
Accepted an unsubscribe subscription(s) request. The response body will contain info about which subscription(s) are already unsubscribed, and which subscription(s) will be unsubscribed (asynchronously).
Invalid parameter in request query or body
Unauthorized
Access Denied
The specified resource was not found
The user has sent too many requests in a given amount of time
Internal Server Error
{- "user": {
- "phone": "+13115552368",
- "email": "test@gmail.com"
}, - "subscriptions": [
- {
- "type": "MARKETING",
- "channel": "TEXT"
}
], - "notification": {
- "language": "string",
- "disabled": true
}
}
{- "user": {
- "phone": "+13115552368",
- "email": "test@gmail.com"
}, - "subscriptionResponses": [
- {
- "subscription": {
- "type": "MARKETING",
- "channel": "TEXT"
}, - "subscriptionUnsubscribeStatus": "NEWLY_UNSUBSCRIBED"
}
]
}