Catch-up note for the organizer display-name fetch added with 5cb67af:
GET /organizers/<slug>/ returns the organisation name (multi-lingual object
or string), which the sidecar resolves via pickPretixName and stores on
events.company during each Pretix sync so badges can bind a Company field.
There is no separate company field on the organizer resource.
Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
175 lines
5.9 KiB
Markdown
175 lines
5.9 KiB
Markdown
# Pretix — ticket order sync
|
||
|
||
The **Pretix integration** pulls paid ticket orders from
|
||
[pretix.eu](https://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/`](../../apps/sidecar/) — see
|
||
[sidecar.md](./sidecar.md)
|
||
- DB side: the `sync_pretix_attendees` RPC — see [rpcs.md](./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".
|
||
|
||
### 3. Organizer detail (the owning company name)
|
||
|
||
```
|
||
GET https://pretix.eu/api/v1/organizers/appecommday/
|
||
```
|
||
|
||
| Field | Type | Notes |
|
||
|---|---|---|
|
||
| `slug` | string | `appecommday` |
|
||
| `name` | multi-lingual object or string | the organisation / company display name, e.g. `"Austrian Power Platform Enthusiasts"` |
|
||
|
||
The sidecar fetches this during each Pretix sync and stores the resolved name on
|
||
`events.company`, so badges can bind a **Company / organizer** field independent
|
||
of the event's own name. (There is no separate `company` field on the organizer
|
||
resource — the display name is the company.)
|
||
|
||
## Pagination
|
||
|
||
List responses are:
|
||
|
||
```json
|
||
{ "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:
|
||
|
||
```json
|
||
{
|
||
"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:
|
||
|
||
1. **Groups positions by attendee email** — using `attendee_email`, falling
|
||
back to the order `email` when `attendee_email` is null (one buyer, several
|
||
tickets → several attendees under the same email).
|
||
2. **Maps the ticket item name to a registration type** — `speaker` / `staff` /
|
||
`sponsor` / `attendee` by substring match on the item name, **defaulting to
|
||
`attendee`**.
|
||
3. **Uses the position `secret` as the QR token** — which doubles as the
|
||
contact's **login password** (the same convention as
|
||
`create_registration` / `reset_registration_qr_token` in
|
||
[rpcs.md](./rpcs.md)).
|
||
4. **Writes via the service-role-only `sync_pretix_attendees` RPC** — the
|
||
sidecar is the only component that holds the service-role key (see
|
||
[sidecar.md](./sidecar.md)); the RPC upserts contacts + registrations
|
||
transactionally and is idempotent on re-run.
|
||
|
||
## Source
|
||
|
||
- [REST API overview](https://docs.pretix.eu/dev/api/)
|
||
- [Fundamentals — auth, pagination, errors, conditional fetching](https://docs.pretix.eu/dev/api/fundamentals.html)
|
||
- [Token authentication](https://docs.pretix.eu/dev/api/tokenauth.html)
|
||
- [Orders resource](https://docs.pretix.eu/dev/api/resources/orders.html)
|
||
- [Items resource](https://docs.pretix.eu/dev/api/resources/items.html)
|
||
- [Rate limiting](https://docs.pretix.eu/dev/api/ratelimit.html)
|