Skip to main content
Generates tickets for every seat across all zones of an event. The event must have a setup/zones document with status: true before tickets can be generated. Each ticket is written to both Firestore (events/{idevent}/tickets) and PostgreSQL.

Endpoint

POST https://{region}-{project}.cloudfunctions.net/tickets_generate

Request body

data.idevent
string
required
The Firestore document ID of the event to generate tickets for.

Example

curl -X POST https://{region}-{project}.cloudfunctions.net/tickets_generate \
  -H "Content-Type: application/json" \
  -d '{"data": {"idevent": "JAOTIiQrtU1fMWZZY2IZ"}}'

What it does

  1. Fetches the event document at events/{idevent}. Returns 400 if not found.
  2. Fetches events/{idevent}/setup/zones. Returns 400 if the zones document has status: false.
  3. For each zone, iterates from 1 to zone.seats and creates one ticket per seat.
  4. Commits all tickets to Firestore in a single batch.
  5. Inserts all tickets into the PostgreSQL tickets table.

Ticket structure

Each generated ticket has the following fields:
{
  "date": {
    "created": "<Firestore Timestamp>",
    "updated": ""
  },
  "date_start": "<event date_start>",
  "date_end": "<event date_end>",
  "event_name": "<event.event.name>",
  "event_id": "JAOTIiQrtU1fMWZZY2IZ",
  "seat_id": "VIP-1",
  "status": true,
  "ticket_id": "JAOTIiQrtU1fMWZZY2IZ-nGxHQ00YzCg9PphEwlYb",
  "zone": "VIP",
  "color": "#FFD700",
  "seat_row": "por asignar",
  "ledger": [
    {
      "date": "<ISO timestamp>",
      "action": "generated",
      "metadata": ""
    }
  ]
}
FieldSourceDescription
ticket_id{idevent}-{auto-id}Globally unique ticket identifier.
seat_id{zone.id}-{seat number}Seat identifier within the zone.
zonezone.nameZone name from the event setup.
colorzone.colorDisplay color for the zone.
seat_row"por asignar"Row assignment, filled in later.
statustruetrue means the ticket is available.
event_nameevent.event.nameName of the event.
date_start / date_endevent documentEvent start and end timestamps.

Response

message
string
Summary of how many tickets were generated.
status
number
200 on success, 400 on error.
data
object
Success (200):
{
  "message": "Se Generaron: 200",
  "status": 200,
  "data": { "valido": true }
}
Event not found (400):
{
  "message": "Evento no Encontrado",
  "status": 400,
  "data": { "valido": false }
}
Event zones not active (200):
{
  "message": "El evento no esta activo para generar tickets",
  "status": 200,
  "data": { "valido": false }
}
Ticket generation is triggered based on datos.seats_allocated. Ensure the zones setup document is fully configured before calling this endpoint to avoid partial generation.

Build docs developers (and LLMs) love