- docs/backend/pretix.md: Pretix REST API reference (auth, orders/items endpoints, pagination, rate limiting, worked example) - migration 20260909000000_pretix_sync.sql: events.pretix_organizer + pretix_event_slug; _map_ticket_type, _ensure_auth_user (QR token = password), sync_pretix_attendees (service-role-only, idempotent) - sidecar: pretixFetch/fetchPretixOrders/fetchPretixItems/transformPretix, runPretixSync + every-minute runPretixLoop, POST /run-pretix, /status extended with pretix state - admin: Pretix panel + recent runs in Interfaces, per-event Pretix config + Sync button in Events, api/types for Pretix - docker-compose: PRETIX_API_KEY / PRETIX_BASE / PRETIX_SYNC_INTERVAL_MS Verified on VM: 25 paid orders -> 25 attendees, auto-sync every minute, login via QR token works, idempotent (no duplicate registrations).
5.3 KiB
Pretix — ticket order sync
The Pretix integration pulls paid ticket orders from pretix.eu (pretix Hosted) into Convivo so that ticket buyers become registered attendees. The sidecar owns the polling and the transform; the database owns the write (a service-role-only RPC).
- Consumer:
apps/sidecar/— see sidecar.md - DB side: the
sync_pretix_attendeesRPC — see rpcs.md
Service & credentials
| What | Value |
|---|---|
| Service | pretix.eu (pretix Hosted) |
| REST API base URL | https://pretix.eu/api/v1/ |
| Authentication | token-based — header Authorization: Token <API_KEY> |
| API key | zkex2grqjxpcialy9msnm6zd7x1i2bc08gm8k5b7vlstpit7xb98p33oq7zggxqy |
| Organizer | "Austrian Power Platform Enthusiasts" (slug appecommday) |
| Event | "Community Day 2026" (slug tickets), live, currency EUR, 2026-10-23 |
The API key is a team-level token created in the pretix web UI under an organizer team (Organizer → Teams → create token). It is shown once at creation — there is no way to retrieve it later, only regenerate.
Endpoints we use
1. List paid orders
GET https://pretix.eu/api/v1/organizers/appecommday/events/tickets/orders/?status=p
Order resource fields we rely on:
| Field | Type | Notes |
|---|---|---|
code |
string | the order code (e.g. BZWHN) |
status |
string | one of n=pending, p=paid, e=expired, c=canceled |
email |
string | the buyer email |
invoice_address |
object or null | has name |
positions |
list | order-position objects (see below) |
Order-position fields we rely on:
| Field | Type | Notes |
|---|---|---|
id |
integer | the position id |
item |
integer | the item id |
attendee_name |
string or null | |
attendee_email |
string or null | often null in practice — fall back to the order email |
secret |
string | the per-ticket secret — we use this as the QR token / login password |
canceled |
boolean |
2. List items (to map ticket type by name)
GET https://pretix.eu/api/v1/organizers/appecommday/events/tickets/items/
| Field | Type | Notes |
|---|---|---|
id |
integer | |
name |
multi-lingual object | e.g. {"en": "Regular ticket"} |
active |
boolean |
Currently the event has a single item: id 1074118, name "Regular ticket".
Pagination
List responses are:
{ "count": 42, "next": "https://.../orders/?status=p&page=2", "previous": null, "results": [ ... ] }
50 results per page by default; follow next until it is null. You can
pass page_size (max 50) and page query parameters.
Conditional fetching (optional optimization)
The orders list returns an X-Page-Generated header (ISO 8601 server
time). Pass it back as the modified_since query parameter on the next
call to fetch only changed orders.
Errors
4xx responses are JSON:
- General errors:
{"detail": "..."} - Field errors:
{"<field>": ["message", ...]}
| Status | Meaning |
|---|---|
401 |
auth failure (bad/missing token) |
403 |
no permission / not found |
404 |
not found |
Rate limiting (pretix.eu only)
360 requests/minute per organizer account. Exceeding it returns
429 Too Many Requests with a Retry-After header (seconds to wait).
Our usage (~2–4 requests/minute) is far below the limit.
Worked example (anonymized)
A real paid-order response shape, based on verified data:
{
"code": "BZWHN",
"status": "p",
"email": "[email protected]",
"invoice_address": { "name": "Markus Franz" },
"positions": [
{
"id": 48560142,
"item": 1074118,
"attendee_name": "Markus Franz",
"attendee_email": null,
"secret": "awu65383xd8kyte8xkh...",
"canceled": false
}
]
}
Note attendee_email is null — the sync falls back to the order email
([email protected]) as the attendee's identity.
How Convivo uses this
The sidecar polls paid orders every minute and, for each order:
- Groups positions by attendee email — using
attendee_email, falling back to the orderemailwhenattendee_emailis null (one buyer, several tickets → several attendees under the same email). - Maps the ticket item name to a registration type —
speaker/staff/sponsor/attendeeby substring match on the item name, defaulting toattendee. - Uses the position
secretas the QR token — which doubles as the contact's login password (the same convention ascreate_registration/reset_registration_qr_tokenin rpcs.md). - Writes via the service-role-only
sync_pretix_attendeesRPC — the sidecar is the only component that holds the service-role key (see sidecar.md); the RPC upserts contacts + registrations transactionally and is idempotent on re-run.