Skip to main content

Users API

The Users API allows you to manage user profiles and accounts in your TraderPal Connect integration.

Endpoints​

Create User​

POST /v1/users

Create a new user account.

Request Body​

{
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe",
"dateOfBirth": "1990-01-01",
"country": "US",
"phoneNumber": "+1234567890"
}

Response​

{
"userId": "usr_123456789",
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe",
"status": "pending_verification",
"createdAt": "2024-01-01T00:00:00Z"
}

Get User​

GET /v1/users/{userId}

Retrieve user information by ID.

Response​

{
"userId": "usr_123456789",
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe",
"status": "active",
"createdAt": "2024-01-01T00:00:00Z",
"verificationStatus": {
"email": "verified",
"identity": "verified",
"address": "pending"
}
}

Update User​

PATCH /v1/users/{userId}

Update user information.

Request Body​

{
"firstName": "John",
"lastName": "Smith",
"phoneNumber": "+1987654321"
}

Response​

{
"userId": "usr_123456789",
"email": "user@example.com",
"firstName": "John",
"lastName": "Smith",
"status": "active",
"updatedAt": "2024-01-01T01:00:00Z"
}

List Users​

GET /v1/users

List all users with pagination.

Query Parameters​

ParameterTypeDescription
limitintegerNumber of records to return (default: 100, max: 1000)
offsetintegerNumber of records to skip (default: 0)
statusstringFilter by user status (active, pending, suspended)

Response​

{
"users": [
{
"userId": "usr_123456789",
"email": "user@example.com",
"firstName": "John",
"lastName": "Smith",
"status": "active",
"createdAt": "2024-01-01T00:00:00Z"
}
],
"metadata": {
"total": 150,
"limit": 100,
"offset": 0
}
}

User Statuses​

StatusDescription
pending_verificationUser created but not verified
activeUser verified and active
suspendedUser account suspended
closedUser account closed

Error Codes​

CodeDescription
400Invalid request parameters
404User not found
409Email already exists
422Invalid user data

Examples​

Create a New User​

const response = await client.users.create({
email: 'user@example.com',
firstName: 'John',
lastName: 'Doe',
dateOfBirth: '1990-01-01',
country: 'US',
phoneNumber: '+1234567890'
});

console.log(response.userId);

Update User Information​

const userId = 'usr_123456789';
const response = await client.users.update(userId, {
firstName: 'John',
lastName: 'Smith'
});

console.log(response.updatedAt);

List Active Users​

const response = await client.users.list({
status: 'active',
limit: 50
});

console.log(response.users.length);

Best Practices​

  1. Data Validation

    • Validate email format
    • Verify phone number format
    • Check date of birth is valid
  2. Error Handling

    • Handle duplicate email errors
    • Implement retry logic for network errors
    • Log validation errors for debugging
  3. User Management

    • Implement user deactivation flow
    • Handle user data updates securely
    • Monitor user status changes

Next Steps​