Customer Users
Update User
Update customer user information
Endpoint
PUT https://api.perform.chat/rest/v1/customer-users/:idRequest Body
{
"keyId": "your-key-id",
"keySecret": "your-key-secret",
"name": "John Doe Updated", // Optional
"email": "newemail@example.com", // Optional
"metadata": { // Optional
"plan": "enterprise",
"custom_field": "value"
}
}Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Customer user ID to update |
Response
{
"id": "cu_123",
"external_id": "user_123",
"name": "John Doe Updated",
"email": "newemail@example.com",
"metadata": {
"plan": "enterprise",
"custom_field": "value"
},
"active": true,
"updated_at": "2025-01-15T15:00:00Z"
}Example Request
async function updateCustomerUser(userId, updates) {
const response = await axios.put(
`https://api.performchat.com/rest/v1/v1/customer-users/${userId}`,
{
keyId: process.env.API_KEY_ID,
keySecret: process.env.API_KEY_SECRET,
...updates
}
)
return response.data
}
// Update user metadata
await updateCustomerUser('cu_123', {
metadata: {
plan: 'enterprise',
renewal_date: '2025-12-31'
}
})Metadata Field
The metadata field is a flexible JSON object for custom data:
{
"metadata": {
"plan": "enterprise",
"subscription_id": "sub_123",
"country": "US",
"language": "en",
"custom_fields": {
"company": "Acme Corp",
"role": "admin"
}
}
}Metadata Best Practices
- Use consistent field names - Standardize your metadata structure
- Don't store sensitive data - Avoid passwords, API keys, or PII
- Keep it flat when possible - Simpler structures are easier to query
- Version your schema - Include a version field if metadata evolves
Error Responses
| Status | Description |
|---|---|
| 404 | Customer user not found or doesn't belong to company |
| 401 | Invalid API credentials |
| 400 | Invalid request body |
| 500 | Internal server error |
Use Cases
Sync User Data
async function syncUserData(externalId, userData) {
const existingUser = await findUserByExternalId(externalId)
if (existingUser) {
return await updateCustomerUser(existingUser.id, {
name: userData.name,
email: userData.email,
metadata: userData.metadata
})
}
}Update User Plan
async function updateUserPlan(externalId, newPlan) {
const user = await findUserByExternalId(externalId)
if (!user) {
throw new Error('User not found')
}
return await updateCustomerUser(user.id, {
metadata: {
...user.metadata,
plan: newPlan,
updated_at: new Date().toISOString()
}
})
}Related Endpoints
- List Users - Search and list customer users
- Token Invalidation - Invalidate user tokens