Skip to main content
POST
/
api
/
v1
/
customers
/
csv-upload
Python SDK
from metrifox_sdk import MetrifoxClient

client = MetrifoxClient(api_key="your_api_key")

# Upload customers via CSV
result = client.customers.upload_csv("/path/to/customers.csv")

print(f"Total customers: {result['data']['total_customers']}")
print(f"Successful: {result['data']['successful_upload_count']}")
print(f"Failed: {result['data']['failed_upload_count']}")

# Handle failed uploads
if result['data']['failed_upload_count'] > 0:
    for failure in result['data']['customers_failed']:
        print(f"Row {failure['row']}: {failure['errors']}")
{ "total_customers": 3, "successful_upload_count": 3, "failed_upload_count": 0, "customers_added": [ { "id": "550e8400-e29b-41d4-a716-446655440000", "customer_key": "acme-corp-001", "primary_email": "contact@acme.com", "customer_type": "BUSINESS" }, { "id": "550e8400-e29b-41d4-a716-446655440001", "customer_key": "tech-solutions-002", "primary_email": "info@techsolutions.com", "customer_type": "BUSINESS" }, { "id": "550e8400-e29b-41d4-a716-446655440002", "customer_key": "jane-doe-003", "primary_email": "jane.doe@example.com", "customer_type": "INDIVIDUAL" } ], "customers_failed": [] }

Authorizations

x-api-key
string
header
required

Body

multipart/form-data
file
file
required

CSV file containing customer data

Response

CSV upload processed successfully

total_customers
integer
required

Total number of customers in the CSV file

successful_upload_count
integer
required

Number of customers successfully created

failed_upload_count
integer
required

Number of customers that failed to be created

customers_added
object[]
required

Array of successfully created customers

customers_failed
object[]
required

Array of customers that failed to be created with error details