# Import channels

> Channels API · Import Export

```http
POST /api/channel-import/
```

Creates and updates channels from an export, and with `mode=replace` deletes the others. It returns at once, saying whether each channel was accepted, skipped or rejected. Accepted channels are then configured in the background: each channel's `status.syncState` shows when that has finished.

Requires the add and change permissions. With `mode=replace` the delete permission is also required.

## Authentication

- `Authorization` header — Bearer authentication of the form `Bearer <token>`.

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `dryRun` | boolean | No | When true, nothing is changed. The response describes what the same request would do without `dryRun`. _Defaults to false_ |

## Request body

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

- `payload` · object · **Required** — The export document, exactly as export returned it.
  - `schemaVersion` · string · Optional · _Defaults to 1_ — The export's format version. Import accepts `1`.
  - `description` · object · Optional — The `description` given when the export was made.
    - One of the following variants:
      - **string** (string)
      - **null** (null)
  - `exportedAt` · string · **Required** · _format: date-time_ — When the export was made.
  - `sourceVersion` · object · Optional — The software version of the unit that made the export.
    - One of the following variants:
      - **string** (string)
      - **null** (null)
  - `sourceBeamVersion` · object · Optional — The Beam software version of the unit that made the export, when it could be read.
    - One of the following variants:
      - **string** (string)
      - **null** (null)
  - `channels` · list of objects · **Required** — The exported channels. Each entry is made by export, and its contents aren't documented. Leave them as returned: the whole export document goes to import as `payload`.
    - Array items (object):
- `mode` · enum · Optional · _Defaults to merge_ — How an import treats the channels already on this unit. - `merge`: create the channels that don't exist, update those that do, and leave every other channel alone. - `replace`: as `merge`, and also delete every channel that isn't in the export. An export with no channels deletes them all.
  - Allowed values: `merge`, `replace`
- `state` · object · Optional — The state of each channel the import creates. Absent, they are created `Stopped`. A channel that already exists keeps its state.
  - One of the following variants:
    - **DesiredState** (enum)
    - **null** (null)

## Example request

```bash
curl -X POST "/api/channel-import/?dryRun=false" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
  "payload": {
    "schemaVersion": "1",
    "description": "string",
    "exportedAt": "2024-01-01T00:00:00Z",
    "sourceVersion": "string",
    "sourceBeamVersion": "string",
    "channels": [
      {}
    ]
  },
  "mode": "merge",
  "state": "Running"
}'
```

## Responses

### 200 — Successful Response

