Skip to main content

Customer API

Overview

The Customer API manages customer accounts - the vendors/operators who purchase subscriptions or licenses to use the photobooth.

API Endpoints

Create Customer

Endpoint: POST /v1/customers

Creates a new customer account.

Request Body:

{
name?: string;
email?: string;
phone?: string;
licenseType: "starter" | "pro" | "enterprise";
}

Response: 201 Created

{
id: string;
name?: string;
email?: string;
phone?: string;
licenseType: "starter" | "pro" | "enterprise";
purchaseDate?: string;
createdAt: string;
updatedAt: string;
}

Code Reference: services/api/customers/controller.ts


Get Current Customer

Endpoint: GET /v1/customers/me

Returns the current customer based on session context.

Response:

{
customer: Customer | null; // null if no active session
}

Code Reference: services/api/customers/controller.ts - GET /me


Get Customer by ID

Endpoint: GET /v1/customers/:id

Retrieves a specific customer by their ID.

Response: Customer object or 404 Not Found

Code Reference: services/api/customers/controller.ts - GET /:id


Customer Model

interface Customer {
id: string;
name?: string;
email?: string;
phone?: string;
licenseType: "starter" | "pro" | "enterprise";
purchaseDate?: string;
createdAt: string;
updatedAt: string;
}

Code Reference

  • Controller: services/api/customers/controller.ts
  • Service: services/api/customers/service.ts
  • Use Cases:
    • services/api/customers/use-cases/create-customer.ts
    • services/api/customers/use-cases/get-customer.ts
  • Models: services/api/customers/models.ts

Usage Patterns

Use CaseEndpoint Called
New vendor signupPOST /v1/customers
Session restorationGET /v1/customers/me
Admin lookupGET /v1/customers/:id

Database Schema (D1)

CREATE TABLE customers (
id TEXT PRIMARY KEY,
name TEXT,
email TEXT,
phone TEXT,
license_type TEXT NOT NULL,
purchase_date TEXT,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);