Lists loyalty v2 lists - Heyloyalty/api GitHub Wiki
Gets basic info about all lists check documentation for v1.
Gets information about a single list check documentation for v1.
Creates a new list check documentation for v1.
NOTE: endpoint for v2 is: /loyalty/v2
Name | Description | Required |
---|---|---|
name | Name of the list | |
country_id | Id of primary list country. (Fx. 1 for Denmark) | |
duplicates | How to handle duplicate members. Can be "allow", "allow_email", "allow_mobile" and "disallow". | |
double_opt-in | Can be "0" disable double opt-in or "1" enable double opt-in | |
fields | An array of fields. Se below. |
Fields determine what kind of information can be stored on members who are added to the list. There are two types of fields, Fixed fields and Custom fields. A Fixed field has a predefined name, label and format, which can't be altered. Custom fields on the other hand, allows for customization of these attributes.
The following Fixed fields are available:
Name | Format |
---|---|
firstname | Text |
lastname | Text |
Text | |
mobile | Number |
sex | Single choice |
birthdate | Date |
address | Text |
postalcode | Number |
city | Text |
country | Single choice |
password | Text |
reference | Text |
The Format determines what kind of data a field can hold, and how input is presented.
The following formats are available:
Name | Description | Input |
---|---|---|
text | Text | A string with a maximum length of 255 characters. |
number | Number | An integer |
date | Date | An ISO 8601 date (YYYY-MM-DD) |
boolean | Yes/No (Checkbox) | An integer which can only by 1 or 0. |
choice | Single choice | An integer representing the id of an option |
multi | Multiple choice | An array of integers representing options |
Name | Description |
---|---|
type | Field type. Can be "fixed" or "custom" |
id | Id is optional can only be used if type is "custom" |
name | Name of the field. When type is "fixed" this must match one of the Fixed field names. |
fallback | Field fallback. Default value, if field left empty this will be set. |
format | Field format. Only required for custom fields. |
label | Field label. Only for custom fields and defaults to name if not provided. |
options | An array of options. Only for custom fields with format "choice" or "multi". Each option should specify a label. For example options[0][label]=First&options[1][label]=Second can also specify with id to change label on specific option. |
Updates an existing list.
PATCH v2/lists/:id
Note that this method overrides and creates fields. Add the field id as the first parameter:
?fields[0][id]=1234
Existing custom fields and options can be provide an id. (Can be retrieved from get single list method). fields and options specified with an existing id will be overwritten.
Note: when updating multi or choice fields. If you want to update the options within the field, you need to add the option id as well &field[0][options][0][id]=804
?fields[0][id]=1234&fields[0][type]=custom&fields[0][format]=choice&fields[0][name]=shoesize&fields[0][label]=shoe size&fields[0][options][0][id]=803&fields[0][options][0][label]=size 40&fields[0][options][0][id]=804&fields[0][options][1][label]=size 41&fields[0][options][0][id]=805&fields[0][options][2][label]=size 42
Status: 200 OK
{
"id": 2,
"name": "Customers",
"fields": [
{
"id": 1,
"list_id": 2,
"field_type_id": 1,
"name": null,
"label": null,
"type": {
"id": 1,
"type": "fixed",
"name": "firstname",
"datatype": "text"
},
"options": []
},
{
"id": 2,
"list_id": 2,
"field_type_id": 3,
"name": null,
"label": null,
"type": {
"id": 3,
"type": "fixed",
"name": "email",
"datatype": "text"
},
"options": []
},
{
"id": 3,
"list_id": 2,
"field_type_id": 13,
"name": "tester",
"label": "tester",
"type": {
"id": 13,
"type": "custom",
"name": "custom_text",
"datatype": "text"
},
"options": []
},
{
"id": 4,
"list_id": 2,
"field_type_id": 17,
"name": "customTest",
"label": "customTest",
"type": {
"id": 17,
"type": "custom",
"name": "custom_choice",
"datatype": "choice"
},
"options": [
{
"id": 5,
"field_id": 17,
"order": 1,
"value": "test"
},
{
"id": 6,
"field_id": 17,
"order": 2,
"value": "test2"
}
]
}
]
}
List not found Status 404 list not found
{"error": "What went wrong."}}
Deleting a single custom field can be done, simply by calling our v2 endpoint, as a DELETE, adding the field ID parameter, with the id as the value: /loyalty/v2/lists/[listid]
DELETE ?fields[0][id]=1234