Skip to main content
TMT allows end users to transfer tickets to other registered users. Both online and offline transfer modes write to Firestore and PostgreSQL and append a transferred ledger entry to the ticket.

Transfer flow

1

Verify recipient

The function looks up the recipient by email in u_users. The recipient must exist and have account_validated: true.
2

Retrieve current ledger

The ticket’s existing ledger is read from PostgreSQL (tickets table) to preserve the full audit history.
3

Update ticket ownership

Firestore and PostgreSQL are updated with the new customer_email, customer_id, customer_name, customer_phone, and a new transferred ledger entry.
4

Sync to both users' wallets

The ticket document is written to both the sender’s and recipient’s u_users/{uid}/tickets subcollections.

app_transfer_tickets

Transfers a ticket online to another registered user. Both users must be registered in u_users. The recipient must have account_validated: true.

Endpoint

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

Request

data.ticket_id
string
required
The full ticket ID (e.g., eventId-ticketDocId) to transfer.
data.email
string
required
Email address of the recipient user.
data.email_from
string
required
Email address of the sender (current ticket holder).
{
  "data": {
    "ticket_id": "abc123-def456",
    "email": "[email protected]",
    "email_from": "[email protected]"
  }
}

Response

Success:
{
  "message": "Ticket Transferido",
  "status": 200,
  "data": {
    "valido": true,
    "ticket": "abc123-def456",
    "message": "Ticket Transferido"
  }
}
Recipient email not validated:
{
  "message": "Email no validado",
  "status": 400,
  "data": { "valido": false, "message": "Email no validado" }
}
Recipient not registered:
{
  "message": "Email no registrado",
  "status": 400,
  "data": { "valido": false, "message": "Email no registrado" }
}

app_transfer_tickets_offline

Same as app_transfer_tickets but adds a deduplication guard: if the ticket’s transferred field in PostgreSQL is already set (non-null), the transfer is rejected with "Ticket ya sincronizado". This prevents double-transfers of tickets that were already transferred offline.

Endpoint

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

Request

Same parameters as app_transfer_tickets.
data.ticket_id
string
required
Full ticket ID to transfer.
data.email
string
required
Recipient email address.
data.email_from
string
required
Sender email address.

Additional response case

Ticket already transferred offline:
{
  "message": "Ticket ya sincronizado",
  "status": 400,
  "data": { "valido": false, "message": "Ticket ya sincronizado" }
}
The offline transfer sets transferred: "offline" in both Firestore and PostgreSQL. The online transfer sets transferred: "online". Use app_transfer_tickets_offline when the device may have been offline during the original transfer to prevent duplicate processing.

Build docs developers (and LLMs) love