Campaigns¶
Note
This API is only available when the plugin pretix-campaigns is installed (pretix Hosted and Enterprise only).
The campaigns plugin provides a HTTP API that allows you to create new campaigns.
Resource description¶
The campaign resource contains the following public fields:
Field |
Type |
Description |
|---|---|---|
id |
integer |
Internal campaign ID |
code |
string |
The URL component of the campaign, e.g. with code |
description |
string |
An internal, human-readable name of the campaign. |
external_target |
string |
An URL to redirect to from the tracking link. To redirect to the ticket shop, use an empty string. |
order_count |
integer |
Number of orders tracked on this campaign (read-only) |
click_count |
integer |
Number of clicks tracked on this campaign (read-only) |
Endpoints¶
- GET /api/v1/organizers/(organizer)/events/(event)/campaigns/¶
Returns a list of all campaigns configured for an event.
Example request:
GET /api/v1/organizers/bigevents/events/sampleconf/campaigns/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: application/json { "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "code": "wZnL11fjq", "description": "Facebook", "external_target": "", "order_count:" 0, "click_count:" 0 } ] }
- Query Parameters:
page – The page number in case of a multi-page result set, default is 1
- Parameters:
organizer – The
slugfield of a valid organizerevent – The
slugfield of the event to fetch
- Status Codes:
200 OK – no error
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer or event does not exist or you have no permission to view it.
- GET /api/v1/organizers/(organizer)/events/(event)/campaigns/(id)/¶
Returns information on one campaign, identified by its ID.
Example request:
GET /api/v1/organizers/bigevents/events/sampleconf/campaigns/1/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: application/json { "id": 1, "code": "wZnL11fjq", "description": "Facebook", "external_target": "", "order_count:" 0, "click_count:" 0 }
- Parameters:
organizer – The
slugfield of the organizer to fetchevent – The
slugfield of the event to fetchid – The
idfield of the campaign to fetch
- Status Codes:
200 OK – no error
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer/event/campaign does not exist or you have no permission to view it.
- POST /api/v1/organizers/(organizer)/events/(event)/campaigns/¶
Create a new campaign.
Example request:
POST /api/v1/organizers/bigevents/events/sampleconf/campaigns/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript Content-Type: application/json Content-Length: 166 { "description": "Twitter" }
Example response:
HTTP/1.1 201 Created Vary: Accept Content-Type: application/json { "id": 2, "code": "IfVJQzSBL", "description": "Twitter", "external_target": "", "order_count:" 0, "click_count:" 0 }
- Parameters:
organizer – The
slugfield of the organizer to create a campaign forevent – The
slugfield of the event to create a campaign for
- Status Codes:
201 Created – no error
400 Bad Request – The campaign could not be created due to invalid submitted data.
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer/event does not exist or you have no permission to create campaigns.
- PATCH /api/v1/organizers/(organizer)/events/(event)/campaigns/(id)/¶
Update a campaign. You can also use
PUTinstead ofPATCH. WithPUT, you have to provide all fields of the resource, other fields will be reset to default. WithPATCH, you only need to provide the fields that you want to change.Example request:
PATCH /api/v1/organizers/bigevents/events/sampleconf/campaigns/1/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript Content-Type: application/json Content-Length: 34 { "external_target": "https://mywebsite.com" }
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "id": 2, "code": "IfVJQzSBL", "description": "Twitter", "external_target": "https://mywebsite.com", "order_count:" 0, "click_count:" 0 }
- Parameters:
organizer – The
slugfield of the organizer to modifyevent – The
slugfield of the event to modifyid – The
idfield of the campaign to modify
- Status Codes:
200 OK – no error
400 Bad Request – The campaign could not be modified due to invalid submitted data.
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer/event/campaign does not exist or you have no permission to change it.
- DELETE /api/v1/organizers/(organizer)/events/(event)/campaigns/(id)/¶
Delete a campaign and all associated data.
Example request:
DELETE /api/v1/organizers/bigevents/events/sampleconf/campaigns/1/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript
Example response:
HTTP/1.1 204 No Content Vary: Accept
- Parameters:
organizer – The
slugfield of the organizer to modifyevent – The
slugfield of the event to modifyid – The
idfield of the campaign to delete
- Status Codes:
204 No Content – no error
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer/event/campaign does not exist or you have no permission to change it