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

# Create Content Type

> Create a new content type definition

## Path Parameters

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

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

## Request Body

<ParamField body="name" type="string" required>
  Display name for the content type (e.g., "Article", "BlogPost")
</ParamField>

<ParamField body="description" type="string">
  Structured markdown description for semantic search and LLM understanding
</ParamField>

<ParamField body="layoutComponentId" type="string" required>
  ID of the layout component that defines the structure
</ParamField>

<ParamField body="componentIdsAllowList" type="array" required>
  Array of component IDs or component groups that can be used within this content type
</ParamField>

<ParamField body="packageVersion" type="string" required>
  Version of package to use for component resolution
</ParamField>

<ParamField body="templateContentIds" type="string[]">
  Array of pre-built content example IDs
</ParamField>

<ParamField body="permissions" type="object">
  Access control settings

  <Expandable title="properties">
    <ParamField body="permissions.roles" type="string[]">
      Roles that can create content of this type
    </ParamField>

    <ParamField body="permissions.users" type="string[]">
      Specific users that can create content
    </ParamField>

    <ParamField body="permissions.publish" type="object">
      Publishing permission settings
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="metadata" type="object">
  Additional type metadata

  <Expandable title="properties">
    <ParamField body="metadata.tags" type="string[]">
      Type categories
    </ParamField>

    <ParamField body="metadata.locales" type="string[]">
      Supported locales
    </ParamField>
  </Expandable>
</ParamField>

### Example Request

```json theme={null}
{
  "name": "BlogPost",
  "description": "Blog post content type for personal and corporate blogging.\n\n**Content structure:**\n- Featured image and title\n- Author bio section\n- Rich text with code snippets\n\n**Best for:**\n- Personal blogs\n- Technical tutorials\n\n**Typical length:** 800-2000 words\n**Supported platforms:** Web, iOS, Android, React",
  "layoutComponentId": "c125",
  "componentIdsAllowList": ["c126", "c127", "c128"],
  "packageVersion": "1.0.0",
  "templateContentIds": ["cont125"],
  "permissions": {
    "roles": ["blogger", "editor"]
  },
  "metadata": {
    "tags": ["blog", "content"],
    "locales": ["en-US"]
  }
}
```

<Note>
  New content types are created with `draft` status and `null` version. Use the publish endpoint to create the first published version.
</Note>

## Response

Returns the created ContentType object.

```json theme={null}
{
  "id": "ct125",
  "name": "BlogPost",
  "description": "Blog post content type for personal and corporate blogging...",
  "status": "draft",
  "version": null,
  "lastPublishedVersion": null,
  "layoutComponentId": "c125",
  "componentIdsAllowList": ["c126", "c127", "c128"],
  "packageVersion": "1.0.0",
  "schema": { ... },
  "templateContentIds": ["cont125"],
  "permissions": {
    "roles": ["blogger", "editor"],
    "users": [],
    "publish": {
      "roles": [],
      "users": []
    }
  },
  "metadata": {
    "author": "user123",
    "tags": ["blog", "content"],
    "locales": ["en-US"]
  },
  "createdAt": "2024-03-20T10:00:00Z",
  "updatedAt": "2024-03-20T10:00:00Z"
}
```

## Error Responses

### Component Not Found

```json theme={null}
{
  "error": {
    "code": "COMPONENT_NOT_FOUND",
    "message": "Layout component not found",
    "details": {
      "componentId": "c125"
    }
  }
}
```

### Invalid Package Version

```json theme={null}
{
  "error": {
    "code": "PACKAGE_NOT_FOUND",
    "message": "Package version 1.0.0 not found"
  }
}
```

### Invalid Component Allow List

```json theme={null}
{
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "componentIdsAllowList validation failed",
    "details": {
      "invalidComponentIds": ["c999"],
      "emptyGroups": ["media"]
    }
  }
}
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content-types" \
    -H "Authorization: Bearer YOUR_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "BlogPost",
      "layoutComponentId": "c125",
      "componentIdsAllowList": ["c126", "c127"],
      "packageVersion": "1.0.0"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content-types',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_JWT',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        name: 'BlogPost',
        layoutComponentId: 'c125',
        componentIdsAllowList: ['c126', 'c127'],
        packageVersion: '1.0.0'
      })
    }
  );

  const contentType = await response.json();
  console.log(`Created content type: ${contentType.id}`);
  ```
</CodeGroup>
