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

# Add Table Field

> Add a new field to a table.

## Field Types Reference

### Editable Fields

| Type               | Value Format        | Description                                    |
| ------------------ | ------------------- | ---------------------------------------------- |
| `SINGLE_LINE_TEXT` | `string`            | Short text                                     |
| `LONG_TEXT`        | `string`            | Multi-line text                                |
| `EMAIL`            | `string`            | Email address                                  |
| `PHONE`            | `string`            | Phone number                                   |
| `URL`              | `string`            | Web URL                                        |
| `NUMBER`           | `number`            | Numeric value                                  |
| `CURRENCY`         | `number`            | Monetary amount                                |
| `PERCENT`          | `number`            | Percentage (0–100)                             |
| `RATING`           | `number`            | Star rating                                    |
| `DURATION`         | `number`            | Duration                                       |
| `CHECKBOX`         | `boolean`           | True/false                                     |
| `SELECT`           | `string` or `array` | Single or multi-select from predefined choices |
| `USER`             | `object` or `array` | User reference                                 |
| `LINKED_RECORD`    | `string` or `array` | Link to record(s) in another table             |
| `ATTACHMENT`       | `object` or `array` | File attachment                                |
| `DATE`             | `string`            | Date (ISO 8601)                                |
| `DATETIME`         | `string`            | Date and time (ISO 8601)                       |

### Read-Only Fields

These are computed or system-managed and cannot be set when creating or updating records.

| Type         | Description                          |
| ------------ | ------------------------------------ |
| `LOOKUP`     | Value from a linked record's field   |
| `ROLLUP`     | Aggregation over linked records      |
| `FORMULA`    | Calculated from a formula expression |
| `CREATED_AT` | Record creation timestamp            |
| `UPDATED_AT` | Record last modified timestamp       |
| `CREATED_BY` | User who created the record          |
| `UPDATED_BY` | User who last modified the record    |
| `AUTONUMBER` | Auto-incrementing number             |
| `RECORD_ID`  | System record identifier             |

## Field Options

Type-specific configuration passed in the `options` object when creating or updating fields.

### SELECT

```json theme={null}
{
  "choices": [
    { "id": "choice-1", "label": "Option A", "color": "#FF0000" },
    { "id": "choice-2", "label": "Option B", "color": "#00FF00" }
  ],
  "allowToAddNewChoice": true,
  "sorting": "CUSTOM",
  "enforceOrder": false
}
```

`sorting` can be `CUSTOM`, `ALPHA_ASC`, or `ALPHA_DESC`.

### NUMBER

```json theme={null}
{
  "precision": 2,
  "min": 0,
  "max": 1000000,
  "showThousandSeparator": true,
  "thousandSeparatorLocale": "en-US",
  "largeNumberAbbreviation": "NONE",
  "prefix": null,
  "suffix": null
}
```

`largeNumberAbbreviation` can be `NONE`, `K`, `M`, `B`, or `T`.

### CURRENCY

```json theme={null}
{
  "precision": 2,
  "min": null,
  "max": null,
  "isoCode": "USD",
  "customSymbol": null,
  "showAs": "SYMBOL",
  "showThousandSeparator": true,
  "thousandSeparatorLocale": "en-US",
  "largeNumberAbbreviation": "NONE",
  "symbolOrCodePosition": "BEFORE"
}
```

* `showAs`: `SYMBOL` or `CODE`
* `symbolOrCodePosition`: `BEFORE` or `AFTER`

### LINKED\_RECORD

```json theme={null}
{
  "linkedTableId": "table-uuid",
  "inverseLinkFieldId": "field-uuid",
  "viewId": null,
  "sorting": [],
  "filter": null,
  "enforceOrder": false
}
```

### LOOKUP

```json theme={null}
{
  "linkedRecordFieldId": "field-uuid",
  "lookupFieldId": "field-uuid",
  "isValid": true
}
```

### ROLLUP

```json theme={null}
{
  "linkedRecordFieldId": "field-uuid",
  "rollupFieldId": "field-uuid",
  "function": "SUM",
  "filter": null
}
```

Available functions: `SUM`, `MIN`, `MAX`, `COUNT`, `AVERAGE`, `ARRAYCOMPACT`, `ARRAYJOIN`, `ARRAYUNIQUE`, `ARRAYFLATTEN`, `CONCATENATE`, `COUNTALL`, `COUNTA`, `OR`, `AND`.

### ATTACHMENT

```json theme={null}
{
  "showAs": "PREVIEW",
  "inferredFileType": "OTHER",
  "enableFileLinkExpiration": true,
  "fileLinkExpirationValue": 2,
  "fileLinkExpirationUnit": "HOURS"
}
```

* `showAs`: `PREVIEW`, `LIST`, or `BADGE`
* `inferredFileType`: `IMAGE`, `VIDEO`, `PDF`, `AUDIO`, or `OTHER`
* `fileLinkExpirationUnit`: `HOURS` or `MINUTES`

