## Create or update opportunity definitions

**post** `/v1/opportunities/definitions`

> [!WARNING]
This endpoint is in beta and isn't available to every workspace yet. Its parameters and response schemas may change, including breaking changes.

Requires a workspace owner or admin. Creates, changes, archives and restores definitions, keyed the way `GET` returns them. A key that names no definition creates one; a key that names one changes only the properties sent, and restores it first if it is archived. Sending the same request again changes nothing.

Every definition is checked before any is written. If any check fails, nothing is changed and the response is 422, or 409 when a definition that already exists disagrees with the request, with every problem listed under `issues`. The writes themselves are independent: in the rare case one fails after the checks pass, the others are still written, and the response is 409 with the written definitions listed under `applied`. If another request is writing definitions at the same time, the response can be 429 with nothing changed; send the request again.

Pipeline and stage fields cannot be changed through this endpoint. Labels are stored without leading or trailing whitespace. Labels, new keys and new option IDs can be at most 255 characters.

Validation rules and `required` on fields are available only where `GET` lists them. A rule that uses a field created by the same request is checked only when it is saved, after that field is written.

**[Required scopes](/using-the-api/scopes/):** `opportunities:read`, plus `config:create` to create, `config:update` to change or restore, `config:delete` to archive or delete a rule

**[Rate limit category](/using-the-api/rate-limits/):** Write

### Body Parameters

- `fieldDefinitions: optional map[object { aiFillable, aiFillablePrompt, archived, 6 more } ]`

  Field definitions to create or change, keyed by field key. A key that names no field creates one with that key, and needs `label` and `valueType`. `filter`, `fields` and `sort` can't be new keys, since list endpoints use them as query params. A key that names a field changes only the properties sent. `archived` archives or restores it. At most 10 definitions per request.

  - `aiFillable: optional "ON" or "OFF" or "SUGGEST"`

    Whether AI fills this field automatically (`ON`), only suggests values (`SUGGEST`), or leaves it alone (`OFF`). Absent on built-in fields that have no `id`.

    - `"ON"`

    - `"OFF"`

    - `"SUGGEST"`

  - `aiFillablePrompt: optional string`

    Instructions AI follows when filling this field, or null when none are set. Absent on built-in fields that have no `id`.

  - `archived: optional boolean`

    Whether the field definition is archived.

  - `description: optional string`

    Description of the field, or null.

  - `formula: optional string`

    Formula a calculated field evaluates, with fields and relationships referenced by key. Null for fields that are not calculated. Absent on built-in fields that have no `id`.

  - `label: optional string`

    Human-readable display name of the field.

  - `required: optional boolean`

    Whether a record must have a value for this field to be created or saved. Absent when validation rules are not available, and on calculated and built-in fields that have no `id`.

  - `typeConfiguration: optional object { currency, decimalPlaces, handleService, 3 more }`

    - `currency: optional string`

      ISO 4217 3-letter currency code. Present on `CURRENCY` fields, absent on every other type.

    - `decimalPlaces: optional number`

      Number of decimal places values carry, or null when none is set. Present on `NUMBER` and `CURRENCY` fields, absent on every other type.

    - `handleService: optional "TWITTER" or "LINKEDIN" or "FACEBOOK" or "INSTAGRAM"`

      Social platform associated with this handle field, or null when none is set. Present on `SOCIAL_HANDLE` fields, absent on every other type.

      - `"TWITTER"`

      - `"LINKEDIN"`

      - `"FACEBOOK"`

      - `"INSTAGRAM"`

    - `multipleValues: optional boolean`

      Whether this field accepts multiple values. Present on `EMAIL`, `TELEPHONE` and `URL` fields, absent on every other type.

    - `options: optional array of object { id, label, color, description }`

      The full option list of a `SINGLE_SELECT` or `MULTI_SELECT` field, matched to the options the field has by `id`. An `id` the field does not have creates an option with that `id`, which must be `opt_` followed by lowercase letters and digits separated by single hyphens or underscores. A new option cannot take the label of an existing one unless the same request relabels that one. A `description` sent as null is cleared; a property left out is kept. Options left out are removed. `SINGLE_SELECT` options are displayed in the order sent.

      - `id: string`

        Unique identifier of the select option.

      - `label: string`

        Human-readable display name of the option.

      - `color: optional "RED" or "ORANGE" or "YELLOW" or 7 more`

        Color the option is displayed in, `GRAY` when none was chosen. Absent on selects whose options take no color.

        - `"RED"`

        - `"ORANGE"`

        - `"YELLOW"`

        - `"LIME"`

        - `"GREEN"`

        - `"BLUE"`

        - `"INDIGO"`

        - `"PURPLE"`

        - `"COPPER"`

        - `"GRAY"`

      - `description: optional string`

        Description of the option, or null.

    - `parentFieldKey: optional string`

      For a dependent select, the field key whose selected option determines which of this field's options apply. Absent for ordinary selects.

  - `valueType: optional "ADDRESS" or "CHECKBOX" or "CURRENCY" or 13 more`

    Data type of the field.

    - `"ADDRESS"`

    - `"CHECKBOX"`

    - `"CURRENCY"`

    - `"DATE"`

    - `"DATETIME"`

    - `"EMAIL"`

    - `"FULL_NAME"`

    - `"MARKDOWN"`

    - `"MULTI_SELECT"`

    - `"NUMBER"`

    - `"SINGLE_SELECT"`

    - `"SOCIAL_HANDLE"`

    - `"TELEPHONE"`

    - `"TEXT"`

    - `"URL"`

    - `"HTML"`

