API reference
Customers
Read, write, export and delete one person by their external id.
Read, write, export and delete one person by their external id.
GET /v1/customers/{id}#
Read a customer
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
id | path | string required |
curl -X GET "$SAPAGAN_URL/v1/customers/user-42" \
-H "Authorization: Bearer $SAPAGAN_KEY"const res = await fetch(`${process.env.SAPAGAN_URL}/v1/customers/user-42`, {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.SAPAGAN_KEY}`,
},
});
const data = await res.json();Responses
{
"id": "user-42",
"email": "budi@example.com",
"phone": "+6281234567890",
"attributes": {},
"createdAt": "<createdAt>",
"updatedAt": "<updatedAt>",
"unsubscribedAt": "<unsubscribedAt>"
}PUT /v1/customers/{id}#
Create or update a customer
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
id | path | string required |
Request body
| Field | Type | Notes |
|---|---|---|
email | string or null | max 320 |
phone | string or null | max 40 |
attributes | object |
curl -X PUT "$SAPAGAN_URL/v1/customers/user-42" \
-H "Authorization: Bearer $SAPAGAN_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "budi@example.com",
"phone": "+6281234567890",
"attributes": {}
}'const res = await fetch(`${process.env.SAPAGAN_URL}/v1/customers/user-42`, {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.SAPAGAN_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"email": "budi@example.com",
"phone": "+6281234567890",
"attributes": {}
}),
});
const data = await res.json();Responses
{
"id": "user-42",
"email": "budi@example.com",
"phone": "+6281234567890",
"attributes": {},
"createdAt": "<createdAt>",
"updatedAt": "<updatedAt>",
"unsubscribedAt": "<unsubscribedAt>"
}DELETE /v1/customers/{id}#
Delete a customer (PDP): soft delete now, erasure in 30 days
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
id | path | string required |
curl -X DELETE "$SAPAGAN_URL/v1/customers/user-42" \
-H "Authorization: Bearer $SAPAGAN_KEY"const res = await fetch(`${process.env.SAPAGAN_URL}/v1/customers/user-42`, {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.SAPAGAN_KEY}`,
},
});
const data = await res.json();Responses
{
"id": "user-42",
"deletedAt": "<deletedAt>",
"eraseAfter": "<eraseAfter>"
}GET /v1/customers/{id}/export#
Export everything held about a customer (PDP)
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
id | path | string required |
curl -X GET "$SAPAGAN_URL/v1/customers/user-42/export" \
-H "Authorization: Bearer $SAPAGAN_KEY"const res = await fetch(`${process.env.SAPAGAN_URL}/v1/customers/user-42/export`, {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.SAPAGAN_KEY}`,
},
});
const data = await res.json();Responses
{}GET /v1/customers/{id}/relationships#
List a customer's scope relationships
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
id | path | string required |
curl -X GET "$SAPAGAN_URL/v1/customers/user-42/relationships" \
-H "Authorization: Bearer $SAPAGAN_KEY"const res = await fetch(`${process.env.SAPAGAN_URL}/v1/customers/user-42/relationships`, {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.SAPAGAN_KEY}`,
},
});
const data = await res.json();Responses
{
"relationships": [
{
"scopeId": "<scopeId>",
"relation": "buyer",
"firstAt": "<firstAt>",
"lastAt": "<lastAt>",
"orderCount": 1,
"endedAt": "<endedAt>",
"source": "<source>",
"consentSource": "follow"
}
]
}