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

# Content

> Query content items with filtering and sorting

## List Content

Fetch a paginated list of content with filtering, sorting, and search.

```graphql theme={null}
query GetContents(
  $typeId: ID
  $tags: [String!]
  $locale: String
  $search: String
  $filter: ContentFilter
  $sort: [SortCriteria!]
  $cursor: String
  $limit: Int
) {
  contents(
    typeId: $typeId
    tags: $tags
    locale: $locale
    search: $search
    filter: $filter
    sort: $sort
    cursor: $cursor
    limit: $limit
  ) {
    data {
      id
      name
      description
      tags
      locale
      updatedAt
    }
    pagination {
      cursor
      hasMore
      limit
    }
  }
}
```

### Parameters

| Parameter | Type             | Default | Description                    |
| --------- | ---------------- | ------- | ------------------------------ |
| `typeId`  | ID               | -       | Filter by content type         |
| `tags`    | \[String!]       | -       | Filter by tags (AND logic)     |
| `locale`  | String           | -       | Filter by locale               |
| `search`  | String           | -       | Search in name and description |
| `filter`  | ContentFilter    | -       | Advanced field filtering       |
| `sort`    | \[SortCriteria!] | -       | Sort criteria                  |
| `cursor`  | String           | null    | Cursor for pagination          |
| `limit`   | Int              | 20      | Items per page                 |

### Filter Example

```graphql theme={null}
query {
  contents(
    typeId: "ct123"
    tags: ["tutorial"]
    locale: "en-US"
    filter: {
      createdAt: { gte: "2024-01-01T00:00:00Z" }
    }
    sort: [{ field: "updatedAt", order: DESC }]
    limit: 20
  ) {
    data {
      id
      name
      tags
      locale
    }
    pagination {
      cursor
      hasMore
    }
  }
}
```

Response:

```json theme={null}
{
  "data": {
    "contents": {
      "data": [
        {
          "id": "cont456",
          "name": "Getting Started Guide",
          "tags": ["tutorial", "beginner"],
          "locale": "en-US"
        }
      ],
      "pagination": {
        "cursor": "eyJsYXN0SWQiOiJjb250NDU2IiwibGFzdFVwZGF0ZWRBdCI6IjIwMjQtMDEtMTVUMTA6MDA6MDBaIn0=",
        "hasMore": false
      }
    }
  }
}
```

## Get Single Content

Fetch a specific content item by ID.

```graphql theme={null}
query GetContent($id: ID!) {
  content(id: $id) {
    id
    name
    description
    compiled
    tags
    locale
    contentType {
      id
      name
      schema
    }
    createdAt
    updatedAt
  }
}
```

### Parameters

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id`      | ID!  | Yes      | Content ID  |

## Get Content with Resolved Package

Include all package data needed to render the content.

```graphql theme={null}
query GetContentResolved($id: ID!) {
  content(id: $id) {
    id
    name
    compiled
    contentType {
      name
      schema
    }
    resolvedPackage {
      package {
        id
        version
        components
        assets
      }
      dependencies {
        id
        version
        components
        assets
      }
    }
  }
}
```

## Get Content with Caching References

For optimal caching, fetch only package IDs and resolve separately.

```graphql theme={null}
query GetContentWithCaching($id: ID!) {
  content(id: $id) {
    id
    name
    compiled
    resolvedRef {
      package
      dependencies
    }
  }
}
```

Response:

```json theme={null}
{
  "data": {
    "content": {
      "id": "cont123",
      "name": "Getting Started",
      "compiled": "const body = () => { ... }",
      "resolvedRef": {
        "package": "abc123def456...",
        "dependencies": ["xyz789ghi012..."]
      }
    }
  }
}
```

Use [resolvedPackageData](/graphql/queries/package-data) to fetch the actual package content by ID.

## Content Fields

| Field                  | Type                | Description                   |
| ---------------------- | ------------------- | ----------------------------- |
| `id`                   | ID!                 | Unique identifier             |
| `typeId`               | ID!                 | Content type ID               |
| `packageVersion`       | String!             | Package version               |
| `name`                 | String!             | Content name                  |
| `description`          | String!             | Content description           |
| `content`              | String!             | Content data                  |
| `compiled`             | String!             | Compiled content data         |
| `tags`                 | \[String!]!         | Associated tags               |
| `locale`               | String              | Content locale                |
| `lastPublishedVersion` | Int                 | Last published version number |
| `cdnUrl`               | String              | CDN URL for the content       |
| `contentType`          | ContentType         | Associated content type       |
| `resolvedPackage`      | ResolvedPackage     | Full package data             |
| `resolvedRef`          | ResolvedPackageRef! | Package IDs for caching       |
| `createdAt`            | DateTime!           | Creation timestamp            |
| `updatedAt`            | DateTime!           | Last update timestamp         |