- `relationshipDefinitions: optional map[object { archived, cardinality, description, 4 more } ]`

  Relationship definitions to create or change, keyed by relationship key. Creating one needs `label`, `cardinality`, `objectType` and `inverse.cardinality`.

  - `archived: optional boolean`

    Whether the relationship definition is archived.

  - `cardinality: optional "HAS_ONE" or "HAS_MANY"`

    Whether this is a `has_one` or `has_many` relationship.

    - `"HAS_ONE"`

    - `"HAS_MANY"`

  - `description: optional string`

    Description of the relationship, or null.

  - `groupKey: optional string`

    Key of the relationship group to create this relationship in: one that exists, or one created by the same request. Fixed once the relationship exists.

  - `inverse: optional object { cardinality, label }`

    - `cardinality: optional "HAS_ONE" or "HAS_MANY"`

      Whether the related object type reads this relationship as `HAS_ONE` or `HAS_MANY`. Required to create a relationship.

      - `"HAS_ONE"`

      - `"HAS_MANY"`

    - `label: optional string`

      Display name of the relationship as it reads from the related object type. Defaults to `label`.

  - `label: optional string`

    Human-readable display name of the relationship, as it reads from this object type.

  - `objectType: optional string`

    The type of the related object (e.g. `account`, `contact`).

- `relationshipGroupDefinitions: optional map[object { archived, inverse, label, objectType } ]`

  Relationship group definitions to create or change, keyed by group key. Creating one needs `label` and `objectType`. Groups are written before relationships, so a relationship in the same request can name a new group.

  - `archived: optional boolean`

    Whether the relationship group is archived.

  - `inverse: optional object { label }`

    - `label: optional string`

      Display name of the group as it reads from the related object type. Defaults to `label`.

  - `label: optional string`

    Human-readable display name of the group, as it reads from this object type.

  - `objectType: optional string`

    The type of the related object every relationship in the group points to.

- `validationRules: optional map[object { name, require, when } ]`

  Validation rules to create, replace or delete, keyed by rule key. A key that names no rule creates one. A rule sent replaces the stored one whole; null deletes it. Rules not sent are kept. Required fields are set with `required` on the field instead. All rule and `required` changes in a request are saved together, after the field and relationship writes, so a rule can use a field the same request creates.

  - `name: string`

    Name of the rule, shown when a write breaks it.

  - `require: array of object { expression, id }`

    What a record the rule applies to must meet. A requirement sent without an `id` is given one.

    - `expression: string`

      Formula a record the rule applies to must make true, with fields and relationships referenced by key.

    - `id: optional string`

      Identifier of the requirement.

  - `when: string`

    Formula deciding whether the rule applies to a record, with fields and relationships referenced by key. It can't be `true`; to always require a field, set `required` on the field.

