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

# ContentType

> Schema definitions for content structure

The `ContentType` type defines the structure and validation rules for content items.

## Type Definition

```graphql theme={null}
type ContentType {
  id: ID!
  name: String!
  description: String!
  packageVersion: String!
  schema: String!
  createdAt: DateTime!
  updatedAt: DateTime!
}
```

## Fields

| Field            | Type      | Description                              |
| ---------------- | --------- | ---------------------------------------- |
| `id`             | ID!       | Unique identifier                        |
| `name`           | String!   | Content type name                        |
| `description`    | String!   | Content type description                 |
| `packageVersion` | String!   | Package version for component resolution |
| `schema`         | String!   | JSON Schema defining content structure   |
| `createdAt`      | DateTime! | Creation timestamp                       |
| `updatedAt`      | DateTime! | Last update timestamp                    |

## Field Details

### packageVersion

Content types are bound to a specific package version. This ensures that the components referenced in the content type's layout are available when rendering content.

### schema

The schema field contains a JSON Schema that defines the content structure:

```json theme={null}
{
  "type": "object",
  "properties": {
    "title": {
      "type": "string",
      "description": "Article title",
      "minLength": 1,
      "maxLength": 200
    },
    "body": {
      "type": "string",
      "description": "Article body content"
    },
    "author": {
      "type": "string",
      "description": "Author name"
    },
    "publishDate": {
      "type": "string",
      "format": "date-time",
      "description": "Publication date"
    },
    "tags": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Article tags"
    },
    "featuredImage": {
      "type": "string",
      "format": "uri",
      "description": "Featured image URL"
    }
  },
  "required": ["title", "body"]
}
```

Content items of this type must conform to this schema.

## Example Queries

### List Content Types

```graphql theme={null}
query GetContentTypes($search: String, $cursor: String) {
  contentTypes(search: $search, cursor: $cursor, limit: 20) {
    data {
      id
      name
      description
      packageVersion
    }
    pagination {
      cursor
      hasMore
      limit
    }
  }
}
```

### Get Content Type with Schema

```graphql theme={null}
query GetContentType($id: ID!) {
  contentType(id: $id) {
    id
    name
    description
    packageVersion
    schema
    createdAt
    updatedAt
  }
}
```

Response:

```json theme={null}
{
  "data": {
    "contentType": {
      "id": "ct123",
      "name": "Article",
      "description": "Blog articles and news posts",
      "packageVersion": "2.0.0",
      "schema": "{\"type\":\"object\",\"properties\":{\"title\":{\"type\":\"string\"},\"body\":{\"type\":\"string\"}},\"required\":[\"title\",\"body\"]}",
      "createdAt": "2024-01-10T10:00:00Z",
      "updatedAt": "2024-01-15T14:30:00Z"
    }
  }
}
```

## Schema Validation

When creating or updating content, the content data is validated against the content type's schema:

* **Required fields** must be present
* **Type validation** ensures fields match expected types
* **Format validation** checks strings against formats (date-time, uri, email)
* **Constraints** like minLength, maxLength, minimum, maximum are enforced

## Related Types

* [Content](/graphql/types/content) - Content items that use this type
* [Package](/graphql/types/package) - Package version bound to content type
