> ## 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.

# segmentById

> Gets a segment by its global id, archived ones included. Fails with `NotFoundError` when no segment has it.



**query** `segmentById(id: ID!): Segment!`

## Arguments

**`id`**: `ID!` (required)

Global id of the segment (`Segment.id`).

## Returns

`Segment!`

**`cardDefinition`**: `CardDefinition!`

Card definition whose cards the segment picks.

---

**`cardDefinitionId`**: `ID!`

Global id of the card definition whose cards the segment picks (`CardDefinition.id`), taken from the segment definition.

---

**`colorHex`**: `String`

Color of the segment (e.g. `#ff8800`), copied from the segment definition when the segment was created.

---

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

When the segment was created (UTC).

---

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

Id of the user or application that created the segment.

---

**`description`**: `String`

Free-text note about the segment.

---

**`endpointConnections`**: `EndpointConnectionsConnection`

Where the segment is assigned: one item per endpoint and content path.

**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.
- `order`: `[EndpointSegmentSortInput!]`
- `where`: `EndpointConnectionFilterInput`

---

**`endpoints`**: `EndpointsConnection`

Endpoints the segment is assigned to.

**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.
- `where`: `SegmentEndpointFilterInput`

---

**`endTime`**: `DateTime`

When the segment is archived, on the hour (UTC). Null = never archived on a schedule.

---

**`entriesCount`**: `Long!`

Entries matching the segment's search criteria in its language, whatever its status. 0 for a segment without search criteria.

---

**`etag`**: `Etag`

Version tag for optimistic concurrency. Pass back the value you last read when you change the item.

---

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

Global id of the segment: base64 of `Segment:<segment id>:<segment definition id>`, both raw ids, because a segment id is unique only within its segment definition. `segmentById`, `segmentByIds` and the segment mutations take it. Criteria use the raw ids (`SegmentsCriteriaInput.include` and `segmentDefinitionId`).

---

**`image`**: `String`

Image key, lowercase letters a-z only. Null when not set.

---

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

True if the segment is archived, by `deleteSegment` or because its `endTime` passed. `segments` and `SegmentDefinition.segments` return archived segments too. `restoreSegment` restores it.

---

**`isUpdating`**: `Boolean`

True while `status` is `INITIALIZING`.

---

**`language`**: `String!`

Language code the criteria use for localized card properties (e.g. `en`).

---

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

When the segment last changed (UTC).

---

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

Id of the user or application that last changed the segment.

---

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

Name of the segment.

---

**`properties`**: `[KeyValuePairOfStringAndObject!]!`

Values of the segment definition's custom segment properties. Each item is `{key, value}`: `key` is a `SegmentPropertyDefinition.id`. Can't be set through this API.

---

**`queuedChanges`**: `QueuedChangesConnection`

Changes to the segment's endpoint assignments that are queued and not applied yet.

**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.
- `order`: `[QueuedEndpointSegmentChangeSortInput!]`
- `where`: `QueuedEndpointSegmentChangeFilterInput`

---

**`searchCriteria`**: `JSON`

Criteria that pick the segment's cards, as a JSON list of objects; a card must match every item. Each item has an `operator` and its keys, with card property ids of the segment's card definition: `equals` {propertyId, values, invert} matches any of the values; `equalsAll` {propertyId, values, invert} needs every value (list card properties); `range` {propertyId, from, to, invert} is inclusive; `hasValue` {propertyId, invert}; `wildcard` {propertyId, value, invert} takes `*` and `?`, case-sensitive; `ids` {include, exclude} takes card ids; `relations` {relationDefinitionId, invert} takes a raw relation definition id; `anyOf` {criteria} matches if any nested item matches. A `FIXED` segment holds exactly one `ids` item. Example: `[{"operator":"equals","propertyId":"brand","values":["Acme"],"invert":false},{"operator":"range","propertyId":"price","from":10,"to":50,"invert":false}]`.

---

**`searchCriteriaPropertyIds`**: `[String!]!`

Card property ids the criteria use, `anyOf` children included. `@existingRelations` stands for any `relations` criterion.

---

**`segmentDefinition`**: `SegmentDefinition!`

Segment definition the segment belongs to.

---

**`segmentDefinitionId`**: `ID!`

Global id of the segment definition the segment belongs to (`SegmentDefinition.id`).

---

**`startTime`**: `DateTime`

When the segment becomes active, on the hour (UTC). Null = active as soon as it's created.

---

**`status`**: `SegmentStatus!`

Lifecycle state of the segment. See `SegmentStatus`.

---

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

Labels for grouping and filtering segments. Alphanumeric, no duplicates.

---

**`type`**: `SegmentType!`

How the segment picks its cards. See `SegmentType`.

## Examples

```graphql Query
query SegmentById($id: ID!) {
  segmentById(id: $id) {
    cardDefinition {
      activationStatus {
        status
        steps {
          __typename
        }
      }
      activePropertySet {
        key
        properties {
          __typename
        }
        propertyIds
      }
      allowsEnrichment
      cardsCount
      createdAt
      createdByUser
    }
    cardDefinitionId
    colorHex
    createdAt
    createdByUser
    description
  }
}
```

```json Variables
{
  "id": "id"
}
```

```json Response
{
  "data": {
    "segmentById": {
      "cardDefinition": {
        "activationStatus": {
          "status": "RUNNING",
          "steps": [
            {
              "__typename": "KeyValuePairOfStringAndWorkflowStep"
            }
          ]
        },
        "activePropertySet": {
          "key": "string",
          "properties": [
            {
              "__typename": "CardPropertyDefinition"
            }
          ],
          "propertyIds": [
            "string"
          ]
        },
        "allowsEnrichment": true,
        "cardsCount": "value",
        "createdAt": "value",
        "createdByUser": "value"
      },
      "cardDefinitionId": "id",
      "colorHex": "string",
      "createdAt": "value",
      "createdByUser": "value",
      "description": "string"
    }
  }
}
```


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