Users

Update User Traits

Replaces all stored traits for an identified user.

PUT /api/sites/:site/users/:userId/traits

Replaces the user's stored traits with the object you send. Unlike identify(), which merges, this overwrites: traits you leave out are removed. Keys with a null value are dropped. The profile is created if the user doesn't have one yet.

Permissions: the member role or above on the site. API keys need the users:write scope.

Path Parameters

Prop

Type

Request Body

Prop

Type

Response

Prop

Type

Error Responses

Errors use the standard body { error, code, message, resolution }.

Prop

Type

Request
curl -X PUT "https://app.rybbit.io/api/sites/123/users/user_8421/traits" \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "traits": {
      "email": "jane@example.com",
      "plan": "enterprise",
      "company": "Acme Inc"
    }
  }'
Request
const response = await fetch(
  'https://app.rybbit.io/api/sites/123/users/user_8421/traits',
  {
    method: 'PUT',
    headers: {
      'Authorization': 'Bearer your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      traits: {
        email: 'jane@example.com',
        plan: 'enterprise',
        company: 'Acme Inc'
      }
    })
  }
);

const data = await response.json();
Request
import requests

response = requests.put(
    'https://app.rybbit.io/api/sites/123/users/user_8421/traits',
    json={
        'traits': {
            'email': 'jane@example.com',
            'plan': 'enterprise',
            'company': 'Acme Inc'
        }
    },
    headers={
        'Authorization': 'Bearer your_api_key_here'
    }
)

data = response.json()
Request
$body = [
    'traits' => [
        'email' => 'jane@example.com',
        'plan' => 'enterprise',
        'company' => 'Acme Inc'
    ]
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.rybbit.io/api/sites/123/users/user_8421/traits');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer your_api_key_here',
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
Request
require 'net/http'
require 'json'

uri = URI('https://app.rybbit.io/api/sites/123/users/user_8421/traits')
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer your_api_key_here'
request['Content-Type'] = 'application/json'
request.body = {
  traits: {
    email: 'jane@example.com',
    plan: 'enterprise',
    company: 'Acme Inc'
  }
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

data = JSON.parse(response.body)
Request
body := map[string]interface{}{
    "traits": map[string]interface{}{
        "email": "jane@example.com",
        "plan": "enterprise",
        "company": "Acme Inc",
    },
}
jsonBody, _ := json.Marshal(body)

req, _ := http.NewRequest("PUT", "https://app.rybbit.io/api/sites/123/users/user_8421/traits", bytes.NewBuffer(jsonBody))
req.Header.Set("Authorization", "Bearer your_api_key_here")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
Request
let body = serde_json::json!({
  "traits": {
    "email": "jane@example.com",
    "plan": "enterprise",
    "company": "Acme Inc"
  }
});

let client = reqwest::Client::new();
let res = client
    .put("https://app.rybbit.io/api/sites/123/users/user_8421/traits")
    .header("Authorization", "Bearer your_api_key_here")
    .json(&body)
    .send()
    .await?;

let data: serde_json::Value = res.json().await?;
Request
String json = """
{
  "traits": {
    "email": "jane@example.com",
    "plan": "enterprise",
    "company": "Acme Inc"
  }
}
""";

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://app.rybbit.io/api/sites/123/users/user_8421/traits"))
    .header("Authorization", "Bearer your_api_key_here")
    .header("Content-Type", "application/json")
    .PUT(HttpRequest.BodyPublishers.ofString(json))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
Request
var body = new
{
    traits = new
    {
        email = "jane@example.com",
        plan = "enterprise",
        company = "Acme Inc"
    }
};

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer your_api_key_here");

var content = new StringContent(
    JsonSerializer.Serialize(body),
    Encoding.UTF8,
    "application/json");

var response = await client.PutAsync("https://app.rybbit.io/api/sites/123/users/user_8421/traits", content);
var data = await response.Content.ReadAsStringAsync();
Response
{
  "success": true
}