### Returns

- `OpportunityUpdateDefinitionsResponse object { fieldDefinitions, objectType, relationshipDefinitions, 2 more }`

  - `fieldDefinitions: map[object { archived, archivedAt, description, 10 more } ]`

    Map of field keys to their definitions, including both system and custom fields.

    - `archived: boolean`

      Whether the field definition is archived.

    - `archivedAt: string`

      When the field definition was archived, or null if active.

    - `description: string`

      Description of the field, or null.

    - `label: string`

      Human-readable display name of the field.

    - `typeConfiguration: object { currency, decimalPlaces, handleService, 4 more }`

      Type-specific configuration (e.g. select options, currency code). A key the field type does not support is absent; a supported key with nothing set is null.

      - `currency: optional string`

        ISO 4217 3-letter currency code. Present on `CURRENCY` fields, absent on every other type.

      - `decimalPlaces: optional number`

        Number of decimal places values carry, or null when none is set. Present on `NUMBER` and `CURRENCY` fields, absent on every other type.

      - `handleService: optional "TWITTER" or "LINKEDIN" or "FACEBOOK" or "INSTAGRAM"`

        Social platform associated with this handle field, or null when none is set. Present on `SOCIAL_HANDLE` fields, absent on every other type.

        - `"TWITTER"`

        - `"LINKEDIN"`

        - `"FACEBOOK"`

        - `"INSTAGRAM"`

      - `multipleValues: optional boolean`

        Whether this field accepts multiple values. Present on `EMAIL`, `TELEPHONE` and `URL` fields, absent on every other type.

      - `options: optional array of object { id, label, category, 7 more }`

        Available options. Always present on `SINGLE_SELECT` and `MULTI_SELECT` fields, as an empty list when there are none. Absent on every other type.

        - `id: string`

          Unique identifier of the select option.

        - `label: string`

          Human-readable display name of the option.

        - `category: optional "ACTIVE" or "COMPLETED"`

          Lifecycle group of the option, in-progress (`ACTIVE`) or done (`COMPLETED`), `ACTIVE` when none was set. Absent on selects whose options are not grouped.

          - `"ACTIVE"`

          - `"COMPLETED"`

        - `color: optional "RED" or "ORANGE" or "YELLOW" or 7 more`

          Color the option is displayed in, `GRAY` when none was chosen. Absent on selects whose options take no color.

          - `"RED"`

          - `"ORANGE"`

          - `"YELLOW"`

          - `"LIME"`

          - `"GREEN"`

          - `"BLUE"`

          - `"INDIGO"`

          - `"PURPLE"`

          - `"COPPER"`

          - `"GRAY"`

        - `description: optional string`

          Description of the option, or null.

        - `forecastEnabled: optional boolean`

          Whether the pipeline's stages carry a `forecastPercentage`. Present only on $pipeline.

        - `forecastPercentage: optional number`

          Forecast weighting of the option from 0 to 100, or null when none is set. Absent on selects whose options take no forecast.

        - `icon: optional "BACKLOG" or "QUALIFICATION" or "DISCOVERY" or 4 more`

          Icon the option is displayed with, `BACKLOG` when none was chosen. Present only on $stage.

          - `"BACKLOG"`

          - `"QUALIFICATION"`

          - `"DISCOVERY"`

          - `"ACTIVE"`

          - `"NEGOTIATION"`

          - `"CLOSED_WON"`

          - `"CLOSED_LOST"`

        - `parentId: optional string`

          For a dependent select, the ID of the option in the parent field named by `typeConfiguration.parentFieldKey` that owns this option. Absent for ordinary selects.

        - `slug: optional string`

          Key of the pipeline, unique on the object type. Pipelines provisioned by Lightfield use a `$` prefix (e.g. `$default-pipeline`). Present only on $pipeline.

      - `parentFieldKey: optional string`

        For a dependent select, the field key whose selected option determines which of this field's options apply. Absent for ordinary selects.

      - `unique: optional boolean`

        Whether values for this field must be unique, or null when not set. Present on `EMAIL`, `TELEPHONE`, `URL` and `SOCIAL_HANDLE` fields, absent on every other type.

    - `valueType: "ADDRESS" or "CHECKBOX" or "CURRENCY" or 13 more`

      Data type of the field.

      - `"ADDRESS"`

      - `"CHECKBOX"`

      - `"CURRENCY"`

      - `"DATE"`

      - `"DATETIME"`

      - `"EMAIL"`

      - `"FULL_NAME"`

      - `"MARKDOWN"`

      - `"MULTI_SELECT"`

      - `"NUMBER"`

      - `"SINGLE_SELECT"`

      - `"SOCIAL_HANDLE"`

      - `"TELEPHONE"`

      - `"TEXT"`

      - `"URL"`

      - `"HTML"`

    - `id: optional string`

      Unique identifier of the field definition.

    - `aiFillable: optional "ON" or "OFF" or "SUGGEST"`

      Whether AI fills this field automatically (`ON`), only suggests values (`SUGGEST`), or leaves it alone (`OFF`). Absent on built-in fields that have no `id`.

      - `"ON"`

      - `"OFF"`

      - `"SUGGEST"`

    - `aiFillablePrompt: optional string`

      Instructions AI follows when filling this field, or null when none are set. Absent on built-in fields that have no `id`.

    - `formula: optional string`

      Formula a calculated field evaluates, with fields and relationships referenced by key. Null for fields that are not calculated. Absent on built-in fields that have no `id`.

    - `readOnly: optional boolean`

      `true` for fields that are not writable via the API (e.g. AI-generated summaries, calculated fields). `false` or absent for writable fields.

    - `required: optional boolean`

      Whether a record must have a value for this field to be created or saved. Absent when validation rules are not available, and on calculated and built-in fields that have no `id`.

    - `valueSource: optional "MANUAL" or "COMPUTED"`

      Whether values are entered (`MANUAL`) or calculated from a formula (`COMPUTED`). Absent on built-in fields that have no `id`.

      - `"MANUAL"`

      - `"COMPUTED"`

  - `objectType: string`

    The object type these definitions belong to (e.g. `account`).

  - `relationshipDefinitions: map[object { archived, archivedAt, cardinality, 7 more } ]`

    Map of relationship keys to their definitions. Self-referential relationships include optional directional metadata on the bare definition.

    - `archived: boolean`

      Whether the relationship definition is archived.

    - `archivedAt: string`

      When the relationship definition was archived, or null if active.

    - `cardinality: "HAS_ONE" or "HAS_MANY"`

      Whether this is a `has_one` or `has_many` relationship.

      - `"HAS_ONE"`

      - `"HAS_MANY"`

    - `description: string`

      Description of the relationship, or null.

    - `label: string`

      Human-readable display name of the relationship, as it reads from this object type.

    - `objectType: string`

      The type of the related object (e.g. `account`, `contact`).

    - `id: optional string`

      Unique identifier of the relationship definition.

    - `directions: optional object { asDestination, asSource }`

      Directional metadata for a self-referential relationship. List filters use the relationship key with `:asSource` or `:asDestination`; writes continue to use the bare key.

      - `asDestination: object { cardinality, label }`

        The current record is the destination (incoming) endpoint.

        - `cardinality: "HAS_ONE" or "HAS_MANY"`

          Whether this endpoint direction is `HAS_ONE` or `HAS_MANY`.

          - `"HAS_ONE"`

          - `"HAS_MANY"`

        - `label: string`

          Human-readable display name for this endpoint direction.

      - `asSource: object { cardinality, label }`

        The current record is the source (outgoing) endpoint.

        - `cardinality: "HAS_ONE" or "HAS_MANY"`

          Whether this endpoint direction is `HAS_ONE` or `HAS_MANY`.

          - `"HAS_ONE"`

          - `"HAS_MANY"`

        - `label: string`

          Human-readable display name for this endpoint direction.

    - `groupKey: optional string`

      Key of the relationship group this relationship belongs to, as listed under `relationshipGroupDefinitions`. Absent when the relationship is not in a group.

    - `inverse: optional object { cardinality, label }`

      How the same relationship reads from the related object type.

      - `cardinality: "HAS_ONE" or "HAS_MANY"`

        Whether this endpoint direction is `HAS_ONE` or `HAS_MANY`.

        - `"HAS_ONE"`

        - `"HAS_MANY"`

      - `label: string`

        Human-readable display name for this endpoint direction.

  - `relationshipGroupDefinitions: map[object { id, archived, archivedAt, 3 more } ]`

    Map of relationship group keys to their definitions. A group collects relationships between the same two object types, such as the roles a contact can hold on an opportunity. Relationships name their group with `groupKey`.

    - `id: string`

      Unique identifier of the relationship group.

    - `archived: boolean`

      Whether the relationship group is archived.

    - `archivedAt: string`

      When the relationship group was archived, or null if active.

    - `inverse: object { label }`

      How the same group reads from the related object type.

      - `label: string`

        Human-readable display name of the group, as it reads from the related object type.

    - `label: string`

      Human-readable display name of the group, as it reads from this object type.

    - `objectType: string`

      The type of the related object every relationship in the group points to.

  - `validationRules: optional map[object { name, require, when } ]`

    Map of rule keys to the validation rules records of this object type must meet. Required fields are listed as `required` on the field instead. Absent when validation rules are not available for the object type.

    - `name: string`

      Name of the rule, shown when a write breaks it.

    - `require: array of object { id, expression }`

      What a record the rule applies to must meet.

      - `id: string`

        Identifier of the requirement.

      - `expression: string`

        Formula a record the rule applies to must make true, with fields and relationships referenced by key.

    - `when: string`

      Formula deciding whether the rule applies to a record, with fields and relationships referenced by key. It can't be `true`; to always require a field, set `required` on the field.

