> ## 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.

# Rollback Component

> Create a working copy from a previous version

## 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>
  Component ID
</ParamField>

<ParamField path="version" type="number" required>
  Target version number to rollback to
</ParamField>

## Request Body

No request body required.

## Behavior

Rollback creates a new working copy using the content from the specified version:

1. The original version remains unchanged
2. All package references are preserved
3. The component status becomes `modified`
4. The working copy will receive a new version number when published in a package

<Note>
  Rollback does not modify or delete any existing versions. It creates a working copy based on historical content that can be published as a new version.
</Note>

## Response

Returns the Component object with `modified` status.

```json theme={null}
{
  "id": "c123",
  "name": "ProductCard",
  "status": "modified",
  "version": null,
  "lastPublishedVersion": 3,
  "content": "// Content from version 2\nconst metadata = () => ({...});",
  "compiled": "...",
  "schema": {...},
  "metadata": {
    "rolledBackFrom": 2,
    "rolledBackAt": "2024-03-22T10:00:00Z",
    "rolledBackBy": "user123"
  },
  "createdAt": "2024-03-20T10:00:00Z",
  "updatedAt": "2024-03-22T10:00:00Z"
}
```

## Error Responses

### Version Not Found

```json theme={null}
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Component version 5 was not found"
  }
}
```

### Component Not Found

```json theme={null}
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Component not found"
  }
}
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/components/c123/rollback/2" \
    -H "Authorization: Bearer YOUR_JWT"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/components/c123/rollback/2',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_JWT'
      }
    }
  );

  const component = await response.json();
  ```
</CodeGroup>
