Update a user
const url = 'https://optlo.com/api/v1/users/example';const options = { method: 'PATCH', headers: { 'idempotency-key': 'example', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"name":"Sam Rivera-Smith"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://optlo.com/api/v1/users/example \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'idempotency-key: example' \ --data '{ "name": "Sam Rivera-Smith" }'Requires users:write. The path uses the Optlo user ID. Omitted fields remain unchanged; null clears a field. attrs replaces the entire object, including when it is empty. Email addresses may be shared. External IDs can be changed or cleared; an external ID assigned to another user returns 409. Numeric and string external IDs are distinct. An empty object leaves the user unchanged. Idempotency-Key is required and retained for 24 hours; identical retries return the original response and conflicting reuse returns 409. The updated user is returned without requiring users:read.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Unique identifier for the user.
Request Bodyrequired
Section titled “Request Bodyrequired”Show child attributes
User identifier in your system. String and numeric IDs are distinct.
User’s email address. Matching is case-insensitive.
User’s display name.
URL of the user’s avatar image.
Custom user attributes. Up to 100 attributes; keys contain 1–256 characters and string values at most 4096 characters. Updating attrs replaces the entire dictionary.
Show child attributes
Response
Section titled “Response”Success
Show child attributes
Unique identifier for the user.
User’s display name.
User’s email address.
User identifier in your system. String and numeric IDs are distinct.
URL of the user’s avatar image.
Custom attributes attached to the user, such as plan or company. Values can be strings, numbers, booleans, or null.
Show child attributes
Time the user was created.
Time of the user’s most recent visit. Null if no visit has been recorded.
Example
{ "id": "user_kR7mP3xB9nQ2vL5z", "name": "Sam Rivera-Smith", "email": "sam@example.com", "externalId": "customer_1042", "avatarUrl": null, "attrs": { "plan": "pro", "company": "Acme" }, "createdAt": "2026-10-13T09:00:00.000Z", "lastVisitedAt": "2026-10-13T09:05:00.000Z"}