Skip to main content

AttributesSets

Read attribute sets: the field schemas of pages, products, blocks, forms and other entities.

More information about the module's user interface https://doc.oneentry.cloud/docs/category/attributes (opens in a new tab)


The AttributesSets module reads the custom-field definitions (attribute sets) used by your content: products, pages, forms, blocks and more. An attribute set is a schema: it describes which fields an entity has and the type of each field. You define attribute sets in the OneEntry admin panel and read their structure with this module.

Note: attribute sets describe the schema, not the values. Values live on the entities themselves (a page, a product, etc.) under attributeValues. The one exception is the timeInterval type, which can carry values; see the examples below.

Quickstart​

Initialize the module from defineOneEntry:


const { } = defineOneEntry(
, {
}
);

Fetch the attributes of a set and read their markers and types:

// Get every attribute in the "productAttributes" set.
const attributes = await AttributesSets.getAttributesByMarker(
"productAttributes",
"en_US",
);
if ('statusCode' in attributes) throw new Error(attributes.message);

attributes.forEach((attr) => {
console.log(attr.marker, attr.type, attr.localizeInfos.title);
});

Concepts​

Attribute, attribute set, value​

TermWhat It IsExample
AttributeA single field definition (a marker + a type)price (float)
Attribute SetA collection of attributes - the entity's schema"Product" set
ValueThe data an entity stores for an attribute19.99 on a specific product

An attribute set groups attributes into a reusable schema. You can attach the same set to multiple entities, so changing the set changes the fields everywhere it is used.

Attributes are defined within a set's schema, by marker. To reuse a field elsewhere, either create a similar attribute with a different marker, or reuse the whole attribute set on multiple entities.

Markers​

The marker is the technical identifier you use in code (e.g. product_name), as opposed to the human-readable title shown in the admin panel.

product.attributeValues.product_name; // "product_name" is the marker

A marker must be unique, can't contain spaces (use _) and can't start with a number. Lowercase is the convention.

Good: product_name, price_usd, main_image. Bad: product name, 2nd_price, Product Name.

Shared attribute sets​

When several entities use the same attribute set, changes to the set apply to all of them:

  • Adding an attribute: it appears on every entity that uses the set. Existing content keeps its values, and the new field starts empty.
  • Removing an attribute: it is removed from every entity that uses the set, and its existing values are permanently deleted.

You can't delete an attribute while an attribute set still uses it.

Validators​

Attributes can carry validators: required fields, min/max length, file-size limits, image pixel dimensions, date ranges and a default value. Each attribute returns its validator config under validators.

To add validators, open the attribute set in the OneEntry admin panel, click an attribute, add validators (required, min/max, etc.) and save.

Click to see validator examples
  • requiredValidator: a value is required.
{
"type": "string",
"value": null,
"marker": "string",
"position": 1,
"listTitles": [],
"validators": {
"requiredValidator": {
"strict": true
}
},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Currency"
},
"additionalFields": {
"extra": {
"type": "integer",
"value": 10
}
}
}

  • defaultValueValidator: a default value for the field.
{
"type": "string",
"value": null,
"marker": "string",
"position": 1,
"listTitles": [],
"validators": {
"defaultValueValidator": {
"customErrorText": "Custom error",
"fieldDefaultValue": "usd",
"fieldDefaultValue2": ""
}
},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "String"
},
"additionalFields": {
"extra": {
"type": "integer",
"value": 10
}
}
}

See Validators (opens in a new tab) for configuration details.

Additional fields​

You can attach extra fields to an attribute with Additional Fields (opens in a new tab). They are returned under additionalFields.


Methods​

MethodWhat It Does
getAttributes()Get all attribute set objects.
getAttributesByMarker()Get all attributes of a set, with data from the attribute set.
getAttributeSetByMarker()Get a single attribute set object by marker.
getSingleAttributeByMarkerSet()Get one attribute (with set data) by set marker and attribute marker.

Data types​

Each attribute has a type:

