Create Customer

This guide walks through the setup of a customer.

Related Guides:

Create a Customer

POSThttps://testapi.payarc.net/v1/customers

For this guide, we will create a full customer profile. Depending on your use case, you can choose to capture less data, for example only the email address as in this example.

ParameterDescription
name
Optional
Alphabetic and Whitespace, Min Length: 3, Max Length: 50
Name of the customer.
Example: John Smith
email
Optional
Alphanumeric and Special Characters, Max Length: 40
Email address of the customer. It is displayed next to the customer in the dashboard and can be used for searching and tracking.
Example: [email protected]
description
Optional
Alphanumeric and Special Characters, Min Length: 5
An arbitrary string that you can attach to a customer. It is displayed next to the customer in the dashboard.
Max Length: 50
Example: Donut shop customer
send_email_address
Optional
Alphanumeric and Special Characters, Min Length: 5, Max Length: 40
Email address to which the invoices will be sent.
Example: [email protected]
cc_email_address
Optional
Alphanumeric and Special Characters, Min Length: 5, Max Length: 40
Email address to which the invoices will be sent.
Example: [email protected]
country
Optional
Alphabetic, Min Length: 2, Max Length: 50
Customer's country name.
Example: US
address_1
Optional
Alphanumeric, Min Length: 5, Max Length: 50
The customer's address for line 1.
Example: 103 Mason Street
address_2
Optional
Alphanumeric, Min Length: 5, Max Length: 50
The customer's address for line 2.
Example: 2nd Floor
city
Optional
Alphabetic and Whitespace, Min Length: 2, Max Length: 50
The customer's city name. Can be a City/District/Suburb/Town/Village.
Example: New York
state
Optional
Alphabetic and Whitespace, Min Length: 2, Max Length: 50
The customer's state name. Can be State/County/Province/Region.
Example: NY
zip
Optional
Numeric and Hyphen, Max Length: 10, Example: 10469
The customer's ZIP code.
10469-2345
phone
Optional
Numeric, Min Length: 2, Max Length: 11
The customer's phone number.
Example: 541754301
import http.client

conn = http.client.HTTPSConnection("https")
payload = 'name=John%20Smith&email=customer%40xyz.com&send_email_address=invoicing%40xyz.com&cc_email_address=cc%40xyz.com&address_1=103%20Mason%20Street&address_2=2nd%20Floor&city=New%20York&state=NY&zip=10469&phone=541754301&country=US'
headers = {
  'Authorization': '{{bearer_token}}',
  'Accept': 'application/json',
  'Content-Type': 'application/x-www-form-urlencoded'
}
conn.request("POST", "//testapi.payarc.net/v1/customers", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
var https = require('follow-redirects').https;
var fs = require('fs');

var qs = require('querystring');

var options = {
  'method': 'POST',
  'hostname': 'https',
  'path': '//testapi.payarc.net/v1/customers',
  'headers': {
    'Authorization': '{{bearer_token}}',
    'Accept': 'application/json',
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = qs.stringify({
  'name': 'John Smith',
  'email': '[email protected]',
  'send_email_address': '[email protected]',
  'cc_email_address': '[email protected]',
  'address_1': '103 Mason Street',
  'address_2': '2nd Floor',
  'city': 'New York',
  'state': 'NY',
  'zip': '10469',
  'phone': '541754301',
  'country': 'US'
});

req.write(postData);

req.end();
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://testapi.payarc.net/v1/customers");
request.Headers.Add("Authorization", "{{bearer_token}}");
request.Headers.Add("Accept", "application/json");
var collection = new List<KeyValuePair<string, string>>();
collection.Add(new("name","John Smith"));
collection.Add(new("email", "[email protected]"));
collection.Add(new("send_email_address","[email protected]"));
collection.Add(new("cc_email_address","[email protected]"));
collection.Add(new("address_1","103 Mason Street"));
collection.Add(new("address_2","2nd Floor"));
collection.Add(new("city","New York"));
collection.Add(new("state","NY"));
collection.Add(new("zip","10469"));
collection.Add(new("phone","541754301"));
collection.Add(new("country","US"));
var content = new FormUrlEncodedContent(collection);
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

The response will return a new Customer object. For the next steps, you will need the newly generated customer ID KPxMADVnxMV4nNjp:

{
  "data": {
    "object": "customer",
    "id": "KPxMADVnxMV4nNjp",
    "name": "John Smith",
    "real_id": 110,
    "email": "[email protected]",
    "description": null,
    "payment_overdue": null,
    "send_email_address": "[email protected]",
    "cc_email_address": "[email protected]",
    "source_id": null,
    "address_1": "103 Mason Street",
    "address_2": "2nd Floor",
    "city": "New York",
    "state": "NY",
    "zip": "10469",
    "phone": "541754301",
    "country": "US",
    "created_at": "2018-11-27 07:36:58",
    "updated_at": "2018-11-27 07:36:58",
    "readable_created_at": "1 second ago",
    "readable_updated_at": "1 second ago",
    "invoice_prefix": "52KZ",
    "card": {
      "data": []
    },
    "charge": {
      "data": []
    }
  },
  "meta": {
    "include": [
      "card",
      "charge",
      "subscription",
      "invoice"
    ],
    "custom": []
  }
}

You now have a customer record.