perform.chat
Customer Users

Update User

Update customer user information

Endpoint

PUT https://api.perform.chat/rest/v1/customer-users/:id

Request 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

ParameterTypeDescription
idstringCustomer 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

  1. Use consistent field names - Standardize your metadata structure
  2. Don't store sensitive data - Avoid passwords, API keys, or PII
  3. Keep it flat when possible - Simpler structures are easier to query
  4. Version your schema - Include a version field if metadata evolves

Error Responses

StatusDescription
404Customer user not found or doesn't belong to company
401Invalid API credentials
400Invalid request body
500Internal 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()
    }
  })
}