cURL
curl -X POST https://api.retain.so/identify \
-H "Content-Type: application/json" \
-H "Authorization: Basic $RETAIN_WRITE_KEY" \
-d '{
"userId": "user_123",
"email": "[email protected]",
"properties": {
"name": "Jane Doe",
"avatar": "https://example.com/avatar.jpg"
}
}'import { Retain } from '@retain-so/sdk';
const retain = new Retain(process.env.RETAIN_WRITE_KEY);
retain.identify({
userId: 'user_123',
email: '[email protected]',
properties: {
name: 'Jane Doe',
avatar: 'https://example.com/avatar.jpg',
// Add anything else about the user here
},
});import os
import requests
requests.post(
'https://api.retain.so/identify',
headers={
'Content-Type': 'application/json',
'Authorization': f'Basic {os.environ["RETAIN_WRITE_KEY"]}',
},
json={
'userId': 'user_123',
'email': '[email protected]',
'properties': {
'name': 'Jane Doe',
'avatar': 'https://example.com/avatar.jpg',
},
},
)<?php
$payload = json_encode([
'userId' => 'user_123',
'email' => '[email protected]',
'properties' => [
'name' => 'Jane Doe',
'avatar' => 'https://example.com/avatar.jpg',
],
]);
$ch = curl_init('https://api.retain.so/identify');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Basic ' . getenv('RETAIN_WRITE_KEY'),
],
CURLOPT_POSTFIELDS => $payload,
]);
curl_exec($ch);
curl_close($ch);require 'net/http'
require 'json'
uri = URI('https://api.retain.so/identify')
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/json'
req['Authorization'] = "Basic #{ENV.fetch('RETAIN_WRITE_KEY')}"
req.body = {
userId: 'user_123',
email: '[email protected]',
properties: {
name: 'Jane Doe',
avatar: 'https://example.com/avatar.jpg',
},
}.to_json
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String json = """
{
"userId": "user_123",
"email": "[email protected]",
"properties": {
"name": "Jane Doe",
"avatar": "https://example.com/avatar.jpg"
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.retain.so/identify"))
.header("Content-Type", "application/json")
.header("Authorization", "Basic " + System.getenv("RETAIN_WRITE_KEY"))
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());{
"success": true
}{
"message": "email must be a valid email address",
"statusCode": 400,
"name": "validation_error"
}{
"message": "Missing or invalid Project Token.",
"statusCode": 401,
"name": "invalid_write_key"
}{
"message": "Too many requests. Please limit the number of requests per second.",
"statusCode": 429,
"name": "rate_limit_exceeded"
}{
"message": "An unexpected error occurred, please try again later.",
"statusCode": 500,
"name": "application_error"
}API documentation
Identify a user
Registers or updates a user (customer) in your organization. Call this when a user signs up or when their profile changes. You must identify a user before tracking events for them.
POST
/
identify
cURL
curl -X POST https://api.retain.so/identify \
-H "Content-Type: application/json" \
-H "Authorization: Basic $RETAIN_WRITE_KEY" \
-d '{
"userId": "user_123",
"email": "[email protected]",
"properties": {
"name": "Jane Doe",
"avatar": "https://example.com/avatar.jpg"
}
}'import { Retain } from '@retain-so/sdk';
const retain = new Retain(process.env.RETAIN_WRITE_KEY);
retain.identify({
userId: 'user_123',
email: '[email protected]',
properties: {
name: 'Jane Doe',
avatar: 'https://example.com/avatar.jpg',
// Add anything else about the user here
},
});import os
import requests
requests.post(
'https://api.retain.so/identify',
headers={
'Content-Type': 'application/json',
'Authorization': f'Basic {os.environ["RETAIN_WRITE_KEY"]}',
},
json={
'userId': 'user_123',
'email': '[email protected]',
'properties': {
'name': 'Jane Doe',
'avatar': 'https://example.com/avatar.jpg',
},
},
)<?php
$payload = json_encode([
'userId' => 'user_123',
'email' => '[email protected]',
'properties' => [
'name' => 'Jane Doe',
'avatar' => 'https://example.com/avatar.jpg',
],
]);
$ch = curl_init('https://api.retain.so/identify');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Basic ' . getenv('RETAIN_WRITE_KEY'),
],
CURLOPT_POSTFIELDS => $payload,
]);
curl_exec($ch);
curl_close($ch);require 'net/http'
require 'json'
uri = URI('https://api.retain.so/identify')
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/json'
req['Authorization'] = "Basic #{ENV.fetch('RETAIN_WRITE_KEY')}"
req.body = {
userId: 'user_123',
email: '[email protected]',
properties: {
name: 'Jane Doe',
avatar: 'https://example.com/avatar.jpg',
},
}.to_json
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String json = """
{
"userId": "user_123",
"email": "[email protected]",
"properties": {
"name": "Jane Doe",
"avatar": "https://example.com/avatar.jpg"
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.retain.so/identify"))
.header("Content-Type", "application/json")
.header("Authorization", "Basic " + System.getenv("RETAIN_WRITE_KEY"))
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());{
"success": true
}{
"message": "email must be a valid email address",
"statusCode": 400,
"name": "validation_error"
}{
"message": "Missing or invalid Project Token.",
"statusCode": 401,
"name": "invalid_write_key"
}{
"message": "Too many requests. Please limit the number of requests per second.",
"statusCode": 429,
"name": "rate_limit_exceeded"
}{
"message": "An unexpected error occurred, please try again later.",
"statusCode": 500,
"name": "application_error"
}Authorizations
Your organization's Project Token (starts with rk-). Get it from Settings.
Body
application/json
Unique identifier for the user in your system (string or number)
User's email address
Customer traits, shallow-merged into existing ones. Reserved keys power dashboard features; any other key is stored as a custom trait.
Show child attributes
Show child attributes
Whether this user is the account owner
Account/workspace this user belongs to
Show child attributes
Show child attributes
Response
User identified successfully. Response body: { "success": true }.
Indicates the request was successful
⌘I