Leat Docs
Register APIOther

Custom Attributes

Custom Attributes are flexible, tailored attributes that allow you to extend the entities in the Piggy system.

Custom Attributes

Custom Attributes are flexible, tailored attributes that allow you to extend the entities in the Piggy system.

Currently, Custom Attributes can be created for the following entities:

business_profilesFor entity: Business Profile (or Shop)

contactFor entity: Contact

rewardFor entity: Reward

promotionFor entity: Promotion (note: use this one when working with Vouchers)

voucherFor entity: Voucher (note: this is for individual vouchers, you'll likely need Promotion instead

giftcardFor entity: Giftcard

giftcard_transactionFor entity: Giftcard Transaction

prepaidFor entity: Prepaid Transaction

bookingFor entity: Booking

visitFor entity: Visit

shiftFor entity: Shift

If you're missing any entity here, please reach out so we can see if we can make it happen on short notice.


List Custom Attributes

Get a list of Custom Attributes for a specified entity.

GET

https://api.piggy.eu/api//custom-attributes

Headers

Authorization

Bearer {{ api_key }}

Accept

application/json

Params

entity string

REQUIRED

The entity of the Custom Attributes you want to retrieve.

Response Example

{
    "data": [
        {
            "id": 2234,
            "entity": "voucher",
            "name": "rens_123",
            "label": "Rens123",
            "type": "select",
            "group_name": null,
            "group": {
                "id": 141,
                "name": "General",
                "created_by_user": null,
                "position": 1
            },
            "is_piggy_defined": false,
            "is_soft_read_only": false,
            "is_hard_read_only": false,
            "field_type": null,
            "has_unique_value": false,
            "description": "some description",
            "options": [
                {
                    "value": "100",
                    "label": "Blue",
                    "description": null,
                    "media": null
                },
                {
                    "value": "200",
                    "label": "Red",
                    "description": null,
                    "media": null
                },
                {
                    "value": "300",
                    "label": "Yellow",
                    "description": null,
                    "media": null
                }
            ],
            "position": 1,
            "created_at": "2023-11-13T16:04:14+00:00",
            "meta": [],
            "can_be_deleted": true,
            "last_used_date": null,
            "created_by_user": null
        }
    ]
}

Create Custom Attribute

Creates a new Custom Attribute for a specified entity. You need to provide essential details like the entity type, name, label, and data type of the attribute. There's also the option to add a description and, for select attributes, an array of options.

POST

https://api.piggy.eu/api//custom-attributes

Headers

Authorization

Bearer {{ api_key }}

Accept

application/json

Body

entity string

REQUIRED

The entity that you want to create the Custom Attributes for.

name string

REQUIRED

The unique value for the Custom Attribute, used for internal purposes.

label string

REQUIRED

The label for the attribute, which is outputted.

type string

REQUIRED

The data type of the attribute, possible options: url, text, date, phone, float, color, email, number, select, boolean, rich_text, date_time, long_text, date_range, time_range, identifier, birth_date, file_upload, media_upload, multi_select or license_plate.

options array

OPTIONAL

Applicable for (multi)selects only. Array consisting of name and value arrays.

description string

OPTIONAL

A description for the attribute.

group_name string

OPTIONAL

Name of the Group to which the attribute belongs.

Response Example

{
    "data": {
        "entity": "promotion",
        "name": "discount_type",
        "label": "Discount Type",
        "type": "select",
        "group": {
            "name": "General",
        },
        "is_piggy_defined": false,
        "is_soft_read_only": false,
        "is_hard_read_only": false,
        "has_unique_value": false,
        "description": "Type of discount for this Voucher",
        "options": [
            {
                "value": "percentage",
                "label": "Percentage",
            },
            {
                "value": "fixed",
                "label": "Fixed",
            },
        ],
        "created_at": "2023-11-13T16:04:14+00:00",
    },
    "meta": []
}

Update Custom Attribute

Updates the properties of a Custom Attribute. Note that only the label, description, options for selects and multiselects, group can be updated. Attributes defined by the system cannot be updated.

PUT

https://api.piggy.eu/api//custom-attributes/{{custom_attribute_name}}

Headers

Authorization

Bearer {{ api_key }}

Accept

application/json

Body

entity string

REQUIRED

The entity that you want to create the Custom Attributes for.

label string

OPTIONAL

The label for the attribute, which is outputted.

options array

OPTIONAL

Applicable for (multi)selects only. Array consisting of name and value arrays.

description string

OPTIONAL

A description for the attribute.

group_name string

OPTIONAL

Name of the Group to which the attribute belongs.

Response Example

{
    "data": {
        "entity": "promotion",
        "name": "discount_type",
        "label": "Discount Type",
        "type": "select",
        "group": {
            "name": "General",
        },
        "is_piggy_defined": false,
        "is_soft_read_only": false,
        "is_hard_read_only": false,
        "has_unique_value": false,
        "description": "Type of discount for this Voucher",
        "options": [
            {
                "value": "percentage",
                "label": "Percentage",
            },
            {
                "value": "fixed",
                "label": "Fixed",
            },
        ],
        "created_at": "2023-11-13T16:04:14+00:00",
    },
    "meta": []
}

On this page