SapaganDocs sapagan.com

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

Accepted keys Server key Store key Store token

Parameters

NameInTypeNotes
idpathstring required
curl -X GET "$SAPAGAN_URL/v1/customers/user-42" \
  -H "Authorization: Bearer $SAPAGAN_KEY"

Responses

200 OK, 404 Not found. Errors use the error body.

Example response 200

{
  "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

Accepted keys Server key

Parameters

NameInTypeNotes
idpathstring required

Request body

FieldTypeNotes
emailstring or nullmax 320
phonestring or nullmax 40
attributesobject
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": {}
  }'

Responses

200 OK, 404 Not found, 409 Conflict. Errors use the error body.

Example response 200

{
  "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

Accepted keys Server key

Parameters

NameInTypeNotes
idpathstring required
curl -X DELETE "$SAPAGAN_URL/v1/customers/user-42" \
  -H "Authorization: Bearer $SAPAGAN_KEY"

Responses

200 OK, 404 Not found. Errors use the error body.

Example response 200

{
  "id": "user-42",
  "deletedAt": "<deletedAt>",
  "eraseAfter": "<eraseAfter>"
}

GET /v1/customers/{id}/export#

Export everything held about a customer (PDP)

Accepted keys Server key

Parameters

NameInTypeNotes
idpathstring required
curl -X GET "$SAPAGAN_URL/v1/customers/user-42/export" \
  -H "Authorization: Bearer $SAPAGAN_KEY"

Responses

200 OK, 404 Not found. Errors use the error body.

Example response 200

{}

GET /v1/customers/{id}/relationships#

List a customer's scope relationships

Accepted keys Server key Store key Store token

Parameters

NameInTypeNotes
idpathstring required
curl -X GET "$SAPAGAN_URL/v1/customers/user-42/relationships" \
  -H "Authorization: Bearer $SAPAGAN_KEY"

Responses

200 OK, 404 Not found. Errors use the error body.

Example response 200

{
  "relationships": [
    {
      "scopeId": "<scopeId>",
      "relation": "buyer",
      "firstAt": "<firstAt>",
      "lastAt": "<lastAt>",
      "orderCount": 1,
      "endedAt": "<endedAt>",
      "source": "<source>",
      "consentSource": "follow"
    }
  ]
}