- One of the following variants:
  - **ImportResult** (object)
    - `imported` · list of objects · Optional
      - Array items (object):
        - `name` · string · **Required**
        - `sourceName` · string · **Required**
        - `displayName` · string · **Required**
        - `status` · enum · **Required**
          - Allowed values: `accepted`, `skipped`, `rejected`
        - `error` · object · Optional — Why the channel was rejected: the first entry's `userMessage` from `errors`.
          - One of the following variants:
            - **string** (string)
            - **null** (null)
        - `errors` · list of objects · Optional — Why the channel was rejected. Empty unless `status` is `rejected`.
          - Array items (object):
            - `code` · string · **Required** — Identifies the failure, for example `PLATFORM-0001`. Quote it if you contact support.
            - `transient` · boolean · **Required** — True if the problem may go away on its own, so trying again later could work.
            - `showCode` · boolean · **Required** — A hint that showing `code` to the user is advisable because the problems is unlikely to be resolvable directly by the user. This puts the code in front of the user in the situations where they are most likely to contact support.
            - `userShort` · string · **Required** · _<=40 characters_ — A short label for the problem, written for the user. Can be used as a title or heading.
            - `userMessage` · string · **Required** · _<=512 characters_ — What went wrong and what to do about it, written for the user.
            - `detail` · string · **Required** · _<=512 characters_ — Technical text for an integrator or support. Don't make it the first thing the UI user sees. In some cases, it could be reasonable to make it available to the user if they ask for it, for example in a 'Show technical details' link.
            - `loc` · list of objects · Optional — Where in the request this error is, as a list of keys and indexes, for example `["body", "spec", "outputs", 0, "transport", "url"]`. The first item says which part of the request: `body` or `query`. Empty when the error isn't about a part of the request.
              - Array items (object):
                - One of the following variants:
                  - **string** (string)
                  - **integer** (integer)
    - `deleted` · list of strings · Optional
      - Array items (string):
    - `errors` · list of strings · Optional
      - Array items (string):
    - `warnings` · list of strings · Optional
      - Array items (string):
  - **DryRunImportResult** (object)
    - `dryRun` · boolean · Optional · _Defaults to true_
    - `imported` · list of objects · Optional
      - Array items (object):
        - `name` · string · **Required**
        - `sourceName` · string · **Required**
        - `displayName` · string · **Required**
        - `status` · enum · **Required**
          - Allowed values: `accepted`, `skipped`, `rejected`
        - `error` · object · Optional — Why the channel was rejected: the first entry's `userMessage` from `errors`.
          - One of the following variants:
            - **string** (string)
            - **null** (null)
        - `errors` · list of objects · Optional — Why the channel was rejected. Empty unless `status` is `rejected`.
          - Array items (object):
            - `code` · string · **Required** — Identifies the failure, for example `PLATFORM-0001`. Quote it if you contact support.
            - `transient` · boolean · **Required** — True if the problem may go away on its own, so trying again later could work.
            - `showCode` · boolean · **Required** — A hint that showing `code` to the user is advisable because the problems is unlikely to be resolvable directly by the user. This puts the code in front of the user in the situations where they are most likely to contact support.
            - `userShort` · string · **Required** · _<=40 characters_ — A short label for the problem, written for the user. Can be used as a title or heading.
            - `userMessage` · string · **Required** · _<=512 characters_ — What went wrong and what to do about it, written for the user.
            - `detail` · string · **Required** · _<=512 characters_ — Technical text for an integrator or support. Don't make it the first thing the UI user sees. In some cases, it could be reasonable to make it available to the user if they ask for it, for example in a 'Show technical details' link.
            - `loc` · list of objects · Optional — Where in the request this error is, as a list of keys and indexes, for example `["body", "spec", "outputs", 0, "transport", "url"]`. The first item says which part of the request: `body` or `query`. Empty when the error isn't about a part of the request.
              - Array items (object):
                - One of the following variants:
                  - **string** (string)
                  - **integer** (integer)
        - `action` · object · Optional — What the import would do. Empty when the channel would be rejected.
          - One of the following variants:
            - **ImportAction** (enum)
            - **null** (null)
        - `channelType` · object · Optional — The channel's type. Empty when the spec could not be loaded.
          - One of the following variants:
            - **ChannelType** (enum)
            - **null** (null)
        - `inputTypes` · list of enums · Optional — The transport type of each input, in order.
          - Array items (enum):
        - `outputTypes` · list of enums · Optional — The transport type of each output, in order.
          - Array items (enum):
        - `bissMode` · object · Optional — The BISS mode, when the channel decrypts BISS.
          - One of the following variants:
            - **BissMode** (enum)
            - **null** (null)
        - `bissInjectedKeyId` · object · Optional — The Injected ID the channel's BISS mode E refers to.
          - One of the following variants:
            - **string** (string)
            - **null** (null)
        - `running` · object · Optional — Whether the channel on this device is running. Empty for a channel that does not exist here or whose state could not be read.
          - One of the following variants:
            - **boolean** (boolean)
            - **null** (null)
        - `warnings` · list of objects · Optional
          - Array items (object):
            - `code` · enum · **Required** — Why a channel in a dry run needs the caller's attention.
              - Allowed values: `BissInjectedIdMissing`, `ServiceIdsInUse`, `AsiPortUnusable`
            - `message` · string · **Required**
            - `details` · map from strings to string · Optional — Values the message is built from, such as `bissInjectedKeyId`.
              - `[any key]` · string — map of additional properties
    - `deleted` · list of strings · Optional — Channels `replace` mode would delete.
      - Array items (string):
    - `errors` · list of strings · Optional
      - Array items (string):
    - `warnings` · list of strings · Optional
      - Array items (string):

Example:

```json
{
  "imported": [
    {
      "name": "string",
      "sourceName": "string",
      "displayName": "string",
      "status": "accepted",
      "error": "string",
      "errors": [
        {
          "code": "string",
          "transient": true,
          "showCode": true,
          "userShort": "string",
          "userMessage": "string",
          "detail": "string",
          "loc": [
            "string"
          ]
        }
      ]
    }
  ],
  "deleted": [
    "string"
  ],
  "errors": [
    "string"
  ],
  "warnings": [
    "string"
  ]
}
```

