> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.apologist.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.apologist.ai/_mcp/server.

# Search Corpus

POST https://your-agent-domain.com/api/v1/corpus/search
Content-Type: application/json

Performs a semantic search across the agent's corpus of knowledge

Reference: https://docs.apologist.ai/agent-api/api-reference/semantic-search/search-corpus

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: agent-api
  version: 1.0.0
paths:
  /corpus/search:
    post:
      operationId: searchCorpus
      summary: Search Corpus
      description: Performs a semantic search across the agent's corpus of knowledge
      tags:
        - corpus
      parameters:
        - name: x-api-key
          in: header
          description: API key for authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Search results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Corpus_searchCorpus_Response_200'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Invalid request payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CorpusSearchRequest'
servers:
  - url: https://your-agent-domain.com/api/v1
    description: Production server
components:
  schemas:
    CorpusSearchRequestFilters:
      type: object
      properties:
        model:
          type:
            - string
            - 'null'
        ids:
          type:
            - array
            - 'null'
          items:
            type: integer
        types:
          type:
            - array
            - 'null'
          items:
            type: string
        languages:
          type:
            - array
            - 'null'
          items:
            type: string
        collection_ids:
          type:
            - array
            - 'null'
          items:
            type: integer
        contributor_ids:
          type:
            - array
            - 'null'
          items:
            type: integer
        category_ids:
          type:
            - array
            - 'null'
          items:
            type: integer
        classification_ids:
          type:
            - array
            - 'null'
          items:
            type: integer
      title: CorpusSearchRequestFilters
    CorpusSearchRequest:
      type: object
      properties:
        query:
          type: string
        prompt_id:
          type:
            - string
            - 'null'
        limit:
          type:
            - integer
            - 'null'
        filters:
          oneOf:
            - $ref: '#/components/schemas/CorpusSearchRequestFilters'
            - type: 'null'
      required:
        - query
      title: CorpusSearchRequest
    CorpusSearchPostResponsesContentApplicationJsonSchemaResultsItems:
      type: object
      properties: {}
      title: CorpusSearchPostResponsesContentApplicationJsonSchemaResultsItems
    Corpus_searchCorpus_Response_200:
      type: object
      properties:
        results:
          type: array
          items:
            $ref: >-
              #/components/schemas/CorpusSearchPostResponsesContentApplicationJsonSchemaResultsItems
      title: Corpus_searchCorpus_Response_200
    Error:
      type: object
      properties:
        success:
          type: boolean
        errors:
          type: array
          items:
            type: string
      required:
        - success
        - errors
      title: Error
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication

```

## Examples



**Request**

```json
{
  "query": "string"
}
```

**Response**

```json
{
  "results": [
    {}
  ]
}
```

**SDK Code**

```typescript
import { ApologistAgentClient } from "apologist";

async function main() {
    const client = new ApologistAgentClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.corpus.searchCorpus({
        query: "string",
    });
}
main();

```

```python
from apologist import ApologistAgent

client = ApologistAgent(
    api_key="YOUR_API_KEY_HERE",
)

client.corpus.search_corpus(
    query="string",
)

```

```java
package com.example.usage;

import ai.apologist.AgentClient;
import ai.apologist.resources.corpus.requests.CorpusSearchRequest;

public class Example {
    public static void main(String[] args) {
        AgentClient client = AgentClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.corpus().searchCorpus(
            CorpusSearchRequest
                .builder()
                .query("string")
                .build()
        );
    }
}
```

```ruby
require "apologist"

client = Apologist::AgentClient.new(api_key: "YOUR_API_KEY_HERE")

client.corpus.search_corpus(query: "string")

```

```csharp
using Apologist;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new AgentClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Corpus.SearchCorpusAsync(
            new CorpusSearchRequest {
                Query = "string"
            }
        );
    }

}

```

```go
package example

import (
    context "context"

    apgsdkgo "github.com/apologist-project/apg-sdk-go"
    client "github.com/apologist-project/apg-sdk-go/client"
    option "github.com/apologist-project/apg-sdk-go/option"
)

func do() {
    client := client.NewApologistAgentClient(
        option.WithAPIKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &apgsdkgo.CorpusSearchRequest{
        Query: "string",
    }
    client.Corpus.SearchCorpus(
        context.TODO(),
        request,
    )
}

```

```php
<?php

namespace Example;

use Apologist\AgentClient;
use Apologist\Corpus\Requests\CorpusSearchRequest;

$client = new AgentClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->corpus->searchCorpus(
    new CorpusSearchRequest([
        'query' => 'string',
    ]),
);

```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["query": "string"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://your-agent-domain.com/api/v1/corpus/search")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```