> This page is for Camera to Cloud.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://next.developer.frame.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://next.developer.frame.io/_mcp/server.

# 连接新的设备通道

POST https://api.frame.io/v2/devices/channels
Content-Type: application/json

我们可以通过以下请求连接新通道

Reference: https://next.developer.frame.io/camera-to-cloud/api-reference/device-channels/connect-device-channel

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Headers

- `x-client-version` (string, optional, default: 0.0.0) — Firmware or software version of a C2C integration. Will be used to determine the correct Device Model configuration for the device when multiple are available. Must be a valid semantic version. For more on semantic versions, see here: https://semver.org/

### Body (application/json)

This endpoint expects an object.

- `client_id` (string, required)
- `device_model_id` (string, required)

## Response

### 200

Example response

- `_type` (string, optional, default: project_device_channel)
- `id` (string, optional)
- `actor_id` (string, optional)
- `asset_type` (enum, optional)
  - Allowed values: `audio`, `video`, `data`
- `device_id` (string, optional)
- `external_index` (double, optional)
- `inserted_at` (string, optional)
- `name` (string, optional) — 基于设备型号自动生成的名称
- `project_id` (string, optional) — 此设备所关联的项目 ID
- `project_device_id` (string, optional)
- `real_time_logging_capable` (boolean, optional, default: false)
- `status` (enum, optional)
  - Allowed values: `offline`, `online`
- `updated_at` (string, optional)

## Errors

### 401 Unauthorized Error

Unauthorized response

- `code` (integer, optional)
- `errors` (list of HttpErrorErrorsItems, optional)
- `message` (string, optional)

### 409 Conflict Error

Device channel already exists

- `code` (integer, optional)
- `errors` (list of HttpErrorErrorsItems, optional)
- `message` (string, optional)

## Types

### HttpErrorErrorsItems

- `code` (integer, optional)
- `detail` (string, optional)
- `status` (integer, optional)
- `title` (string, optional)

## Examples

**Request**

```json
{
  "body": {
    "client_id": "[client_id]",
    "device_model_id": "[device_model_id]"
  }
}
```

**SDK Code**

```typescript
const response = await fetch('https://api.frame.io/v2/devices/channels/connect', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer [access_token]',
    'Content-Type': 'application/json',
    'x-client-version': '2.0.0'
  },
  body: JSON.stringify({
    client_id: '[client_id]',
    device_model_id: '[device_model_id]'
  })
});

const result = await response.json();
console.log(result);
```

```python
import requests

headers = {
    'Authorization': 'Bearer [access_token]',
    'Content-Type': 'application/json',
    'x-client-version': '2.0.0'
}

data = {
    'client_id': '[client_id]',
    'device_model_id': '[device_model_id]'
}

response = requests.post(
    'https://api.frame.io/v2/devices/channels/connect',
    headers=headers,
    json=data
)

result = response.json()
print(result)
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.frame.io/v2/devices/channels"

	payload := strings.NewReader("{\n  \"body\": {\n    \"client_id\": \"[client_id]\",\n    \"device_model_id\": \"[device_model_id]\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.frame.io/v2/devices/channels")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"body\": {\n    \"client_id\": \"[client_id]\",\n    \"device_model_id\": \"[device_model_id]\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.frame.io/v2/devices/channels")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"body\": {\n    \"client_id\": \"[client_id]\",\n    \"device_model_id\": \"[device_model_id]\"\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.frame.io/v2/devices/channels', [
  'body' => '{
  "body": {
    "client_id": "[client_id]",
    "device_model_id": "[device_model_id]"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.frame.io/v2/devices/channels");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"body\": {\n    \"client_id\": \"[client_id]\",\n    \"device_model_id\": \"[device_model_id]\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["body": [
    "client_id": "[client_id]",
    "device_model_id": "[device_model_id]"
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.frame.io/v2/devices/channels")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```