Endpoint
Description
Retrieves all tickets belonging to a specific user, enriched with complete event information. This query is useful for displaying a user’s ticket collection, ticket history, or event dashboard.
Source: convex/events.ts:279-299
Parameters
The unique identifier of the user whose tickets to retrieve
Response
Array of ticket objects with embedded event detailsReference to the event this ticket is for
User who owns this ticket
Current ticket status: valid, used, refunded, or cancelled
Unix timestamp (milliseconds) when the ticket was purchased
Stripe payment intent ID for this purchase
Amount paid for the ticket in cents
Complete event information (null if event was deleted)Event date as Unix timestamp (milliseconds)
Total tickets available for this event
Event organizer’s user ID
Whether the event has been cancelled
Example
import { useQuery } from "convex/react";
import { api } from "../convex/_generated/api";
function UserTickets({ userId }: { userId: string }) {
const tickets = useQuery(api.events.getUserTickets, { userId });
if (!tickets) return <div>Loading...</div>;
return (
<div>
<h2>My Tickets</h2>
{tickets.length === 0 ? (
<p>No tickets yet</p>
) : (
<ul>
{tickets.map((ticket) => (
<li key={ticket._id}>
<h3>{ticket.event?.name || "Event Deleted"}</h3>
<p>Status: {ticket.status}</p>
<p>Amount: ${(ticket.amount / 100).toFixed(2)}</p>
<p>
Purchased: {new Date(ticket.purchasedAt).toLocaleDateString()}
</p>
{ticket.event && (
<div>
<p>Location: {ticket.event.location}</p>
<p>
Event Date:{" "}
{new Date(ticket.event.eventDate).toLocaleDateString()}
</p>
</div>
)}
</li>
))}
</ul>
)}
</div>
);
}
Response Example
[
{
"_id": "jx7abc123def",
"eventId": "jd7xyz789ghi",
"userId": "user_abc123",
"status": "valid",
"purchasedAt": 1678901234000,
"paymentIntentId": "pi_3MtwBwLkdIwHu7ix0NJLlkJq",
"amount": 5000,
"event": {
"_id": "jd7xyz789ghi",
"name": "Tech Conference 2026",
"description": "Annual technology conference",
"location": "San Francisco, CA",
"eventDate": 1679500800000,
"price": 5000,
"totalTickets": 100,
"userId": "organizer_xyz789"
}
},
{
"_id": "jx7def456ghi",
"eventId": "jd7uvw456jkl",
"userId": "user_abc123",
"status": "used",
"purchasedAt": 1676309234000,
"paymentIntentId": "pi_3LpqRsLkdIwHu7ix1ABCdefG",
"amount": 2500,
"event": {
"_id": "jd7uvw456jkl",
"name": "Local Meetup",
"description": "Community networking event",
"location": "New York, NY",
"eventDate": 1676400000000,
"price": 2500,
"totalTickets": 50,
"userId": "organizer_xyz789"
}
}
]
Use Cases
- Display user’s ticket dashboard
- Show purchase history
- List upcoming events user has tickets for
- Filter tickets by status (valid, used, refunded)
- Generate QR codes for valid tickets