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

Returned when a component in `componentIdsAllowList` does not exist:

```json theme={null}
{
  "error": {
    "code": "COMPONENT_NOT_FOUND",
    "message": "Component with ID c999 not found"
  }
}
```

### Invalid Package Version

Returned when the layout component is not in the package version, including when that package version does not exist:

```json theme={null}
{
  "error": {
    "code": "INVALID_LAYOUT_COMPONENT",
    "message": "Layout component c125 not found in package version 1.0.0"
  }
}
```

### Invalid Component Allow List

A group with an empty `componentIds` array (here at index 1) returns the schema errors in `details`:

```json theme={null}
{
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "Content type create validation failed",
    "details": [
      {
        "instancePath": "/componentIdsAllowList/1",
        "schemaPath": "#/properties/componentIdsAllowList/items/oneOf/0/type",
        "keyword": "type",
        "params": { "type": "string" },
        "message": "must be string"
      },
      {
        "instancePath": "/componentIdsAllowList/1/componentIds",
        "schemaPath": "#/properties/componentIdsAllowList/items/oneOf/1/properties/componentIds/minItems",
        "keyword": "minItems",
        "params": { "limit": 1 },
        "message": "must NOT have fewer than 1 items"
      },
      {
        "instancePath": "/componentIdsAllowList/1",
        "schemaPath": "#/properties/componentIdsAllowList/items/oneOf",
        "keyword": "oneOf",
        "params": { "passingSchemas": null },
        "message": "must match exactly one schema in oneOf"
      }
    ]
  }
}
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/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/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>


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