Contacts
Upsert Contact
Creates a new contact or updates an existing contact if the email already exists.
POST
/
contacts
/
email
curl --request POST \
--url https://api.autosend.com/v1/contacts/email \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": {
"company": "Acme Corp",
"role": "Developer",
"plan": "premium"
}
}'
import requests
url = "https://api.autosend.com/v1/contacts/email"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": {
"company": "Acme Corp",
"role": "Developer",
"plan": "premium"
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
fetch('https://api.autosend.com/v1/contacts/email', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe',
userId: 'user_12345',
mobile: '+14155552671',
contactProperties: {
company: 'Acme Corp',
role: 'Developer',
plan: 'premium'
}
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
<?php
$url = 'https://api.autosend.com/v1/contacts/email';
$data = [
'email' => 'john.doe@example.com',
'firstName' => 'John',
'lastName' => 'Doe',
'userId' => 'user_12345',
'mobile' => '+14155552671',
'contactProperties' => [
'company' => 'Acme Corp',
'role' => 'Developer',
'plan' => 'premium'
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer <token>',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.autosend.com/v1/contacts/email"
payload := map[string]interface{}{
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": map[string]string{
"company": "Acme Corp",
"role": "Developer",
"plan": "premium",
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class UpsertContact {
public static void main(String[] args) {
try {
URL url = new URL("https://api.autosend.com/v1/contacts/email");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Bearer <token>");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
String jsonInputString = "{\n" +
" \"email\": \"john.doe@example.com\",\n" +
" \"firstName\": \"John\",\n" +
" \"lastName\": \"Doe\",\n" +
" \"userId\": \"user_12345\",\n" +
" \"mobile\": \"+14155552671\",\n" +
" \"contactProperties\": {\n" +
" \"company\": \"Acme Corp\",\n" +
" \"role\": \"Developer\",\n" +
" \"plan\": \"premium\"\n" +
" }\n" +
"}";
try (OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
int status = con.getResponseCode();
System.out.println("Response Status: " + status);
} catch (Exception e) {
e.printStackTrace();
}
}
}
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://api.autosend.com/v1/contacts/email')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path)
request['Authorization'] = 'Bearer <token>'
request['Content-Type'] = 'application/json'
request.body = {
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe',
userId: 'user_12345',
mobile: '+14155552671',
contactProperties: {
company: 'Acme Corp',
role: 'Developer',
plan: 'premium'
}
}.to_json
response = http.request(request)
puts response.body
{
"success": true,
"data": {
"id": "507f1f77bcf86cd799439011",
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": {
"company": "Acme Corp",
"role": "Developer",
"plan": "premium"
},
"listIds": ["507f1f77bcf86cd799439011"],
"segmentIds": [],
"updatedAt": "2024-01-15T10:30:00.000Z",
"createdAt": "2024-01-15T10:30:00.000Z",
"projectId": "229f1f77bcf86cd9273048038"
}
}
curl --request POST \
--url https://api.autosend.com/v1/contacts/email \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": {
"company": "Acme Corp",
"role": "Developer",
"plan": "premium"
}
}'
import requests
url = "https://api.autosend.com/v1/contacts/email"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": {
"company": "Acme Corp",
"role": "Developer",
"plan": "premium"
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
fetch('https://api.autosend.com/v1/contacts/email', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe',
userId: 'user_12345',
mobile: '+14155552671',
contactProperties: {
company: 'Acme Corp',
role: 'Developer',
plan: 'premium'
}
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
<?php
$url = 'https://api.autosend.com/v1/contacts/email';
$data = [
'email' => 'john.doe@example.com',
'firstName' => 'John',
'lastName' => 'Doe',
'userId' => 'user_12345',
'mobile' => '+14155552671',
'contactProperties' => [
'company' => 'Acme Corp',
'role' => 'Developer',
'plan' => 'premium'
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer <token>',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.autosend.com/v1/contacts/email"
payload := map[string]interface{}{
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": map[string]string{
"company": "Acme Corp",
"role": "Developer",
"plan": "premium",
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class UpsertContact {
public static void main(String[] args) {
try {
URL url = new URL("https://api.autosend.com/v1/contacts/email");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Bearer <token>");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
String jsonInputString = "{\n" +
" \"email\": \"john.doe@example.com\",\n" +
" \"firstName\": \"John\",\n" +
" \"lastName\": \"Doe\",\n" +
" \"userId\": \"user_12345\",\n" +
" \"mobile\": \"+14155552671\",\n" +
" \"contactProperties\": {\n" +
" \"company\": \"Acme Corp\",\n" +
" \"role\": \"Developer\",\n" +
" \"plan\": \"premium\"\n" +
" }\n" +
"}";
try (OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
int status = con.getResponseCode();
System.out.println("Response Status: " + status);
} catch (Exception e) {
e.printStackTrace();
}
}
}
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://api.autosend.com/v1/contacts/email')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path)
request['Authorization'] = 'Bearer <token>'
request['Content-Type'] = 'application/json'
request.body = {
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe',
userId: 'user_12345',
mobile: '+14155552671',
contactProperties: {
company: 'Acme Corp',
role: 'Developer',
plan: 'premium'
}
}.to_json
response = http.request(request)
puts response.body
{
"success": true,
"data": {
"id": "507f1f77bcf86cd799439011",
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": {
"company": "Acme Corp",
"role": "Developer",
"plan": "premium"
},
"listIds": ["507f1f77bcf86cd799439011"],
"segmentIds": [],
"updatedAt": "2024-01-15T10:30:00.000Z",
"createdAt": "2024-01-15T10:30:00.000Z",
"projectId": "229f1f77bcf86cd9273048038"
}
}
This is the recommended endpoint for most contact synchronization scenarios.
Authorizations
Bearer authentication header of the form Bearer
<token>, where <token> is your auth token.Body
Contact information to create or updateFor the optional fields
firstName, lastName, userId, and mobile, sending an empty string ("") clears the stored value on an existing contact. Sending null or omitting the field leaves the current value unchanged.Valid email address (automatically normalized to lowercase)Example:
"john.doe@example.com"Contact’s first nameSend an empty string (
"") to clear this field on an existing contact. Sending null or omitting it leaves the current value unchanged.Example: "John"Contact’s last nameSend an empty string (
"") to clear this field on an existing contact. Sending null or omitting it leaves the current value unchanged.Example: "Doe"An optional reference field to store your application’s user ID. Use this to map your internal users to AutoSend contacts.Send an empty string (
"") to clear this field on an existing contact. Sending null or omitting it leaves the current value unchanged.Example: "user_12345"Contact’s mobile number in E.164 format.Send an empty string (
"") to clear this field on an existing contact. Sending null or omitting it leaves the current value unchanged.Example: "+14155552671"IDs of the contact lists to add this contact to. You can find list IDs in your AutoSend Dashboard.Do not pass segment IDs here. Segments are computed automatically based on contact field values. Adding a contact to a list will also trigger any live automations associated with that list.Example:
["507f1f77bcf86cd799439011"]Key-value pairs for custom contact attributes. There are four supported value types:
string, number, boolean, and date. Learn more about contact properties.Example:contactProperties: {
"company": "Acme Corp",
"isPremium": true,
"loginCount": 42,
"trialEndsAt": "2024-03-01"
}
Response
Contact created or updated successfullyShow child attributes
Show child attributes
Was this page helpful?
⌘I
curl --request POST \
--url https://api.autosend.com/v1/contacts/email \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": {
"company": "Acme Corp",
"role": "Developer",
"plan": "premium"
}
}'
import requests
url = "https://api.autosend.com/v1/contacts/email"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": {
"company": "Acme Corp",
"role": "Developer",
"plan": "premium"
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
fetch('https://api.autosend.com/v1/contacts/email', {
method: 'POST',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe',
userId: 'user_12345',
mobile: '+14155552671',
contactProperties: {
company: 'Acme Corp',
role: 'Developer',
plan: 'premium'
}
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
<?php
$url = 'https://api.autosend.com/v1/contacts/email';
$data = [
'email' => 'john.doe@example.com',
'firstName' => 'John',
'lastName' => 'Doe',
'userId' => 'user_12345',
'mobile' => '+14155552671',
'contactProperties' => [
'company' => 'Acme Corp',
'role' => 'Developer',
'plan' => 'premium'
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer <token>',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.autosend.com/v1/contacts/email"
payload := map[string]interface{}{
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": map[string]string{
"company": "Acme Corp",
"role": "Developer",
"plan": "premium",
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class UpsertContact {
public static void main(String[] args) {
try {
URL url = new URL("https://api.autosend.com/v1/contacts/email");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Authorization", "Bearer <token>");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
String jsonInputString = "{\n" +
" \"email\": \"john.doe@example.com\",\n" +
" \"firstName\": \"John\",\n" +
" \"lastName\": \"Doe\",\n" +
" \"userId\": \"user_12345\",\n" +
" \"mobile\": \"+14155552671\",\n" +
" \"contactProperties\": {\n" +
" \"company\": \"Acme Corp\",\n" +
" \"role\": \"Developer\",\n" +
" \"plan\": \"premium\"\n" +
" }\n" +
"}";
try (OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
int status = con.getResponseCode();
System.out.println("Response Status: " + status);
} catch (Exception e) {
e.printStackTrace();
}
}
}
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://api.autosend.com/v1/contacts/email')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path)
request['Authorization'] = 'Bearer <token>'
request['Content-Type'] = 'application/json'
request.body = {
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe',
userId: 'user_12345',
mobile: '+14155552671',
contactProperties: {
company: 'Acme Corp',
role: 'Developer',
plan: 'premium'
}
}.to_json
response = http.request(request)
puts response.body
{
"success": true,
"data": {
"id": "507f1f77bcf86cd799439011",
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"userId": "user_12345",
"mobile": "+14155552671",
"contactProperties": {
"company": "Acme Corp",
"role": "Developer",
"plan": "premium"
},
"listIds": ["507f1f77bcf86cd799439011"],
"segmentIds": [],
"updatedAt": "2024-01-15T10:30:00.000Z",
"createdAt": "2024-01-15T10:30:00.000Z",
"projectId": "229f1f77bcf86cd9273048038"
}
}