Skip to main content
POST /api/customer/:branchSlug/:tableCode/register This public endpoint allows customers to scan a table QR code and request access to dine. The request creates a pending session that staff must approve.
This endpoint is public and does not require authentication. The table code comes from the QR code.

URL Parameters

branchSlug
string
required
Branch slug identifier (e.g., downtown-lima)
tableCode
string
required
Unique table QR code in format {branchSlug}-{tableNumber} (e.g., downtown-lima-15)

Request Body

customerName
string
required
Customer’s full name (1-255 characters)
customerPhone
string
Customer’s phone number (optional, max 20 characters)
email
string
Customer’s email address (optional, enables loyalty tracking)
birthDate
string
Customer’s birth date in ISO 8601 format (optional)

Response

Success (201 Created)

success
boolean
Always true for successful requests
data
object
session
object
Created session object
id
string
Session UUID
table_id
string
Table UUID
customer_name
string
Customer’s name
status
string
Session status - will be pending initially
started_at
string
ISO 8601 timestamp when session was created
token
string
JWT token for customer authentication. Use this in the Authorization: Bearer header for subsequent requests.
sessionId
string
Session UUID (same as session.id)
customer
object
Customer record (created or existing)
id
string
Customer UUID
name
string
Customer’s name
email
string
Customer’s email
phone
string
Customer’s phone
existing
boolean
Only present if table already has an active session. When true, the response returns the existing session and its token instead of creating a new one.

Customer Access Flow

  1. Customer Scans QR Code: Table QR code contains the branch slug and table code
  2. Request Access: Customer fills out their information and submits
  3. Session Created: System creates a pending session and customer record
  4. Wait for Approval: Customer polls the session status or listens via WebSocket
  5. Staff Approves: Staff sees pending session notification and approves/rejects
  6. Customer Notified: Session status changes to active or rejected
  7. Place Orders: With active session, customer can browse menu and place orders

Deduplication

The system automatically deduplicates customers based on email or phone number:
  • If a customer with the same email or phone exists, the existing record is used
  • This enables loyalty points to accumulate across visits
  • Without email/phone, a new customer record is created for each session

Session Constraints

One Active Session Per Table: If the table already has an active session, this endpoint returns the existing session with existing: true. The customer can join the existing session.
Pending Session Conflict: If the table has a pending session awaiting approval, the request returns a 409 SESSION_PENDING error.

Examples

Request

curl -X POST https://api.restai.com/api/customer/downtown-lima/downtown-lima-15/register \
  -H "Content-Type: application/json" \
  -d '{
    "customerName": "Maria Garcia",
    "customerPhone": "+51987654321",
    "email": "[email protected]",
    "birthDate": "1990-05-15"
  }'

Response - New Session

{
  "success": true,
  "data": {
    "session": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "table_id": "123e4567-e89b-12d3-a456-426614174000",
      "customer_name": "Maria Garcia",
      "customer_phone": "+51987654321",
      "status": "pending",
      "started_at": "2024-03-15T18:30:00Z",
      "ended_at": null
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1NTBlODQwMC1lMjliLTQxZDQtYTcxNi00NDY2NTU0NDAwMDAiLCJvcmciOiI3ODllODQwMC1lMjliLTQxZDQtYTcxNi00NDY2NTU0NDAwMDAiLCJicmFuY2giOiI5OTllODQwMC1lMjliLTQxZDQtYTcxNi00NDY2NTU0NDAwMDAiLCJ0YWJsZSI6IjEyM2U0NTY3LWU4OWItMTJkMy1hNDU2LTQyNjYxNDE3NDAwMCIsImN1c3RvbWVySWQiOiJhYWFlODQwMC1lMjliLTQxZDQtYTcxNi00NDY2NTU0NDAwMDAiLCJyb2xlIjoiY3VzdG9tZXIiLCJpYXQiOjE3MTA1MjU4MDAsImV4cCI6MTcxMDU0MDIwMH0.xyz123",
    "sessionId": "550e8400-e29b-41d4-a716-446655440000",
    "customer": {
      "id": "aaae8400-e29b-41d4-a716-446655440000",
      "name": "Maria Garcia",
      "email": "[email protected]",
      "phone": "+51987654321"
    }
  }
}

Response - Existing Active Session

{
  "success": true,
  "data": {
    "session": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "table_id": "123e4567-e89b-12d3-a456-426614174000",
      "customer_name": "Juan Perez",
      "status": "active",
      "started_at": "2024-03-15T18:00:00Z"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "sessionId": "550e8400-e29b-41d4-a716-446655440000",
    "existing": true
  }
}

Error Responses

404 NOT_FOUND
Branch or table not found with the provided slug/code
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Sucursal no encontrada"
  }
}
409 SESSION_PENDING
Table has a pending session awaiting approval
{
  "success": false,
  "error": {
    "code": "SESSION_PENDING",
    "message": "Esta mesa esta en espera de aprobacion"
  }
}

Next Steps

After receiving the token:
  1. Poll Session Status: Use GET /api/customer/:branchSlug/:tableCode/session-status/:sessionId to check if approved
  2. WebSocket Connection: Connect to session:{sessionId} channel to receive real-time approval notification
  3. Browse Menu: Use GET /api/customer/:branchSlug/:tableCode/menu to view available items
  4. Place Orders: Once approved, use POST /api/customer/orders with the customer token

WebSocket Events

After registration, listen for these events on the session:{sessionId} channel:
  • session:approved - Session was approved by staff
  • session:rejected - Session was rejected by staff

Build docs developers (and LLMs) love