Update a Field
PUT
Update a Field
https://api.moltin.com/v2/fields/:id
Path Parameters:
Name | Required | Type | Description |
---|---|---|---|
id | Required | string | The ID for the field you are requesting to be updated. |
Headers:
Name | Required | Type | Description |
---|---|---|---|
Authorization | Required | string | The Bearer token to grant access to the API. |
Body:
Name | Required | Type | Description |
---|---|---|---|
type | Required | string | Represents the type of object being returned. |
name | Optional | string | The name of the field. |
slug | Optional | string | A unique slug identifier for the field. |
description | Optional | string | Any description for this field. |
required | Optional | boolean | true if required on input, false if not. Always false if the field_type is a relationship. |
default | Optional | string | A default value if none is supplied and field is not required. |
enabled | Optional | boolean | If this field is enabled on the flow this should be true , otherwise false . |
order | Optional | integer | Denotes the order in which this field is returned relative to the rest of the flow fields. |
omit_null | Optional | boolean | Omit this field from responses if the value is null . |
relationships | Optional | object | A relationship object to link this field to a flow. |
200 OK
{
"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,
"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",
}
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X'
})
const fieldId = 'xx'
const data = {
id: '{fieldId}',
name: 'Average Product Rating'
}
Moltin.Fields.Update('{fieldId}', data).then(field => {
// Do something
})