# Segments

**Summary:** Endpoints for Segments

- Role: [Developers](https://www.subrite.no/developers)
- Source: https://www.subrite.no/developers/segments
- Updated: 2026-10-13
- Markdown index: https://www.subrite.no/developers/llms.txt

<a id="get-api-v1-segments"></a>
## Get segments

`GET /api/v1/segments`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `page` | query | `number` | Default: `1` · `minimum`: `1` |
| `take` | query | `number` | Default: `10` · `minimum`: `1`, `maximum`: `50` |
| `orderBy` | query | `string` | Allowed values: `"createdAt"`, `"id"`, `"updatedAt"` · Default: `"createdAt"` |
| `orderDirection` | query | `string` | Allowed values: `"asc"`, `"desc"` · Default: `"desc"` |

### Responses

#### 200

Content type: `application/json` · `SegmentResponsePaginated`

| Name | Type | Description |
| --- | --- | --- |
| `items` (Required) | `array of SegmentResponse` |   |
| `items[].id` (Required when parent is present) | `number` |   |
| `items[].name` (Required when parent is present) | `string` |   |
| `items[].description` (Required when parent is present) | `string` |   |
| `items[].query` (Required when parent is present) | `JsonQuery` |   |
| `items[].query.rules` (Required when parent is present) | `array of object` |   |
| `items[].query.combinator` (Required when parent is present) | `string` | Allowed values: `"AND"`, `"OR"` |
| `items[].query.id` | `string` |   |
| `items[].type` (Required when parent is present) | `string` |   |
| `items[].tenantId` (Required when parent is present) | `number` |   |
| `items[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].status` (Required when parent is present) | `string` | Allowed values: `"draft"`, `"published"` |
| `items[].adminUserName` (Required when parent is present) | `string` |   |
| `items[].adminUserEmail` (Required when parent is present) | `string` |   |
| `items[].adminUserId` (Required when parent is present) | `number` |   |
| `meta` (Required) | `PageMeta` |   |
| `meta.page` (Required) | `number` |   |
| `meta.take` (Required) | `number` |   |
| `meta.count` (Required) | `number` |   |
| `meta.pageCount` (Required) | `number` |   |
| `meta.hasPreviousPage` (Required) | `boolean` |   |
| `meta.hasNextPage` (Required) | `boolean` |   |

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

| Name | Type | Description |
| --- | --- | --- |
| `messageCode` (Required) | `string` |   |
| `message` | `string` |   |
| `errors` (Required) | `array of FieldError` |   |
| `errors[].field` (Required when parent is present) | `string` |   |
| `errors[].fieldValue` (Required when parent is present) | `string` |   |
| `errors[].identifier` (Required when parent is present) | `string` |   |
| `errors[].identifierValue` (Required when parent is present) | `string` |   |
| `errors[].messageCode` (Required when parent is present) | `string` |   |
| `errors[].message` | `string` |   |
| `errors[].errorType` (Required when parent is present) | `string` |   |

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl https://api.subrite.no/api/v1/segments \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
{
  "items": [
    {}
  ],
  "meta": {
    "page": 0,
    "take": 0,
    "count": 0,
    "pageCount": 0,
    "hasPreviousPage": true,
    "hasNextPage": true
  }
}
```

<a id="post-api-v1-segments"></a>
## Create a new segment

`POST /api/v1/segments`

**Authentication:** Bearer token (JWT)

### Request body

Content type: `application/json` · Required · `CreateSegmentDto`

| Name | Type | Description |
| --- | --- | --- |
| `name` (Required) | `string` |   |
| `description` | `string` |   |
| `status` (Required) | `string` | Allowed values: `"draft"`, `"published"` |
| `query` | `JsonQuery` |   |
| `query.rules` (Required when parent is present) | `array of object` |   |
| `query.combinator` (Required when parent is present) | `string` | Allowed values: `"AND"`, `"OR"` |
| `query.id` | `string` |   |
| `type` (Required) | `string` | Allowed values: `"static"`, `"dynamic"` |

**Example request body**

`application/json`

```json
{
  "name": "string",
  "description": "string",
  "status": "draft",
  "query": {
    "rules": [
      {}
    ],
    "combinator": "AND",
    "id": "string"
  },
  "type": "static"
}
```

### Responses

#### 201

Content type: `application/json` · `SegmentResponse`

| Name | Type | Description |
| --- | --- | --- |
| `id` (Required) | `number` |   |
| `name` (Required) | `string` |   |
| `description` (Required) | `string` |   |
| `query` (Required) | `JsonQuery` |   |
| `query.rules` (Required) | `array of object` |   |
| `query.combinator` (Required) | `string` | Allowed values: `"AND"`, `"OR"` |
| `query.id` | `string` |   |
| `type` (Required) | `string` |   |
| `tenantId` (Required) | `number` |   |
| `createdAt` (Required) | `string (date-time)` |   |
| `updatedAt` (Required) | `string (date-time)` |   |
| `status` (Required) | `string` | Allowed values: `"draft"`, `"published"` |
| `adminUserName` (Required) | `string` |   |
| `adminUserEmail` (Required) | `string` |   |
| `adminUserId` (Required) | `number` |   |

#### 400

Content type: `application/json` · `ErrorResponse`

shouldNotBeEmpty

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl https://api.subrite.no/api/v1/segments \
  --request POST \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "string",
  "description": "string",
  "status": "draft",
  "query": {
    "rules": [
      {}
    ],
    "combinator": "AND",
    "id": "string"
  },
  "type": "static"
}'
```

### Example response

201 · `application/json`

```json
{
  "id": 0,
  "name": "string",
  "description": "string",
  "query": {
    "rules": [
      {}
    ],
    "combinator": "AND",
    "id": "string"
  },
  "type": "string",
  "tenantId": 0,
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "status": "draft",
  "adminUserName": "<adminUserName>",
  "adminUserEmail": "string",
  "adminUserId": 0
}
```

<a id="get-api-v1-segments-id"></a>
## Get a segment by id

`GET /api/v1/segments/{id}`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (Required) | path | `number` |   |

### Responses

#### 200

Content type: `application/json` · `SegmentResponse`

Same fields as [Create a new segment (201)](https://www.subrite.no/developers/segments?md=true#post-api-v1-segments).

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl 'https://api.subrite.no/api/v1/segments/{id}' \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
{
  "id": 0,
  "name": "string",
  "description": "string",
  "query": {
    "rules": [
      {}
    ],
    "combinator": "AND",
    "id": "string"
  },
  "type": "string",
  "tenantId": 0,
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "status": "draft",
  "adminUserName": "<adminUserName>",
  "adminUserEmail": "string",
  "adminUserId": 0
}
```

<a id="delete-api-v1-segments-id"></a>
## Delete a segment

`DELETE /api/v1/segments/{id}`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (Required) | path | `number` |   |

### Responses

#### 200

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl 'https://api.subrite.no/api/v1/segments/{id}' \
  --request DELETE \
  --header 'Authorization: Bearer <token>'
```

<a id="patch-api-v1-segments-id"></a>
## Update a segment

`PATCH /api/v1/segments/{id}`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (Required) | path | `number` |   |

### Request body

Content type: `application/json` · Required · `CreateSegmentDto`

Same fields as [Create a new segment (Request body)](https://www.subrite.no/developers/segments?md=true#post-api-v1-segments).

**Example request body**

`application/json`

```json
{
  "name": "string",
  "description": "string",
  "status": "draft",
  "query": {
    "rules": [
      {}
    ],
    "combinator": "AND",
    "id": "string"
  },
  "type": "static"
}
```

### Responses

#### 200

Content type: `application/json` · `SegmentResponse`

Same fields as [Create a new segment (201)](https://www.subrite.no/developers/segments?md=true#post-api-v1-segments).

#### 400

Content type: `application/json` · `ErrorResponse`

shouldNotBeEmpty

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl 'https://api.subrite.no/api/v1/segments/{id}' \
  --request PATCH \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "string",
  "description": "string",
  "status": "draft",
  "query": {
    "rules": [
      {}
    ],
    "combinator": "AND",
    "id": "string"
  },
  "type": "static"
}'
```

### Example response

200 · `application/json`

```json
{
  "id": 0,
  "name": "string",
  "description": "string",
  "query": {
    "rules": [
      {}
    ],
    "combinator": "AND",
    "id": "string"
  },
  "type": "string",
  "tenantId": 0,
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "status": "draft",
  "adminUserName": "<adminUserName>",
  "adminUserEmail": "string",
  "adminUserId": 0
}
```

<a id="get-api-v1-segments-published"></a>
## Get all published segments

`GET /api/v1/segments/published`

**Authentication:** Bearer token (JWT)

### Responses

#### 200

Content type: `application/json` · `array of Segment`

| Name | Type | Description |
| --- | --- | --- |
| `[].name` (Required when parent is present) | `string` |   |
| `[].description` (Required when parent is present) | `string` |   |
| `[].query` (Required when parent is present) | `JsonQuery` |   |
| `[].query.rules` (Required when parent is present) | `array of object` |   |
| `[].query.combinator` (Required when parent is present) | `string` | Allowed values: `"AND"`, `"OR"` |
| `[].query.id` | `string` |   |
| `[].type` (Required when parent is present) | `string` | Allowed values: `"static"`, `"dynamic"` |
| `[].status` (Required when parent is present) | `string` | Allowed values: `"draft"`, `"published"` |
| `[].adminUserId` (Required when parent is present) | `number` |   |
| `[].adminUser` (Required when parent is present) | `User` |   |
| `[].adminUser.userType` (Required when parent is present) | `string` | Allowed values: `"system_admin"`, `"tenant_admin"`, `"member"`, `"not_set"` |
| `[].adminUser.tenantId` (Required when parent is present) | `number` |   |
| `[].adminUser.email` (Required when parent is present) | `string` | Can be null |
| `[].adminUser.fullName` (Required when parent is present) | `string` |   |
| `[].adminUser.phone` (Required when parent is present) | `string` |   |
| `[].adminUser.emailVerified` (Required when parent is present) | `string` | Can be null |
| `[].adminUser.phoneVerified` (Required when parent is present) | `boolean` |   |
| `[].adminUser.isOwner` (Required when parent is present) | `boolean` |   |
| `[].adminUser.isTestUser` (Required when parent is present) | `boolean` |   |
| `[].adminUser.image` (Required when parent is present) | `string` |   |
| `[].adminUser.createdInCheckoutUuid` (Required when parent is present) | `string` |   |
| `[].adminUser.userRoles` | `array of UserRole` |   |
| `[].adminUser.userRoles[].userId` (Required when parent is present) | `number` |   |
| `[].adminUser.userRoles[].roleId` (Required when parent is present) | `number` |   |
| `[].adminUser.userRoles[].user` (Required when parent is present) | `User` | Recursive schema; nested fields are not repeated. |
| `[].adminUser.userRoles[].role` (Required when parent is present) | `Role` | Nested fields omitted: depth limit. |
| `[].adminUser.userRoles[].id` (Required when parent is present) | `number` |   |
| `[].adminUser.userRoles[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `[].adminUser.userRoles[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].adminUser.userRoles[].deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].adminUser.userRoles[].metaData` (Required when parent is present) | `object` |   |
| `[].adminUser.notes` (Required when parent is present) | `array of Note` |   |
| `[].adminUser.notes[].note` (Required when parent is present) | `string` |   |
| `[].adminUser.notes[].memberId` (Required when parent is present) | `string` |   |
| `[].adminUser.notes[].adminUserId` (Required when parent is present) | `number` |   |
| `[].adminUser.notes[].member` (Required when parent is present) | `Member` | Nested fields omitted: depth limit. |
| `[].adminUser.notes[].adminUser` (Required when parent is present) | `User` | Recursive schema; nested fields are not repeated. |
| `[].adminUser.notes[].tenantId` (Required when parent is present) | `number` |   |
| `[].adminUser.notes[].tenant` (Required when parent is present) | `Tenant` | Nested fields omitted: depth limit. |
| `[].adminUser.notes[].id` (Required when parent is present) | `number` |   |
| `[].adminUser.notes[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `[].adminUser.notes[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].adminUser.notes[].deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].adminUser.notes[].metaData` (Required when parent is present) | `object` |   |
| `[].adminUser.exportHistory` (Required when parent is present) | `array of ExportHistory` | Nested fields omitted: field limit. |
| `[].adminUser.userSettings` | `UserSettings` | Nested fields omitted: field limit. |
| `[].adminUser.member` | `Member` | Nested fields omitted: field limit. |
| `[].adminUser.tenant` (Required when parent is present) | `Tenant` | Nested fields omitted: field limit. |
| `[].adminUser.userAccounts` (Required when parent is present) | `array of UserAccount` | Nested fields omitted: field limit. |
| `[].adminUser.userSessions` (Required when parent is present) | `array of UserSession` |   |
| `[].adminUser.userSessions[].id` (Required when parent is present) | `string` |   |
| `[].adminUser.userSessions[].expires` (Required when parent is present) | `string` |   |
| `[].adminUser.userSessions[].sessionToken` (Required when parent is present) | `string` |   |
| `[].adminUser.userSessions[].userId` (Required when parent is present) | `number` |   |
| `[].adminUser.userSessions[].user` (Required when parent is present) | `User` | Recursive schema; nested fields are not repeated. |
| `[].adminUser.id` (Required when parent is present) | `number` |   |
| `[].adminUser.createdAt` (Required when parent is present) | `string (date-time)` |   |
| `[].adminUser.updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].adminUser.deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].adminUser.metaData` (Required when parent is present) | `object` |   |
| `[].tenantId` (Required when parent is present) | `number` |   |
| `[].tenant` (Required when parent is present) | `Tenant` | Nested fields omitted: field limit. |
| `[].segmentMembers` (Required when parent is present) | `array of SegmentMember` |   |
| `[].segmentMembers[].memberId` (Required when parent is present) | `string` |   |
| `[].segmentMembers[].member` (Required when parent is present) | `Member` | Nested fields omitted: field limit. |
| `[].segmentMembers[].exceptionType` (Required when parent is present) | `string` | Allowed values: `"included"`, `"excluded"` |
| `[].segmentMembers[].segmentId` (Required when parent is present) | `number` |   |
| `[].segmentMembers[].segment` (Required when parent is present) | `Segment` | Recursive schema; nested fields are not repeated. |
| `[].segmentMembers[].tenantId` (Required when parent is present) | `number` |   |
| `[].segmentMembers[].tenant` (Required when parent is present) | `Tenant` | Nested fields omitted: field limit. |
| `[].segmentMembers[].id` (Required when parent is present) | `number` |   |
| `[].segmentMembers[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `[].segmentMembers[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].segmentMembers[].deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].segmentMembers[].metaData` (Required when parent is present) | `object` |   |
| `[].id` (Required when parent is present) | `number` |   |
| `[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `[].metaData` (Required when parent is present) | `object` |   |

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl https://api.subrite.no/api/v1/segments/published \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
[
  {
    "name": "string",
    "description": "string",
    "query": {
      "rules": []
    },
    "type": "static",
    "status": "draft",
    "adminUserId": 0,
    "adminUser": {
      "userRoles": [],
      "notes": [],
      "exportHistory": [],
      "userAccounts": [],
      "userSessions": [],
      "metaData": {}
    },
    "tenantId": 0,
    "tenant": {
      "additionalFeatures": [],
      "disabledFeatures": [],
      "taxRates": [],
      "products": [],
      "users": [],
      "members": [],
      "roles": [],
      "subscriptionPlans": [],
      "packages": [],
      "invoices": [],
      "orders": [],
      "paymentProviders": [],
      "newslettersProviderConfig": [],
      "paymentProviderConfigs": [],
      "oidcClients": [],
      "oauthProviders": [],
      "activityLogs": [],
      "m2m_api_clients": [],
      "customProperties": [],
      "consents": [],
      "communicationTemplates": [],
      "additionalHostnames": [],
      "exportHistory": [],
      "arReportHistory": [],
      "mypageCardsSettings": [],
      "webhooks": [],
      "customOrders": [],
      "customOrderSources": [],
      "brandKits": [],
      "communicationReceivers": [],
      "metaData": {}
    },
    "segmentMembers": [],
    "id": 0,
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z",
    "deletedAt": "2019-08-24T14:15:22Z",
    "metaData": {}
  }
]
```

<a id="get-api-v1-segments-published-export-options"></a>
## Get published segments with member counts for the list-export picker

`GET /api/v1/segments/published/export-options`

**Authentication:** Bearer token (JWT)

### Responses

#### 200

Content type: `application/json` · `array of PublishedSegmentExportOptionResponse`

| Name | Type | Description |
| --- | --- | --- |
| `[].id` (Required when parent is present) | `number` |   |
| `[].name` (Required when parent is present) | `string` |   |
| `[].memberCount` (Required when parent is present) | `number` | Number of members currently in this list. |

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl https://api.subrite.no/api/v1/segments/published/export-options \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
[
  {
    "id": 0,
    "name": "string",
    "memberCount": 0
  }
]
```

<a id="get-api-v1-segments-attributes"></a>
## Get segmentation entity and attributes

`GET /api/v1/segments/attributes`

**Authentication:** Bearer token (JWT)

### Responses

#### 200

Content type: `application/json` · `object`

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl https://api.subrite.no/api/v1/segments/attributes \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
{}
```

<a id="get-api-v1-segments-id-members"></a>
## Get members of a segment

`GET /api/v1/segments/{id}/members`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (Required) | path | `number` |   |
| `page` | query | `number` | Default: `1` · `minimum`: `1` |
| `take` | query | `number` | Default: `10` · `minimum`: `1`, `maximum`: `50` |
| `orderBy` | query | `string` | Allowed values: `"createdAt"`, `"id"`, `"updatedAt"` · Default: `"createdAt"` |
| `orderDirection` | query | `string` | Allowed values: `"asc"`, `"desc"` · Default: `"desc"` |

### Responses

#### 200

Content type: `application/json` · `SegmentMemberResponsePaginated`

| Name | Type | Description |
| --- | --- | --- |
| `items` (Required) | `array of SegmentMemberResponse` |   |
| `items[].id` (Required when parent is present) | `string` |   |
| `items[].fullName` (Required when parent is present) | `string` |   |
| `items[].email` (Required when parent is present) | `string` |   |
| `items[].phone` (Required when parent is present) | `string` |   |
| `items[].memberNumber` (Required when parent is present) | `number` |   |
| `items[].userId` (Required when parent is present) | `number` | Can be null |
| `meta` (Required) | `PageMeta` |   |
| `meta.page` (Required) | `number` |   |
| `meta.take` (Required) | `number` |   |
| `meta.count` (Required) | `number` |   |
| `meta.pageCount` (Required) | `number` |   |
| `meta.hasPreviousPage` (Required) | `boolean` |   |
| `meta.hasNextPage` (Required) | `boolean` |   |

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 404

Content type: `application/json` · `ErrorResponse`

segmentNotFound

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl 'https://api.subrite.no/api/v1/segments/{id}/members' \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
{
  "items": [
    {}
  ],
  "meta": {
    "page": 0,
    "take": 0,
    "count": 0,
    "pageCount": 0,
    "hasPreviousPage": true,
    "hasNextPage": true
  }
}
```

<a id="get-api-v1-segments-id-member-count"></a>
## Get member count of a segment

`GET /api/v1/segments/{id}/member-count`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` (Required) | path | `number` |   |

### Responses

#### 200

Content type: `application/json` · `number`

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 404

Content type: `application/json` · `ErrorResponse`

segmentNotFound

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl 'https://api.subrite.no/api/v1/segments/{id}/member-count' \
  --header 'Authorization: Bearer <token>'
```

### Example response

200 · `application/json`

```json
0
```

<a id="post-api-v1-segments-preview"></a>
## Preview segment result

`POST /api/v1/segments/preview`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `page` | query | `number` | Default: `1` · `minimum`: `1` |
| `take` | query | `number` | Default: `10` · `minimum`: `1`, `maximum`: `50` |
| `orderBy` | query | `string` | Allowed values: `"createdAt"`, `"id"`, `"updatedAt"` · Default: `"createdAt"` |
| `orderDirection` | query | `string` | Allowed values: `"asc"`, `"desc"` · Default: `"desc"` |

### Request body

Content type: `application/json` · Required · `JsonQuery`

| Name | Type | Description |
| --- | --- | --- |
| `rules` (Required) | `array of object` |   |
| `combinator` (Required) | `string` | Allowed values: `"AND"`, `"OR"` |
| `id` | `string` |   |

**Example request body**

`application/json`

```json
{
  "rules": [
    {}
  ],
  "combinator": "AND",
  "id": "string"
}
```

### Responses

#### 200

Content type: `application/json` · `MemberPaginated`

| Name | Type | Description |
| --- | --- | --- |
| `items` (Required) | `array of Member` |   |
| `items[].userId` (Required when parent is present) | `number` | Can be null |
| `items[].memberNumber` (Required when parent is present) | `number` | Can be null |
| `items[].tenantId` (Required when parent is present) | `number` |   |
| `items[].externalId` (Required when parent is present) | `string` | Can be null |
| `items[].fullName` (Required when parent is present) | `string` |   |
| `items[].nickName` (Required when parent is present) | `string` |   |
| `items[].avatar` (Required when parent is present) | `string` |   |
| `items[].email` (Required when parent is present) | `string` |   |
| `items[].birthDate` (Required when parent is present) | `string (date-time)` | Can be null |
| `items[].phone` (Required when parent is present) | `string` |   |
| `items[].isCompany` (Required when parent is present) | `boolean` |   |
| `items[].companyName` (Required when parent is present) | `string` | Can be null |
| `items[].organizationNo` (Required when parent is present) | `string` | Can be null |
| `items[].deleteAfterExpiration` (Required when parent is present) | `boolean` |   |
| `items[].customPropertyValues` (Required when parent is present) | `object` |   |
| `items[].productRecipients` (Required when parent is present) | `array of MemberPackageProductRecipient` |   |
| `items[].productRecipients[].memberPackageProductId` (Required when parent is present) | `number` |   |
| `items[].productRecipients[].memberId` (Required when parent is present) | `string` |   |
| `items[].productRecipients[].memberPackageProduct` (Required when parent is present) | `MemberPackageProduct` | Nested fields omitted: depth limit. |
| `items[].productRecipients[].member` (Required when parent is present) | `Member` | Recursive schema; nested fields are not repeated. |
| `items[].productRecipients[].id` (Required when parent is present) | `number` |   |
| `items[].productRecipients[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].productRecipients[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].productRecipients[].deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].productRecipients[].metaData` (Required when parent is present) | `object` |   |
| `items[].id` (Required when parent is present) | `string` |   |
| `items[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].updatedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].deletedAt` (Required when parent is present) | `string (date-time)` |   |
| `items[].metaData` (Required when parent is present) | `object` |   |
| `meta` (Required) | `PageMeta` |   |
| `meta.page` (Required) | `number` |   |
| `meta.take` (Required) | `number` |   |
| `meta.count` (Required) | `number` |   |
| `meta.pageCount` (Required) | `number` |   |
| `meta.hasPreviousPage` (Required) | `boolean` |   |
| `meta.hasNextPage` (Required) | `boolean` |   |

#### 201

#### 401

unauthorized

#### 403

Content type: `application/json` · `ErrorResponse`

forbiddenResource

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

**Example response**

`application/json`

```json
{
  "messageCode": "string",
  "message": "string",
  "errors": [
    {}
  ]
}
```

#### 500

Content type: `application/json` · `ErrorResponse`

internalServerError

Same fields as [Get segments (403)](https://www.subrite.no/developers/segments?md=true#get-api-v1-segments).

### Example request

```bash
curl https://api.subrite.no/api/v1/segments/preview \
  --request POST \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "rules": [
    {}
  ],
  "combinator": "AND",
  "id": "string"
}'
```

### Example response

200 · `application/json`

```json
{
  "items": [
    {
      "customPropertyValues": {},
      "productRecipients": [],
      "metaData": {}
    }
  ],
  "meta": {
    "page": 0,
    "take": 0,
    "count": 0,
    "pageCount": 0,
    "hasPreviousPage": true,
    "hasNextPage": true
  }
}
```
