Customer
Base path: /api/data/customer
POST /api/data/customer
Find or create a customer record. If a customer with the given discordId already exists for the tenant, returns the existing record with status 200; otherwise creates a new one with status 201.
Auth: Session cookie required
Tenant: Scoped via x-tenant-id header
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| discordId | string | Yes | Customer's Discord user ID |
| discordUsername | string | Yes | Customer's Discord username |
| discordDisplayName | string | Yes | Customer's Discord display name |
| source | enum | No | DISCORD (default), EMAIL, MANUAL |
| string | No | Customer email address (must be valid email) | |
| phone | string | No | Customer phone number |
| userId | string | No | Associated platform user ID |
Response (201 Created / 200 OK)
Returns the full customer record.
Errors
| Status | Condition |
|---|---|
| 400 | Validation error |
GET /api/data/customer/:id
Retrieve a customer by ID.
Auth: Session cookie required
Tenant: Scoped via x-tenant-id header
Response (200)
Returns the customer record.
Errors
| Status | Condition |
|---|---|
| 400 | Missing customer ID |
| 404 | Customer not found |
PATCH /api/data/customer/:id
Update a customer record.
Auth: Session cookie required
Tenant: Scoped via x-tenant-id header
Request Body
All fields are optional:
| Field | Type | Required | Description |
|---|---|---|---|
| discordUsername | string | No | Updated Discord username |
| discordDisplayName | string | No | Updated Discord display name |
| string | No | Updated email (must be valid email) | |
| phone | string | No | Updated phone number |
| notes | string | No | Free-form notes |
| userId | string | No | Associated platform user ID |
Response (200)
Returns the updated customer record.
Errors
| Status | Condition |
|---|---|
| 400 | Missing customer ID or validation error |
DELETE /api/data/customer/:id
Deactivate a customer (soft delete — sets isActive to false).
Auth: Session cookie required
Tenant: Scoped via x-tenant-id header
Response (200)
Returns the deactivated customer record.
Errors
| Status | Condition |
|---|---|
| 400 | Missing customer ID |
GET /api/data/customer
List all customers for the current tenant.
Auth: Session cookie required
Tenant: Scoped via x-tenant-id header
Response (200)
Returns an array of customer records.
Errors
| Status | Condition |
|---|---|
| 500 | Internal server error |
POST /api/data/customer/:id/address
Add an address to a customer.
Auth: Session cookie required
Tenant: Scoped via x-tenant-id header
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| addressId | string | Yes | Unique identifier for the address |
| name | string | Yes | Recipient name |
| line1 | string | Yes | Street address line 1 |
| line2 | string | No | Street address line 2 |
| city | string | Yes | City |
| state | string | Yes | State / province |
| postalCode | string | Yes | ZIP / postal code |
| country | string | Yes | Country code (min 2 chars) |
| phone | string | No | Phone number |
Response (200)
Returns the updated customer record with the new address.
Errors
| Status | Condition |
|---|---|
| 400 | Validation error or operation failure |
DELETE /api/data/customer/:id/address/:addressId
Remove an address from a customer.
Auth: Session cookie required
Tenant: Scoped via x-tenant-id header
Response (200)
Returns the updated customer record.
Errors
| Status | Condition |
|---|---|
| 400 | Operation failure |
PATCH /api/data/customer/:id/default-address
Set the default address for a customer.
Auth: Session cookie required
Tenant: Scoped via x-tenant-id header
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| addressId | string | Yes | ID of the address to set as default |
Response (200)
Returns the updated customer record.
Errors
| Status | Condition |
|---|---|
| 400 | Missing addressId or operation failure |
POST /api/data/customer/:id/link
Link a customer to a platform user.
Auth: Session cookie required
Tenant: Scoped via x-tenant-id header
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | Platform user ID to link |
Response (200)
Returns the updated customer record.
Errors
| Status | Condition |
|---|---|
| 400 | Missing userId or operation failure |