Gift cards

Resource description

The gift card resource contains the following public fields:

Field Type Description
id integer Internal ID of the gift card
secret string Gift card code (can not be modified later)
value money (string) Current gift card value
currency string Currency of the value (can not be modified later)
testmode boolean Whether this is a test gift card

Endpoints

GET /api/v1/organizers/(organizer)/giftcards/

Returns a list of all gift cards issued by a given organizer.

Example request:

GET /api/v1/organizers/bigevents/giftcards/ 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,
      "secret": "HLBYVELFRC77NCQY",
      "currency": "EUR",
      "testmode": false,
      "value": "13.37"
    }
  ]
}
Query Parameters:
 
  • page (integer) – The page number in case of a multi-page result set, default is 1
Parameters:
  • organizer – The slug field of the organizer to fetch
Status Codes:
GET /api/v1/organizers/(organizer)/giftcards/(id)/

Returns information on one gift card, identified by its ID.

Example request:

GET /api/v1/organizers/bigevents/giftcards/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,
  "secret": "HLBYVELFRC77NCQY",
  "currency": "EUR",
  "testmode": false,
  "value": "13.37"
}
Parameters:
  • organizer – The slug field of the organizer to fetch
  • id – The id field of the gift card to fetch
Status Codes:
POST /api/v1/organizers/(organizer)/giftcards/

Creates a new gift card

Example request:

POST /api/v1/organizers/bigevents/giftcards/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json

{
  "secret": "HLBYVELFRC77NCQY",
  "currency": "EUR",
  "value": "13.37"
}

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json

{
  "id": 1,
  "secret": "HLBYVELFRC77NCQY",
  "testmode": false,
  "currency": "EUR",
  "value": "13.37"
}
Parameters:
  • organizer – The slug field of the organizer to create a gift card for
Status Codes:
PATCH /api/v1/organizers/(organizer)/giftcards/(id)/

Update a gift card. You can also use PUT instead of PATCH. With PUT, you have to provide all fields of the resource, other fields will be reset to default. With PATCH, you only need to provide the fields that you want to change.

You can change all fields of the resource except the id, secret, testmode, and currency fields. Be careful when modifying the value field to avoid race conditions. We recommend to use the transact method described below.

Example request:

PATCH /api/v1/organizers/bigevents/giftcards/1/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
Content-Length: 94

{
  "value": "14.00"
}

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

{
  "id": 1,
  "secret": "HLBYVELFRC77NCQY",
  "testmode": false,
  "currency": "EUR",
  "value": "14.00"
}
Parameters:
  • organizer – The slug field of the organizer to modify
  • id – The id field of the gift card to modify
Status Codes:
  • 200 OK – no error
  • 400 Bad Request – The gift card could not be modified due to invalid submitted data
  • 401 Unauthorized – Authentication failure
  • 403 Forbidden – The requested organizer does not exist or you have no permission to change this resource.
POST /api/v1/organizers/(organizer)/giftcards/(id)/transact/

Atomically change the value of a gift card. A positive amount will increase the value of the gift card, a negative amount will decrease it.

Example request:

PATCH /api/v1/organizers/bigevents/giftcards/1/transact/ HTTP/1.1
Host: pretix.eu
Accept: application/json, text/javascript
Content-Type: application/json
Content-Length: 94

{
  "value": "2.00"
}

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

{
  "id": 1,
  "secret": "HLBYVELFRC77NCQY",
  "currency": "EUR",
  "testmode": false,
  "value": "15.37"
}
Parameters:
  • organizer – The slug field of the organizer to modify
  • id – The id field of the gift card to modify
Status Codes:
  • 200 OK – no error
  • 400 Bad Request – The gift card could not be modified due to invalid submitted data
  • 401 Unauthorized – Authentication failure
  • 403 Forbidden – The requested organizer does not exist or you have no permission to change this resource.