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

# Search Content

> Search content using advanced filters

Search content using filters. Supports both GET (query parameters) and POST (request body) methods.

## GET Method

<div className="mb-4">
  <span className="bg-blue-100 text-blue-800 px-2 py-1 rounded text-sm font-medium">GET</span>
  <code className="ml-2">/app/v1/organizations/{organizationId}/projects/{projectId}/content/search</code>
</div>

Use query parameters for simple searches.

***

## POST Method

<div className="mb-4">
  <span className="bg-green-100 text-green-800 px-2 py-1 rounded text-sm font-medium">POST</span>
  <code className="ml-2">/app/v1/organizations/{organizationId}/projects/{projectId}/content/search</code>
</div>

Use request body for advanced filtering with operators.

## Path Parameters

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

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

## Query Parameters (GET)

<ParamField query="status" type="string">
  Filter by status: `draft`, `published`, `modified`, `deleted`
</ParamField>

<ParamField query="name" type="string">
  Filter by name (minimum 3 characters)
</ParamField>

<ParamField query="type" type="string">
  Filter by content type ID
</ParamField>

<ParamField query="isTemplate" type="string">
  Filter templates: `true` or `false`
</ParamField>

<ParamField query="tag" type="string | string[]">
  Filter by tag(s)
</ParamField>

<ParamField query="from" type="string">
  Filter by updated date (from)
</ParamField>

<ParamField query="to" type="string">
  Filter by updated date (to)
</ParamField>

<ParamField query="query" type="string">
  Natural language query for semantic search (1-500 characters)
</ParamField>

<ParamField query="sort" type="string">
  Sort field and order (e.g., `updatedAt:desc`)
</ParamField>

<ParamField query="page" type="string">
  Page number
</ParamField>

<ParamField query="limit" type="string">
  Items per page (max 100)
</ParamField>

## Request Body (POST)

<ParamField body="filter" type="object">
  Filter conditions
</ParamField>

<ParamField body="filter.status" type="object">
  Status filter with operators: `eq`, `neq`, `in`
</ParamField>

<ParamField body="filter.name" type="object">
  Name filter with operators: `eq`, `neq`, `like`
</ParamField>

<ParamField body="filter.typeId" type="object">
  Content type filter with operators: `eq`, `neq`, `in`
</ParamField>

<ParamField body="filter.isTemplate" type="object">
  Template filter with operators: `eq`, `neq`
</ParamField>

<ParamField body="filter.tags" type="object">
  Tags filter with operators: `eq`, `any`, `all`
</ParamField>

<ParamField body="filter.updatedAt" type="object">
  Updated date filter with operators: `lt`, `lte`, `gt`, `gte`
</ParamField>

<ParamField body="filter.hasPublishedVersion" type="object">
  Filter by whether content has a published version: `eq`
</ParamField>

<ParamField body="sort" type="array">
  Sort configuration array
</ParamField>

<ParamField body="pagination" type="object">
  Pagination options with `page`, `limit`
</ParamField>

<ParamField body="query" type="string">
  Natural language query for semantic search
</ParamField>

### Example Request (POST)

```json theme={null}
{
  "filter": {
    "status": { "eq": "published" },
    "typeId": { "in": ["ct-article", "ct-blog"] },
    "tags": { "any": ["featured", "trending"] }
  },
  "sort": [
    { "field": "updatedAt", "order": "desc" }
  ],
  "pagination": {
    "limit": 20,
    "page": 1
  }
}
```

## Response

```json theme={null}
{
  "data": [
    {
      "id": "cont123",
      "name": "Getting Started Guide",
      "typeId": "ct-article",
      "status": "published",
      "version": 3,
      "lastPublishedVersion": 3,
      "content": { ... },
      "tags": ["featured", "guide"],
      "isTemplate": false,
      "metadata": { ... },
      "createdAt": "2024-03-20T10:00:00Z",
      "updatedAt": "2024-03-22T10:00:00Z"
    }
  ],
  "pagination": {
    "lastKey": "eyJwayI6Ik9SR..."
  }
}
```

## Filter Operators

| Operator | Description                 | Example                                    |
| -------- | --------------------------- | ------------------------------------------ |
| `eq`     | Equals                      | `{"status": {"eq": "published"}}`          |
| `neq`    | Not equals                  | `{"status": {"neq": "deleted"}}`           |
| `like`   | Contains (case-insensitive) | `{"name": {"like": "guide"}}`              |
| `in`     | In array                    | `{"typeId": {"in": ["ct1", "ct2"]}}`       |
| `any`    | Has any of tags             | `{"tags": {"any": ["featured"]}}`          |
| `all`    | Has all of tags             | `{"tags": {"all": ["featured", "guide"]}}` |
| `lt`     | Less than                   | `{"updatedAt": {"lt": "2024-03-22"}}`      |
| `lte`    | Less than or equal          | `{"updatedAt": {"lte": "2024-03-22"}}`     |
| `gt`     | Greater than                | `{"updatedAt": {"gt": "2024-03-20"}}`      |
| `gte`    | Greater than or equal       | `{"updatedAt": {"gte": "2024-03-20"}}`     |

## Code Examples

<CodeGroup>
  ```bash cURL (GET) theme={null}
  curl -X GET "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/search?status=published&limit=20" \
    -H "Authorization: Bearer YOUR_JWT"
  ```

  ```bash cURL (POST) theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/search" \
    -H "Authorization: Bearer YOUR_JWT" \
    -H "Content-Type: application/json" \
    -d '{
      "filter": {
        "status": {"eq": "published"},
        "tags": {"any": ["featured"]}
      },
      "pagination": {"limit": 20}
    }'
  ```

  ```javascript JavaScript theme={null}
  // GET method
  const searchParams = new URLSearchParams({
    status: 'published',
    tag: 'featured',
    limit: '20'
  });

  const response = await fetch(
    `https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/search?${searchParams}`,
    {
      headers: {
        'Authorization': 'Bearer YOUR_JWT'
      }
    }
  );

  // POST method for complex queries
  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/content/search',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_JWT',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        filter: {
          status: { eq: 'published' },
          tags: { any: ['featured'] }
        },
        pagination: { limit: 20 }
      })
    }
  );

  const { data, pagination } = await response.json();
  ```
</CodeGroup>
