Skip to main content
POST
/
api
/
v1
/
customers
/
csv-upload
Javascript SDK
import { init } from "metrifox-js";

const metrifoxClient = init({
  apiKey: process.env.METRIFOX_API_KEY
});

// Example: File input handler
const handleFileUpload = async (event) => {
  const file = event.target.files[0];
  if (file && file.type === 'text/csv') {
    await metrifoxClient.customers.uploadCsv(file);
  } else {
    alert('Please select a valid CSV file');
  }
};
{
"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": "[email protected]",
"customer_type": "BUSINESS"
},
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"customer_key": "tech-solutions-002",
"primary_email": "[email protected]",
"customer_type": "BUSINESS"
},
{
"id": "550e8400-e29b-41d4-a716-446655440002",
"customer_key": "jane-doe-003",
"primary_email": "[email protected]",
"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