PUT
/
customers
/
{id}
cURL
curl --request PUT \
  --url https://gateway.cyrexa.com/ipg/2.0.0/customers/{id} \
  --header 'Content-Type: application/json-patch+json' \
  --data '{
  "id": 123,
  "ownerId": 123,
  "userId": 123,
  "ownerName": "<string>",
  "name": "<string>",
  "email": "jsmith@example.com",
  "address": "<string>",
  "phone": "<string>",
  "memberId": "<string>",
  "hasPaymentRequests": true,
  "totalDeposits": 123,
  "createDate": "2023-11-07T05:31:56Z"
}'
This response does not have an example.

Overview

Update existing customer profiles in the Cyrexa IPG system to maintain accurate customer information and payment preferences. This endpoint is essential for maintaining accurate customer data and ensuring optimal payment processing experiences.
Customer updates should be performed whenever customer information changes, such as address updates, contact information changes, or preference modifications.

API Endpoint

  • Method: PUT
  • Path: /customers/{id}
  • id (required): The unique identifier of the customer to update
    • Type: integer (int64)
    • Example: 12345

Path Parameters

  • id (required): The unique identifier of the customer to update
    • Type: integer (int64)
    • Example: 12345

Request Body

The request body should contain a Client object with the updated customer information. You only need to include the fields you want to update.

Updatable Fields

  • Personal Information
    • Name
    • Email address
    • Phone number
    • Date of birth
  • Address Information
    • Billing address
    • Shipping address
    • Country and region
  • Account Preferences
    • Default currency
    • Language preference
    • Notification settings
    • Communication preferences
  • Account Status
    • Active/inactive status
    • Account verification status
    • Subscription preferences

Integration Examples

Basic Customer Update

// Update customer information
const customerId = 12345;
const updateData = {
  email: "newemail@example.com",
  phone: "+1234567890",
  address: {
    street: "456 New Street",
    city: "San Francisco",
    state: "CA",
    zipCode: "94105",
    country: "US"
  }
};

const response = await fetch(`/api/customers/${customerId}`, {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer ' + accessToken,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(updateData)
});

if (response.ok) {
  console.log('Customer updated successfully');
} else {
  console.error('Update failed:', response.statusText);
}

Partial Customer Update

// Update only specific fields
const customerId = 12345;
const partialUpdate = {
  preferences: {
    currency: "EUR",
    notifications: false,
    language: "fr"
  }
};

const response = await fetch(`/api/customers/${customerId}`, {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer ' + accessToken,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(partialUpdate)
});

Update with Validation

// Update customer with validation
async function updateCustomer(customerId, updateData) {
  try {
    // Validate update data
    if (updateData.email && !isValidEmail(updateData.email)) {
      throw new Error('Invalid email format');
    }
    
    if (updateData.phone && !isValidPhone(updateData.phone)) {
      throw new Error('Invalid phone format');
    }
    
    const response = await fetch(`/api/customers/${customerId}`, {
      method: 'PUT',
      headers: {
        'Authorization': 'Bearer ' + accessToken,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(updateData)
    });
    
    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(`Update failed: ${errorData.message}`);
    }
    
    return await response.json();
  } catch (error) {
    console.error('Customer update error:', error);
    throw error;
  }
}

Response Codes

Success Response

  • 200 OK: Customer updated successfully

Error Responses

  • 400 Bad Request: Invalid request data or validation errors
  • 401 Unauthorized: Invalid or missing authentication credentials
  • 404 Not Found: Customer with specified ID does not exist

Error Handling

Common Error Scenarios

  1. Customer Not Found
    • Status: 404 Not Found
    • Cause: Invalid customer ID or customer has been deleted
    • Solution: Verify the customer ID exists before attempting update
  2. Validation Errors
    • Status: 400 Bad Request
    • Cause: Invalid data format, missing required fields, or constraint violations
    • Solution: Validate data before sending the request
  3. Authentication Errors
    • Status: 401 Unauthorized
    • Cause: Invalid, expired, or missing authentication token
    • Solution: Refresh authentication token and retry

Error Response Format

{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "Bad Request",
  "status": 400,
  "detail": "Invalid email format",
  "instance": "/customers/12345"
}

Best Practices

Data Validation

  1. Client-Side Validation: Validate data before sending to reduce server errors
  2. Format Checking: Ensure email, phone, and address formats are correct
  3. Required Fields: Check that all required fields are provided
  4. Data Sanitization: Clean and sanitize user input before processing

Update Strategy

  1. Partial Updates: Only send fields that have changed to minimize data transfer
  2. Optimistic Updates: Update UI immediately, then sync with server
  3. Conflict Resolution: Handle cases where data has been modified by another process
  4. Audit Trail: Log all customer updates for compliance and debugging

Security Considerations

  1. Authorization: Ensure users can only update their own profiles or have proper permissions
  2. Data Validation: Validate all input data to prevent injection attacks
  3. Rate Limiting: Implement rate limiting to prevent abuse
  4. Sensitive Data: Handle sensitive information with extra care

Use Cases

Profile Management

  • Contact Updates: When customers change email or phone numbers
  • Address Changes: When customers move or update billing/shipping addresses
  • Preference Updates: When customers modify notification or payment preferences

Account Management

  • Status Changes: Activating, deactivating, or suspending customer accounts
  • Verification Updates: Updating verification status after identity checks
  • Subscription Changes: Modifying subscription levels or preferences

Compliance Updates

  • GDPR Compliance: Updating consent preferences and data processing agreements
  • KYC Updates: Refreshing Know Your Customer information as required
  • Tax Information: Updating tax-related customer information

Integration Considerations

Before Updating

  1. Fetch Current Data: Get current customer information to avoid overwriting unchanged fields
  2. User Permissions: Verify the requesting user has permission to update the customer
  3. Data Backup: Consider backing up current data before major updates

After Updating

  1. Confirmation: Send confirmation to customer about profile changes
  2. Audit Logging: Log the update for compliance and troubleshooting
  3. Cache Invalidation: Clear any cached customer data to ensure consistency
  4. Downstream Systems: Notify other systems that depend on customer data

Next Steps

Create Customer

Learn how to create new customer profiles

User Payment Methods

Manage customer’s saved payment methods

Customer Authentication

Implement secure customer authentication

Path Parameters

id
integer
required

Body

Response

200

OK