### 400 — Unsupported export version (REQUEST-0011).

- `detail` · string · **Required** — The first entry's `userMessage`, for a caller that reads only one string.
- `status` · integer · **Required** — The HTTP status of this response, repeated so a stored copy of the body is complete.
- `errors` · list of objects · **Required** — Each problem found. Never empty. `detail` repeats the first one.
  - Array items (object):
    - `code` · string · **Required** — Identifies the failure, for example `PLATFORM-0001`. Quote it if you contact support.
    - `transient` · boolean · **Required** — True if the problem may go away on its own, so trying again later could work.
    - `showCode` · boolean · **Required** — A hint that showing `code` to the user is advisable because the problems is unlikely to be resolvable directly by the user. This puts the code in front of the user in the situations where they are most likely to contact support.
    - `userShort` · string · **Required** · _<=40 characters_ — A short label for the problem, written for the user. Can be used as a title or heading.
    - `userMessage` · string · **Required** · _<=512 characters_ — What went wrong and what to do about it, written for the user.
    - `detail` · string · **Required** · _<=512 characters_ — Technical text for an integrator or support. Don't make it the first thing the UI user sees. In some cases, it could be reasonable to make it available to the user if they ask for it, for example in a 'Show technical details' link.
    - `loc` · list of objects · Optional — Where in the request this error is, as a list of keys and indexes, for example `["body", "spec", "outputs", 0, "transport", "url"]`. The first item says which part of the request: `body` or `query`. Empty when the error isn't about a part of the request.
      - Array items (object):
        - One of the following variants:
          - **string** (string)
          - **integer** (integer)

Example:

```json
{
  "detail": "Input should be greater than or equal to 1024",
  "errors": [
    {
      "code": "REQUEST-0021",
      "detail": "spec.outputs[0].transport.port: Input should be greater than or equal to 1024",
      "loc": [
        "body",
        "spec",
        "outputs",
        0,
        "transport",
        "port"
      ],
      "showCode": false,
      "transient": false,
      "userMessage": "Input should be greater than or equal to 1024",
      "userShort": "Invalid value"
    }
  ],
  "status": 422
}
```

### 401 — - Sign-in needed (AUTH-0002). - Sign-in expired (AUTH-0003). - Sign-in not valid (AUTH-0004).

- `detail` · string · **Required** — The first entry's `userMessage`, for a caller that reads only one string.
- `status` · integer · **Required** — The HTTP status of this response, repeated so a stored copy of the body is complete.
- `errors` · list of objects · **Required** — Each problem found. Never empty. `detail` repeats the first one.
  - Array items (object):
    - `code` · string · **Required** — Identifies the failure, for example `PLATFORM-0001`. Quote it if you contact support.
    - `transient` · boolean · **Required** — True if the problem may go away on its own, so trying again later could work.
    - `showCode` · boolean · **Required** — A hint that showing `code` to the user is advisable because the problems is unlikely to be resolvable directly by the user. This puts the code in front of the user in the situations where they are most likely to contact support.
    - `userShort` · string · **Required** · _<=40 characters_ — A short label for the problem, written for the user. Can be used as a title or heading.
    - `userMessage` · string · **Required** · _<=512 characters_ — What went wrong and what to do about it, written for the user.
    - `detail` · string · **Required** · _<=512 characters_ — Technical text for an integrator or support. Don't make it the first thing the UI user sees. In some cases, it could be reasonable to make it available to the user if they ask for it, for example in a 'Show technical details' link.
    - `loc` · list of objects · Optional — Where in the request this error is, as a list of keys and indexes, for example `["body", "spec", "outputs", 0, "transport", "url"]`. The first item says which part of the request: `body` or `query`. Empty when the error isn't about a part of the request.
      - Array items (object):
        - One of the following variants:
          - **string** (string)
          - **integer** (integer)

Example:

```json
{
  "detail": "Input should be greater than or equal to 1024",
  "errors": [
    {
      "code": "REQUEST-0021",
      "detail": "spec.outputs[0].transport.port: Input should be greater than or equal to 1024",
      "loc": [
        "body",
        "spec",
        "outputs",
        0,
        "transport",
        "port"
      ],
      "showCode": false,
      "transient": false,
      "userMessage": "Input should be greater than or equal to 1024",
      "userShort": "Invalid value"
    }
  ],
  "status": 422
}
```

