Update customer details - customer context - Fabric
Update Customer Details - Customer Context
cURL
curl --request PUT \
--url https://api.fabric.inc/v3/customers/self \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data ' \
{ \
"name": { \
"title": "Dr.", \
"firstName": "Pat", \
"middleName": "E", \
"lastName": "Kake", \
"suffix": "Jr."
}, \
"emailAddress": "test@example.com", \
"phone": { \
"number": 15555551234, \
"type": "MOBILE" \
}, \
"additionalAttributes": { \
"middleName": "user" \
} \
}'
Python
import requests
url = "https://api.fabric.inc/v3/customers/self"
payload = {
"name": {
"title": "Dr.",
"firstName": "Pat",
"middleName": "E",
"lastName": "Kake",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"additionalAttributes": { "middleName": "user" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: {
title: 'Dr.',
firstName: 'Pat',
middleName: 'E',
lastName: 'Kake',
suffix: 'Jr.'
},
emailAddress: 'test@example.com',
phone: {number: 15555551234, type: 'MOBILE'},
additionalAttributes: {middleName: 'user'}
})
};
fetch('https://api.fabric.inc/v3/customers/self', 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/self",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => [
'title' => 'Dr.',
'firstName' => 'Pat',
'middleName' => 'E',
'lastName' => 'Kake',
'suffix' => 'Jr.'
],
'emailAddress' => 'test@example.com',
'phone' => [
'number' => 15555551234,
'type' => 'MOBILE'
],
'additionalAttributes' => [
'middleName' => 'user'
]
]),
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;
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fabric.inc/v3/customers/self"
payload := strings.NewReader("{\n \"name\": {\n \"title\": \"Dr.\",\n \"firstName\": \"Pat\",\n \"middleName\": \"E\",\n \"lastName\": \"Kake\",\n \"suffix\": \"Jr.\"\n },\n \"emailAddress\": \"test@example.com\",\n \"phone\": {\n \"number\": 15555551234,\n \"type\": \"MOBILE\"\n },\n \"additionalAttributes\": {\n \"middleName\": \"user\"\n }\n}")
req, _ := http.NewRequest("PUT", 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))
}
Expected Responses
200 OK Example:
{
"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",
"defaultAddress": [
{
"id": "61604a30fdfacd0009816e44",
"address": {
"type": "BILLING",
"addressLine1": "123 Main St.",
"addressLine2": "Suite 100",
"addressLine3": "Seventh floor",
"addressLine4": "Attention: Pat E. Doe",
"city": "Seattle",
"region": "WA",
"postalCode": 98121,
"county": "King County",
"country": "US",
"latitude": 47.6205,
"longitude": -122.3493
},
"isDeleted": false,
"createdAt": "2023-08-30T23:20:42.822Z",
"updatedAt": "2023-08-30T23:20:42.822Z",
"additionalAttributes": {
"landmark": "Beach"
},
"isDefault": false,
"deletedAt": "2023-08-30T23:20:42.822Z"
}
]
}
Error Responses
- 400 Invalid Account Provided
{
"type": "INVALID_ACCOUNT_PROVIDED",
"message": "Invalid account provided for the request."
}
- 403 Request Denied
{
"type": "REQUEST_DENIED",
"message": "Forbidden"
}
- 404 Customer Not Found
{
"type": "CUSTOMER_NOT_FOUND",
"message": "Data with the given identifier isn't found"
}
- 500 Internal Server Error
{
"type": "INTERNAL_SERVER_ERROR",
"message": "Internal server error"
}
Headers
- Authorization: Bearer
- x-fabric-tenant-id: string (required)
- x-fabric-request-id: string (unique request ID)
Body
application/json - A sample request to update customer's details.
Example Request Body:
{
"name": {
"title": "Dr.",
"firstName": "Pat",
"middleName": "E",
"lastName": "Kake",
"suffix": "Jr."
},
"emailAddress": "test@example.com",
"phone": {
"number": 15555551234,
"type": "MOBILE"
},
"additionalAttributes": {
"middleName": "user"
}
}
Example Response:
{
"id": "61df41892bf06d00092d0d8a",
"name": {...},
"emailAddress": "test@example.com",
"isDeleted": false,
"createdAt": "2023-08-30T23:20:42.822Z",
"updatedAt": "2023-08-30T23:20:42.822Z",
"status": "ACTIVE",
"phone": {...},
"externalId": "1231012312-312-31231asda",
"additionalAttributes": {...},
"deletedAt": "2023-08-30T23:20:42.822Z",
"defaultAddress": [...]
}