Rebrand 2023 Learn more 

  • Products/
    Extending Products/
    Product Attributes API/
    Create an Attribute

    Create an Attribute

    This endpoint is for Administrator use only. Do not use this endpoint on your customer-facing frontends.

    POST Create an Attribute

    The API does not support creating attributes in bulk. Attributes must be created individually.

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

    Parameters

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API.

    Body

    NameRequiredTypeDescription
    typeRequiredstringSpecifies the type of the resource. You must use field.
    nameRequiredstringSpecifies the name of the attribute.
    slugRequiredstringSpecifies a unique slug identifier for the attribute.
    field_typeRequiredstringSpecifies the type of field. The options are string, integer, boolean, float, or date. You cannot update the field_type after creating an attribute.
    descriptionRequiredstringProvides a description for the attribute.
    requiredRequiredbooleanSpecifies whether an input is required for this attribute when you create an entry fo r the attribute. Set true if input is required. Set false if no input is required for the attribute entries.
    defaultOptionalstringSpecifies an optional value to use if the attribute is required and no value is provided.
    enabledRequiredbooleanSpecifies whether the attribute is enabled. Set true to enable using the attribute in a template, other wise use false.
    validation_rulesOptionalarray[object]Specifies the validation rules to use for attribute.
    orderOptionalintegerSpecifies the order in which the attribute is returned relative to the rest of the flow fields.
    omit_nullOptionalbooleanSpecifies whether the attribute is omitted from responses. Set true to omit the attribute from response. Set true to include the attribute in responses.
    relationshipsRequiredobjectSpecifies the relationship object to link this attribute to a template by providing the ID of the template. Note: You can link an attribute to only one template.

    Request Example

    curl -X POST "https://useast.api.elasticpath.com/v2/fields" \
         -H "Authorization: XXXX" \
         -H "Content-Type: application/json" \
         -d $'{
      "data": {
        "type": "field",
        "name": "SkinType",
        "slug": "SkinType",
        "field_type": "string",
        "description": "Pim Product Custom Flow Field",
        "required": false,
        "default": 0,
        "enabled": true,
        "order": 1,
        "relationships": {
          "flow": {
            "data": {
              "type": "flow",
              "id": "{{flowID}}"
            }
    

    Response Example

    201 Created

    {
        "data": {
            "id": "102b2087-d56a-45e7-bf1c-e9517716abb3",
            "type": "field",
            "name": "SkinType",
            "slug": "SkinType",
            "description": "PIM Product Custom Flow Field",
            "required": false,
            "default": 0,
            "enabled": true,
            "order": 1,
            "omit_null": false,
            "links": {
                "self": "https://epcc-integration.global.ssl.fastly.net/v2/flows/24c2a332-a76a-4988-81e3-8a24324998a6/fields/e0b2031d-eda0-4e7d-946a-aa3f845fd572"
            },
            "relationships": {
                "flow": {
                    "data": {
                        "id": "24c2a332-a76a-4988-81e3-8a24324998a6",
                        "type": "flow"
                    }
                }
            },
            "meta": {
                "owner": "store",
                "timestamps": {
                    "created_at": "2023-06-23T10:04:41.756Z",
                    "updated_at": "2023-06-23T10:04:41.756Z"
                }
            }
        }
    }
    

    You cannot update the field_type after creating an attribute.

    Previous
    Get an Attribute