A customer object stores the contact details of one of your end users. Attach a customer to a
payment with customer_id to save payment methods for that person, set up
mandates and see their history in one place.
You choose the customer_id. Use the ID from your own system (for example your user ID) so you
never need a lookup table. If you leave it out, VNSwitch generates one.
Send request bodies as UTF-8 JSON. Vietnamese names and addresses keep their diacritics (for example Nguyễn Văn An) and are returned exactly as sent.
constres=awaitfetch("https://sandbox.api.vnswitch.nivc.ai/customers",{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8","api-key":process.env.VNSWITCH_API_KEY,},body:JSON.stringify({customer_id:"cus_demo_001",name:"Nguyễn Văn An",email:"an.nguyen@example.vn",phone:"912345678",phone_country_code:"+84",description:"Khách hàng thân thiết",address:{line1:"12 Lý Thái Tổ",city:"Hà Nội",country:"VN"},metadata:{crm_id:"A-1001"},}),});console.log(awaitres.json());
importosimportrequestsresp=requests.post("https://sandbox.api.vnswitch.nivc.ai/customers",headers={"api-key":os.environ["VNSWITCH_API_KEY"]},json={"customer_id":"cus_demo_001","name":"Nguyễn Văn An","email":"an.nguyen@example.vn","phone":"912345678","phone_country_code":"+84","description":"Khách hàng thân thiết","address":{"line1":"12 Lý Thái Tổ","city":"Hà Nội","country":"VN"},"metadata":{"crm_id":"A-1001"},},)print(resp.json())
{"customer_id":"cus_demo_001","name":"Nguyễn Văn An","email":"an.nguyen@example.vn","phone":"912345678","phone_country_code":"+84","description":"Khách hàng thân thiết","address":{"line1":"12 Lý Thái Tổ","line2":null,"line3":null,"city":"Hà Nội","state":null,"zip":null,"country":"VN","first_name":null,"last_name":null,"origin_zip":null},"created_at":"2026-11-01T08:15:30.000Z","metadata":{"crm_id":"A-1001"},"default_payment_method_id":null,"tax_registration_id":null,"document_details":null}
The customer object. customer_id and created_at are always present.
default_payment_method_id is set once the customer has a default saved payment method.
{"customer_id":"cus_demo_001","name":"Nguyễn Văn An","email":"an.nguyen@example.vn","phone":"912345678","phone_country_code":"+84","description":"Khách hàng thân thiết","address":{"line1":"12 Lý Thái Tổ","city":"Hà Nội","country":"VN"},"created_at":"2026-11-01T08:15:30.000Z","metadata":{"crm_id":"A-1001"},"default_payment_method_id":"pm_5d1c9a7e3b","tax_registration_id":null,"document_details":null}
Changes the details of an existing customer. Send only the fields you want to change; fields
you leave out keep their current value. The customer_id cannot be changed.
{"customer_id":"cus_demo_001","name":"Nguyễn Văn An","email":"an.nguyen.work@example.vn","phone":"912345678","phone_country_code":"+84","description":"Khách hàng thân thiết","address":{"line1":"45 Nguyễn Huệ","city":"Thành phố Hồ Chí Minh","country":"VN"},"created_at":"2026-11-01T08:15:30.000Z","metadata":{"crm_id":"A-1001"},"default_payment_method_id":"pm_5d1c9a7e3b","tax_registration_id":null,"document_details":null}
Deletes a customer’s personal data and their saved payment methods. Use it when a customer
closes their account or asks you to erase their data. Past payments stay in your records.
DELETE /customers/{customer_id}
Authentication: secret API key (api-key header).
You cannot delete a customer who has an active mandate. The request fails with HTTP 400 and error code IR_10. Revoke the mandates first, then delete the customer.
[{"customer_id":"cus_demo_001","name":"Nguyễn Văn An","email":"an.nguyen@example.vn","phone":"912345678","phone_country_code":"+84","description":"Khách hàng thân thiết","address":null,"created_at":"2026-11-01T08:15:30.000Z","metadata":{"crm_id":"A-1001"},"default_payment_method_id":"pm_5d1c9a7e3b","tax_registration_id":null,"document_details":null}]