Units
Units can be seen as the input values for Credit Receptions. An input value goes in, a certain amount of credits comes out. For most Piggy Clients, 'purchase_amount' will be the default value, but it can be virtually anything (calories, kilometers, visits; anything countable).
An Account always has at least one Unit, and one of the Units is the Account's default (fallback) Unit. This default Unit is used whenever the Unit to be used is not specified.
List Units
Lists all Units for an account. These can subsequently be used to create Credit Receptions, where the unit_name parameter needs to be supplied if the default unit purchase_amount is not wished to be used.
https://api.piggy.eu/api//unitsBearer {{ access_token | api_key }}application/json1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"data": [
{
"name": "purchase_amount",
"label": "Purchase Amount",
"prefix": "",
"is_default": false
},
{
"name": "test",
"label": "Calories",
"prefix": "",
"is_default": true
}
],
"meta": {}
}Create Unit
Create a new Unit for your Account with this API call. By default, a Unit always exists for an Account. If is_default is set to true, the newly created Unit will be the default Unit for the Account, meaning this will be used for Credit Receptions if Unit is not specified. For integrating purposes, however, we recommend the Unit to be explicitly set if a certain Unit should be used (while creating a Credit Reception for example), and not rely on it being the default on creation, as it can later be changed.
https://api.piggy.eu/api//unitsBearer {{ access_token | api_key }}application/jsonBody
namestringREQUIREDlabelstringREQUIREDis_defaultbooleanOPTIONALprefixstringOPTIONAL1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"data": {
"loyalty_program_id": 3545,
"name": "test2",
"label": "Calories",
"is_default": true,
"prefix": "t",
"format": "int",
"updated_at": "2023-11-06T14:39:24.000000Z",
"created_at": "2023-11-06T14:39:24.000000Z",
"id": 298
},
"meta": {}
}Code
Message
100355045