# Widget

**Summary:** Endpoints for Widget

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

<a id="get-api-v1-widget"></a>
## Get all widgets

`GET /api/v1/widget`

**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` · `WidgetResponseDtoPaginated`

| Name | Type | Description |
| --- | --- | --- |
| `items` (Required) | `array of WidgetResponseDto` |   |
| `items[].id` (Required when parent is present) | `string` |   |
| `items[].name` (Required when parent is present) | `string` |   |
| `items[].slug` (Required when parent is present) | `string` |   |
| `items[].type` (Required when parent is present) | `string` | Allowed values: `"consent"` |
| `items[].displayType` (Required when parent is present) | `string` | Allowed values: `"popup"`, `"embed"` |
| `items[].status` (Required when parent is present) | `string` | Allowed values: `"draft"`, `"published"` |
| `items[].config` (Required when parent is present) | `WidgetConfig` |   |
| `items[].config.active` (Required when parent is present) | `boolean` |   |
| `items[].config.consent` (Required when parent is present) | `ConsentObjType` | Nested fields omitted: depth limit. |
| `items[].config.target` (Required when parent is present) | `TargetObjType` | Nested fields omitted: depth limit. |
| `items[].config.theme` (Required when parent is present) | `ThemeObjType` | Nested fields omitted: depth limit. |
| `items[].createdAt` (Required when parent is present) | `string (date-time)` |   |
| `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

### Example request

```bash
curl https://api.subrite.no/api/v1/widget \
  --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-widget"></a>
## Create a widget

`POST /api/v1/widget`

**Authentication:** Bearer token (JWT)

### Request body

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

| Name | Type | Description |
| --- | --- | --- |
| `name` (Required) | `string` | The name of the widget |
| `slug` (Required) | `string` | The slug of the widget |
| `type` (Required) | `string` | The type of the widget · Allowed values: `"consent"` · Default: `"consent"` |
| `displayType` (Required) | `string` | The display type of the widget · Allowed values: `"popup"`, `"embed"` · Default: `"popup"` |
| `config` (Required) | `WidgetConfig` | The config of the widget |
| `config.active` (Required) | `boolean` |   |
| `config.consent` (Required) | `ConsentObjType` |   |
| `config.consent.integrationId` (Required) | `string` |   |
| `config.target` (Required) | `TargetObjType` |   |
| `config.target.triggers` (Required) | `array of TriggerObjType` | Nested fields omitted: depth limit. |
| `config.target.frequency` (Required) | `FrequencyObjType` | Nested fields omitted: depth limit. |
| `config.target.websites` (Required) | `array of WebsiteObjType` | Nested fields omitted: depth limit. |
| `config.target.popUpPosition` (Required) | `PopUpPosition` | Allowed values: `"center"`, `"bottom-left"`, `"bottom-right"` |
| `config.theme` (Required) | `ThemeObjType` |   |
| `config.theme.termsAndConditionsText` (Required) | `object` |   |
| `config.theme.emailLabel` (Required) | `string` |   |
| `config.theme.emailPlaceholder` (Required) | `string` |   |
| `config.theme.submitText` (Required) | `string` |   |
| `config.theme.successMessageTitle` (Required) | `string` |   |
| `config.theme.successMessage` (Required) | `string` |   |
| `config.theme.errorMessage` (Required) | `string` |   |
| `config.theme.widgetHeaderText` (Required) | `string` |   |
| `config.theme.widgetDescriptionText` (Required) | `object` |   |
| `config.theme.primaryColor` (Required) | `string` |   |
| `config.theme.textColor` (Required) | `string` |   |
| `config.theme.backgroundColor` (Required) | `string` |   |
| `config.theme.showCloseButton` (Required) | `boolean` |   |
| `config.theme.typography` (Required) | `TypographyObjType` | Nested fields omitted: depth limit. |
| `config.theme.redirectCTAText` (Required) | `string` |   |
| `config.theme.redirectCTAUrl` (Required) | `string` |   |
| `status` (Required) | `string` | The status of the widget · Allowed values: `"draft"`, `"published"` · Default: `"draft"` |

### Responses

#### 201

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

| Name | Type | Description |
| --- | --- | --- |
| `id` (Required) | `string` |   |
| `name` (Required) | `string` |   |
| `slug` (Required) | `string` |   |
| `type` (Required) | `string` | Allowed values: `"consent"` |
| `displayType` (Required) | `string` | Allowed values: `"popup"`, `"embed"` |
| `status` (Required) | `string` | Allowed values: `"draft"`, `"published"` |
| `config` (Required) | `WidgetConfig` |   |
| `config.active` (Required) | `boolean` |   |
| `config.consent` (Required) | `ConsentObjType` |   |
| `config.consent.integrationId` (Required) | `string` |   |
| `config.target` (Required) | `TargetObjType` |   |
| `config.target.triggers` (Required) | `array of TriggerObjType` | Nested fields omitted: depth limit. |
| `config.target.frequency` (Required) | `FrequencyObjType` | Nested fields omitted: depth limit. |
| `config.target.websites` (Required) | `array of WebsiteObjType` | Nested fields omitted: depth limit. |
| `config.target.popUpPosition` (Required) | `PopUpPosition` | Allowed values: `"center"`, `"bottom-left"`, `"bottom-right"` |
| `config.theme` (Required) | `ThemeObjType` |   |
| `config.theme.termsAndConditionsText` (Required) | `object` |   |
| `config.theme.emailLabel` (Required) | `string` |   |
| `config.theme.emailPlaceholder` (Required) | `string` |   |
| `config.theme.submitText` (Required) | `string` |   |
| `config.theme.successMessageTitle` (Required) | `string` |   |
| `config.theme.successMessage` (Required) | `string` |   |
| `config.theme.errorMessage` (Required) | `string` |   |
| `config.theme.widgetHeaderText` (Required) | `string` |   |
| `config.theme.widgetDescriptionText` (Required) | `object` |   |
| `config.theme.primaryColor` (Required) | `string` |   |
| `config.theme.textColor` (Required) | `string` |   |
| `config.theme.backgroundColor` (Required) | `string` |   |
| `config.theme.showCloseButton` (Required) | `boolean` |   |
| `config.theme.typography` (Required) | `TypographyObjType` | Nested fields omitted: depth limit. |
| `config.theme.redirectCTAText` (Required) | `string` |   |
| `config.theme.redirectCTAUrl` (Required) | `string` |   |
| `createdAt` (Required) | `string (date-time)` |   |

#### 400

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

badRequest, slugExist

| 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": [
    {}
  ]
}
```

