Fields

A Field represents a single Field of data (for example a Product Rating) to be applied to an entity. All Fields have a field_type (string, integer, boolean, date or relationship), a default value and an optional set of validation rules.

There is a hard limit of 100 fields per flow

The Field Object

Attribute

Type

Description

id

string

The unique identifier for this field

type

string

Represents the type of object being returned

name

string

The name of the field

slug

string

A unique slug identifier for the field

field_type

string

This field is immutable and cannot be updated. The type of field - string, integer, boolean, float, date, relationship

validation_rules

array[object]

description

string

Any description for this field

required

boolean

true if required on input, false if not. Always false if the field_type is a relationship

unique

boolean

true if each entry should be unique, false if not

default

mixed

A default value if none is supplied and field is not required

enabled

boolean

If this field is enabled on the flow this should be true, otherwise false

order

integer

Denotes the order in which this field is returned relative to the rest of the flow fields

relationships

object

A relationship object to link this field to a flow

omit_null

boolean

Hide this field from responses if the value is null

Get all Fields

GET https://api.moltin.com/v2/fields

Headers

NameTypeDescription

Authorization

string

The Bearer token to grant access to the API

{
    "data": [
        {
            "id": "e88d03d3-d46e-40d0-8302-25e6b5b1bd33",
            "type": "field",
            "field_type": "boolean",
            "slug": "on_sale",
            "name": "On Sale?",
            "description": "Is this on sale?",
            "required": false,
            "unique": false,
            "default": null,
            "enabled": true,
            "order": null,
            "omit_null": false,
            "validation_rules": [],
            "links": {
                "self": "https://api.moltin.com/v2/flows/9d69c6cf-aaee-4dc6-8908-d2bd053446a2/fields/e88d03d3-d46e-40d0-8302-25e6b5b1bd33"
            },
            "relationships": {
                "flow": {
                    "data": {
                        "id": "9d69c6cf-aaee-4dc6-8908-d2bd053446a2",
                        "type": "flow"
                    }
                }
            },
            "meta": {
                "timestamps": {
                    "created_at": "2018-08-23T10:28:43.609Z",
                    "updated_at": "2018-08-23T10:28:43.609Z"
                }
            }
        }
    ]
}
curl https://api.moltin.com/v2/fields \
     -H "Authorization: Bearer XXXX"

Get all Fields by Flow

GET https://api.moltin.com/v2/flows/:slug/fields

Path Parameters

NameTypeDescription

slug

string

The slug of the Flow you wish to return fields for

Headers

NameTypeDescription

Authorization

string

The Bearer token to grant access to the API

{
    "data": [
        {
            "id": "23d26fd2-d2e2-4c72-b4b4-3ef7a31bc47f",
            "type": "field",
            "field_type": "string",
            "slug": "background_colour",
            "name": "background colours",
            "description": "background colour for the product",
            "required": false,
            "unique": false,
            "default": "#ffffff",
            "enabled": true,
            "validation_rules": [],
            "order": null,
            "omit_null": false,
            "links": {
                "self": "https://api.moltin.com/v2/flows/248c7776-bd9f-4075-8980-461b02ed3757/fields/23d26fd2-d2e2-4c72-b4b4-3ef7a31bc47f"
            },
            "relationships": {
                "flow": {
                    "data": {
                        "id": "248c7776-bd9f-4075-8980-461b02ed3757",
                        "type": "flow"
                    }
                }
            },
            "meta": {
                "timestamps": {
                    "created_at": "2017-06-26T12:55:33.560Z",
                    "updated_at": "2017-12-19T12:31:24.570Z"
                }
            }
        },
        {
            "id": "5f4be5bd-0c83-417a-b744-7d8c49636ab1",
            "type": "field",
            "field_type": "string",
            "slug": "background_image",
            "name": "Background Image",
            "description": "The background image for the category",
            "required": false,
            "unique": false,
            "default": null,
            "enabled": true,
            "validation_rules": [],
            "order": null,
            "omit_null": false,
            "links": {
                "self": "https://api.moltin.com/v2/flows/248c7776-bd9f-4075-8980-461b02ed3757/fields/5f4be5bd-0c83-417a-b744-7d8c49636ab1"
            },
            "relationships": {
                "flow": {
                    "data": {
                        "id": "248c7776-bd9f-4075-8980-461b02ed3757",
                        "type": "flow"
                    }
                }
            },
            "meta": {
                "timestamps": {
                    "created_at": "2018-03-29T10:33:24.056Z",
                    "updated_at": "2018-03-29T10:33:24.056Z"
                }
            }
        }
    ]
}
curl https://api.moltin.com/v2/flows/:slug/fields \
     -H "Authorization: Bearer XXXX"

Get a Field

GET https://api.moltin.com/v2/fields/:id

Path Parameters

NameTypeDescription

id

string

The ID for the field you are requesting

Headers

NameTypeDescription

Authorization

string

The Bearer token to grant access to the API

{
    "data": {
        "id": "102b2087-d56a-45e7-bf1c-e9517716abb3",
        "type": "field",
        "field_type": "integer",
        "slug": "product-rating",
        "name": "Product Rating",
        "description": "Average rating as given by our users",
        "required": false,
        "unique": false,
        "default": null,
        "enabled": true,
        "validation_rules": [
            {
                "type": "between",
                "options": {
                    "from": 1,
                    "to": 5
                }
            }
        ],
        "order": 1,
        "omit_null": false,
        "links": {
            "self": "https://api.moltin.com/v2/flows/6d320b42-237d-4474-8452-d49f884d4ae1/fields/102b2087-d56a-45e7-bf1c-e9517716abb3"
        },
        "relationships": {
            "flow": {
                "data": {
                    "id": "6d320b42-237d-4474-8452-d49f884d4ae1",
                    "type": "flow"
                }
            }
        },
        "meta": {
            "timestamps": {
                "created_at": "2018-05-10T18:19:11.559Z",
                "updated_at": "2018-05-10T18:19:11.559Z"
            }
        }
    }
}
curl https://api.moltin.com/v2/fields/:id \
     -H "Authorization: Bearer XXXX"