TypeBest ForExample Use
stringShort text (< 255 chars)Product name, email
textLong formatted textBlog post, description
textWithHeaderText with a titleArticle sections
integerWhole numbersQuantity, age
realHigh-precision decimalsScientific data
floatDecimal numbersPrice, rating
dateJust the dateBirth date, deadline
dateTimeDate + timeEvent start, published at
timeJust the timeOpening hours
fileAny filePDF, document
imageSingle imageAvatar, logo
groupOfImagesMultiple imagesPhoto gallery
radioButtonSingle choiceSize (S/M/L)
listDropdown selectionCountry, category
buttonInteractive actionSubmit form, CTA
spamForm spam protectionAnti-bot honeypot field
entityLink to other contentRelated products
timeIntervalDate/time rangesSchedules, promotion period
jsonStructured JSON dataSettings, raw payloads

Choosing a type​

  • Text: string (a single line, up to ~255 characters, for names, titles, emails), text (multiple paragraphs, supports formatting and HTML, for descriptions and articles), textWithHeader (text with a headline).
  • Numbers: integer (whole numbers only, e.g. 1, 2, 100, -5, for quantities and counts), float (decimals, e.g. 19.99, 4.5, for prices, ratings and measurements), real (like float with higher precision, for scientific calculations).
  • Date/time: date, time, dateTime, or timeInterval (ranges/schedules).
  • Files/images: file (any document), image (one picture), groupOfImages (a gallery).
  • Choices: radioButton (pick one), list (dropdown).
  • Advanced: entity (link to other pages/products), button (interactive action), spam (bot protection), json (a JSON string, validated as JSON on submission).

Data type examples​

The structure of each data type as the SDK returns it.

The attribute set doesn't include attribute values; those live on specific entities (pages, products, etc.). The only exception is timeInterval, which can carry values when the corresponding box is checked in the admin panel (opens in a new tab).

Click to see all data type examples

Data types reference​

  • String: plain text, for example "Hello, world!".
{
"type": "string",
"value": null,
"marker": "string",
"position": 1,
"listTitles": [],
"validators": {
"requiredValidator": {
"strict": true
}
},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "String"
},
"additionalFields": {
"Extra": {
"type": "integer",
"value": 10
}
}
}

  • Text: longer text, often formatted, for example an article or a letter.
{
"type": "text",
"value": null,
"marker": "text",
"position": 2,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Text"
},
"additionalFields": {}
}

  • Text with Header: text with a header, for example to name a topic or category.
{
"type": "textWithHeader",
"value": null,
"marker": "text_with_header",
"position": 3,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Text With Header"
},
"additionalFields": {}
}

  • Integer: an integer, for example 5, 100, -2.
{
"type": "integer",
"value": null,
"marker": "integer",
"position": 4,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Integer"
},
"additionalFields": {}
}

  • Real: like Float, but with higher precision.
{
"type": "real",
"value": null,
"marker": "real_number",
"position": 5,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Real Number"
},
"additionalFields": {}
}

  • Float: a floating-point number, for example 3.14, 1.5, -0.25.
{
"type": "float",
"value": null,
"marker": "float",
"position": 6,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Float"
},
"additionalFields": {}
}

  • Date and Time: a date with a time, for example 2023-10-27 10:00:00.
{
"type": "dateTime",
"value": null,
"marker": "date_time",
"position": 7,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "DateTime"
},
"additionalFields": {}
}

  • Date: a date, for example 2023-10-27.
{
"type": "date",
"value": null,
"marker": "date",
"position": 8,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Date"
},
"additionalFields": {}
}

  • Time: a time, for example 10:00:00.
{
"type": "time",
"value": null,
"marker": "time",
"position": 9,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Time"
},
"additionalFields": {}
}

  • File: any file, for example a document, an image or music.
{
"type": "file",
"value": null,
"marker": "file",
"position": 10,
"listTitles": [],
"validators": {
"checkingFilesValidator": {
"maxUnits": "kb",
"maxValue": "2000",
"minUnits": "kb",
"minValue": 0,
"extensions": []
}
},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "File"
},
"additionalFields": {}
}

  • Image: an image, for example a photo or a drawing.
{
"type": "image",
"value": null,
"marker": "image",
"position": 11,
"listTitles": [],
"validators": {
"sizeInPixelsValidator": {
"maxX": "500",
"maxY": "500"
}
},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Image"
},
"additionalFields": {}
}

  • Group of Images: a set of images, for example a photo album.
{
"type": "groupOfImages",
"value": null,
"marker": "image_group",
"position": 12,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Image Group"
},
"additionalFields": {}
}

  • Radio Button: a choice where only one option can be selected.
{
"type": "radioButton",
"value": null,
"marker": "radio",
"position": 13,
"listTitles": [
{
"title": "A",
"value": "a",
"extended": {
"type": null,
"value": null
},
"position": 1
},
{
"title": "B",
"value": "b",
"extended": {
"type": null,
"value": null
},
"position": 2
}
],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Radio"
},
"additionalFields": {}
}

  • List: a list of selectable items, for example a dropdown.
{
"type": "list",
"value": null,
"marker": "list",
"position": 14,
"listTitles": [
{
"title": "A",
"value": "a",
"extended": {
"type": null,
"value": null
},
"position": 1
},
{
"title": "B",
"value": "b",
"extended": {
"type": null,
"value": null
},
"position": 2
},
{
"title": "C",
"value": "c",
"extended": {
"type": "string",
"value": "Additional Value"
},
"position": 3
}
],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "List"
},
"additionalFields": {}
}