### FORMULA

```json theme={null}
{
  "formula": "IF({Status} = 'Active', {Amount} * 1.1, {Amount})",
  "isValid": true,
  "referencedFieldIds": ["field-uuid-1", "field-uuid-2"]
}
```

## AI Options

Fields can include an `aiOptions` object that configures AI-powered auto-fill behavior. This is returned in field definitions and can be set when creating or updating fields.

```json theme={null}
{
  "aiFillable": true,
  "aiOnly": false,
  "allowWebSearch": true,
  "aiModel": "GPT_4_1",
  "prompt": "Summarize the customer's request based on {Description}",
  "canBeTriggeredManually": true,
  "runWhenRecordIsCreated": true,
  "runWhenRecordIsUpdated": false
}
```

| Property                 | Type    | Default     | Description                                                 |
| ------------------------ | ------- | ----------- | ----------------------------------------------------------- |
| `aiFillable`             | boolean | `false`     | Whether AI can fill this field                              |
| `aiOnly`                 | boolean | `true`      | If `true`, only AI can write to this field                  |
| `allowWebSearch`         | boolean | `false`     | Allow AI to use web search when filling                     |
| `aiModel`                | string  | `"GPT_4_1"` | AI model to use                                             |
| `prompt`                 | string  | `""`        | Prompt template (reference other fields with `{FieldName}`) |
| `canBeTriggeredManually` | boolean | `true`      | Whether users can trigger AI fill manually                  |
| `runWhenRecordIsCreated` | boolean | `true`      | Auto-run when record is created                             |
| `runWhenRecordIsUpdated` | boolean | `true`      | Auto-run when record is updated                             |

Fields without AI configuration return `"aiOptions": null`.


## OpenAPI

````yaml openapi.yaml POST /databases/{databaseId}/tables/{tableId}/fields
openapi: 3.0.0
info:
  title: Softr Database API
  description: >
    Public API to communicate with Softr Databases. The API follows REST
    semantics and uses JSON to encode objects.


    **Rate Limiting:**

    All calls are subject to rate limiting. On exceeding the limit, you will
    receive a 429 HTTP Response Status Code.

    - **Reads** (GET, POST /search): 40 requests/second per token.

    - **Writes** (POST, PUT, PATCH, DELETE): 30 requests/second per token.
  version: 1.0.0
servers:
  - url: https://tables-api.softr.io/api/v1
    description: Production Server
security:
  - ApiKeyAuth: []
tags:
  - name: Databases
    description: Operations related to Softr databases.
  - name: Tables
    description: Operations related to tables within a database.
  - name: Table Fields
    description: Operations to manage fields within a table.
  - name: Records
    description: Operations to manage records (rows) within a table.
paths:
  /databases/{databaseId}/tables/{tableId}/fields:
    parameters:
      - name: databaseId
        in: path
        required: true
        schema:
          type: string
      - name: tableId
        in: path
        required: true
        schema:
          type: string
    post:
      tags:
        - Table Fields
      summary: Add Table Field
      description: Add a new field to a table.
      operationId: addTableField
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - type
              properties:
                name:
                  type: string
                type:
                  type: string
                options:
                  type: object
                  additionalProperties: true
      responses:
        '200':
          description: The newly created field.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/TableField'
        '429':
          description: Rate limit exceeded.
components:
  schemas:
    TableField:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        description:
          type: string
          nullable: true
          description: Optional description of the field.
        type:
          type: string
          description: The type of the field.
          enum:
            - SINGLE_LINE_TEXT
            - CHECKBOX
            - CURRENCY
            - DATE
            - DATETIME
            - DURATION
            - EMAIL
            - SELECT
            - NUMBER
            - ATTACHMENT
            - RATING
            - LINKED_RECORD
            - LONG_TEXT
            - URL
            - PERCENT
            - PHONE
            - LOOKUP
            - ROLLUP
            - FORMULA
            - CREATED_AT
            - UPDATED_AT
            - CREATED_BY
            - UPDATED_BY
            - AUTONUMBER
            - RECORD_ID
            - USER
        options:
          type: object
          description: >-
            Configuration options for the field, specific to its type. See the
            official documentation for the structure of each type.
          additionalProperties: true
        allowMultipleEntries:
          type: boolean
        readonly:
          type: boolean
        required:
          type: boolean
        locked:
          type: boolean
        defaultValue:
          type: string
          nullable: true
        aiOptions:
          type: object
          nullable: true
          description: AI-powered auto-fill configuration. Null if not configured.
          properties:
            aiFillable:
              type: boolean
            aiOnly:
              type: boolean
            allowWebSearch:
              type: boolean
            aiModel:
              type: string
            prompt:
              type: string
            canBeTriggeredManually:
              type: boolean
            runWhenRecordIsCreated:
              type: boolean
            runWhenRecordIsUpdated:
              type: boolean
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Softr-Api-Key

````