Skip to main content

Create a Custom Field

POST 

https://useast.api.elasticpath.com/v2/settings/extensions/custom-apis/:custom_api_id/fields

Create a Custom Field

Request

Path Parameters

    custom_api_id stringrequired

    The id of the Custom API.

    Example: 3fa85f64-5717-4562-b3fc-2c963f66afa6

Body

    data objectrequired
    field_typerequired

    Possible values: [boolean, float, integer, string]

    typestring

    Specifies the type of the resource object, use custom_field for Custom Field.

    namestring

    Specifies the name of this Custom Field.

    Possible values: non-empty and <= 255 characters

    descriptionstring

    Specifies the description for this Custom API.

    Possible values: <= 255 characters

    slugstring

    Specifies a slug that must be unique within the scope of the Custom API. This slug will be value as the key in the JSON Object in all entries.

    Possible values: non-empty and <= 63 characters

    field_typestring

    Specifies the type of the field. This field cannot be updated.

    Possible values: [string, integer, boolean, float]

    use_as_url_slugboolean

    Enabling this field will mean Custom API Entries created in this Custom API will use this value in the URL instead of the id attribute. In order to set this field, the field must be a string, and unique, not allow null values, no entries have been created yet, and this field cannot be set to true on another custom field. This field cannot be updated. In addition to any validation rules you create, the values must be Unreserved URL Characters (i.e., be alpha-numeric, or one of -, ., _ or ~).

    presentation object
    sort_orderinteger

    Specifies the order of the field in the User Interface.

    Possible values: <= 1000

    Default value: 0
    Example: 10
    validation object
    boolean object
    allow_null_valuesboolean | null

    When set to true, this allows null values for that field on Custom API Entries. When set to false, storing null values is not permitted.

    Default value: true
    immutableboolean | null

    When set to true, prevents changing the field.

    Default value: false

Responses

Created

Schema
    data objectrequired
    field_typerequired

    Possible values: [boolean, float, integer, string]

    iduuid

    The unique identifier of the Custom Field.

    typestring

    Specifies the type of the resource object, use custom_field for Custom Field.

    namestring

    Specifies the name of this Custom Field.

    Possible values: non-empty and <= 255 characters

    descriptionstring

    Specifies the description for this Custom API.

    Possible values: <= 255 characters

    slugstring

    Specifies a slug that must be unique within the scope of the Custom API. This slug will be value as the key in the JSON Object in all entries.

    Possible values: non-empty and <= 63 characters

    field_typestring

    Specifies the type of the field. This field cannot be updated.

    Possible values: [string, integer, boolean, float]

    use_as_url_slugboolean

    Enabling this field will mean Custom API Entries created in this Custom API will use this value in the URL instead of the id attribute. In order to set this field, the field must be a string, and unique, not allow null values, no entries have been created yet, and this field cannot be set to true on another custom field. This field cannot be updated. In addition to any validation rules you create, the values must be Unreserved URL Characters (i.e., be alpha-numeric, or one of -, ., _ or ~).

    presentation object
    sort_orderinteger

    Specifies the order of the field in the User Interface.

    Possible values: <= 1000

    Default value: 0
    Example: 10
    links object
    selfuri
    meta object
    timestamps objectrequired
    updated_atstringrequired

    Specifies the date the entity is created.

    Example: 2017-01-10T11:41:19.244Z
    created_atstringrequired

    Specifies the date the entity is last updated.

    Example: 2017-01-10T11:41:19.244Z
    validation object
    boolean object
    allow_null_valuesboolean | null

    When set to true, this allows null values for that field on Custom API Entries. When set to false, storing null values is not permitted.

    Default value: true
    immutableboolean | null

    When set to true, prevents changing the field.

    Default value: false

Authorization: http

name: bearerAuthtype: httpscheme: bearer
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://useast.api.elasticpath.com/v2/settings/extensions/custom-apis/:custom_api_id/fields");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"data\": {\n \"type\": \"string\",\n \"name\": \"string\",\n \"description\": \"string\",\n \"slug\": \"string\",\n \"field_type\": \"string\",\n \"use_as_url_slug\": true,\n \"presentation\": {\n \"sort_order\": 10\n },\n \"validation\": {\n \"boolean\": {\n \"allow_null_values\": true\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://useast.api.elasticpath.com
Auth
Parameters
— pathrequired
Body
{
  "data": {
    "type": "string",
    "name": "string",
    "description": "string",
    "slug": "string",
    "field_type": "string",
    "use_as_url_slug": true,
    "presentation": {
      "sort_order": 10
    },
    "validation": {
      "boolean": {
        "allow_null_values": true
      }
    }
  }
}
ResponseClear

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

We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.