Create a Field
POST/v2/fields
- For Commerce, this endpoint creates a field.
- For Product Experience Manager, this endpoint creates an attribute.
Request
- application/json
Body
required
string
integer
boolean
float
date
relationship
- Array [
- MOD1
- MOD2
- Array [
- ]
- ]
data object
Specifies a default value for a field/attribute if no value is provided and the field/attribute is required.
A description for a field/attribute.
This field is immutable and cannot be updated. You can have the following field types:
The name of a field/attribute.
Denotes the order in which a field/attribute is returned relative to the rest of flow fields/template attributes.
relationships object
Relationships are established between different flow/template entities. For example, a field/attribute is related to a flow/template, as the field/attribute is attached to the flow/template.
flow object
data object
A unique identifier for a resource.
Represents the type of object being returned.
true
if required on input, false
if not. Always false
if the field_type
relationship
.
A unique identifier of a field/attribute.
Represents the type of object being returned.
validation_rules object[]
An array of validation rule objects. See Field Validation Rules.
Possible values: [enum
, email
, slug
, between
, one-to-many
, one-to-one
]
The validation you use depends on the field_type
of the field/attribute. Each validation rule is expressed as a validation rule object.
options object
string
Responses
- 201
- 422
- 500
Created
- application/json
- Schema
- Example (from schema)
- default
Schema
string
integer
boolean
float
date
relationship
- Array [
- MOD1
- MOD2
- Array [
- ]
- ]
data object
A unique identifier for a resource.
Represents the type of object being returned.
This field is immutable and cannot be updated. You can have the following field types:
A short description for a field/attribute.
The name of a field/attribute.
A short description of a field/attribute.
true
if required on input, false
if not. Always false
if the field_type
is a relationship.
A default value if none is supplied and a field/attribute is not required.
Denotes the order in which this field is returned relative to the rest of the flow/template fields/attributes.
Hide this field/attribute from responses if the value is null
.
validation_rules object[]
Possible values: [enum
, email
, slug
, between
, one-to-many
, one-to-one
]
The validation you use depends on the field_type
of the field/attribute. Each validation rule is expressed as a validation rule object.
options object
string
meta object
Possible values: [store
, organization
]
The resource owner, either organization
or store
.
timestamps object
The date and time a resource is created.
The date and time a resource is updated.
links object
Links allow you to move between requests. Single entities use a self
parameter with a link to that specific resource. Listing pages use the following:
Property | Description |
---|---|
current | Always the current page |
first | Always the first page |
last | null if there is only one page. |
prev | null if you are on the first page. |
next | null if there is only one page. |
relationships object
Relationships are established between different flow/template entities. For example, a field/attribute is related to a flow/template, as the field/attribute is attached to the flow/template.
flow object
data object
A unique identifier for a resource.
Represents the type of object being returned.
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "string",
"field_type": "string",
"slug": "string",
"name": "string",
"description": "string",
"required": true,
"enabled": true,
"omit_null": true,
"validation_rules": [
{
"type": "enum",
"options": [
null
],
"to": "customer"
}
],
"meta": {
"owner": "enum",
"timestamps": {
"created_at": "2023-10-11T13:02:25.293Z",
"updated_at": "2023-10-11T13:02:25.293Z"
}
},
"links": {
"self": "https://euwest.api.elasticpath.com/v2/flows/3cf3ad3f-b12c-4a08-a6ab-05e6aab0122c/fields/c1c788d1-f1c7-4b90-938f-f158f3353c66"
},
"relationships": {
"flow": {
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "flow"
}
}
}
}
}
{
"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,
"default": 0,
"enabled": true,
"order": 1,
"omit_null": false,
"relationships": {
"flow": {
"data": {
"type": "flow",
"id": "e4145c27-aba1-46af-81a3-58f5e1cf7f15"
}
}
}
}
}
Bad request. The request failed validation.
- application/json
- Schema
- Example (from schema)
- missing-name
Schema
- Array [
- ]
errors Error[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": 500,
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"title": "Validation Error",
"status": 400,
"detail": "data.attributes.name: \"name\" is required"
}
]
}
Internal server error. There was a system failure in the platform.
- application/json
- Schema
- Example (from schema)
- internal-server-error
Schema
- Array [
- ]
errors Error[]required
The HTTP response code of the error.
A brief summary of the error.
Optional additional detail about the error.
Internal request ID.
Additional supporting meta data for the error.
{
"errors": [
{
"status": 500,
"title": "Internal server error",
"detail": "An internal error has occurred.",
"request_id": "00000000-0000-0000-0000-000000000000",
"meta": {
"missing_ids": [
"e7d50bd5-1833-43c0-9848-f9d325b08be8"
]
}
}
]
}
{
"errors": [
{
"status": 500,
"title": "Internal Server Error",
"detail": "There was an internal server error, you can report with your request id.",
"request_id": "635da56d-75a1-43cd-b696-7ab119756b3a"
}
]
}