Manage Customers with the API

Learn how to add and manage customers with the Payabli API
View as MarkdownOpen in Claude
Applies to:Developers

In Payabli, customers are the entities that buy goods and services and make payments to your paypoints (merchants). This guide explains how to manage customers with the API.

Considerations

Keep these considerations in mind when working with customers:

  • Each paypoint has its own isolated list of customers.
  • Each customer has their own stored payment methods.
  • Customers and stored payment methods can’t be shared across paypoints.

Custom identifiers

By default, when working with the API on any task that involves customer data, you must include at least one of these identifier fields:

  • firstname and lastname
  • email
  • customerId

These tasks include things like making transactions, working with customer records, managing invoices, and more. Payabli first searches to match customer records based on your custom identifiers. If you don’t have any custom identifiers set, then Payabli falls back to matching on customerId.

Custom identifiers are managed in PartnerHub by navigating to Settings > Custom Fields.

Payabli recommends using the system-generated customerId field to identify customers for ease of integration and consistency. However, you can configure custom identifiers, which lets you decide which customer profile fields to use to uniquely identify and associate customer records and payments.

Custom identifiers cascade from org parent to child entities, so you can set them at the organization level and have them apply to all child paypoints. This is useful if you want to use a specific field across all your customers, such as email or clientId.

For example, if your company uses the customer’s email address as their unique identifier, you can choose email as the identifier. If your organization prefers to identify customers by a field called clientId, you can create that custom field in Payabli and set it as an identifier. This means that every API call that involves a customer must include the clientId because Payabli uses that field to search for customers.

Custom fields settings screen showing the Custom Identifiers section
Click to zoom

Pass custom identifiers in the customerData.additionalData object like this:

1"customerData": {
2 "additionalData": {
3 "YourCustomIdentifier": "123"
4 }
5 }

The max field length for custom identifiers is 100 characters.

Create a customer

To create a customer record, send a POST request to the /api/Customer/single/{entry} endpoint. For complete details, see the API reference for this endpoint.

The add customer request has these optional parameters:

replaceExisting
integerDefaults to 0

When set to 1, an existing customer record will be overwritten with a new customer record (if the identifiers find a match). Possible values: 0 (don’t replace), 1 (replace). Default is 0.

forceCustomerCreation
booleanDefaults to false

When set to true, a new customer record will be created even if an existing customer record is found. Possible values: true or false. Default is false.

The body is where you include information about the customer, including identifiers. An identifier is required to create customer records. You can change your identifier settings in Settings > Custom Fields in PartnerHub.

When you create a new customer record, Payabli first looks for an existing customer based on matching any of your configured identifier fields. If Payabli doesn’t find a match, then it attempts to match based on the CustomerNumber field, if included. If there is no match, Payabli creates a new customer.

This example creates a customer record. It includes firstname and lastname as the minimum required identifiers, as set in the example account.

POST
/api/Customer/single/:entry
1curl -X POST https://api-sandbox.payabli.com/api/Customer/single/8cfec329267 \
2 -H "requestToken: <apiKey>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "customerNumber": "C-90010",
6 "firstname": "Irene",
7 "lastname": "Canizales",
8 "email": "irene@canizalesconcrete.com",
9 "address1": "123 Bishop'\''s Trail",
10 "city": "Mountain City",
11 "state": "TN",
12 "zip": "37612",
13 "country": "US",
14 "timeZone": -5,
15 "identifierFields": [
16 "email"
17 ]
18}'

A successful request returns a JSON response. The customerId value is the Payabli-generated identifier that you can use with other endpoints to manage the customer and make transactions.

Response
1{
2 "responseText": "Success",
3 "isSuccess": true,
4 "responseData": {
5 "customerId": 4440,
6 "customerNumber": "C-90010",
7 "customerUsername": null,
8 "customerStatus": 0,
9 "Company": null,
10 "Firstname": "Irene",
11 "Lastname": "Canizales",
12 "Phone": null,
13 "Email": "irene@canizalesconcrete.com",
14 "Address": null,
15 "Address1": "123 Bishop's Trail",
16 "City": "Mountain City",
17 "State": "TN",
18 "Zip": "37612",
19 "Country": "US",
20 "ShippingAddress": null,
21 "ShippingAddress1": null,
22 "ShippingCity": null,
23 "ShippingState": null,
24 "ShippingZip": null,
25 "ShippingCountry": null,
26 "Balance": 0,
27 "TimeZone": -5,
28 "MFA": false,
29 "MFAMode": 0,
30 "snProvider": null,
31 "snIdentifier": null,
32 "snData": null,
33 "LastUpdated": "2024-03-13T12:49:56Z",
34 "Created": "2024-03-13T12:49:56Z",
35 "AdditionalFields": {
36 "key": "value"
37 },
38 "IdentifierFields": [
39 "email"
40 ],
41 "Subscriptions": null,
42 "StoredMethods": null,
43 "customerSummary": {
44 "NumberofTransactions": 30,
45 "RecentTransactions": [
46 {
47 "splitCount": 0,
48 "EntrypageId": 0,
49 "FeeAmount": 1,
50 "PayorId": 1551,
51 "PaypointId": 3040,
52 "SettlementStatus": 2,
53 "TotalAmount": 30.22,
54 "TransStatus": 1
55 }
56 ],
57 "TotalAmountTransactions": 1500,
58 "TotalNetAmountTransactions": 1500
59 },
60 "PaypointLegalname": "Gruzya Adventure Outfitters, LLC",
61 "PaypointDbaname": "Gruzya Adventure Outfitters",
62 "ParentOrgName": "The Pilgrim Planner",
63 "ParentOrgId": 123,
64 "PaypointEntryname": "41035afaa7",
65 "pageidentifier": "null",
66 "externalPaypointID": null,
67 "customerConsent": null
68 }
69}

