Skip to main content
POST
/
contacts
Create a contact
curl --request POST \
  --url https://api.privy.com/v1/contacts \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "email": "jane@example.com",
  "first_name": "Jane",
  "last_name": "Doe",
  "tags": [
    "new-contact"
  ],
  "email_consent": "subscribed"
}
'
import requests

url = "https://api.privy.com/v1/contacts"

payload = {
"email": "jane@example.com",
"first_name": "Jane",
"last_name": "Doe",
"tags": ["new-contact"],
"email_consent": "subscribed"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
email: 'jane@example.com',
first_name: 'Jane',
last_name: 'Doe',
tags: ['new-contact'],
email_consent: 'subscribed'
})
};

fetch('https://api.privy.com/v1/contacts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.privy.com/v1/contacts",
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([
'email' => 'jane@example.com',
'first_name' => 'Jane',
'last_name' => 'Doe',
'tags' => [
'new-contact'
],
'email_consent' => 'subscribed'
]),
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;
}
package main

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

func main() {

url := "https://api.privy.com/v1/contacts"

payload := strings.NewReader("{\n \"email\": \"jane@example.com\",\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"tags\": [\n \"new-contact\"\n ],\n \"email_consent\": \"subscribed\"\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.privy.com/v1/contacts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"jane@example.com\",\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"tags\": [\n \"new-contact\"\n ],\n \"email_consent\": \"subscribed\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.privy.com/v1/contacts")

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 \"email\": \"jane@example.com\",\n \"first_name\": \"Jane\",\n \"last_name\": \"Doe\",\n \"tags\": [\n \"new-contact\"\n ],\n \"email_consent\": \"subscribed\"\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "cus_x9y8z7w6v5u4t3s2",
    "first_name": "Jane",
    "last_name": "Doe",
    "email": "jane@example.com",
    "email_consent": "subscribed",
    "phone_number": null,
    "sms_consent": "never_subscribed",
    "tags": [
      "new-contact"
    ],
    "custom_fields": {},
    "created_at": "2025-04-01T12:00:00Z",
    "updated_at": "2025-04-01T12:00:00Z"
  }
}
{
"error": {
"code": "unauthorized",
"message": "Bearer token is missing or invalid"
}
}
{
"error": {
"code": "insufficient_scope",
"message": "Token does not have the required scope"
}
}
{
"error": {
"code": "conflict",
"message": "A contact with this email already exists",
"id": "cus_x9y8z7w6v5u4t3s2"
}
}
{
"error": {
"code": "validation_failed",
"message": "One or more fields are invalid",
"details": [
{
"field": "email",
"message": "is required"
}
]
}
}
{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded"
}
}

Authorizations

Authorization
string
header
required

Send either an API token or an OAuth access token as Authorization: Bearer <token>. See the Authentication page for details.

Body

application/json

At least one of email or phone_number is required.

Use email_consent and sms_consent to set the contact's marketing consent status at creation time.

email
string<email>

Contact's email address.

Example:

"jane@example.com"

phone_number
string

Contact's phone number in E.164 format.

Example:

"+15551234567"

first_name
string

Contact's first name.

Example:

"Jane"

last_name
string

Contact's last name.

Example:

"Doe"

tags
string[]

Tags to apply to the contact.

Example:
["vip", "repeat-buyer"]
custom_fields
object

Flat key-value pairs. Nested objects are not allowed.

Example:
{ "loyalty_tier": "gold" }

Email marketing consent status. If not provided, defaults to never_subscribed. compliance_suppressed is read-only and cannot be set on create.

Available options:
subscribed,
unsubscribed,
never_subscribed,
suppressed
Example:

"subscribed"

SMS marketing consent status. pending is read-only and cannot be set. subscribed and single_opt_in require a valid phone_number from a supported country. Cannot be unsubscribed for new contacts (no existing consent to revoke).

Available options:
subscribed,
unsubscribed,
never_subscribed,
single_opt_in
Example:

"never_subscribed"

send_welcome_sms
boolean
default:true

When sms_consent is set to subscribed and the contact transitions to a confirmed SMS opt-in state, Privy sends a TCPA-required welcome SMS. Set to false to suppress this message when you have already collected consent outside of Privy.

Example:

false

Response

Contact created successfully.

data
object