Skip to main content
Table sessions represent active dining experiences. They track customer information, session status, and link to orders.

Session Lifecycle

Sessions progress through these statuses:
  1. pending: Customer requested access, awaiting staff approval
  2. active: Staff approved, customer can place orders
  3. completed: Session ended, table available
  4. rejected: Staff rejected the session request

Start Table Session

This endpoint is for internal/staff use. Customers should use the /api/customer endpoints to request access.
POST /api/tables/sessions Create a new table session with a customer token.

Request Body

tableId
string
required
UUID of the table
customerName
string
required
Customer’s name (1-255 characters)
customerPhone
string
Customer’s phone number (max 20 characters)

Response

success
boolean
Indicates if the request was successful
data
object
session
object
The created session object
id
string
Session UUID
table_id
string
Table UUID
customer_name
string
Customer’s name
status
string
Session status (pending, active, completed, rejected)
started_at
string
ISO 8601 timestamp
token
string
Customer JWT token for authenticated requests

Example

curl -X POST https://api.restai.com/api/tables/sessions \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "tableId": "123e4567-e89b-12d3-a456-426614174000",
    "customerName": "Juan Perez",
    "customerPhone": "+51987654321"
  }'
{
  "success": true,
  "data": {
    "session": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "table_id": "123e4567-e89b-12d3-a456-426614174000",
      "customer_name": "Juan Perez",
      "customer_phone": "+51987654321",
      "status": "pending",
      "started_at": "2024-03-15T18:30:00Z"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

List Sessions

GET /api/tables/sessions Retrieve sessions for the current branch with optional filtering.

Query Parameters

status
string
Filter by status: pending, active, completed, or rejected

Response

success
boolean
Indicates if the request was successful
data
array
Array of session objects with table numbers
id
string
Session UUID
table_id
string
Table UUID
table_number
number
Table number
customer_name
string
Customer’s name
status
string
Session status
started_at
string
Session start timestamp
ended_at
string
Session end timestamp (null if active)

Example

curl -X GET "https://api.restai.com/api/tables/sessions?status=active" \
  -H "Authorization: Bearer YOUR_TOKEN"

List Pending Sessions

GET /api/tables/sessions/pending Retrieve all sessions awaiting staff approval.

Response

success
boolean
Indicates if the request was successful
data
array
Array of pending sessions
id
string
Session UUID
customer_name
string
Customer’s name
customer_phone
string
Customer’s phone
table_id
string
Table UUID
table_number
number
Table number
started_at
string
Request timestamp

Approve Session

PATCH /api/tables/sessions/:id/approve Approve a pending session, allowing the customer to place orders.

Path Parameters

id
string
required
Session UUID

Response

success
boolean
Indicates if the request was successful
data
object
Updated session object with active status

Example

curl -X PATCH https://api.restai.com/api/tables/sessions/550e8400-e29b-41d4-a716-446655440000/approve \
  -H "Authorization: Bearer YOUR_TOKEN"

Events

Broadcasts WebSocket events:
  • session:approved to branch channel
  • session:approved to session-specific channel

Reject Session

PATCH /api/tables/sessions/:id/reject Reject a pending session request.

Path Parameters

id
string
required
Session UUID

Response

success
boolean
Indicates if the request was successful
data
object
Updated session object with rejected status

Events

Broadcasts WebSocket events:
  • session:rejected to branch channel
  • session:rejected to session-specific channel

End Session

PATCH /api/tables/sessions/:id/end End an active session, freeing the table for new customers.

Path Parameters

id
string
required
Session UUID

Response

success
boolean
Indicates if the request was successful
data
object
Updated session object with completed status and ended_at timestamp

Example

curl -X PATCH https://api.restai.com/api/tables/sessions/550e8400-e29b-41d4-a716-446655440000/end \
  -H "Authorization: Bearer YOUR_TOKEN"

Events

Broadcasts session:ended to branch channel.

Get Session Details

GET /api/tables/sessions/:id Retrieve detailed information about a specific session.

Path Parameters

id
string
required
Session UUID

Response

success
boolean
Indicates if the request was successful
data
object
Complete session object including all fields

Error Responses

404 NOT_FOUND
Session not found or doesn’t belong to your branch
404 PENDING_SESSION_NOT_FOUND
No pending session found with that ID (for approve/reject)
404 ACTIVE_SESSION_NOT_FOUND
No active session found with that ID (for end)

Build docs developers (and LLMs) love