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

# Migrate and link knowledge through a LogicDialog source

POST https://app.logicdialog.ai/api/workspaces/{workspaceId}/knowledge/sources/{sourceKey}/migrate
Content-Type: application/json

Single migration entry point for LogicDialog sources. Preview/import fetch the legacy block API with transient credentials; link-preview/link use saved snapshot content without credentials or remote requests. Preview returns eligible destinations, suggestions and ambiguity indicators. Import/link require explicit record-to-source assignments. All destinations must belong to the same workstream and target environment, match the original URL or filename and ID, and be inactive before linking. The entire plan is committed atomically, preserves logical document keys and upstream IDs, and never overwrites later connector updates. Requires workspace membership and workspace.edit. Optional collections creates named manual or webpages collections atomically with migration. Each entry has key, title and type; assignments reference its key with targetSourceKey and may supply a corrected page URL. Saved text and document keys are retained. Webpage refresh is explicit; migration does not scrape.

Reference: https://api.logicdialog.ai/api-reference/knowledge/post-knowledge-source-migrate

## Authentication

- `Authorization` header (bearer token, required) — Kinde access token with the configured LogicDialog audience and workspace membership/permissions. Channel API keys cannot authenticate management operations.

## Request

### Path parameters

- `workspaceId` (string, required)
- `sourceKey` (string, required)

### Query parameters

- `branch` (string, required)

### Body (application/json)

This endpoint expects a LegacyKnowledgeMigration.

- `LegacyKnowledgeMigration`
  - LegacyKnowledgeMigration0
  - LegacyKnowledgeMigration1
  - LegacyKnowledgeMigration2
  - LegacyKnowledgeMigration3

## Response

### 200

Previewed or committed migration

- `Knowledge_post_knowledge_source_migrate_Response_200`
  - KnowledgeMigrationPreview: KnowledgeMigrationPreview
  - KnowledgePostKnowledgeSourceMigrateResponse2001

## Errors

### 400 Bad Request Error

Invalid configuration or missing workstream

- `any`

### 403 Forbidden Error

Permission denied

- `any`

### 409 Conflict Error

Resolve the source mapping or workstream conflict before retrying

- `any`

## Types

### LegacyKnowledgeMigration0

- `mode` (enum, optional)
  - Allowed values: `preview`

### LegacyKnowledgeMigration1

- `mode` (enum, optional)
  - Allowed values: `import`

### LegacyKnowledgeMigration2

- `mode` (enum, optional)
  - Allowed values: `link-preview`

### LegacyKnowledgeMigration3

- `mode` (enum, optional)
  - Allowed values: `link`

### KnowledgeMigrationPreview

- `documents` (list of KnowledgeMigrationPreviewDocumentsItems, required)

### KnowledgePostKnowledgeSourceMigrateResponse2001

- `imported` (integer, required)
- `skipped` (integer, required)
- `published` (boolean, required)
- `changed` (boolean, optional)

### KnowledgeMigrationPreviewDocumentsItems

- `id` (string, optional)
- `title` (string, optional)
- `url` (string, optional, nullable)
- `filename` (string, optional)
- `eligible` (boolean, optional)
- `suggestedSourceKey` (string, optional)
- `existingSourceKey` (string, optional)
- `ambiguous` (boolean, optional)
- `alreadyLinked` (boolean, optional)
- `destinations` (list of KnowledgeMigrationPreviewDocumentsItemsDestinationsItems, optional)

### KnowledgeMigrationPreviewDocumentsItemsDestinationsItems

- `key` (string, optional)
- `title` (string, optional)
- `type` (string, optional)
- `available` (boolean, optional)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "documents": [
    {
      "alreadyLinked": true,
      "ambiguous": true,
      "destinations": [
        {
          "available": true,
          "key": "string",
          "title": "string",
          "type": "string"
        }
      ],
      "eligible": true,
      "existingSourceKey": "string",
      "filename": "string",
      "id": "string",
      "suggestedSourceKey": "string",
      "title": "string",
      "url": "string"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://app.logicdialog.ai/api/workspaces/workspaceId/knowledge/sources/sourceKey/migrate"

querystring = {"branch":"branch"}

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

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

print(response.json())
```

```javascript
const url = 'https://app.logicdialog.ai/api/workspaces/workspaceId/knowledge/sources/sourceKey/migrate?branch=branch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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://app.logicdialog.ai/api/workspaces/workspaceId/knowledge/sources/sourceKey/migrate?branch=branch"

	payload := strings.NewReader("{}")

	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://app.logicdialog.ai/api/workspaces/workspaceId/knowledge/sources/sourceKey/migrate?branch=branch")

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 = "{}"

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://app.logicdialog.ai/api/workspaces/workspaceId/knowledge/sources/sourceKey/migrate?branch=branch")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.logicdialog.ai/api/workspaces/workspaceId/knowledge/sources/sourceKey/migrate?branch=branch', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.logicdialog.ai/api/workspaces/workspaceId/knowledge/sources/sourceKey/migrate?branch=branch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.logicdialog.ai/api/workspaces/workspaceId/knowledge/sources/sourceKey/migrate?branch=branch")! 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()
```