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

> Publish content, creating a new version

Publishing content creates a new immutable version that becomes the active version for end users. The compiled BindJS code is locked at this 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>
  Content ID
</ParamField>

## Response

Returns the published Content object with the new version number.

```json theme={null}
{
  "data": {
    "id": "cont123",
    "typeId": "ct123",
    "version": 3,
    "lastPublishedVersion": 3,
    "packageVersion": "1.0.0",
    "name": "Getting Started Guide",
    "status": "published",
    "isTemplate": false,
    "content": { ... },
    "compiled": "const body = () => { ... }",
    "tags": ["Tutorial"],
    "metadata": {
      "createdBy": "user123",
      "publishedAt": "2024-03-21T10:00:00Z",
      "publishedBy": "user123",
      "locale": "en-US"
    },
    "createdAt": "2024-03-20T10:00:00Z",
    "updatedAt": "2024-03-21T10:00:00Z"
  }
}
```

## Status Transitions

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

<Note>
  Only `draft` or `modified` content can be published, and its ContentType must be published.
</Note>

## Error Responses

### Invalid Status

```json theme={null}
{
  "error": {
    "code": "INVALID_CONTENT_STATUS",
    "message": "Only draft or modified content can be published. Current status: deleted"
  }
}
```

### Validation Failed

```json theme={null}
{
  "error": {
    "code": "CONTENT_VALIDATION_FAILED",
    "message": "Content does not match the ContentType schema. Fix the row via PUT /content/:id (which validates the same way) and retry publish."
  }
}
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/cont123/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/cont123/publish',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_JWT'
      }
    }
  );

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


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