Skip to main content
Three functions cover the core read and update operations against tickets. All queries run against PostgreSQL for performance; write operations (tickets_update_individual) are dual-written to both PostgreSQL and Firestore.

List Event Tickets

tickets_list_event returns every ticket row for a given event from the PostgreSQL tickets table.
POST /tickets_list_event
Content-Type: application/json
{
  "data": {
    "event_id": "JAOTIiQrtU1fMWZZY2IZ"
  }
}

Request Parameters

data.event_id
string
required
The event ID to list tickets for. Matches the event_id column in the tickets table.

Response Fields

data.valido
boolean
true when at least one ticket was found.
data.response
array
Array of ticket rows. Each row contains all columns from the tickets table including ticket_id, seat_id, zone, color, status, access_status, access_entry, customer_id, customer_name, customer_email, ledger, date_start, date_end, date_created, and date_updated.
Success (200)
{
  "message": "Evento Encontrado",
  "status": 200,
  "data": {
    "valido": true,
    "response": [
      {
        "ticket_id": "JAOTIiQrtU1fMWZZY2IZ-nGxHQ00YzCg9PphEwlYb",
        "seat_id": "VIP1",
        "zone": "VIP",
        "color": "#FFD700",
        "status": true,
        "access_status": false,
        "access_entry": false,
        "event_id": "JAOTIiQrtU1fMWZZY2IZ",
        "event_name": "Festival de Verano 2024",
        "seat_row": "por asignar",
        "date_start": "2024-11-15T18:00:00-05:00",
        "date_end": "2024-11-15T23:00:00-05:00",
        "date_created": "2024-10-01T10:00:00-05:00",
        "date_updated": "2024-10-01T10:00:00-05:00",
        "ledger": [
          { "date": "2024-10-01T10:00:00-05:00", "action": "generated", "metadata": "{}" }
        ]
      }
    ]
  }
}
Not found (400)
{
  "message": "Evento no Encontrado",
  "status": 400,
  "data": { "valido": false }
}

Get Individual Ticket

tickets_individual fetches a single ticket by its ticket_id.
POST /tickets_individual
Content-Type: application/json
{
  "data": {
    "ticket_id": "JAOTIiQrtU1fMWZZY2IZ-nGxHQ00YzCg9PphEwlYb"
  }
}

Request Parameters

data.ticket_id
string
required
The full composite ticket ID in the format {event_id}-{firestoreDocId}.

Response Fields

data.valido
boolean
true when the ticket was found.
data.response
array
Single-element array containing the complete ticket row from PostgreSQL.
Success (200)
{
  "message": "Ticket Encontrado",
  "status": 200,
  "data": {
    "valido": true,
    "response": [
      {
        "ticket_id": "JAOTIiQrtU1fMWZZY2IZ-nGxHQ00YzCg9PphEwlYb",
        "seat_id": "VIP1",
        "zone": "VIP",
        "color": "#FFD700",
        "status": false,
        "access_status": true,
        "access_entry": true,
        "customer_id": "usr_001",
        "customer_name": "María González",
        "customer_email": "[email protected]",
        "customer_phone": "+58 412 555 0001",
        "ledger": [
          { "date": "2024-10-01T10:00:00-05:00", "action": "generated", "metadata": "{}" },
          { "date": "2024-11-01T14:23:00-05:00", "action": "accessed", "metadata": "{}" }
        ]
      }
    ]
  }
}

Update Individual Ticket

tickets_update_individual updates the status field of a ticket and appends an updated entry to the ledger. The change is written to both PostgreSQL and Firestore.
POST /tickets_update_individual
Content-Type: application/json
{
  "data": {
    "id": "JAOTIiQrtU1fMWZZY2IZ-nGxHQ00YzCg9PphEwlYb",
    "status": false
  }
}

Request Parameters

data.id
string
required
Full composite ticket ID ({event_id}-{firestoreDocId}). The function splits this on - to derive the Firestore path events/{event_id}/tickets/{docId}.
data.status
boolean
required
The new status value for the ticket. true = available, false = sold/unavailable.

What gets updated

StoreFields written
PostgreSQL ticketsstatus, ledger, date_updated
Firestore events/{id}/tickets/{docId}status, date.updated, ledger
The ledger entry appended by this function uses the action "accessed" (as written in the PostgreSQL update string). This is distinct from the access control "accessed" action — it means the ticket record was accessed/modified administratively.
Success (200)
{
  "message": "Ticket Actualizado",
  "status": 200,
  "data": { "valido": true }
}
Ticket not found (400)
{
  "message": "Ticket no Encontrado",
  "status": 400,
  "data": { "valido": false }
}

Sales View: List Event Tickets with Block Status

tickets_list_event_sales returns tickets with a computed status that accounts for both the sold state (status) and any active hold in the tickets_blocked table.
POST /tickets_list_event_sales
Content-Type: application/json
{
  "data": {
    "event_id": "JAOTIiQrtU1fMWZZY2IZ"
  }
}

Response Fields

data.response[].status
boolean
Computed availability: false if the ticket is blocked (status_d) OR already sold (!status). true only if the ticket is both unblocked and unsold.
data.response[].status_real
boolean
The raw status column value from the tickets table, before the block calculation.
data.response[].status_offline
boolean
true when the ticket is currently assigned to an offline office and not available for online sale.

Build docs developers (and LLMs) love