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

# createSegment

> Creates a segment in a segment definition and starts matching cards in the background. Returns the segment; follow `status` until `ACTIVE`, or `SCHEDULED` when `startTime` is later. `ConflictError`: the id is taken or the segment definition is archived; `ValidationError`: invalid criteria, schedule, tags or image.



**mutation** `createSegment(input: CreateSegmentInput!): CreateSegmentPayload!`

## Arguments

**`input`**: `CreateSegmentInput!` (required)

## Returns

`CreateSegmentPayload!`

**`errors`**: `[CreateSegmentError!]`

---

**`segment`**: `Segment`

## Examples

```graphql Mutation
mutation CreateSegment($input: CreateSegmentInput!) {
  createSegment(input: $input) {
    errors {
      __typename
      ... on GraphQlError {
        code
        details {
          __typename
        }
        message
      }
    }
    segment {
      cardDefinition {
        activationStatus {
          __typename
        }
        activePropertySet {
          __typename
        }
        allowsEnrichment
        cardsCount
        createdAt
        createdByUser
      }
      cardDefinitionId
      colorHex
      createdAt
      createdByUser
      description
    }
  }
}
```

```json Variables
{
  "input": {
    "language": "string",
    "name": "string",
    "searchCriteria": [
      "value"
    ],
    "segmentId": "id",
    "tags": [
      "string"
    ],
    "type": "QUERY"
  }
}
```

```json Response
{
  "data": {
    "createSegment": {
      "errors": [
        {
          "__typename": "GraphQlError",
          "code": "string",
          "details": [
            {
              "__typename": "KeyValuePairOfStringAndString"
            }
          ],
          "message": "string"
        }
      ],
      "segment": {
        "cardDefinition": {
          "activationStatus": {
            "__typename": "WorkflowStatus"
          },
          "activePropertySet": {
            "__typename": "PropertySet"
          },
          "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.