curl --request POST \
--url https://api.fabric.inc/v3/Customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": {
"firstName": "Pat",
"lastName": "Doe",
"title": "Dr.",
"middleName": "E",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"externalId": "1231012312-312-31231asda",
"additionalAttributes": {
"type": "shopper"
}
}
'import requests
url = "https://api.fabric.inc/v3/Customers"
payload = {
"name": {
"firstName": "Pat",
"lastName": "Doe",
"title": "Dr.",
"middleName": "E",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"externalId": "1231012312-312-31231asda",
"additionalAttributes": { "type": "shopper" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: {
firstName: 'Pat',
lastName: 'Doe',
title: 'Dr.',
middleName: 'E',
suffix: 'Jr.'
},
emailAddress: 'test@example.com',
phone: {number: 15555551234, type: 'MOBILE'},
externalId: '1231012312-312-31231asda',
additionalAttributes: {type: 'shopper'}
})
};
fetch('https://api.fabric.inc/v3/Customers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fabric.inc/v3/Customers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => [
'firstName' => 'Pat',
'lastName' => 'Doe',
'title' => 'Dr.',
'middleName' => 'E',
'suffix' => 'Jr.'
],
'emailAddress' => 'test@example.com',
'phone' => [
'number' => 15555551234,
'type' => 'MOBILE'
],
'externalId' => '1231012312-312-31231asda',
'additionalAttributes' => [
'type' => 'shopper'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fabric.inc/v3/Customers"
payload := strings.NewReader("{\n \"name\": {\n \"firstName\": \"Pat\",\n \"lastName\": \"Doe\",\n \"title\": \"Dr.\",\n \"middleName\": \"E\",\n \"suffix\": \"Jr.\"\n },\n \"emailAddress\": \"test@example.com\",\n \"phone\": {\n \"number\": 15555551234,\n \"type\": \"MOBILE\"\n },\n \"externalId\": \"1231012312-312-31231asda\",\n \"additionalAttributes\": {\n \"type\": \"shopper\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.fabric.inc/v3/Customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": {\n \"firstName\": \"Pat\",\n \"lastName\": \"Doe\",\n \"title\": \"Dr.\",\n \"middleName\": \"E\",\n \"suffix\": \"Jr.\"\n },\n \"emailAddress\": \"test@example.com\",\n \"phone\": {\n \"number\": 15555551234,\n \"type\": \"MOBILE\"\n },\n \"externalId\": \"1231012312-312-31231asda\",\n \"additionalAttributes\": {\n \"type\": \"shopper\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/Customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": {\n \"firstName\": \"Pat\",\n \"lastName\": \"Doe\",\n \"title\": \"Dr.\",\n \"middleName\": \"E\",\n \"suffix\": \"Jr.\"\n },\n \"emailAddress\": \"test@example.com\",\n \"phone\": {\n \"number\": 15555551234,\n \"type\": \"MOBILE\"\n },\n \"externalId\": \"1231012312-312-31231asda\",\n \"additionalAttributes\": {\n \"type\": \"shopper\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "61df41892bf06d00092d0d8a",
"name": {
"firstName": "Pat",
"lastName": "Doe",
"title": "Dr.",
"middleName": "E",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"isDeleted": false,
"createdAt": "2023-08-30T23:20:42.822Z",
"updatedAt": "2023-08-30T23:20:42.822Z",
"status": "ACTIVE",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"externalId": "1231012312-312-31231asda",
"additionalAttributes": {
"middleName": "user"
},
"deletedAt": "2023-08-30T23:20:42.822Z"
}{
"type": "INVALID_ACCOUNT_PROVIDED",
"message": "Invalid account provided for the request."
}{
"type": "REQUEST_DENIED",
"message": "Forbidden"
}{
"type": "INTERNAL_SERVER_ERROR",
"message": "Internal server error"
}Add a new customer
Using this endpoint, you can add a new customer to the system. The response includes an id which is required in subsequent calls, such as GET /customers/{customerId}, PUT /customers/{customerId}, PATCH /customers/{customerId}, and more.
When externalId is specified, the customers have the ability to manage their own details through the storefront UI.
curl --request POST \
--url https://api.fabric.inc/v3/Customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": {
"firstName": "Pat",
"lastName": "Doe",
"title": "Dr.",
"middleName": "E",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"externalId": "1231012312-312-31231asda",
"additionalAttributes": {
"type": "shopper"
}
}
'import requests
url = "https://api.fabric.inc/v3/Customers"
payload = {
"name": {
"firstName": "Pat",
"lastName": "Doe",
"title": "Dr.",
"middleName": "E",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"externalId": "1231012312-312-31231asda",
"additionalAttributes": { "type": "shopper" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: {
firstName: 'Pat',
lastName: 'Doe',
title: 'Dr.',
middleName: 'E',
suffix: 'Jr.'
},
emailAddress: 'test@example.com',
phone: {number: 15555551234, type: 'MOBILE'},
externalId: '1231012312-312-31231asda',
additionalAttributes: {type: 'shopper'}
})
};
fetch('https://api.fabric.inc/v3/Customers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fabric.inc/v3/Customers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => [
'firstName' => 'Pat',
'lastName' => 'Doe',
'title' => 'Dr.',
'middleName' => 'E',
'suffix' => 'Jr.'
],
'emailAddress' => 'test@example.com',
'phone' => [
'number' => 15555551234,
'type' => 'MOBILE'
],
'externalId' => '1231012312-312-31231asda',
'additionalAttributes' => [
'type' => 'shopper'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fabric.inc/v3/Customers"
payload := strings.NewReader("{\n \"name\": {\n \"firstName\": \"Pat\",\n \"lastName\": \"Doe\",\n \"title\": \"Dr.\",\n \"middleName\": \"E\",\n \"suffix\": \"Jr.\"\n },\n \"emailAddress\": \"test@example.com\",\n \"phone\": {\n \"number\": 15555551234,\n \"type\": \"MOBILE\"\n },\n \"externalId\": \"1231012312-312-31231asda\",\n \"additionalAttributes\": {\n \"type\": \"shopper\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.fabric.inc/v3/Customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": {\n \"firstName\": \"Pat\",\n \"lastName\": \"Doe\",\n \"title\": \"Dr.\",\n \"middleName\": \"E\",\n \"suffix\": \"Jr.\"\n },\n \"emailAddress\": \"test@example.com\",\n \"phone\": {\n \"number\": 15555551234,\n \"type\": \"MOBILE\"\n },\n \"externalId\": \"1231012312-312-31231asda\",\n \"additionalAttributes\": {\n \"type\": \"shopper\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.fabric.inc/v3/Customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": {\n \"firstName\": \"Pat\",\n \"lastName\": \"Doe\",\n \"title\": \"Dr.\",\n \"middleName\": \"E\",\n \"suffix\": \"Jr.\"\n },\n \"emailAddress\": \"test@example.com\",\n \"phone\": {\n \"number\": 15555551234,\n \"type\": \"MOBILE\"\n },\n \"externalId\": \"1231012312-312-31231asda\",\n \"additionalAttributes\": {\n \"type\": \"shopper\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "61df41892bf06d00092d0d8a",
"name": {
"firstName": "Pat",
"lastName": "Doe",
"title": "Dr.",
"middleName": "E",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"isDeleted": false,
"createdAt": "2023-08-30T23:20:42.822Z",
"updatedAt": "2023-08-30T23:20:42.822Z",
"status": "ACTIVE",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"externalId": "1231012312-312-31231asda",
"additionalAttributes": {
"middleName": "user"
},
"deletedAt": "2023-08-30T23:20:42.822Z"
}{
"type": "INVALID_ACCOUNT_PROVIDED",
"message": "Invalid account provided for the request."
}{
"type": "REQUEST_DENIED",
"message": "Forbidden"
}{
"type": "INTERNAL_SERVER_ERROR",
"message": "Internal server error"
}Authorizations
The access token.
Headers
A header used by fabric to identify the tenant making the request. You must include tenant id in the authentication header for an API request to access any of fabric’s endpoints. You can retrieve the tenant id , which is also called account id, from Copilot. This header is required.
"517fa9dfd42d8b00g1o3k312"
A UUID of the request.
Body
A sample request to add a new customer.
The full name of the customer.
Show child attributes
Show child attributes
The customer's email.
"test@example.com"
Show child attributes
Show child attributes
A UUID of the customer.
"1231012312-312-31231asda"
A placeholder for additional info, in key-value pairs.
{ "type": "shopper" }
Response
OK
A 24-character system-generated customer ID.
"61df41892bf06d00092d0d8a"
The full name of the customer.
Show child attributes
Show child attributes
The customer's email.
"test@example.com"
A flag indicating whether the customer data is deleted. true indicates the customer data is deleted and false indicates otherwise.
false
The time when the customer was added, in UTC format.
"2023-08-30T23:20:42.822Z"
The time when the customer details were last updated, in UTC format.
"2023-08-30T23:20:42.822Z"
The status of the customer.
ACTIVE, INACTIVE, BLOCKED "ACTIVE"
Show child attributes
Show child attributes
A UUID of the customer.
"1231012312-312-31231asda"
A placeholder for additional info, in key-value pairs.
{ "middleName": "user" }
The time when the customer data was deleted, in UTC format.
"2023-08-30T23:20:42.822Z"
Was this page helpful?
