Replace a user's ID with a new identifier across all records.
Endpoint
POST /users/replace-id
Authentication
Required: Bearer token in Authorization header
Authorization: Bearer YOUR_API_KEY
Request Body
{
"user_id": "user_123",
"new_user_id": "user_456"
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | string | Yes | Current user identifier |
new_user_id | string | Yes | Desired new identifier |
Response
{
"success": true,
"user_id": "user_456",
"message": "User ID updated"
}
Examples
JavaScript
const response = await fetch('https://api.appizer.com/v1/users/replace-id', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
user_id: 'user_123',
new_user_id: 'user_456'
})
});
const data = await response.json();
console.log(data);
Python
import requests
response = requests.post(
'https://api.appizer.com/v1/users/replace-id',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'user_id': 'user_123',
'new_user_id': 'user_456'
}
)
print(response.json())
cURL
curl -X POST https://api.appizer.com/v1/users/replace-id \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user_123",
"new_user_id": "user_456"
}'
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid request body or missing required fields |
| 401 | Unauthorized - Invalid or missing API key |
| 404 | Not Found - User ID does not exist |
| 409 | Conflict - New user ID already exists |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error - Something went wrong on our end |
Important Notes
- This operation updates the user ID across all historical data
- All events, properties, and associations will be updated to the new ID
- The old user ID will no longer be valid after this operation
- Consider using Create User Alias if you need to maintain both IDs
Use Cases
- ID Format Changes: Update IDs to match new system requirements
- User Merging: Consolidate duplicate user profiles
- System Refactoring: Align user IDs with new architecture
Best Practices
- Verify the new_user_id doesn't already exist before replacing
- Update your application's user ID references before making this API call
- Consider the impact on historical data and reports
- Use aliases instead if you need to maintain backward compatibility
- Document ID changes for audit purposes