Skip to content

Create Enum

Creates a new Enum model: a closed, named list of string values that entity fields of type enum can reference. The server assigns an id to the enum and to each value.

Endpoint

shell
curl -X POST https://api.contentisland.net/api/1.0/model/enum \
--header 'Authorization: Bearer YOUR_WRITE_TOKEN' \
--header 'Content-Type: application/json' \
--data '{ ... }'

Body

interface CreateEnumPayload {
name: string; // enum name (same rules as a model name)
values: EnumValueSpec[]; // at least one value, in order
}
interface EnumValueSpec {
id?: string; // omit when creating — the server assigns one
value: string; // the value label
}
NameDescription
nameThe enum name. Same name rules as a model name, unique across the project’s models.
valuesThe enum values, in order. At least one value is required. Values must be unique within the enum (case-insensitive).

Example

shell
curl -X POST https://api.contentisland.net/api/1.0/model/enum \
--header 'Authorization: Bearer YOUR_WRITE_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"name": "Size",
"values": [
{ "value": "S" },
{ "value": "M" },
{ "value": "L" }
]
}'

Response

On success the endpoint returns 201 Created with the id of the new enum:

{
"id": "660f5b8a3a1c2d4e7f8b34cd"
}

Status Codes

CodeDescription
201The enum was created. The response body contains the new enum id.
400Invalid payload — bad name (format / length / reserved / duplicate), empty values, or duplicate values.
401Unauthorized. The token is missing, malformed or expired.
403Forbidden. The token does not have write permissions — use a Write Token.
500Internal server error.