Import customers

You can import a list of customers into Payabli using the API. This is useful if you have a large number of customers to add at once, or if you want to automate the process. Before you get started, download the example CSV file and open it with the editor of your choice. Use it as an example to help you build your import file.

To import a list of customer, send a POST request to the /api/Import/customersForm/{entrypoint} endpoint, with an attached CSV file.

When importing customers, there is an optional query parameter:

replaceExisting
integerDefaults to 0

replaceExisting - Flag indicating whether to replace existing customer with a new record. Possible values:

  • 0 (don’t replace)
  • 1 (replace).

This example imports customerImport.csv for the entrypoint e56ce00572.

POST
/api/Import/customersForm/:entry
1curl -X POST https://api-sandbox.payabli.com/api/Import/customersForm/8cfec329267 \
2 -H "requestToken: <apiKey>" \
3 -H "Content-Type: multipart/form-data" \
4 -F file=@<file1>

A successful request returns a JSON response with the number of added and rejected records, and any errors. The imported data is now available for use, and you can confirm by checking PartnerHub or PayHub.

Response
1{
2 "responseText": "Success",
3 "isSuccess": true,
4 "pageIdentifier": "null",
5 "responseCode": 1,
6 "responseData": {
7 "added": 26,
8 "errors": [
9 "errors",
10 "errors"
11 ],
12 "rejected": 2
13 }
14}
The responseData object contains the number of records added and rejected. The errors field contains any errors that occurred during the import process.

After you import customers, you can manage them with the API. For example, you can update customer information, check customer status, and run payments for customers.

Customer status

In customer endpoints and endpoints that return customer data, the customer status field is customerStatus.

ValueKey
Inactive0
Active1
Deleted-99
Locked85

List customers

To retrieve a list of customers for a paypoint, send a GET request to /api/Query/customers/{entry}. For organization-wide results, use /api/Query/customers/org/{orgId}.

GET
/api/Query/customers/:entry
1curl -G https://api-sandbox.payabli.com/api/Query/customers/8cfec329267 \
2 -H "requestToken: <apiKey>" \
3 -d fromRecord=251 \
4 -d limitRecord=0 \
5 -d sortBy=desc(field_name)

The response returns matching customers in Records and aggregate totals in Summary. Use Summary.totalRecords and Summary.totalPages with the fromRecord and limitRecord query parameters to page through results.

Response
1{
2 "Records": [
3 {
4 "customerId": 4440,
5 "customerNumber": "C-90010",
6 "customerStatus": 0,
7 "Company": "Boudreaux's Shop",
8 "Firstname": "Thibodeaux",
9 "Lastname": "Hebert",
10 "Phone": "(504) 823-4566",
11 "Email": "thibodeaux.hebert@bayoumail.com",
12 "Address": "1234 Bayou Road",
13 "Address1": "Suite 2",
14 "City": "Lafayette",
15 "State": "LA",
16 "Zip": "70501",
17 "Country": "US",
18 "ShippingAddress": "1234 Bayou Road",
19 "ShippingAddress1": "Suite 2",
20 "ShippingCity": "Lafayette",
21 "ShippingState": "LA",
22 "ShippingZip": "70501",
23 "ShippingCountry": "US",
24 "Balance": 0,
25 "TimeZone": 0,
26 "MFA": false,
27 "MFAMode": 0,
28 "LastUpdated": "2023-12-20T13:07:48Z",
29 "Created": "2023-12-20T13:07:48Z",
30 "IdentifierFields": [
31 "email"
32 ],
33 "customerSummary": {
34 "NumberofTransactions": 30,
35 "TotalAmountTransactions": 1500,
36 "TotalNetAmountTransactions": 1500
37 },
38 "PaypointLegalname": "Global Factory LLC",
39 "PaypointDbaname": "Global Factory LLC",
40 "ParentOrgName": "SupplyPro",
41 "PaypointEntryname": "4872acb376a",
42 "externalPaypointID": "pay-10"
43 }
44 ],
45 "Summary": {
46 "pageIdentifier": "XXXXXXXXXXXXXX",
47 "pageSize": 20,
48 "totalAmount": 0,
49 "totalNetAmount": 0,
50 "totalPages": 26,
51 "totalRecords": 510
52 }
53}

Filter and sort results with query parameters — for example, email(eq)=customer@example.com or status(in)=1|0. The full list of filterable fields is on the List customers by paypoint API reference; for operator syntax and pagination, see the Filters and conditions reference.

Customer transaction history

To show a customer’s transaction history, query the transactions endpoint filtered by customer. Send a GET request to /api/Query/transactions/{entry} with a customerId or customerNumber filter:

$curl -X GET "https://api.payabli.com/api/Query/transactions/your-entry-point?customerId(eq)=4440" \
> -H "requestToken: YOUR_API_TOKEN"

Each record includes a numeric TransStatus. See the Pay In status reference to decode TransStatus (and SettlementStatus) when rendering history.

Managing customers

You can also manage customers via the API. See these endpoint references for more information: