Skip to main content

Create a Field

POST 

https://euwest.api.elasticpath.com/v2/fields

  • For Commerce, this endpoint creates a field.
  • For Product Experience Manager, this endpoint creates an attribute.

Request

Bodyrequired

    data object
    defaultnumber

    Specifies a default value for a field/attribute if no value is provided and the field/attribute is required.

    descriptionstring

    A description for a field/attribute.

    enabledboolean
    field_typestring

    This field is immutable and cannot be updated. You can have the following field types:

    • string
    • integer
    • boolean
    • float
    • date
    • relationship
    namestring

    The name of a field/attribute.

    ordernumber

    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
    iduuid

    A unique identifier for a resource.

    Example: 00000000-0000-0000-0000-000000000000
    typestring

    Represents the type of object being returned.

    Example: flow
    requiredboolean

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

    slugstring

    A unique identifier of a field/attribute.

    typestring

    Represents the type of object being returned.

    validation_rules object[]

    An array of validation rule objects. See Field Validation Rules.

  • Array [
  • typestring

    The validation you use depends on the field_type of the field/attribute. Each validation rule is expressed as a validation rule object.

    Possible values: [enum, email, slug, between, one-to-many, one-to-one]

    Example: enum
    options object
    anyOf
  • Array [
  • string
  • ]
  • tostring
    Example: customer
  • ]

Responses

Created

Schema
    data object
    iduuid

    A unique identifier for a resource.

    Example: 00000000-0000-0000-0000-000000000000
    typestring

    Represents the type of object being returned.

    field_typestring

    This field is immutable and cannot be updated. You can have the following field types:

    • string
    • integer
    • boolean
    • float
    • date
    • relationship
    slugstring

    A short description for a field/attribute.

    namestring

    The name of a field/attribute.

    descriptionstring

    A short description of a field/attribute.

    requiredboolean

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

    defaultnumber | string | null

    A default value if none is supplied and a field/attribute is not required.

    enabledboolean
    ordernumber | null

    Denotes the order in which this field is returned relative to the rest of the flow/template fields/attributes.

    omit_nullboolean

    Hide this field/attribute from responses if the value is null.

    validation_rules object[]
  • Array [
  • typestring

    The validation you use depends on the field_type of the field/attribute. Each validation rule is expressed as a validation rule object.

    Possible values: [enum, email, slug, between, one-to-many, one-to-one]

    Example: enum
    options object
    anyOf
  • Array [
  • string
  • ]
  • tostring
    Example: customer
  • ]
  • meta object
    ownerstring

    The resource owner, either organization or store.

    Possible values: [store, organization]

    Example: enum
    timestamps object
    created_atstring

    The date and time a resource is created.

    Example: 2023-10-11T13:02:25.293Z
    updated_atstring

    The date and time a resource is updated.

    Example: 2023-10-11T13:02:25.293Z
    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:

    PropertyDescription
    currentAlways the current page
    firstAlways the first page
    lastnull if there is only one page.
    prevnull if you are on the first page.
    nextnull if there is only one page.
    selfstring
    Example: https://euwest.api.elasticpath.com/v2/flows/3cf3ad3f-b12c-4a08-a6ab-05e6aab0122c/fields/c1c788d1-f1c7-4b90-938f-f158f3353c66
    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
    iduuid

    A unique identifier for a resource.

    Example: 00000000-0000-0000-0000-000000000000
    typestring

    Represents the type of object being returned.

    Example: flow

Authorization: http

name: bearerAuthtype: httpscheme: bearer
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://euwest.api.elasticpath.com/v2/fields");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"data\": {\n \"default\": 0,\n \"description\": \"string\",\n \"enabled\": true,\n \"field_type\": \"string\",\n \"name\": \"string\",\n \"order\": 0,\n \"relationships\": {\n \"flow\": {\n \"data\": {\n \"id\": \"00000000-0000-0000-0000-000000000000\",\n \"type\": \"flow\"\n }\n }\n },\n \"required\": true,\n \"slug\": \"string\",\n \"type\": \"string\",\n \"validation_rules\": [\n {\n \"type\": \"enum\",\n \"options\": [\n \"string\"\n ],\n \"to\": \"customer\"\n }\n ]\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Request Collapse all
Base URL
https://euwest.api.elasticpath.com
Auth
Body required
{
  "data": {
    "default": 0,
    "description": "string",
    "enabled": true,
    "field_type": "string",
    "name": "string",
    "order": 0,
    "relationships": {
      "flow": {
        "data": {
          "id": "00000000-0000-0000-0000-000000000000",
          "type": "flow"
        }
      }
    },
    "required": true,
    "slug": "string",
    "type": "string",
    "validation_rules": [
      {
        "type": "enum",
        "options": [
          "string"
        ],
        "to": "customer"
      }
    ]
  }
}
ResponseClear

Click the Send API Request button above and see the response here!