> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metabind.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate Content

> Migrate content to a new ContentType version

Updates content to use a newer ContentType version, updating the derived `packageVersion`.

## Path Parameters

<ParamField path="organizationId" type="string" required>
  Organization ID
</ParamField>

<ParamField path="projectId" type="string" required>
  Project ID
</ParamField>

<ParamField path="id" type="string" required>
  Content ID
</ParamField>

## Request Body

<ParamField body="targetTypeVersion" type="number | string">
  The published ContentType version to migrate to, or `"draft"` for the ContentType's current package version. Required unless `targetPackageVersion` is set.
</ParamField>

<ParamField body="targetPackageVersion" type="string">
  Package version to migrate to directly. Required unless `targetTypeVersion` is set.
</ParamField>

### Example Request

```json theme={null}
{
  "targetTypeVersion": 3
}
```

## Response

Returns the updated Content object with the new `packageVersion`.

```json theme={null}
{
  "data": {
    "id": "cont123",
    "typeId": "ct123",
    "version": null,
    "lastPublishedVersion": 2,
    "packageVersion": "2.0.0",
    "name": "Getting Started Guide",
    "status": "modified",
    "isTemplate": false,
    "content": { ... },
    "compiled": "const body = () => { ... }",
    "tags": ["Tutorial"],
    "metadata": { ... },
    "createdAt": "2024-03-20T10:00:00Z",
    "updatedAt": "2024-03-23T10:00:00Z"
  }
}
```

<Warning>
  Migration changes the `packageVersion`. Published content becomes `modified` (or `draft` if it was never published), and you must publish it to make the migration live. Migration does not validate content; publishing validates it against the ContentType schema.
</Warning>

## Error Responses

### ContentType Version Not Found

```json theme={null}
{
  "error": {
    "code": "INVALID_TARGET_TYPE_VERSION",
    "message": "ContentType ct123 version 3 must be published"
  }
}
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/cont123/migrate" \
    -H "Authorization: Bearer YOUR_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "targetTypeVersion": 3
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/cont123/migrate',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_JWT',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        targetTypeVersion: 3
      })
    }
  );

  const { data: content } = await response.json();
  console.log(`Migrated to package ${content.packageVersion}`);
  ```
</CodeGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.