To update a contact data in Contact List you need to send POST
Request with your Access Token in headers to the following URL
https://api.smartsender.io/v3/contacts/update
IMPORTANT
Do not send more than 10
concurrent API requests.
Request body:
{
"contactListId": "YOUR_CONTACT_LIST_ID",
"webHookUri": "YOUR_WEBHOOK_URL",
"upsert": false,
"contacts": [
{
"contact": "+15555555",
"name": "John Doe",
"email": "user@example.com",
"phoneNumber": "+15555555",
"userId": "myUserId",
"active": true,
"emailSubscribe": true,
"smsSubscribe": true,
"desktopWebPushSubscribe": true,
"mobileWebPushSubscribe": true,
"telegramSubscribe": true,
"firstName": "John",
"lastName": "Doe",
"contactBirthday": "1990-01-01",
"contactLanguage": "en",
"contactGender ": 2,
"contactTimezone": "Europe/Tallinn",
"contactScore": 100,
"avatarLink": "img.smartsender.io/g/06c38b4568.jpg",
"facebookLink": "facebook.com/smartsender.io",
"instagramLink": "instagram.com/smartsender",
"linkedInLink": "linkedin.com/company/smartsender",
"twitterLink": "twitter.com/smart_sender",
"tiktokLink": "tiktok.com/smartsender",
"sourceId": "Source_ID_from_SmartSender",
"customerSourceId": "Customer_Source_ID_From_Your_Platform",
"cac": {
"value": "2.05",
"currency": "USD"
},
"variables": [
{
"name": "newVariableName",
"value": "newVariableValue"
}
]
}
]
}
Parameters |
contactListId
'required' |
ID of the contact list where the contact to be updated belongs.
The list should be already created in your account on Lists page:
https://partner.smartsender.io/email-list/ |
webHookUri
‘optional’ |
SmartSender will send a POST request to your webHookUri with the status of the request as soon as it is processed. |
upsert
'optional' |
You can set if the contact should be added to the list if it does not exist at the time of the request. |
true
'optional' |
Create new contact if it does not exist |
false
'default' |
Do not create contact if it does not exist |
contacts
'required' |
An array of information on contacts batch you want to update.
IMPORTANT You can update only 100 contacts at once.
IMPORTANT Minimum one unique user identificator (userId | email | phoneNumber ) is required. |
contact
'required' |
The unique user identificator (userId | email | phoneNumber ) of the contact you want to update |
name
'optional' |
The optional display name to use for the recipient |
email
'optional' |
Contact’s email address. |
phoneNumber
'optional' |
IMPORTANT should be valid E.164 phone number format. |
userId
'optional' |
Contact’s unique user ID from your platform to enable management of the contact in the list based on it. |
active
'optional' |
You can set if the contact is enable contact list or not.
The default value is false (disable). |
true
‘optional’ |
Contact enabled. Contact can receive communication from enabled channels. |
false
'default' |
Contact disabled. No communications will be send to this contact. |
emailSubscribe
‘optional’ |
You can set if the contact is subscribed to receiving emails or not.
The default value is false (unsubscribed). |
true
‘optional’ |
Subscribe contact to emails |
false
'default' |
Unsubscribe contact from emails |
smsSubscribe
‘optional’ |
You can set if the contact is subscribed to receiving SMS or not.
The default value is false (unsubscribed). |
true
‘optional’ |
Subscribe contact to SMS |
false
'default' |
Unsubscribe contact from SMS |
desktopWebPushSubscribe
‘optional’ |
You can set if the contact is subscribed to receiving desktop web push notifications or not.
The default value is false (unsubscribed). |
true
‘optional’ |
Subscribe contact to desktop webpush notifications |
false
'default' |
Unsubscribe contact from desktop webpush notifications |
mobileWebPushSubscribe
‘optional’ |
You can set if the contact is subscribed to receiving mobile web push notifications or not.
The default value is false (unsubscribed). |
true
‘optional’ |
Subscribe contact to mobile webpush notifications |
false
'default' |
Unsubscribe contact from mobile webpush notification |
telegramSubscribe
‘optional’ |
You can set if the contact is subscribed to receiving Telegram messages or not.
The default value is false (unsubscribed). |
true
‘optional’ |
Subscribe contact to Telegram messages |
false
'default' |
Unsubscribe contact from Telegram messages |
firstName
‘optional’ |
Contact’s first name |
lastName
‘optional’ |
Contact’s last name |
contactBirthday
‘optional’ |
Contact’s birth date in ENUM_DATE (YYYY-MM-DD) format |
contactLanguage
‘optional’ |
Contact’s locale in ISO 639-1 format |
contactGender
‘optional’ |
Contact’s gender in ISO/IEC 5218 format |
0 |
Not known |
1 |
Male |
2 |
Female |
9 |
Not applicable |
contactTimezone
‘optional’ |
Contact’s timezone in ISO 8601 format |
contactScore
‘optional’ |
Contact Score |
avatarLink
‘optional’ |
Link to contact’s avatar image. |
facebookLink
‘optional’ |
Link to contact’s Facebook profile. |
instagramLink
‘optional’ |
Link to contact’s Instagram profile. |
linkedInLink
‘optional’ |
Link to contact’s LinkedIn profile. |
twitterLink
‘optional’ |
Link to contact’s Twitter profile. |
tiktokLink
‘optional’ |
Link to contact’s TikTok profile. |
variables
‘optional’ |
An array of contact variables and their values. |
name
'required' |
Variable name in lowerCamelCase format
IMPORTANT Please use only latin lowerCamelCase format. No numbers or other symbols allowed. |
value
'required' |
Variable value in 'ENUM_STRING' or 'ENUM_DATE' format correspondingly |
sourceId
‘optional’ |
Contact’s unique source ID from SmartSender platform |
customerSourceId
‘optional’ |
Contact’s unique source ID from your system to synchronize two sides. IMPORTANT If you use sourceId and customerSourceId at the same time, sourceId will have higher priority. |
cac
‘optional’ |
value
'required' |
CAC value in 'ENUM_STRING' format correspondingly |
currency
'required' |
(EUR, USD)
IMPORTANT Please use only latin uppercase format. No numbers or other symbols allowed. |
Response:
{
"result":true,
"requestId":"5d915c22d132d5f45a4e38b8",
"errors":[]
}
Return value |
result |
The value indicates that the contact was successfully added/updated to your contact list. |
true |
Contact was successfully added/updated |
requestId |
Unique request ID to be used to match the specific “Update contact” request with the Status Webhook which will be sent by SmartSender after the request was processed. |
Example Error Response JSON
{
"result":false,
"requestId":"REQUEST_ID",
"errors":[
"Error description text"
]
}
Errors.
The reason for the rejection. |
result |
The rejection acceptance status. |
true |
The request is accepted and queued. The result will be sent via webhook to provided link. |
false |
The request is rejected |
requestId |
Unique request ID to be used to match the specific “Update contact” request with the Status Webhook which will be sent by SmartSender after the request was processed. |
Error description |
“Argument contactListId must be a non-empty string” |
“Argument upsert must be a true or false” |
“Argument webHookUri must be a valid URI” |
“add at least one valid contact to contacts field” |
“Argument contact must be a non-empty string filled with valid email, phoneNumber or userId” |
“Argument name must be a string” |
“invalid RFC2822 email {email} at email field” |
“Argument email must be a string” |
“Argument phoneNumber must be a string” |
“{phoneNumber} is not a valid E.164 phone number” |
“Argument userId must be a string” |
“Argument active can be true or false” |
“Argument emailSubscribe can be true or false” |
“Argument smsSubscribe can be true or false” |
“Argument desktopWebPushSubscribe can be true or false” |
“Argument mobileWebPushSubscribe can be true or false” |
“Argument firstName must be a string”, |
“Argument firstName must be a string with max length within 255 characters” |
“Argument lastName must be a string”, |
“Argument lastName must be a string with max length within 255 characters” |
Argument birthday must be a YYYY-MM-DD date” |
“Argument language must be a valid ISO language” |
“Unknown gender value” |
“Argument timezone must be a valid timezone string” |
“Argument score must have a numeric value” |
“Argument avatarLink must be a valid URL” |
“Argument facebookLink must be a valid URL” |
“Argument instagramLink must be a valid URL” |
“Argument linkedInLink must be a valid URL” |
“Argument twitterLink must be a valid URL” |
“Argument tiktokLink must be a valid URL” |
“Argument variables must be an array of arrays with \”name\” and \”value\ “fields” |
“name of variable must be a string” |
“name of variable can not be empty” |
“variable \”{name}\” is reserved and can not be added as custom variable” |
“invalid name of variable {name}” |
“List with id {contactListId} not found!” |
“email, phoneNumber or externalId\/userId must be filled at contact position {i}” |
“Variable {name} type is date, but value is not valid date. Value {value}” |
“Variable {name} not found in list. Try to add it first” |
“Request saving error. Please, contact us or try again later” |
“Invalid authorization token!” |
“Internal server error” |
“Bad Request” |
“no matches found for access token {accessToken}” |
“user {id} not enabled” |
“no data found for key {userId}” |
“access token check failed for key\/secret $key\/$accessToken” |
“Argument {argument} required” |
“Argument sourceId must be a string” |
“sourceId {sourceId} not found in your account at contact position {i}” |
“Argument customerSourceId must be a string” |
“Argument customerSourceId must be an alphanumeric string with max length within 40 characters” |
“Argument CAC must be an array with value and currency fields” |
“CAC value must be a positive float” |
“CAC currency {currency} not allowed. USD, EUR are” |
Example Request status webhook
If you have provided webHookUri
in your request, SmartSender will send a POST
request to it with the status of the request as soon as it is processed.
Request body
{
"event": "contact_management_request",
"datetime": Unix_Timestamp,
"requestId": "REQUEST_ID",
"results": {
"success": [
{
"id": "SMARTSENDER_CONTACT_ID",
"email": "user@example.com",
"phone": "+15555555",
"userId": "myUserId"
}
],
"errors": [
{
"contact": {
"id": "",
"email": "user+2@example.com",
"phone": "+15555556",
"userId": "myUserId+2"
},
"error": "Error code"
}
]
}
}
Parameters |
event |
Event type: 'contact_management_request' |
datetime |
Request time in Unix_Timestamp format |
requestId |
Unique request ID to be used to match the specific “Add contact” request with the Status Webhook which will be sent by SmartSender after the request was processed. |
results |
success |
“Sucess” status for all successfully processed requests |
id |
Contact ID in SmartSender platform. For informational purposes only. |
email |
Contact’s email address. |
phone |
Contact’s phone number. |
userId |
Contact’s unique user ID from your platform |
errors |
“Errors” for all failed requests with fail reason description. |
contact |
Array of contact information |
id |
Contact ID in SmartSender platform. For informational purposes only. |
email |
Contact’s email address. |
phone |
Contact’s phone number. |
userId |
Contact’s unique user ID from your platform |
errors |
“ERR_EMPTY_IDENTIFIERS” |
“ERR_CONTACT_EXISTS” |
“ERR_CONTACT_DUPLICATION_ATTEMPT” |
“ERR_SYSTEM_ERROR” |
“ERR_CONTACT_NOT_EXISTS” |
“ERR_INVALID_VARIABLE_NAME” |
humanError |
“No identifiers to work with contact” |
“Trying to set all contact’s identifiers empty” |
“Contact already exists” |
“duplication attempt” |
“system error” |
“contact not exists” |
PHP Example
$accessToken = "YOUR_API_KEY";
$url = 'https://api.smartsender.io/v3/contacts/update';
$body = json_encode([
'contactListId' => 'YOUR_CONTACT_LIST_ID',
'webHookUri' => 'YOUR_WEBHOOK_URL',
'upsert' => false,
'contacts' => [
[
"contact" => "+15555555",
"name" => "John Doe",
"email" => "user@example.com",
"phoneNumber" => "+15555555",
"userId" => "myUserId",
"active" => true,
"emailSubscribe" => true,
"smsSubscribe" => true,
"desktopWebPushSubscribe"=> true,
"mobileWebPushSubscribe"=> true,
"firstName" => "John",
"lastName" => "Doe",
"contactBirthday"=> "1990-01-01",
"contactLanguage"=> "en",
"contactGender " => 2,
"contactTimezone"=> "Europe/Tallinn",
"contactScore" => 100,
"avatarLink" => "img.smartsender.io/g/06c38b4568.jpg",
"facebookLink" => "facebook.com/smartsender.io",
"instagramLink" => "instagram.com/smartsender",
"linkedInLink" => "linkedin.com/company/smartsender",
"twitterLink" => "twitter.com/smart_sender",
"tiktokLink" => "tiktok.com/smartsender",
"sourceId" => "5efc8503efeef96ca3151931",
"customerSourceId"=> "mySourceID",
"sourceId" => "5efc8503efeef96ca3151931",
"customerSourceId" => "mySourceId",
"cac" => [
"value" => "2.05",
"currency" => "EUR",
],
"variables" => [
[
"name" => "newVariableName",
"value" => "newVariableValue",
],
],
],
],
]);
/**
* Request Example
*/
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_INFILESIZE, null);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Access-Token: $accessToken",
'Content-Type: application/json',
'Content-Length: ' . strlen($body),
]);
$result = curl_exec($ch);
if ($result === false) {
echo 'cURL error:' . curl_error($ch) . PHP_EOL;
} else {
echo strval($result) . PHP_EOL;
}
curl_close($ch);