#### 401

unauthorized

### Example request

```bash
curl https://api.subrite.no/api/v1/widget \
  --request POST \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "My Widget",
  "slug": "my-widget",
  "type": "consent",
  "displayType": "popup",
  "config": {
    "trigger": {
      "type": "manual",
      "delay": 1000,
      "scrollPercent": 50
    },
    "consent": {
      "showCheckbox": true,
      "labelText": "I agree to the terms and conditions",
      "submitText": "Submit",
      "successMessage": "Thank you for your consent",
      "errorMessage": "Please accept the terms and conditions"
    },
    "theme": {
      "primaryColor": "#000000",
      "textColor": "#000000",
      "backgroundColor": "#ffffff",
      "showCloseButton": true
    }
  },
  "status": "draft"
}'
```

### Example response

201 · `application/json`

```json
{
  "id": "string",
  "name": "string",
  "slug": "string",
  "type": "consent",
  "displayType": "popup",
  "status": "draft",
  "config": {
    "active": true,
    "consent": {},
    "target": {
      "triggers": [],
      "websites": []
    },
    "theme": {
      "termsAndConditionsText": {},
      "widgetDescriptionText": {}
    }
  },
  "createdAt": "2019-08-24T14:15:22Z"
}
```

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

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

**Authentication:** Bearer token (JWT)

### Parameters

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

### Responses

#### 200

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

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

#### 401

unauthorized

#### 404

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

notFound

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

**Example response**

`application/json`

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

### Example request

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

### Example response

200 · `application/json`

```json
{
  "id": "string",
  "name": "string",
  "slug": "string",
  "type": "consent",
  "displayType": "popup",
  "status": "draft",
  "config": {
    "active": true,
    "consent": {},
    "target": {
      "triggers": [],
      "websites": []
    },
    "theme": {
      "termsAndConditionsText": {},
      "widgetDescriptionText": {}
    }
  },
  "createdAt": "2019-08-24T14:15:22Z"
}
```

<a id="delete-api-v1-widget-id"></a>
## Delete a widget by id

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

**Authentication:** Bearer token (JWT)

### Parameters

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

### Responses

#### 200

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

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

#### 401

unauthorized

#### 404

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

notFound

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

**Example response**

`application/json`

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

### Example request

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

### Example response

200 · `application/json`

```json
{
  "id": "string",
  "name": "string",
  "slug": "string",
  "type": "consent",
  "displayType": "popup",
  "status": "draft",
  "config": {
    "active": true,
    "consent": {},
    "target": {
      "triggers": [],
      "websites": []
    },
    "theme": {
      "termsAndConditionsText": {},
      "widgetDescriptionText": {}
    }
  },
  "createdAt": "2019-08-24T14:15:22Z"
}
```

<a id="patch-api-v1-widget-id"></a>
## Update a widget by id

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

**Authentication:** Bearer token (JWT)

### Parameters

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

### Request body

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