Whether a list field accepts several options is configured in the admin panel. getAttributesByMarker() and getSingleAttributeByMarkerSet() always return it as multiselect (boolean, false when not set) on each attribute; the SDK types don't declare this field yet. In the schema of getAttributeSetByMarker() and getAttributes() it appears as the optional IAttributeSchemaItem.multiselect and is omitted when it was never set, so treat a missing value as single-select.


  • Entity: a link to another object (page, product, …).
{
"type": "entity",
"value": null,
"marker": "entity",
"position": 15,
"listTitles": [
{
"title": "Products",
"value": {
"id": 1,
"depth": 0,
"parentId": null,
"isPinned": false,
"position": 1,
"selected": true
}
},
{
"title": "Normal Page",
"value": {
"id": 4,
"depth": 0,
"parentId": null,
"isPinned": false,
"position": 2,
"selected": true
}
},
{
"title": "Error",
"value": {
"id": 2,
"depth": 0,
"parentId": null,
"isPinned": false,
"position": 3,
"selected": true
}
}
],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Entity"
},
"additionalFields": {
"test_field": {
"type": "string",
"value": "Test Field"
}
}
}

  • Time interval: a calendar of time-interval data. The example below is a schema item (schema.time_interval in getAttributeSetByMarker()), not an attribute object; values appear only when Receive values is enabled.
{
"time_interval": {
"id": 4,
"type": "timeInterval",
"value": [
// Array of value groups, each linked to a specific interval (via intervalId). This array is formed when Receive values is enabled in CMS
{
// Specific time records applicable to the specified dates
"values": [
{
// Unique record identifier
"id": "1dc1787d-acc3-4315-a45d-52166c72e577",
// Date range (inclusive) to which this record applies
"dates": ["2025-11-27T00:00:00.000Z", "2025-11-27T00:00:00.000Z"],
// Array of time slots in format [[start, end], ...]
"times": [
[
// Start of time slot (hours and minutes)
{
"hours": 19,
"minutes": 18
},
// End of time slot
{
"hours": 21,
"minutes": 19
}
]
],
// Reserved (not used in current implementation)
"intervals": [],
// Exceptions — time segments excluded from the schedule on the specified date
"exceptions": [
{
// Exception date
"date": "2025-12-17T17:00:00.000Z",
// Array of excluded time segments
"externalTimes": [
["2025-12-17T17:25:00.000Z", "2025-12-17T17:27:00.000Z"]
]
}
],
// Reference to interval from the `intervals` array
"intervalId": "0da61a19-49cb-40b1-88e6-1fa3c93a1fa6",
// Flag for weekly recurrence (on the corresponding day of the week)
"inEveryWeek": true
},
{
"id": "cfa187d3-0284-4e0d-8206-7b353cf47110",
"dates": ["2025-12-18T00:00:00.000Z", "2025-12-18T00:00:00.000Z"],
// Array of time slots in format [[start, end], ...]
"times": [
[
{
"hours": 0,
"minutes": 25
},
{
"hours": 0,
"minutes": 27
}
],
[
{
"hours": 19,
"minutes": 18
},
{
"hours": 21,
"minutes": 19
}
]
],
"intervals": [],
"exceptions": [
{
"date": "2025-12-17T17:00:00.000Z",
"externalTimes": [
["2025-12-17T17:25:00.000Z", "2025-12-17T17:27:00.000Z"]
]
}
],
"intervalId": "0da61a19-49cb-40b1-88e6-1fa3c93a1fa6"
},
{
"id": "474de0f7-595f-49a5-aaa7-65617203ae69",
"dates": ["2025-12-25T00:00:00.000Z", "2025-12-25T00:00:00.000Z"],
// No time slots
"times": [],
// Dynamic rules for schedule expansion
"external": [
{
// Base date for calculating recurring event
"date": "2026-01-15T00:00:00.000Z",
// Event repeats every month on this day
"inEveryMonth": true
}
],
"intervals": [],
"exceptions": [
{
"date": "2025-12-17T17:00:00.000Z",
"externalTimes": [
["2025-12-17T17:25:00.000Z", "2025-12-17T17:27:00.000Z"]
]
}
],
"intervalId": "0da61a19-49cb-40b1-88e6-1fa3c93a1fa6",
// Flag for weekly recurrence
"inEveryWeek": true,
// Flag for monthly recurrence
"inEveryMonth": true,
// Flag for yearly recurrence
"inEveryYears": true
}
],
// Reference to interval from the `intervals` array
"intervalId": "0da61a19-49cb-40b1-88e6-1fa3c93a1fa6"
},
{
"values": [
{
"id": "2f80dc18-16da-45cb-82c6-e41e1f6ee084",
"dates": ["2025-12-22T00:00:00.000Z", "2025-12-23T00:00:00.000Z"],
"times": [],
"intervals": [],
"exceptions": [],
"intervalId": "918175fd-cc18-4ca5-9bee-c78c61c9415a",
"inEveryWeek": true,
"inEveryMonth": true
}
],
"intervalId": "918175fd-cc18-4ca5-9bee-c78c61c9415a"
}
],
"isPrice": false,
"original": true,
"intervals": [
// Array of time interval templates
{
// Unique identifier of interval template
"id": "0da61a19-49cb-40b1-88e6-1fa3c93a1fa6",
"range": [
// Main range of interval applicability
"2025-11-26T17:00:00.000Z",
"2025-11-26T17:00:00.000Z"
],
// Exceptions at the entire interval level
"external": [
{
"date": "2025-12-17T17:00:00.000Z",
"externalTimes": [
["2025-12-17T17:25:00.000Z", "2025-12-17T17:27:00.000Z"]
]
}
],
// Internal time slots (working/active periods)
"intervals": [
{
"id": "01fea594-9933-47ac-af0a-ec0e0884f618",
// End of time slot
"end": {
"hours": 21,
"minutes": 19
},
// Start of time slot
"start": {
"hours": 19,
"minutes": 18
},
// Duration of repeating block (in minutes); null — no periodicity
"period": null
},
{
"id": "22ba24af-1fae-4422-8c92-0635b684a306",
"end": {
"hours": 0,
"minutes": 29
},
"start": {
"hours": 0,
"minutes": 25
},
// Periodicity: time slots repeat with 2-minute step
"period": 2,
// Exception inside periodic slot
"external": {
// Flag for displaying exception in the interface
"show": false,
// Duration of excluded fragment (in minutes)
"value": 2
}
}
],
"inEveryWeek": true,
"inEveryMonth": true,
"inEveryYears": true
},
{
"id": "918175fd-cc18-4ca5-9bee-c78c61c9415a",
"range": ["2026-01-18T17:00:00.000Z", "2026-01-20T17:00:00.000Z"],
// No exceptions
"external": [],
// No internal time slots
"intervals": [],
"inEveryWeek": true,
"inEveryMonth": true,
"inEveryYears": true
}
],
// Flag for attribute visibility in the interface
"isVisible": true,
"identifier": "time_interval",
"localizeInfos": {
"title": "Time interval"
},
"receiveValues": true
}
}

In the admin panel, the content editor for each attribute field matches its data type.