Skip to main content
PATCH
/
contacts
/
{id}
Update a contact by ID
curl --request PATCH \
  --url https://api.privy.com/v1/contacts/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "first_name": "Janet",
  "tags": [
    "vip",
    "wholesale"
  ],
  "email_consent": "unsubscribed"
}
'
import requests

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

payload = {
"first_name": "Janet",
"tags": ["vip", "wholesale"],
"email_consent": "unsubscribed"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({first_name: 'Janet', tags: ['vip', 'wholesale'], email_consent: 'unsubscribed'})
};

fetch('https://api.privy.com/v1/contacts/{id}', 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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'first_name' => 'Janet',
'tags' => [
'vip',
'wholesale'
],
'email_consent' => 'unsubscribed'
]),
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/{id}"

payload := strings.NewReader("{\n \"first_name\": \"Janet\",\n \"tags\": [\n \"vip\",\n \"wholesale\"\n ],\n \"email_consent\": \"unsubscribed\"\n}")

req, _ := http.NewRequest("PATCH", 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.patch("https://api.privy.com/v1/contacts/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"first_name\": \"Janet\",\n \"tags\": [\n \"vip\",\n \"wholesale\"\n ],\n \"email_consent\": \"unsubscribed\"\n}")
.asString();
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"first_name\": \"Janet\",\n \"tags\": [\n \"vip\",\n \"wholesale\"\n ],\n \"email_consent\": \"unsubscribed\"\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "cus_a1b2c3d4e5f6g7h8",
    "first_name": "Janet",
    "last_name": "Doe",
    "email": "jane@example.com",
    "email_consent": "unsubscribed",
    "phone_number": "+15551234567",
    "sms_consent": "subscribed",
    "tags": [
      "vip",
      "wholesale"
    ],
    "custom_fields": {
      "loyalty_tier": "gold"
    },
    "created_at": "2025-01-15T10:30:00Z",
    "updated_at": "2025-04-01T12:15: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": "not_found",
"message": "Contact not found"
}
}
{
"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.

Path Parameters

id
string
required

The contact's unique identifier (returned as id in contact responses).

Body

application/json

Include one or more fields to update. The contact is identified by the id path parameter. Field updates and consent changes can be combined in a single request.

Mutable fields: first_name, last_name, email, phone_number, tags, custom_fields.

email and phone_number can only be set when the existing value is null. Once populated, they cannot be changed or cleared.

Consent fields: email_consent, sms_consent. Use these to manage a contact's marketing consent instead of the deprecated unsubscribe endpoint.

first_name
string

Updated first name.

Example:

"Janet"

last_name
string

Updated last name.

Example:

"Smith"

email
string<email>

Sets the contact's email address. Only allowed when the contact's current email is null; once populated, email is immutable.

Example:

"janet@example.com"

phone_number
string

Sets the contact's phone number in E.164 format. Only allowed when the contact's current phone_number is null; once populated, phone_number is immutable.

Example:

"+15551234567"

tags
string[]

Replaces all existing tags.

Example:
["vip", "wholesale"]
custom_fields
object

Replaces all existing custom fields. Must be a flat key-value object.

Example:
{ "loyalty_tier": "platinum" }

Update the contact's email marketing consent. compliance_suppressed is read-only — any write to a compliance-suppressed contact returns 422.

For merchant-suppressed contacts, writing any consent value first unsuppresses, then applies the requested transition (e.g. subscribed unsuppresses then subscribes).

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

"unsubscribed"

Update the contact's SMS marketing consent. pending is read-only. subscribed, single_opt_in, and unsubscribed require the contact to have a phone number. single_opt_in is idempotent when the contact is already in that state, and returns 422 from terminal states (pending, confirmed, or unsubscribed).

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

"unsubscribed"

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 updated successfully.

data
object