Skip to main content
Spaces (also called zones) allow you to organize tables by physical location, floor, or dining area. Examples include “Main Dining Room”, “Terrace”, “Bar Area”, or “Second Floor”.

Space Object

id
string (uuid)
Unique identifier for the space
branch_id
string (uuid)
ID of the branch this space belongs to
organization_id
string (uuid)
ID of the parent organization
name
string
Space name (1-255 characters)
description
string
Optional description (max 500 characters)
floor_number
integer
Floor level (default: 1, min: 0 for ground/basement)
sort_order
integer
Display order (default: 0, lower numbers appear first)
is_active
boolean
Whether the space is currently active (default: true)

List Spaces

GET /api/spaces

Retrieve all spaces for the current branch, ordered by sort_order
Required Permission: tables:read Request:
curl https://api.restai.com/v1/api/spaces \
  -H "Authorization: Bearer <token>"
Response:
{
  "success": true,
  "data": [
    {
      "id": "a1b2c3d4-e5f6-4a5b-8c9d-0e1f2a3b4c5d",
      "branch_id": "550e8400-e29b-41d4-a716-446655440000",
      "organization_id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "Comedor Principal",
      "description": "Área principal del restaurante con 20 mesas",
      "floor_number": 1,
      "sort_order": 0,
      "is_active": true
    },
    {
      "id": "b2c3d4e5-f6a7-5b6c-9d0e-1f2a3b4c5d6e",
      "branch_id": "550e8400-e29b-41d4-a716-446655440000",
      "organization_id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "Terraza",
      "description": "Área exterior con vista al jardín",
      "floor_number": 1,
      "sort_order": 1,
      "is_active": true
    },
    {
      "id": "c3d4e5f6-a7b8-6c7d-0e1f-2a3b4c5d6e7f",
      "branch_id": "550e8400-e29b-41d4-a716-446655440000",
      "organization_id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "Segundo Piso",
      "description": "Área VIP en el segundo nivel",
      "floor_number": 2,
      "sort_order": 2,
      "is_active": true
    }
  ]
}

Create Space

POST /api/spaces

Create a new space to organize tables
Required Permission: tables:create Body Parameters:
name
string
required
Space name (1-255 characters)
description
string
Space description (max 500 characters)
floorNumber
integer
default:"1"
Floor level (min: 0)
sortOrder
integer
default:"0"
Display order (min: 0)
isActive
boolean
default:"true"
Whether space is active
Request:
curl -X POST https://api.restai.com/v1/api/spaces \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Bar",
    "description": "Área de bar con barra alta",
    "floorNumber": 1,
    "sortOrder": 3,
    "isActive": true
  }'
Response (201 Created):
{
  "success": true,
  "data": {
    "id": "d4e5f6a7-b8c9-7d8e-1f2a-3b4c5d6e7f8a",
    "branch_id": "550e8400-e29b-41d4-a716-446655440000",
    "organization_id": "123e4567-e89b-12d3-a456-426614174000",
    "name": "Bar",
    "description": "Área de bar con barra alta",
    "floor_number": 1,
    "sort_order": 3,
    "is_active": true
  }
}

Update Space

PATCH /api/spaces/:id

Update an existing space. All fields are optional.
Required Permission: tables:update Path Parameters:
id
string (uuid)
required
Space ID
Body Parameters (all optional):
name
string
Space name (1-255 characters)
description
string
Space description (max 500 characters)
floorNumber
integer
Floor level (min: 0)
sortOrder
integer
Display order (min: 0)
isActive
boolean
Whether space is active
Request:
curl -X PATCH https://api.restai.com/v1/api/spaces/d4e5f6a7-b8c9-7d8e-1f2a-3b4c5d6e7f8a \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Área de Bar",
    "isActive": false
  }'
Response:
{
  "success": true,
  "data": {
    "id": "d4e5f6a7-b8c9-7d8e-1f2a-3b4c5d6e7f8a",
    "branch_id": "550e8400-e29b-41d4-a716-446655440000",
    "organization_id": "123e4567-e89b-12d3-a456-426614174000",
    "name": "Área de Bar",
    "description": "Área de bar con barra alta",
    "floor_number": 1,
    "sort_order": 3,
    "is_active": false
  }
}
Error Responses:
// 404 Not Found
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Espacio no encontrado"
  }
}

Delete Space

DELETE /api/spaces/:id

Delete a space (only if no tables are assigned)
Required Permission: tables:update Path Parameters:
id
string (uuid)
required
Space ID
Request:
curl -X DELETE https://api.restai.com/v1/api/spaces/d4e5f6a7-b8c9-7d8e-1f2a-3b4c5d6e7f8a \
  -H "Authorization: Bearer <token>"
Response:
{
  "success": true,
  "data": {
    "id": "d4e5f6a7-b8c9-7d8e-1f2a-3b4c5d6e7f8a",
    "branch_id": "550e8400-e29b-41d4-a716-446655440000",
    "organization_id": "123e4567-e89b-12d3-a456-426614174000",
    "name": "Área de Bar",
    "description": "Área de bar con barra alta",
    "floor_number": 1,
    "sort_order": 3,
    "is_active": false
  }
}
Error Responses:
// 400 Bad Request - Space has tables
{
  "success": false,
  "error": {
    "code": "BAD_REQUEST",
    "message": "No se puede eliminar un espacio que tiene mesas asignadas"
  }
}

// 404 Not Found
{
  "success": false,
  "error": {
    "code": "NOT_FOUND",
    "message": "Espacio no encontrado"
  }
}
You cannot delete a space that has tables assigned to it. First reassign or delete all tables in the space, then delete the space.

Organizing with Spaces

Use Cases

By Location:
[
  { "name": "Comedor Principal", "floorNumber": 1 },
  { "name": "Terraza", "floorNumber": 1 },
  { "name": "Bar", "floorNumber": 1 }
]
By Floor:
[
  { "name": "Planta Baja", "floorNumber": 0 },
  { "name": "Primer Piso", "floorNumber": 1 },
  { "name": "Segundo Piso - VIP", "floorNumber": 2 }
]
By Section:
[
  { "name": "Sección A - Ventanas", "sortOrder": 0 },
  { "name": "Sección B - Centro", "sortOrder": 1 },
  { "name": "Sección C - Privados", "sortOrder": 2 }
]

Best Practices

  1. Logical grouping: Organize spaces by how staff navigate the restaurant
  2. Sort order: Use increments of 10 (0, 10, 20) to allow inserting new spaces later
  3. Clear names: Use descriptive names that staff will immediately recognize
  4. Floor numbers: Use 0 for ground floor, negative numbers for basements
  5. Temporary closure: Use isActive: false to temporarily hide a space without deleting it

Assigning Tables to Spaces

When creating or updating tables, reference the space ID:
curl -X POST https://api.restai.com/v1/api/tables \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "number": 10,
    "capacity": 4,
    "spaceId": "a1b2c3d4-e5f6-4a5b-8c9d-0e1f2a3b4c5d"
  }'
The spaceId field is optional when creating tables. Tables without a space assignment will appear in an “Unassigned” group in the UI.

Build docs developers (and LLMs) love