### 403 — Permission needed (AUTH-0001).

- `detail` · string · **Required** — The first entry's `userMessage`, for a caller that reads only one string.
- `status` · integer · **Required** — The HTTP status of this response, repeated so a stored copy of the body is complete.
- `errors` · list of objects · **Required** — Each problem found. Never empty. `detail` repeats the first one.
  - Array items (object):
    - `code` · string · **Required** — Identifies the failure, for example `PLATFORM-0001`. Quote it if you contact support.
    - `transient` · boolean · **Required** — True if the problem may go away on its own, so trying again later could work.
    - `showCode` · boolean · **Required** — A hint that showing `code` to the user is advisable because the problems is unlikely to be resolvable directly by the user. This puts the code in front of the user in the situations where they are most likely to contact support.
    - `userShort` · string · **Required** · _<=40 characters_ — A short label for the problem, written for the user. Can be used as a title or heading.
    - `userMessage` · string · **Required** · _<=512 characters_ — What went wrong and what to do about it, written for the user.
    - `detail` · string · **Required** · _<=512 characters_ — Technical text for an integrator or support. Don't make it the first thing the UI user sees. In some cases, it could be reasonable to make it available to the user if they ask for it, for example in a 'Show technical details' link.
    - `loc` · list of objects · Optional — Where in the request this error is, as a list of keys and indexes, for example `["body", "spec", "outputs", 0, "transport", "url"]`. The first item says which part of the request: `body` or `query`. Empty when the error isn't about a part of the request.
      - Array items (object):
        - One of the following variants:
          - **string** (string)
          - **integer** (integer)

Example:

```json
{
  "detail": "Input should be greater than or equal to 1024",
  "errors": [
    {
      "code": "REQUEST-0021",
      "detail": "spec.outputs[0].transport.port: Input should be greater than or equal to 1024",
      "loc": [
        "body",
        "spec",
        "outputs",
        0,
        "transport",
        "port"
      ],
      "showCode": false,
      "transient": false,
      "userMessage": "Input should be greater than or equal to 1024",
      "userShort": "Invalid value"
    }
  ],
  "status": 422
}
```

### 422 — Invalid value (REQUEST-0021).

- `detail` · string · **Required** — The first entry's `userMessage`, for a caller that reads only one string.
- `status` · integer · **Required** — The HTTP status of this response, repeated so a stored copy of the body is complete.
- `errors` · list of objects · **Required** — Each problem found. Never empty. `detail` repeats the first one.
  - Array items (object):
    - `code` · string · **Required** — Identifies the failure, for example `PLATFORM-0001`. Quote it if you contact support.
    - `transient` · boolean · **Required** — True if the problem may go away on its own, so trying again later could work.
    - `showCode` · boolean · **Required** — A hint that showing `code` to the user is advisable because the problems is unlikely to be resolvable directly by the user. This puts the code in front of the user in the situations where they are most likely to contact support.
    - `userShort` · string · **Required** · _<=40 characters_ — A short label for the problem, written for the user. Can be used as a title or heading.
    - `userMessage` · string · **Required** · _<=512 characters_ — What went wrong and what to do about it, written for the user.
    - `detail` · string · **Required** · _<=512 characters_ — Technical text for an integrator or support. Don't make it the first thing the UI user sees. In some cases, it could be reasonable to make it available to the user if they ask for it, for example in a 'Show technical details' link.
    - `loc` · list of objects · Optional — Where in the request this error is, as a list of keys and indexes, for example `["body", "spec", "outputs", 0, "transport", "url"]`. The first item says which part of the request: `body` or `query`. Empty when the error isn't about a part of the request.
      - Array items (object):
        - One of the following variants:
          - **string** (string)
          - **integer** (integer)

Example:

```json
{
  "detail": "Input should be greater than or equal to 1024",
  "errors": [
    {
      "code": "REQUEST-0021",
      "detail": "spec.outputs[0].transport.port: Input should be greater than or equal to 1024",
      "loc": [
        "body",
        "spec",
        "outputs",
        0,
        "transport",
        "port"
      ],
      "showCode": false,
      "transient": false,
      "userMessage": "Input should be greater than or equal to 1024",
      "userShort": "Invalid value"
    }
  ],
  "status": 422
}
```