### Example

```http
curl https://api.lightfield.app/v1/opportunities/definitions \
    -H 'Content-Type: application/json' \
    -H 'Lightfield-Version: 2026-03-01' \
    -H "Authorization: Bearer $API_KEY" \
    -d '{}'
```

#### Response

```json
{
  "fieldDefinitions": {
    "foo": {
      "archived": true,
      "archivedAt": "2019-12-27T18:11:19.117Z",
      "description": "description",
      "label": "label",
      "typeConfiguration": {
        "currency": "currency",
        "decimalPlaces": -9007199254740991,
        "handleService": "TWITTER",
        "multipleValues": true,
        "options": [
          {
            "id": "id",
            "label": "label",
            "category": "ACTIVE",
            "color": "RED",
            "description": "description",
            "forecastEnabled": true,
            "forecastPercentage": 0,
            "icon": "BACKLOG",
            "parentId": "parentId",
            "slug": "slug"
          }
        ],
        "parentFieldKey": "parentFieldKey",
        "unique": true
      },
      "valueType": "ADDRESS",
      "id": "id",
      "aiFillable": "ON",
      "aiFillablePrompt": "aiFillablePrompt",
      "formula": "formula",
      "readOnly": true,
      "required": true,
      "valueSource": "MANUAL"
    }
  },
  "objectType": "objectType",
  "relationshipDefinitions": {
    "foo": {
      "archived": true,
      "archivedAt": "2019-12-27T18:11:19.117Z",
      "cardinality": "HAS_ONE",
      "description": "description",
      "label": "label",
      "objectType": "objectType",
      "id": "id",
      "directions": {
        "asDestination": {
          "cardinality": "HAS_ONE",
          "label": "label"
        },
        "asSource": {
          "cardinality": "HAS_ONE",
          "label": "label"
        }
      },
      "groupKey": "groupKey",
      "inverse": {
        "cardinality": "HAS_ONE",
        "label": "label"
      }
    }
  },
  "relationshipGroupDefinitions": {
    "foo": {
      "id": "id",
      "archived": true,
      "archivedAt": "2019-12-27T18:11:19.117Z",
      "inverse": {
        "label": "label"
      },
      "label": "label",
      "objectType": "objectType"
    }
  },
  "validationRules": {
    "foo": {
      "name": "name",
      "require": [
        {
          "id": "id",
          "expression": "expression"
        }
      ],
      "when": "when"
    }
  }
}
```
