Skip to main content
POST
/
customer_identities
/
create_or_update
Create or update a customer identity
curl --request POST \
  --url https://api.smile.io/v1/customer_identities/create_or_update \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "customer_identity": {
    "email": "jane@doe.com",
    "distinct_id": "cust_19238475",
    "first_name": "Jane",
    "last_name": "Doe",
    "properties": {}
  }
}
'
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.smile.io/v1/customer_identities/create_or_update"

payload := strings.NewReader("{\n \"customer_identity\": {\n \"email\": \"jane@doe.com\",\n \"distinct_id\": \"cust_19238475\",\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"properties\": {}\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.smile.io/v1/customer_identities/create_or_update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_identity\": {\n \"email\": \"jane@doe.com\",\n \"distinct_id\": \"cust_19238475\",\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"properties\": {}\n }\n}")
.asString();
const url = 'https://api.smile.io/v1/customer_identities/create_or_update';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_identity: {
email: 'jane@doe.com',
distinct_id: 'cust_19238475',
first_name: 'Jane',
last_name: 'Doe',
properties: {}
}
})
};

fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.smile.io/v1/customer_identities/create_or_update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_identity' => [
'email' => 'jane@doe.com',
'distinct_id' => 'cust_19238475',
'first_name' => 'Jane',
'last_name' => 'Doe',
'properties' => [

]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
$headers=@{}
$headers.Add("Authorization", "Bearer <token>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://api.smile.io/v1/customer_identities/create_or_update' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"customer_identity": {
"email": "jane@doe.com",
"distinct_id": "cust_19238475",
"first_name": "Jane",
"last_name": "Doe",
"properties": {}
}
}'
import requests

url = "https://api.smile.io/v1/customer_identities/create_or_update"

payload = { "customer_identity": {
"email": "jane@doe.com",
"distinct_id": "cust_19238475",
"first_name": "Jane",
"last_name": "Doe",
"properties": {}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
require 'uri'
require 'net/http'

url = URI("https://api.smile.io/v1/customer_identities/create_or_update")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_identity\": {\n \"email\": \"jane@doe.com\",\n \"distinct_id\": \"cust_19238475\",\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"properties\": {}\n }\n}"

response = http.request(request)
puts response.read_body
{
  "customer_identity": {
    "id": 863291377,
    "first_name": "Jane",
    "last_name": "Doe",
    "email": "jane@doe.com",
    "distinct_id": "cust_19238475",
    "properties": {},
    "customer_id": 123
  }
}
{
"customer_identity": {
"id": 863291377,
"first_name": "Jane",
"last_name": "Doe",
"email": "jane@doe.com",
"distinct_id": "cust_19238475",
"properties": {},
"customer_id": 123
}
}
This endpoint requires the scope.
This endpoint is only available to apps making calls using an OAuth token. Attempting to use this endpoint with an API key will fail.
Creating: If no customer identity exists with the provided distinct_id, a new customer identity is created.
  • If the provided email matches an existing customer record, the customer identity is linked to that customer.
  • If the provided email does not match an existing customer record, a new customer is created and a customer identity is linked to the new customer.
Updating: If a customer identity exists with the provided distinct_id, it is updated with any new information provided in the request.
  • No changes to the linked customer record will occur.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
customer_identity
object
required

Response

Customer identity successfully updated.

customer_identity
object