The Fetch Customer endpoint allows you to retrieve detailed information about a specific customer using their unique identifier. This endpoint provides complete customer profile data including contact information, account status, transaction history, and metadata. It’s essential for customer service operations, profile management, and transaction processing workflows.
Endpoint Details
Authentication : Required (API Key & Secret)
Rate Limiting : Subject to standard API rate limits
Authentication
All requests require API key authentication using the following headers:
x-client-key
: Your application’s client key
x-client-secret
: Your application’s client secret
Path Parameters
Customer’s unique identifier (UUID) Format : UUID v4Example : "550e8400-e29b-41d4-a716-446655440000"
Request Examples
Basic Request
JavaScript/TypeScript
Python
PHP
curl -X GET "https://api.devdraft.ai/api/v0/customers/550e8400-e29b-41d4-a716-446655440000" \
-H "x-client-key: YOUR_CLIENT_KEY" \
-H "x-client-secret: YOUR_CLIENT_SECRET"
Success Response (200 OK)
{
"id" : "cust_123456" ,
"first_name" : "John" ,
"last_name" : "Doe" ,
"email" : "john.doe@example.com" ,
"phone_number" : "+1-555-123-4567" ,
"customer_type" : "Enterprise" ,
"status" : "ACTIVE" ,
"last_spent" : 1250.50 ,
"last_purchase_date" : "2024-03-15T14:30:00Z" ,
"appId" : "app_789012" ,
"createdAt" : "2024-03-20T10:00:00Z" ,
"updatedAt" : "2024-03-20T10:00:00Z"
}
Response Fields
Unique customer identifier (UUID)
Customer’s phone number with country code
Type of customer account (Individual, Startup, Small Business, etc.)
Current customer status (ACTIVE, BLACKLISTED, DEACTIVATED)
Amount of customer’s last transaction
Date of customer’s last purchase (ISO 8601 format)
Associated application identifier
Customer account creation timestamp (ISO 8601)
Last update timestamp (ISO 8601)
Error Responses
400 Bad Request - Invalid ID Format
401 Unauthorized
404 Not Found
429 Too Many Requests
{
"statusCode" : 400 ,
"message" : "Invalid customer ID format" ,
"error" : "Bad Request"
}
Use Cases
1. Customer Service Operations
Retrieve complete customer information for support agents during service calls.
2. Transaction Processing
Verify customer details before processing payments or creating invoices.
3. Profile Management
Display customer information in user interfaces and account management systems.
4. Compliance Verification
Check customer status and type before enabling specific features or services.
5. Analytics and Reporting
Gather customer data for business intelligence and reporting purposes.
Advanced Integration Patterns
Customer Profile Dashboard
Customer Analytics
class CustomerProfileManager {
constructor ( api ) {
this . api = api ;
this . cache = new Map ();
}
async getEnhancedProfile ( customerId ) {
// Check cache first
if ( this . cache . has ( customerId )) {
const cached = this . cache . get ( customerId );
if ( Date . now () - cached . timestamp < 300000 ) { // 5 minutes
return cached . data ;
}
}
// Fetch customer and related data
const [ customer , transactions , invoices ] = await Promise . allSettled ([
this . api . fetchCustomer ( customerId ),
this . fetchCustomerTransactions ( customerId ),
this . fetchCustomerInvoices ( customerId )
]);
const profile = {
customer: customer . status === 'fulfilled' ? customer . value : null ,
transactions: transactions . status === 'fulfilled' ? transactions . value : [],
invoices: invoices . status === 'fulfilled' ? invoices . value : [],
metrics: this . calculateMetrics ( customer . value , transactions . value ),
lastUpdated: new Date (). toISOString ()
};
// Cache the result
this . cache . set ( customerId , {
data: profile ,
timestamp: Date . now ()
});
return profile ;
}
calculateMetrics ( customer , transactions ) {
if ( ! customer || ! transactions ) return null ;
return {
totalSpent: transactions . reduce (( sum , t ) => sum + t . amount , 0 ),
averageOrderValue: transactions . length > 0 ?
transactions . reduce (( sum , t ) => sum + t . amount , 0 ) / transactions . length : 0 ,
transactionCount: transactions . length ,
accountAge: Math . floor (
( Date . now () - new Date ( customer . createdAt ). getTime ()) / ( 1000 * 60 * 60 * 24 )
),
riskScore: this . calculateRiskScore ( customer , transactions )
};
}
calculateRiskScore ( customer , transactions ) {
let score = 0 ;
// Account age factor (newer accounts are riskier)
const accountAge = Math . floor (
( Date . now () - new Date ( customer . createdAt ). getTime ()) / ( 1000 * 60 * 60 * 24 )
);
if ( accountAge < 30 ) score += 2 ;
else if ( accountAge < 90 ) score += 1 ;
// Transaction frequency
if ( transactions . length === 0 ) score += 3 ;
else if ( transactions . length < 5 ) score += 1 ;
// Status check
if ( customer . status === 'BLACKLISTED' ) score += 10 ;
else if ( customer . status === 'DEACTIVATED' ) score += 5 ;
return Math . min ( score , 10 ); // Cap at 10
}
async fetchCustomerTransactions ( customerId ) {
// This would be implemented based on your transactions API
return [];
}
async fetchCustomerInvoices ( customerId ) {
// This would be implemented based on your invoices API
return [];
}
}
Best Practices
1. UUID Validation
Always validate UUID format before making API calls to avoid 400 errors.
2. Error Handling
Implement proper error handling for different scenarios (not found, unauthorized, etc.).
3. Caching Strategy
Cache customer data appropriately to reduce API calls, but ensure data freshness.
4. Batch Processing
When fetching multiple customers, implement batch processing with appropriate delays.
Consider fetching related data (transactions, invoices) in parallel for complete profiles.
Monitor API response times and implement timeouts for reliability.
Support
For technical support or questions about fetching customers:
Ensure customer ID is a valid UUID v4 format
Check your API credentials if receiving 401 errors
Verify customer exists in your application scope
Contact support with specific customer IDs that cause issues
For more information, see: