Customers
Subscriptions are associated with the customer resource. Customers can be created either along with a subscription via the subscription API or via the API as follows.
Create a customer
To create a customer, send a POST
request to https://epsp.fortebank.com/customers
with the following parameters:
Parameter | Type | Description |
---|---|---|
first_name | string | First name of the customer. |
last_name | string | Last name of the customer |
address | string | Address of the customer. |
city | string | City of the customer. |
country | string | Country of the customer. It is in ISO 3166-1 Alpha-2 format. |
zip | string | Billing ZIP or postal code of the customer. If country=US , zip format must be NNNNN or NNNNN-NNNN |
state | string | The two-letter state of the customer. It is required to send only if the customer country is US or CA |
phone | string | Phone number of the customer. |
email * required |
string | E-mail address of the customer. |
ip * required |
string | IP address of the customer device. |
external_id | string (255) | The customer's identifier in the merchant's system. |
If the request credentials and parameters are valid, Forte E-commerce will return 201
HTTP status code and a new customer object with all the relevant details. Otherwise, Forte E-commerce will return 422
HTTP status code and an error message.
Example of the request for creating a customer
curl https://epsp.fortebank.com/customers \
-X POST -u shop_id:secret_key \
-H "Content-Type: application/json" \
-d \
'{
"first_name":"John",
"last_name":"Doe",
"address":"1st Street",
"country":"US",
"city":"Denver",
"zip":"92006",
"state":"CO",
"phone":"+1-555-555-5555",
"email":"customer@example.com",
"ip":"127.0.0.1"
}'
Example of the response to the request for creating a customer
{
"id":"cst_7aee5afb954c7ef7",
"first_name":"John",
"last_name":"Doe",
"address":"1st Street",
"country":"US",
"city":"Denver",
"zip":"92006",
"state":"CO",
"phone":"+1-555-555-5555",
"email":"customer@example.com",
"ip":"127.0.0.1"
}
Example of the request for creating a customer with invalid parameters
curl https://epsp.fortebank.com/customers \
-X POST -u shop_id:secret_key \
-H "Content-Type: application/json" \
-d \
'{
"city":"Denver",
"zip":"92006",
"state":"CO",
"phone":"+1-555-555-5555",
"email":"customer@example.com"
}'
Example of the response to the request for creating a customer with invalid parameters
{
"message": "Ip address is invalid. Ip can't be blank",
"errors": {
"ip": [
"address is invalid",
"can't be blank"
]
}
}
Get customer details
To get customer details, send a GET
request to https://epsp.fortebank.com/customers/:customer_id
, where :customer_id
stands for the identifier of the required customer.
If the customer ID exists, Forte E-commerce will return 200
HTTP status code and the customer details.
Example of the request to get details of the customer with the ID cst_7aee5afb954c7ef7
curl -u shop_id:secret \
https://epsp.fortebank.com/customers/cst_7aee5afb954c7ef7
Response example
{
"id":"cst_7aee5afb954c7ef7",
"first_name":"John",
"last_name":"Doe",
"address":"1st Street",
"country":"US",
"city":"Denver",
"zip":"92006",
"state":"CO",
"phone":"+1-555-555-5555",
"email":"customer@example.com",
"ip":"127.0.0.1"
}
Get a list of customers
To get a list of all customers, send a GET
request to https://epsp.fortebank.com/customers
.
If there are customers, Forte E-commerce will return 200
HTTP status code and an array of customer details.
Example of the request for a list of all customers
curl -u shop_id:secret \
https://epsp.fortebank.com/customers
Response example
[
{"id":"cst_5ca4fab9dfc7fcbf","first_name":"John","last_name":"Doe","address":"1st Street","country":"US","city":"Denver","zip":"92006","state":"CO","phone":"+1-555-555-5555","email":"customer@example.com","ip":"127.0.0.1"},
{"id":"cst_9f65045c1f4c3676","first_name":"Mark","last_name":"Dow","address":"2nd Street","country":"US","city":"Denver","zip":"90006","state":"CO","phone":"+1-551-548-5547","email":"customer.mark@example.com","ip":"10.10.0.4"}
]