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

# Publish Content Type

> Publish a content type, creating a new version

Publishing a content type creates a new immutable version. This version becomes the active definition for creating new content of this type.

## 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 published ContentType object with the new version number.

```json theme={null}
{
  "id": "ct123",
  "name": "Article",
  "description": "Standard article content type...",
  "status": "published",
  "version": 4,
  "lastPublishedVersion": 4,
  "layoutComponentId": "c123",
  "componentIdsAllowList": ["c124", "c125", "c126"],
  "packageVersion": "1.0.0",
  "schema": { ... },
  "templateContentIds": ["cont123"],
  "permissions": { ... },
  "metadata": {
    "author": "admin@metabind.ai",
    "tags": ["article"],
    "publishedAt": "2024-03-22T10:00:00Z",
    "publishedBy": "user123"
  },
  "createdAt": "2024-03-20T10:00:00Z",
  "updatedAt": "2024-03-22T10:00:00Z"
}
```

## Status Transitions

| Current Status | After Publish                     |
| -------------- | --------------------------------- |
| `draft`        | `published` (version 1)           |
| `modified`     | `published` (version incremented) |
| `unpublished`  | `published` (version incremented) |

<Note>
  Cannot publish a content type with `deleted` status. Restore it first by updating the status.
</Note>

## Error Responses

### Invalid Status

```json theme={null}
{
  "error": {
    "code": "INVALID_STATUS",
    "message": "Cannot publish content type with status: deleted"
  }
}
```

### Invalid Components

```json theme={null}
{
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "Content type references components not in the specified package version",
    "details": {
      "invalidComponentIds": ["c999"]
    }
  }
}
```

## Code Examples

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

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

  const contentType = await response.json();
  console.log(`Published version ${contentType.version}`);
  ```
</CodeGroup>