Create a Field

POST https://api.moltin.com/v2/fields

Headers

NameTypeDescription

Authorization

string

The Bearer token to grant access to the API

Request Body

NameTypeDescription

type

string

Represents the type of object being returned

name

string

The name of the field

slug

string

A unique slug identifier for the field

field_type

string

The type of field - string, integer, boolean, float, date, relationship

description

string

Any description for this field

required

boolean

true if required on input, false if not. Always false if the field_type is a relationship

unique

boolean

true if each entry should be unique, false if not

default

string

A default value if none is supplied and field is not required

enabled

boolean

If this field is enabled on the flow this should be true, otherwise false

order

integer

Denotes the order in which this field is returned relative to the rest of the flow fields

omit_null

boolean

Omit this field from responses if the value is null

relationships

object

A relationship object to link this field to a flow. Please note that in this instance, you can link a field to only one flow.

{
    "data": {
        "id": "102b2087-d56a-45e7-bf1c-e9517716abb3",
        "type": "field",
        "field_type": "integer",
        "slug": "product-rating",
        "name": "Product Rating",
        "description": "Average rating as given by our users",
        "required": false,
        "unique": false,
        "default": null,
        "enabled": true,
        "validation_rules": [
            {
                "type": "between",
                "options": {
                    "from": 1,
                    "to": 5
                }
            }
        ],
        "order": 1,
        "omit_null": false,
        "links": {
            "self": "https://api.moltin.com/v2/flows/6d320b42-237d-4474-8452-d49f884d4ae1/fields/102b2087-d56a-45e7-bf1c-e9517716abb3"
        },
        "relationships": {
            "flow": {
                "data": {
                    "id": "6d320b42-237d-4474-8452-d49f884d4ae1",
                    "type": "flow"
                }
            }
        },
        "meta": {
            "timestamps": {
                "created_at": "2018-05-10T18:19:11.559Z",
                "updated_at": "2018-05-10T18:19:11.559Z"
            }
        }
    }
}

You cannot update the field_type once a Field has been created.

curl -X "POST" "https://api.moltin.com/v2/fields" \
     -H "Authorization: XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
      "data": {
        "type": "field",
        "name": "Product Rating",
        "slug": "product-rating",
        "field_type": "integer",
        "validation_rules": [
            {
                "type": "between",
                "options": {
                    "from": 1,
                    "to": 5
                }
            }
        ],
        "description": "Average rating as given by our users",
        "required": false,
        "unique": false,
        "default": 0,
        "enabled": true,
        "order": 1,
        "omit_null": false,
        "relationships": {
            "flow": {
                "data": {
                    "type": "flow",
                    "id": "e4145c27-aba1-46af-81a3-58f5e1cf7f15"
                }
            }
        }
      }
    }'

Update a Field

PUT https://api.moltin.com/v2/fields/:id

Path Parameters

NameTypeDescription

id

string

The ID for the field you are requesting to be updated

Headers

NameTypeDescription

Authorization

string

The Bearer token to grant access to the API

Request Body

NameTypeDescription

type

string

Represents the type of object being returned

name

string

The name of the field

slug

string

A unique slug identifier for the field

description

string

Any description for this field

required

boolean

true if required on input, false if not. Always false if the field_type is a relationship

unique

boolean

true if each entry should be unique, false if not

default

string

A default value if none is supplied and field is not required

enabled

boolean

If this field is enabled on the flow this should be true, otherwise false

order

integer

Denotes the order in which this field is returned relative to the rest of the flow fields

omit_null

boolean

Omit this field from responses if the value is null

relationships

object

A relationship object to link this field to a flow

{
    "data": {
        "id": "102b2087-d56a-45e7-bf1c-e9517716abb3",
        "type": "field",
        "field_type": "integer",
        "slug": "start-of-life",
        "name": "start-of-life",
        "description": "day the iphone will work",
        "required": true,
        "unique": false,
        "default": "2018-01-01",
        "enabled": true,
        "validation_rules": [
            {
                "type": "between",
                "options": {
                    "from": 1,
                    "to": 5
                }
            }
        ],
        "order": 1,
        "omit_null": false,
        "links": {
            "self": "https://api.moltin.com/v2/flows/6d320b42-237d-4474-8452-d49f884d4ae1/fields/102b2087-d56a-45e7-bf1c-e9517716abb3"
        },
        "relationships": {
            "flow": {
                "data": {
                    "id": "6d320b42-237d-4474-8452-d49f884d4ae1",
                    "type": "flow"
                }
            }
        },
        "meta": {
            "timestamps": {
                "created_at": "2018-05-10T18:19:11.559Z",
                "updated_at": "2018-05-10T18:36:01.208Z"
            }
        }
    }
}
curl -X "POST" "https://api.moltin.com/v2/fields/:id" \
     -H "Authorization: XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
      "data": {
        "id": "{FIELD_ID}",
        "type": "field",
        "name": "Average Product Rating",
      }
    }'

Delete a Field

DELETE https://api.moltin.com/v2/fields/:id

Path Parameters

NameTypeDescription

id

string

The ID fir the field you are requesting to be deleted

Headers

NameTypeDescription

Authorization

string

The Bearer token to grant access to the API

curl -X DELETE https://api.moltin.com/v2/fields/:id \
    -H "Authorization: Bearer XXXX"

Last updated