> ## Documentation Index
> Fetch the complete documentation index at: https://docs.layest.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Attributes: Define and Manage Fields on Data Objects

> Define and manage attributes (fields) on Layest data objects. Supports text, number, date, boolean, relation, and file attribute types for structured data.

Attributes are the fields that define the structure of objects in a collection — the columns in your table, the building blocks of your records. Every attribute has a name, a type, and a set of configuration options that control how data is stored and validated. Designing your attributes carefully pays dividends throughout your workspace: well-typed fields make agent queries more precise, enable richer filtering in the UI, and reduce the chance of malformed data entering your collections.

## What Are Attributes?

When you create a collection and define its attributes, you are describing the shape of every object that will live in that collection. An attribute named `Status` of type `Select` with options `Open`, `In Progress`, and `Closed` means every object in that collection can have exactly one of those three values for its status — no free-text typos, no ambiguity. Agents use these constraints too: they know the valid values for a select field and will not attempt to write an invalid one.

## Supported Attribute Types

<CardGroup cols={2}>
  <Card title="Text" icon="font">
    Stores any string of characters. Use it for names, descriptions, notes, email addresses, URLs, or any other free-form text. You can configure a maximum length.
  </Card>

  <Card title="Number" icon="hashtag">
    Stores integer or decimal numeric values. Useful for quantities, prices, scores, or any measurable value. Supports minimum and maximum range constraints.
  </Card>

  <Card title="Date" icon="calendar">
    Stores a date or date-and-time value in ISO 8601 format. Displayed in your workspace's configured timezone. Great for deadlines, event timestamps, and expiry dates.
  </Card>

  <Card title="Boolean" icon="toggle-on">
    Stores a true/false value. Renders as a checkbox in the UI. Use it for simple flags like `Is Active`, `Requires Review`, or `Subscribed`.
  </Card>

  <Card title="Select" icon="circle-dot">
    Stores one value chosen from a predefined list of options you configure. Prevents invalid entries and makes filtering fast and reliable.
  </Card>

  <Card title="Multi-select" icon="list-check">
    Like Select, but allows an object to hold multiple chosen options simultaneously. Ideal for tags, categories, and labels where several values may apply at once.
  </Card>

  <Card title="Relation" icon="link">
    Creates a link between an object in this collection and one or more objects in another collection. Use relations to model real-world associations, such as linking a `Ticket` to its `Customer`.
  </Card>

  <Card title="File" icon="paperclip">
    Attaches one or more uploaded files to an object. The attribute stores references to files in Layest's file storage. Agents can read file metadata and contents from these attributes.
  </Card>
</CardGroup>

## Adding and Editing Attributes

**To add a new attribute to a collection:**

<Steps>
  <Step title="Open collection settings">
    Navigate to **Data → Collections**, open the collection you want to modify, and click the **Settings** tab.
  </Step>

  <Step title="Click Add Attribute">
    In the **Attributes** section, click **Add Attribute**. A configuration panel opens on the right.
  </Step>

  <Step title="Name the attribute">
    Enter a clear, concise name. Attribute names must be unique within a collection. Avoid spaces if you plan to reference the attribute in code — use underscores or camelCase instead.
  </Step>

  <Step title="Choose the attribute type">
    Select one of the eight supported types from the **Type** dropdown. The configuration options in the panel update to match the selected type.
  </Step>

  <Step title="Configure type-specific options">
    Set any options relevant to the type — for example, add options for a Select attribute, set a max length for Text, or choose the related collection for a Relation attribute.
  </Step>

  <Step title="Set required and default value options">
    Toggle **Required** on if every object must have a value for this attribute. Optionally set a **Default Value** that pre-populates the field when a new object is created.
  </Step>

  <Step title="Save">
    Click **Save Attribute**. The attribute is added to the collection schema immediately. Existing objects will have a blank value for the new attribute until you or an agent populates them.
  </Step>
</Steps>

**To edit an existing attribute**, click its name in the **Attributes** list in collection settings. You can change the display name, description, required toggle, and default value. Changing the attribute type is not supported after creation — if you need a different type, you must add a new attribute and migrate the data.

## Required vs. Optional Attributes

Mark an attribute as **Required** when every object in the collection must always have a value for that field. Layest enforces this constraint at write time — agents and users cannot save an object with a blank required field.

Leave an attribute as **Optional** (the default) when some objects legitimately may not have a value. Optional attributes display a dash in the collection view when no value has been set.

Use required attributes sparingly: over-constraining a collection can make bulk imports fragile and cause agent actions to fail when the agent cannot determine an appropriate value.

## Default Values

A default value is automatically applied to a new object if no explicit value is provided at creation time. Default values are supported on all attribute types:

* **Text** — any string literal, e.g., `"Unassigned"`
* **Number** — any numeric literal, e.g., `0`
* **Date** — a fixed date or the dynamic value `now` (the creation timestamp)
* **Boolean** — `true` or `false`
* **Select / Multi-select** — one of the configured options
* **Relation / File** — default values are not supported on these types

Defaults reduce friction for both manual object creation and agent-driven writes, ensuring that key fields always have a sensible starting value.

## Using Attributes in Agent Prompts and Workflows

Attributes become part of your agent's vocabulary. When you connect a collection to an agent, Layest shares the collection's attribute schema with the agent so it understands what fields exist and what types they are.

Reference attributes by name in your agent instructions to make them explicit:

```text theme={null}
When a new lead comes in, create an object in the Customer Leads collection with:
- name: the contact's full name
- email: the contact's email address
- status: "New"
- source: the channel the lead came from (e.g. "Website", "Referral")
```

In workflow steps, you can map attribute values to variables and pass them between steps:

```text theme={null}
Step 1 — Read: Query Customer Leads where status = "Qualified"
Step 2 — For each result, read the email attribute and send a follow-up email
Step 3 — Update the status attribute to "Contacted"
```

<Warning>
  Deleting an attribute permanently removes all data stored in that field across every object in the collection. This action cannot be undone. Before deleting an attribute, export your collection data or migrate the values to a different attribute. To delete an attribute, open **Collection Settings → Attributes**, click the attribute, and select **Delete Attribute** from the **⋯ More** menu.
</Warning>
