Campaigns¶
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
slug
field of a valid organizerevent – The
slug
field 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
slug
field of the organizer to fetchevent – The
slug
field of the event to fetchid – The
id
field 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
slug
field of the organizer to create a campaign forevent – The
slug
field 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
PUT
instead 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
slug
field of the organizer to modifyevent – The
slug
field of the event to modifyid – The
id
field 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
slug
field of the organizer to modifyevent – The
slug
field of the event to modifyid – The
id
field 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