Retrieve the list of guest fields

We can use guests fields API without using the back office and create guest fields manually on Eventmaker.

JSON

Request

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

For one guest field particularly

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

With curl

You can display the guest fields list with curl:

Example

curl -X GET "https://app.eventmaker.io/api/v1/events/58332199d1bc514f4b000001/guest_fields.json/?auth_token=ooooooo" -H "Content-type:application/json"

Response

// 200 OK
[
  {
    "_id": "d8a229db7e3c894ca40a71fc4e6a9a2b6e1d5a84",
    "available_values": [],
    "created_at": "2016-10-18T15:51:14.560Z",
    "event_id": "57ff57ca8e50970278001c92",
    "key": "cell_phone_number",
    "label": "Téléphone mobile",
    "object_id": "580644f2d3fab7029200c08a",
    "type": "text",
    "updated_at": "2016-10-18T15:51:14.560Z",
    "use_in_export": true
  }, ...
]

XML

Request

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

For one guest field particularly

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

Response

Guest fields API contains some fields, we can see that in a guest fields JSON file:

<!-- 200 OK -->
<?xml version="1.0" encoding="UTF-8"?>
<guest-fields type="array">
  <guest-field>
    <_id>d8a229db7e3c894ca40a71fc4e6a9a2b6e1d5a84</_id>
    <available-values type="array"/>
    <created-at type="dateTime">2016-10-18T15:51:14Z</created-at>
    <event-id>57ff57ca8e50970278001c92</event-id>
    <key>cell_phone_number</key>
    <label>Téléphone mobile</label>
    <object-id>580644f2d3fab7029200c08a</object-id>
    <type>text</type>
    <updated-at type="dateTime">2016-10-18T15:51:14Z</updated-at>
    <use-in-export type="boolean">true</use-in-export>
  </guest-field>
  <guest-field>
    ...
  </guest-field>
</guest-fields>

Create a guest field

JSON

Request

POST /api/v1/events/{event_id}/guest_fields.json?auth_token=YOUR_API_TOKEN
Content-Type: application/json; charset=utf-8

With curl

You can add a guest field with curl:

Example:

curl -X POST -d '{"guest_field":{"key":"testa","label":"TEST","type":"text","use_in_export":"true"}}' "https://app.eventmaker.io/api/v1/events/58332199d1bc514f4b000001/guest_fields.json/?auth_token=ooooooo" -H "Content-type:application/json"

Response

// 201 Created
  {
    "_id":"6aaabf620ce1a1119ad59d71fc3a59d8796b2fe5",
    "available_values":[],
    "created_at":"2016-11-22T09:08:59.299Z",
    "event_id":"58332199d1bc514f4b000001",
    "key":"testa",
    "label":"TEST",
    "object_id":"58340b2bd1bc51066f000001",
    "type":"text",
    "updated_at":"2016-11-22T09:08:59.299Z",
    "use_in_export":true
  }

XML

Request

POST /api/v1/events/{event_id}/guest_fields.xml?auth_token=YOUR_API_TOKEN
Content-Type: application/xml; charset=utf-8

Response

<?xml version="1.0" encoding="UTF-8"?>
<guest-field>
  <_id>442c5e0b1151ebeef6177a890fad41467b9dce70</_id>
  <available-values type="array"/>
  <created-at type="dateTime">2016-11-22T10:12:30Z</created-at>
  <event-id>58332199d1bc514f4b000001</event-id>
  <key>testu</key>
  <label>TESTU</label>
  <object-id>58341a0ed1bc51066f000007</object-id>
  <type>text</type>
  <updated-at type="dateTime">2016-11-22T10:12:30Z</updated-at>
  <use-in-export type="boolean">true</use-in-export>
</guest-field>

Update a guest field

JSON

Request

PUT /api/v1/events/{event_id}/guest_fields/{id}.json?auth_token=YOUR_API_TOKEN
Content-Type: application/json; charset=utf-8

With curl

You can modify a guest field with curl:

Example:

curl -X PUT -d '{"guest_field":{"key":"testi","label":"TESTI","type":"text","use_in_export":"true"}}' "https://app.eventmaker.io/api/v1/events/58332199d1bc514f4b000001/guest_fields/6aaabf620ce1a1119ad59d71fc3a59d8796b2fe5.json/?auth_token=ooooooo" -H "Content-type:application/json"

Response

// 204 No Content
  {
    "_id":"6aaabf620ce1a1119ad59d71fc3a59d8796b2fe5",
    "available_values":[],
    "created_at":"2016-11-22T09:08:59.299Z",
    "event_id":"58332199d1bc514f4b000001",
    "key":"testi",
    "label":"TESTI",
    "object_id":"58340b2bd1bc51066f000001",
    "type":"text",
    "updated_at":"2016-11-22T10:03:47.650Z",
    "use_in_export":true
  }

XML

Request

PUT /api/v1/events/{event_id}/guest_fields/{id}.xml?auth_token=YOUR_API_TOKEN
Content-Type: application/xml; charset=utf-8

Response

<!-- 204 No Content -->
<?xml version="1.0" encoding="UTF-8"?>
<guest-field>
  <_id>6aaabf620ce1a1119ad59d71fc3a59d8796b2fe5</_id>
  <available-values type="array"/>
  <created-at type="dateTime">2016-11-22T09:08:59Z</created-at>
  <event-id>58332199d1bc514f4b000001</event-id>
  <key>testi</key>
  <label>TESTI</label>
  <object-id>58340b2bd1bc51066f000001</object-id>
  <type>text</type>
  <updated-at type="dateTime">2016-11-22T10:03:47Z</updated-at>
  <use-in-export type="boolean">true</use-in-export>
</guest-field>

##Create more guest fields

JSON

Request

POST /api/v1/events/{event_id}/guest_fields/batch_create.json?auth_token=YOUR_API_TOKEN
Content-Type: application/json; charset=utf-8

With curl

You can create more than one guest fields at a time:

Example:

curl -X POST -d '{"guest_fields":[{"key":"bonjour","label":"BONJOUR","type":"text","use_in_export":"true"}, {"key":"aurevoir","label":"AUREVOIR","type":"text","use_in_export":"true"}]}' "http://app.eventmaker.io/api/v1/events/58332199d1bc514f4b000001/guest_fields/batch_create.json/?auth_token=ooooooo" -H "Content-type:application/json"

Response

// 201 Created
[
  {
    "_id":"6aaabf620ce1a1119ad59d71fc3a59d8796b2fe5",
    "available_values":[],
    "created_at":"2016-11-22T09:08:59.299Z",
    "event_id":"58332199d1bc514f4b000001",
    "key":"testa",
    "label":"TEST",
    "object_id":"58340b2bd1bc51066f000001",
    "type":"text",
    "updated_at":"2016-11-22T09:08:59.299Z",
    "use_in_export":true
  },
  {
    "_id":"6aaabf620ce1a1119ad59d71fc3a59d8796b2fe6",
    "available_values":[],
    "created_at":"2016-11-22T09:08:59.299Z",
    "event_id":"58332199d1bc514f4b000001",
    "key":"testa",
    "label":"TEST",
    "object_id":"58340b2bd1bc51066f000001",
    "type":"text",
    "updated_at":"2016-11-22T09:08:59.299Z",
    "use_in_export":true
  }
]

Types

There are 3 types that you can use when you create a guest_field


types:
  - text
  - file
  - value_list

You can create value list guest fields for example to use it in a registration form in pre filling in a select field which can be useful.