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

# Discard Draft Changes

> Discard unpublished changes and revert to the last published version

Resets a draft or modified content type back to its last published version. This is useful when you want to abandon changes and return to a known good state.

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

## Response

Returns the content type restored to its last published state.

```json theme={null}
{
  "data": {
    "id": "ct123",
    "name": "Article",
    "status": "published",
    "version": 3,
    "lastPublishedVersion": 3,
    "rootComponentId": "c123",
    "config": {
      "allowedComponents": ["c124", "c125"]
    },
    "packageVersion": "1.0.0",
    "schema": { ... },
    "templateContentIds": ["cont123"],
    "permissions": { ... },
    "metadata": { ... },
    "createdAt": "2024-03-20T10:00:00Z",
    "updatedAt": "2024-03-22T10:00:00Z"
  },
  "message": "Content type draft changes discarded successfully"
}
```

## Requirements

* Content type must have status `draft` or `modified`
* Content type must have been previously published (has a `lastPublishedVersion`)

## Error Responses

### Invalid Status

```json theme={null}
{
  "error": {
    "code": "INVALID_STATUS",
    "message": "Can only discard changes for draft or modified content types"
  }
}
```

### Never Published

```json theme={null}
{
  "error": {
    "code": "NO_PUBLISHED_VERSION",
    "message": "Cannot discard - content type has never been published"
  }
}
```

<Note>
  If the content type was `unpublished` before modifications, discarding will return it to `unpublished` status (not `published`).
</Note>

## Code Examples

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

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

  const { data: contentType } = await response.json();
  console.log(`Status is now: ${contentType.status}`);
  ```
</CodeGroup>


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