### 500 — Internal error. The request could not be completed. `errors[].code` identifies the failure; quote it if you contact support.

- `detail` · string · **Required** — The first entry's `userMessage`, for a caller that reads only one string.
- `status` · integer · **Required** — The HTTP status of this response, repeated so a stored copy of the body is complete.
- `errors` · list of objects · **Required** — Each problem found. Never empty. `detail` repeats the first one.
  - Array items (object):
    - `code` · string · **Required** — Identifies the failure, for example `PLATFORM-0001`. Quote it if you contact support.
    - `transient` · boolean · **Required** — True if the problem may go away on its own, so trying again later could work.
    - `showCode` · boolean · **Required** — A hint that showing `code` to the user is advisable because the problems is unlikely to be resolvable directly by the user. This puts the code in front of the user in the situations where they are most likely to contact support.
    - `userShort` · string · **Required** · _<=40 characters_ — A short label for the problem, written for the user. Can be used as a title or heading.
    - `userMessage` · string · **Required** · _<=512 characters_ — What went wrong and what to do about it, written for the user.
    - `detail` · string · **Required** · _<=512 characters_ — Technical text for an integrator or support. Don't make it the first thing the UI user sees. In some cases, it could be reasonable to make it available to the user if they ask for it, for example in a 'Show technical details' link.
    - `loc` · list of objects · Optional — Where in the request this error is, as a list of keys and indexes, for example `["body", "spec", "outputs", 0, "transport", "url"]`. The first item says which part of the request: `body` or `query`. Empty when the error isn't about a part of the request.
      - Array items (object):
        - One of the following variants:
          - **string** (string)
          - **integer** (integer)

Example:

```json
{
  "detail": "Input should be greater than or equal to 1024",
  "errors": [
    {
      "code": "REQUEST-0021",
      "detail": "spec.outputs[0].transport.port: Input should be greater than or equal to 1024",
      "loc": [
        "body",
        "spec",
        "outputs",
        0,
        "transport",
        "port"
      ],
      "showCode": false,
      "transient": false,
      "userMessage": "Input should be greater than or equal to 1024",
      "userShort": "Invalid value"
    }
  ],
  "status": 422
}
```

### 503 — Temporarily unavailable (CONN-0004).

- `detail` · string · **Required** — The first entry's `userMessage`, for a caller that reads only one string.
- `status` · integer · **Required** — The HTTP status of this response, repeated so a stored copy of the body is complete.
- `errors` · list of objects · **Required** — Each problem found. Never empty. `detail` repeats the first one.
  - Array items (object):
    - `code` · string · **Required** — Identifies the failure, for example `PLATFORM-0001`. Quote it if you contact support.
    - `transient` · boolean · **Required** — True if the problem may go away on its own, so trying again later could work.
    - `showCode` · boolean · **Required** — A hint that showing `code` to the user is advisable because the problems is unlikely to be resolvable directly by the user. This puts the code in front of the user in the situations where they are most likely to contact support.
    - `userShort` · string · **Required** · _<=40 characters_ — A short label for the problem, written for the user. Can be used as a title or heading.
    - `userMessage` · string · **Required** · _<=512 characters_ — What went wrong and what to do about it, written for the user.
    - `detail` · string · **Required** · _<=512 characters_ — Technical text for an integrator or support. Don't make it the first thing the UI user sees. In some cases, it could be reasonable to make it available to the user if they ask for it, for example in a 'Show technical details' link.
    - `loc` · list of objects · Optional — Where in the request this error is, as a list of keys and indexes, for example `["body", "spec", "outputs", 0, "transport", "url"]`. The first item says which part of the request: `body` or `query`. Empty when the error isn't about a part of the request.
      - Array items (object):
        - One of the following variants:
          - **string** (string)
          - **integer** (integer)

Example:

```json
{
  "detail": "Input should be greater than or equal to 1024",
  "errors": [
    {
      "code": "REQUEST-0021",
      "detail": "spec.outputs[0].transport.port: Input should be greater than or equal to 1024",
      "loc": [
        "body",
        "spec",
        "outputs",
        0,
        "transport",
        "port"
      ],
      "showCode": false,
      "transient": false,
      "userMessage": "Input should be greater than or equal to 1024",
      "userShort": "Invalid value"
    }
  ],
  "status": 422
}
```

---

Source spec: `channels-api` · operationId: `importChannels`
