Retrieve the list of Discount codes

Eventmaker provides a paginaged API to retrieve the list of discount codes of your event. Starts at page=1. Paginate every 500 objects.

JSON

Request

GET /api/v1/events/{event_id}/promo_codes.json?page=1&auth_token=YOUR_API_TOKEN

Response

// 200 OK
[
  {
    "_id":"{id}",

    // the amount of the discount code
    "amount":10.0,

    // whether the discount code is enabled or not
    "is_enabled":true,

    // label of the discount code
    "label":"{label}",

    // code to enter in the registration form
    "text":"AAA",

    // the number of times the code can be used
    // if max_usage = -1, there is no restrictions
    "max_usage":12,

    // the number of guest who used the discount code
    "times_used":4,

    // if enable,the amount is a percentage(between 0 and 1)
    "percentage_of_total":false,

    // indexes
    "searchable_keywords":["aaa","0.0"],

    // start date when the discount code is enable
    "start_date":"2016-04-27T06:00:00.000+00:00",

    // date of expiration
    "end_date":"2016-04-27T18:00:00.000+00:00",

    "event_id":"{event_id}",
    "timezone":"Paris",
    "created_at":"2016-04-27T09:39:08.279Z",
    "updated_at":"2016-04-27T09:39:08.279Z"
    },
    // ...
]

XML

Request

GET /api/v1/events/{event_id}/promo_codes.xml?page=1&auth_token=YOUR_API_TOKEN

Response

<!-- 200 OK -->
<?xml version="1.0" encoding="UTF-8"?>
<promo-codes type="array">
  <promo-code>
    <_id>{_id}</_id>
    <amount type="float">10.0</amount>
    <is-enabled type="boolean">true</is-enabled>
    <label>{label}</label>
    <text>AAA</text>
    <max-usage type="integer">12</max-usage>
    <times-used type="integer">4</times-used>
    <percentage-of-total type="boolean">false</percentage-of-total>
    <searchable-keywords type="array">
      <searchable-keyword>aaa</searchable-keyword>
      <searchable-keyword>0.0</searchable-keyword>
    </searchable-keywords>
    <start-date type="dateTime">2016-04-27T06:00:00Z</start-date>
    <end-date type="dateTime">2016-04-27T18:00:00Z</end-date>
    <event-id>{event_id}</event-id>
    <timezone>Paris</timezone>
    <created-at type="dateTime">2016-04-27T09:39:08Z</created-at>
    <updated-at type="dateTime">2016-07-07T12:56:59Z</updated-at>
  </promo-code>
</promo-codes>

You can increment the page query string parameter until you get an empty array.

Register a new discount code

You can add a discount code to your event.

JSON

Request

POST /api/v1/{event_id}/promo_codes.json?auth_token=YOUR_API_TOKEN
Content-Type: application/json; charset=utf-8
{
  "promo_code" : {
    "text":"aaa",
    "label":MyDiscountCode,
    "amount": 14.0,
    "max_usage":-1,
    "percentage_of_total":false
  }
}

Response

// 201 Created
{
  "_id":"{Id}",
  "amount":14.0,
  "created_at":"2016-07-07T14:55:37.434Z",
  "end_date":null,
  "event_id":"{event_id}",
  "is_enabled":true,
  "label":"MyDiscountCode",
  "max_usage":-1,
  "percentage_of_total":false,
  "searchable_keywords":["aaa","0.0"],
  "start_date":null,
  "text":"AAA",
  "times_used":0,
  "timezone":"Paris",
  "updated_at":"2016-07-07T14:55:37.434Z"
  }

XML

Request

POST /api/v1/{event_id}/signatures.xml?auth_token=YOUR_API_TOKEN
Content-Type: application/xml; charset=utf-8
<promo-code>
  <amount type="float">0.0</amount>
  <label>MyLabel</label>
  <max-usage type="integer">-1</max-usage>
  <percentage-of-total type="boolean">false</percentage-of-total>
  <text>MYCODE</text>
</promo-code>

Response

<!-- 201 Created -->
<?xml version="1.0" encoding="UTF-8"?>
<promo-code>
  <_id>{_id}</_id>
  <amount type="float">0.0</amount>
  <created-at type="dateTime">2016-07-07T15:04:05Z</created-at>
  <end-date nil="true"/>
  <event-id>{event_id}</event-id>
  <is-enabled type="boolean">true</is-enabled>
  <label>MyLabel</label>
  <max-usage type="integer">-1</max-usage>
  <percentage-of-total type="boolean">false</percentage-of-total>
  <searchable-keywords type="array">
    <searchable-keyword>mycode</searchable-keyword>
    <searchable-keyword>0.0</searchable-keyword>
  </searchable-keywords>
  <start-date nil="true"/>
  <text>MYCODE</text>
  <times-used type="integer">0</times-used>
  <timezone>Paris</timezone>
  <updated-at type="dateTime">2016-07-07T15:04:05Z</updated-at>
</promo-code>

Retrieve information about a discount code

With the id of a discount code, you can details about it.

JSON

Request

GET /api/v1/events/{event_id}/promo_codes/{id}.json?auth_token=YOUR_API_TOKEN

Response

// 200 OK
{
  "_id":"{_id}",
  "amount":0.0,
  "created_at":"2016-07-07T15:04:05.294Z",
  "end_date":null,
  "event_id":"{event_id}",
  "is_enabled":true,
  "label":null,
  "max_usage":-1,
  "percentage_of_total":false,
  "searchable_keywords":["mycode","0.0"],
  "text":"MYCODE",
  ...
}

XML

Request

GET /api/v1/events/{event_id}/promo_codes/{id}.xml?auth_token=YOUR_API_TOKEN

Response

<!-- 200 OK -->
<promo-code>
  <_id>{_id}</_id>
  <amount type="float">0.0</amount>
  <created-at type="dateTime">2016-07-07T15:04:05Z</created-at>
  <end-date nil="true"/>
  <event-id>{event_id}</event-id>
  <is-enabled type="boolean">true</is-enabled>
  <label nil="true"/>
  <max-usage type="integer">-1</max-usage>
  <percentage-of-total type="boolean">false</percentage-of-total>
  <searchable-keywords type="array">
    <searchable-keyword>mycode</searchable-keyword>
    <searchable-keyword>0.0</searchable-keyword>
  </searchable-keywords>
  <start-date nil="true"/>
  <text>MYCODE</text>
  <times-used type="integer">0</times-used>
  <timezone>Paris</timezone>
  <updated-at type="dateTime">2016-07-07T15:04:05Z</updated-at>
</promo-code>

Update a discount code

You can add complementary information, update or delete your discount code fields.

JSON

Request

PUT /api/v1/events/{event_id}/promo_codes/{id}.json?auth_token=YOUR_API_TOKEN
Content-Type: application/json; charset=utf-8
{
  "promo_code": {
    // Fields to update (View the POST request for a complete list of fields)
  }
}

Response

// 204 No Content

XML

Request

PUT /api/v1/events/{event_id}/guests/{id}.xml?auth_token=YOUR_API_TOKEN
Content-Type: application/xml; charset=utf-8
<promo-code>
  <!-- Fields to update (View the POST request for a complete list of fields) -->
</promo-code>

Response

<!-- 204 No Content -->

Delete a discount code

You can delete discount codes (which is irreversible).

JSON

Request

DELETE /api/v1/events/{event_id}/promo_codes/{id}.json?auth_token=YOUR_API_TOKEN

Response

// 204 No Content

XML

Request

DELETE /api/v1/events/{event_id}/promo_codes/{id}.xml?auth_token=YOUR_API_TOKEN

Response

<!-- 204 No Content -->