> This page is for Workspace app.

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

# Preview, transfer or archive one legacy channel

POST https://api.cloudraker.com/triggers/migrate-legacy-channels
Content-Type: application/json

Transfers ONE channel, named by `channelId`. `dryRun: true` reports the outcome without writing. Optional `expectedSourceHash` (64 hex characters) makes the transfer refuse a source that changed since it was read. `archive: true` takes the other exit: it archives a channel the producer REFUSES to transfer, storing that refusal on the row, and is itself refused for a channel that could still migrate.

Reference: https://docs.cloudraker.com/workspace/api/workspace-triggers/migrate-legacy-channel

## Authentication

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

## Request

### Body (application/json)

This endpoint expects an object.

- `channelId` (string, required)
- `dryRun` (boolean, required)
- `expectedSourceHash` (string, optional)
- `archive` (boolean, optional)

## Response

### 200

The producer record, proxied unchanged.

- `data` (TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaData, required)

## Errors

### 400 Bad Request Error

`validation_failed`: a request body field is invalid.

- `error` (string, required) — The sentence a human reads.
- `error_code` (string, required) — The stable snake_case branch key.
- `issues` (list of ErrorEnvelopeIssuesItems, optional) — Per-field detail, present only on a validation failure.

### 403 Forbidden Error

`forbidden` — organization administrators only.

- `error` (string, required) — The sentence a human reads.
- `error_code` (string, required) — The stable snake_case branch key.
- `issues` (list of ErrorEnvelopeIssuesItems, optional) — Per-field detail, present only on a validation failure.

### 409 Conflict Error

`handoff_incomplete` — no readiness record covers this transfer yet.

- `error` (string, required) — The sentence a human reads.
- `error_code` (string, required) — The stable snake_case branch key.
- `issues` (list of ErrorEnvelopeIssuesItems, optional) — Per-field detail, present only on a validation failure.

### 422 Unprocessable Entity Error

`source_changed` — the legacy source moved under the expected hash.

- `error` (string, required) — The sentence a human reads.
- `error_code` (string, required) — The stable snake_case branch key.
- `issues` (list of ErrorEnvelopeIssuesItems, optional) — Per-field detail, present only on a validation failure.

## Types

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaData

- `channelId` (string, required)
- `status` (enum, required)
  - Allowed values: `ready`, `migrated`, `blocked`, `archived`
- `handoffReady` (boolean, required)
- `triggerId` (string, optional)
- `sourceHash` (string, optional)
- `message` (string, optional)
- `trigger` (TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTrigger, optional)

### ErrorEnvelopeIssuesItems

- `path` (string, required)
- `code` (string, required)
- `message` (string, required)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTrigger

- `name` (string, required)
- `when` (TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen, required)
- `open` (TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerOpen, required)
- `permissions` (TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerPermissions, required)
- `id` (string, required)
- `nextRunAt` (datetime, required, nullable)
- `triggerRef` (string, required)
- `createdAt` (datetime, required)
- `updatedAt` (datetime, required)
- `enabled` (boolean, optional, default: true)
- `lastRun` (TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerLastRun, optional)
- `legacy` (TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerLegacy, optional)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen

- TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen0
- TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen1

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerOpen

- `agentIds` (list of string, required)
- `spaces` (list of TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerOpenSpacesItems, required)
- `instruction` (string, required)
- `threadPolicy` (enum, required)
  - Allowed values: `new`, `reuse`
- `filesFrom` (enum, required)
  - Allowed values: `payload`, `none`
- `title` (string, optional)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerPermissions

- `runAsUserId` (string, required)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerLastRun

- `status` (enum, required)
  - Allowed values: `opened`, `busy`, `needs_input`, `blocked`, `error`
- `at` (datetime, required)
- `sessionId` (string, optional)
- `message` (string, optional)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerLegacy

- `channelId` (string, optional)
- `channelType` (enum, optional)
  - Allowed values: `email`, `webhook`
- `automationId` (string, optional)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen0

- TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen00
- TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen01
- TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen02
- TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen03

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen1

- `kind` (enum, required)
  - Allowed values: `webhook`
- `slug` (string, required)
- `secretPreview` (string, required)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerOpenSpacesItems

- `spaceId` (string, required)
- `access` (enum, required)
  - Allowed values: `read`, `commit`

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen00

- `kind` (enum, required)
  - Allowed values: `schedule`
- `schedule` (TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhenOneOf0OneOf0Schedule, required)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen01

- `kind` (enum, required)
  - Allowed values: `email`
- `address` (string, required)
- `from` (list of string, optional)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen02

- `kind` (enum, required)
  - Allowed values: `webhook`
- `slug` (string, required)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhen03

- `kind` (enum, required)
  - Allowed values: `manual`

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhenOneOf0OneOf0Schedule

- TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhenOneOf0OneOf0Schedule0
- TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhenOneOf0OneOf0Schedule1

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhenOneOf0OneOf0Schedule0

- `kind` (enum, required)
  - Allowed values: `cron`
- `expression` (string, required)
- `timezone` (string, required)

### TriggersMigrateLegacyChannelsPostResponsesContentApplicationJsonSchemaDataTriggerWhenOneOf0OneOf0Schedule1

- `kind` (enum, required)
  - Allowed values: `once`
- `at` (datetime, required)

## Examples

**Request**

```json
{
  "channelId": "string",
  "dryRun": true
}
```

**Response**

```json
{
  "data": {
    "channelId": "string",
    "status": "ready",
    "handoffReady": true,
    "triggerId": "string",
    "sourceHash": "string",
    "message": "string",
    "trigger": {
      "name": "string",
      "when": {
        "kind": "schedule",
        "schedule": {
          "expression": "string",
          "kind": "cron",
          "timezone": "string"
        }
      },
      "open": {
        "agentIds": [
          "string"
        ],
        "spaces": [
          {
            "spaceId": "string",
            "access": "read"
          }
        ],
        "instruction": "string",
        "threadPolicy": "new",
        "filesFrom": "payload",
        "title": "string"
      },
      "permissions": {
        "runAsUserId": "string"
      },
      "id": "string",
      "nextRunAt": "2024-01-15T09:30:00Z",
      "triggerRef": "string",
      "createdAt": "2024-01-15T09:30:00Z",
      "updatedAt": "2024-01-15T09:30:00Z",
      "enabled": true,
      "lastRun": {
        "status": "opened",
        "at": "2024-01-15T09:30:00Z",
        "sessionId": "string",
        "message": "string"
      },
      "legacy": {
        "channelId": "string",
        "channelType": "email",
        "automationId": "string"
      }
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.cloudraker.com/triggers/migrate-legacy-channels"

payload = {
    "channelId": "string",
    "dryRun": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.cloudraker.com/triggers/migrate-legacy-channels';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"channelId":"string","dryRun":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api.cloudraker.com/triggers/migrate-legacy-channels"

	payload := strings.NewReader("{\n  \"channelId\": \"string\",\n  \"dryRun\": true\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.cloudraker.com/triggers/migrate-legacy-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  \"channelId\": \"string\",\n  \"dryRun\": true\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.cloudraker.com/triggers/migrate-legacy-channels")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"channelId\": \"string\",\n  \"dryRun\": true\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/triggers/migrate-legacy-channels', [
  'body' => '{
  "channelId": "string",
  "dryRun": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/triggers/migrate-legacy-channels");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"channelId\": \"string\",\n  \"dryRun\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "channelId": "string",
  "dryRun": true
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/triggers/migrate-legacy-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()
```