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

# RelationDefinition

> Links the cards of two card definitions, a source and a target: a source card is related to the target cards whose card property value matches its own. Segments (through `relations` criteria) and endpoints (through relation content) follow relation definitions.



**Kind**: `object`

## Fields

**`createdAt`**: `DateTime!`

When the relation definition was created (UTC).

---

**`createdByUser`**: `UUID!`

Id of the user who created the relation definition.

---

**`description`**: `String`

Free-text note about the relation definition.

---

**`displayCategory`**: `RelationDisplayCategory!`

Display hint for clients such as Studio. See `RelationDisplayCategory`.

---

**`endpoints`**: `EndpointsConnection`

Endpoints whose live or pending content follows the relation definition.

**Arguments:**

- `after`: `String` — Returns the elements in the list that come after the specified cursor.
- `first`: `Int` — Returns the first _n_ elements from the list.

---

**`id`**: `ID!`

Global id of the relation definition: base64 of `RelationDefinition:<raw id>`. `relationDefinitionById` and the update, delete and restore mutations take it. The raw id (e.g. `productAccessories`) is what `relationDefinitions(where: { id })`, `RelationsCriteriaInput.relationDefinitionId` and endpoint content selections use.

---

**`inUse`**: `Boolean!`

True if an endpoint or a segment uses the relation definition. While it's true, `deleteRelationDefinition` fails.

---

**`isDeleted`**: `Boolean!`

True if the relation definition is archived. `relationDefinitions` returns archived ones too and can't filter on this field, so check it in the results. `restoreRelationDefinition` restores it.

---

**`lastModified`**: `DateTime!`

When the relation definition last changed (UTC).

---

**`lastModifiedByUser`**: `UUID!`

Id of the user who last changed the relation definition.

---

**`name`**: `String!`

Name of the relation definition.

---

**`relationDefinitionStatus`**: `RelationDefinitionStatus!`

State of the relation definition. See `RelationDefinitionStatus`.

---

**`segments`**: `SegmentsConnection`

Segments whose criteria include a `relations` criterion for the relation definition.

**Arguments:**

- `after`: `String` — Returns the elements in the list that come after the specified cursor.
- `before`: `String` — Returns the elements in the list that come before the specified cursor.
- `first`: `Int` — Returns the first _n_ elements from the list.
- `last`: `Int` — Returns the last _n_ elements from the list.

---

**`sourceCardDefinition`**: `CardDefinition!`

Source card definition.

---

**`sourceCardDefinitionId`**: `ID!`

Global id of the source card definition (`CardDefinition.id`).

---

**`sourceCriteria`**: `JSON`

Criteria on the source side, as a JSON list of objects, each with an `operator`. Exactly one `dynamic` item, in `sourceCriteria` or `targetCriteria`, links the cards: `{"operator":"dynamic","sourcePropertyId":"sku","targetPropertyId":"parentSku"}` relates a source card to the target cards whose `parentSku` matches its `sku`. Other items use the search criteria shapes (e.g. `equals`) with source card property ids, and filter the source cards when the relation is followed from a target card.

---

**`sourceCriteriaPropertyIds`**: `[String!]!`

Card property ids of the source card definition that the criteria use: the `dynamic` item's `sourcePropertyId` and the property ids of the filters in `sourceCriteria`.

---

**`sourceRelationDisplayName`**: `String`

Label for the relation on the source side (e.g. `Accessories`). Null when not set.

---

**`tags`**: `[String!]!`

Labels for grouping and filtering relation definitions.

---

**`targetCardDefinition`**: `CardDefinition!`

Target card definition.

---

**`targetCardDefinitionId`**: `ID!`

Global id of the target card definition (`CardDefinition.id`).

---

**`targetCriteria`**: `JSON`

Criteria on the target side, same shape as `sourceCriteria`. Items other than the `dynamic` one filter the target cards a source card is related to, by target card property id. Example: `[{"operator":"equals","propertyId":"status","values":["Active"],"invert":false}]` keeps only target cards whose `status` is `Active`.

---

**`targetCriteriaPropertyIds`**: `[String!]!`

Card property ids of the target card definition that the criteria use: the `dynamic` item's `targetPropertyId` and the property ids of the filters in `targetCriteria`.

---

**`targetRelationDisplayName`**: `String`

Label for the relation on the target side (e.g. `Accessory of`). Null when not set.

---

**`targetRelationOrderByProperty`**: `String`

> Deprecated: Target relation order by property should be set via TargetRelationSortingConfiguration using SortingType = BasedOnTargetProperty

---

**`targetRelationSortingConfiguration`**: `RelationDefinitionSortingConfiguration`

How the target cards related to a source card are ordered. Null = no order set.

---

**`tenantId`**: `UUID!`

Id of the tenant that owns the item.



This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.