| Name | Type | Description |
| --- | --- | --- |
| `name` | `string` | The name of the widget |
| `slug` | `string` | The slug of the widget |
| `type` | `string` | The type of the widget · Allowed values: `"consent"` · Default: `"consent"` |
| `displayType` | `string` | The display type of the widget · Allowed values: `"popup"`, `"embed"` · Default: `"popup"` |
| `config` | `WidgetConfig` | The config of the widget |
| `config.active` (Required when parent is present) | `boolean` |   |
| `config.consent` (Required when parent is present) | `ConsentObjType` |   |
| `config.consent.integrationId` (Required when parent is present) | `string` |   |
| `config.target` (Required when parent is present) | `TargetObjType` |   |
| `config.target.triggers` (Required when parent is present) | `array of TriggerObjType` | Nested fields omitted: depth limit. |
| `config.target.frequency` (Required when parent is present) | `FrequencyObjType` | Nested fields omitted: depth limit. |
| `config.target.websites` (Required when parent is present) | `array of WebsiteObjType` | Nested fields omitted: depth limit. |
| `config.target.popUpPosition` (Required when parent is present) | `PopUpPosition` | Allowed values: `"center"`, `"bottom-left"`, `"bottom-right"` |
| `config.theme` (Required when parent is present) | `ThemeObjType` |   |
| `config.theme.termsAndConditionsText` (Required when parent is present) | `object` |   |
| `config.theme.emailLabel` (Required when parent is present) | `string` |   |
| `config.theme.emailPlaceholder` (Required when parent is present) | `string` |   |
| `config.theme.submitText` (Required when parent is present) | `string` |   |
| `config.theme.successMessageTitle` (Required when parent is present) | `string` |   |
| `config.theme.successMessage` (Required when parent is present) | `string` |   |
| `config.theme.errorMessage` (Required when parent is present) | `string` |   |
| `config.theme.widgetHeaderText` (Required when parent is present) | `string` |   |
| `config.theme.widgetDescriptionText` (Required when parent is present) | `object` |   |
| `config.theme.primaryColor` (Required when parent is present) | `string` |   |
| `config.theme.textColor` (Required when parent is present) | `string` |   |
| `config.theme.backgroundColor` (Required when parent is present) | `string` |   |
| `config.theme.showCloseButton` (Required when parent is present) | `boolean` |   |
| `config.theme.typography` (Required when parent is present) | `TypographyObjType` | Nested fields omitted: depth limit. |
| `config.theme.redirectCTAText` (Required when parent is present) | `string` |   |
| `config.theme.redirectCTAUrl` (Required when parent is present) | `string` |   |
| `status` | `string` | The status of the widget · Allowed values: `"draft"`, `"published"` · Default: `"draft"` |

**Example request body**

`application/json`

```json
{
  "name": "My Widget",
  "slug": "my-widget",
  "type": "consent",
  "displayType": "popup",
  "status": "draft"
}
```

### Responses

#### 200

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

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

#### 401

unauthorized

#### 404

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

notFound, slugExist

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

**Example response**

`application/json`

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

### Example request

```bash
curl 'https://api.subrite.no/api/v1/widget/{id}' \
  --request PATCH \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "My Widget",
  "slug": "my-widget",
  "type": "consent",
  "displayType": "popup",
  "config": {
    "trigger": {
      "type": "manual",
      "delay": 1000,
      "scrollPercent": 50
    },
    "consent": {
      "showCheckbox": true,
      "labelText": "I agree to the terms and conditions",
      "submitText": "Submit",
      "successMessage": "Thank you for your consent",
      "errorMessage": "Please accept the terms and conditions"
    },
    "theme": {
      "primaryColor": "#000000",
      "textColor": "#000000",
      "backgroundColor": "#ffffff",
      "showCloseButton": true
    }
  },
  "status": "draft"
}'
```

### Example response

200 · `application/json`

```json
{
  "id": "string",
  "name": "string",
  "slug": "string",
  "type": "consent",
  "displayType": "popup",
  "status": "draft",
  "config": {
    "active": true,
    "consent": {},
    "target": {
      "triggers": [],
      "websites": []
    },
    "theme": {
      "termsAndConditionsText": {},
      "widgetDescriptionText": {}
    }
  },
  "createdAt": "2019-08-24T14:15:22Z"
}
```

<a id="get-api-v1-widget-slug-slug"></a>
## Get a widget by slug

`GET /api/v1/widget/slug/{slug}`

**Authentication:** Bearer token (JWT)

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `slug` (Required) | path | `string` |   |

### Responses

#### 200

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

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

#### 401

unauthorized

#### 404

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

notFound

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

**Example response**

`application/json`

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

### Example request

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

### Example response

200 · `application/json`

```json
{
  "id": "string",
  "name": "string",
  "slug": "string",
  "type": "consent",
  "displayType": "popup",
  "status": "draft",
  "config": {
    "active": true,
    "consent": {},
    "target": {
      "triggers": [],
      "websites": []
    },
    "theme": {
      "termsAndConditionsText": {},
      "widgetDescriptionText": {}
    }
  },
  "createdAt": "2019-08-24T14:15:22Z"
}
```
