> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hydradb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Inspect Context

> Inspect the content of a knowledge or memory source.

export const Field = ({name, type, required, recommended}) => {
  const label = required ? 'required' : recommended ? 'recommended' : null;
  const typeLabel = typeof type === 'string' ? type : null;
  const ariaParts = [name, typeLabel && `${typeLabel}`, label].filter(Boolean);
  return <span aria-label={ariaParts.join(', ')} className={label ? 'field-wrap has-field-tip' : 'field-wrap'} style={{
    position: 'relative',
    cursor: label ? 'default' : undefined
  }} tabIndex={label ? 0 : undefined}>
      <span className="field-name-row">
        <code>{name}</code>
        {required && <span className="field-req"> *</span>}
        {recommended && <span className="field-rec"> ●</span>}
      </span>
      {type && <span className="field-type">{type}</span>}
      {label && <span className="field-tip" role="tooltip">
          {label}
        </span>}
    </span>;
};

Specify the `id` of the knowledge or memory you want to retrieve.

<RequestExample>
  ```python Python SDK theme={"dark"}
  file = client.context.inspect(
      id="policy_main",
      database="acme_corp",
      mode="both",
      expiry_seconds=3600,
  )
  ```

  ```typescript TypeScript SDK theme={"dark"}
  const file = await client.context.inspect({
    id: "policy_main",
    database: "acme_corp",
    mode: "both",
    expirySeconds: 3600,
  });
  ```

  ```bash cURL theme={"dark"}
  curl -G 'https://api.hydradb.com/context/inspect' \
    -H "Authorization: Bearer <your_api_key>" \
    -H "API-Version: 2" \
    --data-urlencode "id=policy_main" \
    --data-urlencode "database=acme_corp" \
    --data-urlencode "mode=both" \
    --data-urlencode "expiry_seconds=3600"
  ```
</RequestExample>

## Query parameters

| Name                                                                                    | Description                                                                                                                                                        |
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <Field name="id" type="string" required />                                              | ID of the source to fetch.                                                                                                                                         |
| <Field name="database" type="string" required />                                        | Owning database. Formerly `tenant_id`; the `tenant_id` alias is still accepted (deprecated).                                                                       |
| <Field name="collection" type="string or null" />                                       | Collection scope. If omitted, the default collection is used. Formerly `sub_tenant_id`; the `sub_tenant_id` alias is still accepted (deprecated). (default=`null`) |
| <Field name="mode" type="&#x22;content&#x22; or &#x22;url&#x22; or &#x22;both&#x22;" /> | What to return. See [Fetch modes](#fetch-modes). (default=`"both"`)                                                                                                |
| <Field name="expiry_seconds" type="integer" />                                          | TTL of the presigned URL (when `mode` includes `url`). Range `60 ≤ x ≤ 604800` (7 days). (default=`3600`)                                                          |

## Fetch modes

| Mode              | Returns                                                                                                                                                         | Use when                                                                                                     |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `content`         | The payload in `content_base64` (base64-encoded); `content` is `null` in this mode. Decode `content_base64` to recover the parsed text or the raw binary bytes. | You want to render the content in-app or feed it to another model.                                           |
| `url`             | Presigned URL (`presigned_url`) valid for `expiry_seconds`.                                                                                                     | You want a client or a service to download the original file directly without proxying through your backend. |
| `both`*(default)* | Text **and** presigned URL.                                                                                                                                     | UI flows that show parsed text inline plus a "Download original" link.                                       |

Regardless of `mode`, the response also includes `inferred_content` when available  -  the model-derived text for the source (for memories, the inferred memory statement; for knowledge, derived/normalized content). It is `null` when the source has no inferred content.

<Info>
  Use `mode=url` when you need the original file. Use `mode=content` when you only need extracted text for display, summarization, or prompting.
</Info>

### Mode examples

<Tabs>
  <Tab title="mode=content">
    ```json theme={"dark"}
    {
      "success": true,
      "data": {
        "success": true,
        "id": "policy_main",
        "content": null,
        "content_base64": "U2VjdGlvbiAxLiBBdXRoZW50aWNhdGlvbiBwb2xpY2llcy4uLg==",
        "inferred_content": null,
        "presigned_url": null,
        "content_type": "application/pdf",
        "size_bytes": 1842233,
        "message": "File fetched successfully"
      },
      "error": null,
      "meta": {
        "request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
        "latency_ms": 12.3
      }
    }
    ```
  </Tab>

  <Tab title="mode=url">
    ```json theme={"dark"}
    {
      "success": true,
      "data": {
        "success": true,
        "id": "policy_main",
        "content": null,
        "content_base64": null,
        "inferred_content": null,
        "presigned_url": "https://storage.hydradb.com/.../policy_main.pdf?X-Amz-...",
        "content_type": "application/pdf",
        "size_bytes": 1842233,
        "message": "File fetched successfully"
      },
      "error": null,
      "meta": {
        "request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
        "latency_ms": 12.3
      }
    }
    ```
  </Tab>

  <Tab title="mode=both (binary file)">
    ```json theme={"dark"}
    {
      "success": true,
      "data": {
        "success": true,
        "id": "diagram_png",
        "content": null,
        "content_base64": "iVBORw0KGgoAAAANSUhEUgAA...",
        "inferred_content": null,
        "presigned_url": "https://storage.hydradb.com/.../diagram.png?X-Amz-...",
        "content_type": "image/png",
        "size_bytes": 92844,
        "message": "File fetched successfully"
      },
      "error": null,
      "meta": {
        "request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
        "latency_ms": 12.3
      }
    }
    ```
  </Tab>

  <Tab title="Memory source">
    ```json theme={"dark"}
    {
      "success": true,
      "data": {
        "success": true,
        "id": "mem_user_alex_tone",
        "content": "Prefers concise answers and dark mode.",
        "content_base64": null,
        "inferred_content": "User prefers concise answers and dark mode.",
        "presigned_url": null,
        "content_type": "text/plain",
        "size_bytes": null,
        "message": "Memory fetched successfully"
      },
      "error": null,
      "meta": {
        "request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
        "latency_ms": 12.3
      }
    }
    ```
  </Tab>
</Tabs>

<ResponseExample>
  ```json Success theme={"dark"}
  {
    "success": true,
    "data": {
      "success": true,
      "id": "policy_main",
      "content": "Section 1. Authentication policies...",
      "content_base64": null,
      "inferred_content": null,
      "presigned_url": "https://storage.hydradb.com/.../policy_main.pdf?X-Amz-...",
      "content_type": "application/pdf",
      "size_bytes": 1842233,
      "message": "File fetched successfully"
    },
    "error": null,
    "meta": {
      "request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
      "latency_ms": 12.3
    }
  }
  ```

  ```json Failure theme={"dark"}
  {
    "success": false,
    "data": null,
    "error": {
      "code": "SOURCE_NOT_FOUND",
      "message": "Source not found"
    },
    "meta": {
      "request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
      "latency_ms": 4.8
    }
  }
  ```
</ResponseExample>

```json For a binary file theme={"dark"}
{
  "success": true,
  "data": {
    "success": true,
    "id": "diagram_png",
    "content": null,
    "content_base64": "iVBORw0KGgoAAAANSUhEUgAA...",
    "inferred_content": null,
    "presigned_url": "https://storage.hydradb.com/.../diagram.png?X-Amz-...",
    "content_type": "image/png",
    "size_bytes": 92844,
    "message": "File fetched successfully"
  },
  "error": null,
  "meta": {
    "request_id": "9d13aef4-02f4-4e73-8c62-4c2601d04f9d",
    "latency_ms": 12.3
  }
}
```

## Behavior notes

<Info>
  **Text vs binary handling.** In `mode=both`, text-parseable sources (PDF, DOCX, MD, TXT) populate `content` with parsed text while non-text/binary files come back in `content_base64`; check both fields when handling unknown content types. In `mode=content`, the payload is always returned base64-encoded in `content_base64` and `content` is `null` - decode `content_base64` to recover the text or bytes.
</Info>

* **`inferred_content`:** Alongside the raw `content`, the response carries `inferred_content`  -  the model-derived text for the source. For **memories** this is the inferred memory statement (e.g. `"User prefers concise answers and dark mode."`); for **knowledge** sources it is typically `null` unless derived content exists. It is returned for every `mode`.

* **Recently ingested sources:** Fetching immediately after ingestion may return a record before the parsed text is ready. For reliable reads, use [Ingestion Status](/api-reference/v2/endpoint/source-status) first.

* **Presigned URL TTL:** The URL is valid only for `expiry_seconds`. Anyone with the URL can download the file during that window, so treat it as a short-lived secret.

* **Memory items:** Fetching a memory's `id` returns its raw text content. There are no presigned URLs for memory items  -  `mode=url` and `mode=both` return `presigned_url: null`.

<div className="api-before-related-resources" />


## OpenAPI

````yaml api-reference/v2/openapi.json GET /context/inspect
openapi: 3.1.0
info:
  contact:
    email: support@hydradb.com
    name: HydraDB Support
  description: >-
    HydraDB Application API — knowledge ingestion, search, and memory
    management.
  license:
    name: Proprietary
  title: HydraDB Application API
  version: 0.1.0
servers:
  - description: Production server
    url: https://api.hydradb.com
security: []
externalDocs:
  description: ''
  url: ''
paths:
  /context/inspect:
    get:
      tags:
        - context
      summary: Fetch document content
      description: >-
        Fetch a previously ingested source's content, inferred content, and a
        downloadable URL.
      parameters:
        - description: Source ID
          in: query
          name: id
          required: true
          schema:
            example: HydraDoc1234
            type: string
        - description: Database (canonical name for the tenant scope)
          in: query
          name: database
          required: true
          schema:
            example: acme_corp
            type: string
        - description: Collection (canonical name for the sub-tenant scope)
          in: query
          name: collection
          schema:
            example: team_docs
            type: string
        - description: Deprecated alias for database
          in: query
          name: tenant_id
          schema:
            deprecated: true
            example: tenant_1234
            type: string
            x-deprecated: 'true'
        - description: Deprecated alias for collection
          in: query
          name: sub_tenant_id
          schema:
            deprecated: true
            example: sub_tenant_4567
            type: string
            x-deprecated: 'true'
        - description: Presigned URL expiry in seconds
          in: query
          name: expiry_seconds
          schema:
            default: 3600
            type: integer
        - description: Fetch mode
          in: query
          name: mode
          schema:
            example: thinking
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/handler.Envelope-fetch_V2SourceFetchResponse
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/handler.ErrorResponse'
          description: Bad Request
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/handler.ErrorResponse'
          description: Not Found
      security:
        - BearerAuth: []
components:
  schemas:
    handler.Envelope-fetch_V2SourceFetchResponse:
      properties:
        data:
          $ref: '#/components/schemas/fetch.V2SourceFetchResponse'
          example:
            content: |-
              # Q4 Report

              Revenue grew 23% quarter over quarter.
            content_type: application/pdf
            error: ''
            id: HydraDoc1234
            inferred_content: 'Summary: Q4 revenue rose 23% QoQ, driven by enterprise expansion.'
            message: Success
            presigned_url: https://storage.hydradb.com/sources/HydraDoc1234?sig=...
            size_bytes: 20480
            success: true
        error:
          $ref: '#/components/schemas/handler.apiError'
          description: Error message, empty string on success.
          example:
            code: DATABASE_NOT_FOUND
            message: Database not found
        meta:
          $ref: '#/components/schemas/handler.responseMeta'
          example:
            collection: team_docs
            database: acme_corp
            latency_ms: 12.3
            request_id: 9d13aef4-02f4-4e73-8c62-4c2601d04f9d
            source_type: file
            sub_tenant_id: sub_tenant_4567
            tenant_id: tenant_1234
        success:
          description: Whether the request succeeded.
          example: true
          type: boolean
      type: object
    handler.ErrorResponse:
      properties:
        detail:
          $ref: '#/components/schemas/handler.ErrorDetail'
          description: Structured error detail with code, message, and deprecation hints.
          example:
            deprecated: true
            deprecated_field: tenant_id
            error_code: VALIDATION_ERROR
            message: Request validation failed
            preferred_field: database
            success: true
      type: object
    fetch.V2SourceFetchResponse:
      properties:
        content:
          description: Extracted text content of the source document.
          example: |-
            # Q4 Report

            Revenue grew 23% quarter over quarter.
          type: string
        content_base64:
          description: Base64-encoded binary content, for binary file types.
          type: string
        content_type:
          description: MIME type of the source (e.g. `application/pdf`, `text/plain`).
          example: application/pdf
          type: string
        error:
          description: Error message, empty string on success.
          example: ''
          type: string
        id:
          description: Unique identifier for this resource.
          example: HydraDoc1234
          type: string
        inferred_content:
          description: LLM-generated summary of the source content.
          example: 'Summary: Q4 revenue rose 23% QoQ, driven by enterprise expansion.'
          type: string
        message:
          description: Human-readable result message.
          example: Success
          type: string
        presigned_url:
          description: Time-limited download URL for the original file.
          example: https://storage.hydradb.com/sources/HydraDoc1234?sig=...
          type: string
        size_bytes:
          description: File size in bytes.
          example: 20480
          type: integer
        success:
          description: Whether the request succeeded.
          example: true
          type: boolean
      type: object
    handler.apiError:
      properties:
        code:
          description: Machine-readable error code (e.g. `DATABASE_NOT_FOUND`).
          example: DATABASE_NOT_FOUND
          type: string
        message:
          description: Human-readable description of the error.
          example: Database not found
          type: string
      type: object
    handler.responseMeta:
      properties:
        collection:
          description: >-
            Collection scope. Defaults to the default collection when omitted.
            Formerly `sub_tenant_id`; the `sub_tenant_id` alias is still
            accepted (deprecated).
          example: team_docs
          type: string
        database:
          description: >-
            Owning database. Formerly `tenant_id`; the `tenant_id` alias is
            still accepted (deprecated).
          example: acme_corp
          type: string
        deprecation:
          description: >-
            Deprecation lists any migration nudges that apply to this request —
            the

            caller used a legacy /tenants route, a legacy
            tenant_id/sub_tenant_id field,

            or the deprecated sub_tenant_ids selector. It is a non-breaking
            signal (the

            status code is unchanged); omitempty keeps it absent for
            fully-migrated

            requests. A list so independent deprecations coexist without
            clobbering.
          items:
            $ref: '#/components/schemas/handler.deprecationNotice'
          type: array
          uniqueItems: false
        latency_ms:
          description: Server-side processing time in milliseconds.
          example: 12.3
          type: number
        request_id:
          description: Unique identifier for this request, useful for support and tracing.
          example: 9d13aef4-02f4-4e73-8c62-4c2601d04f9d
          type: string
        source_type:
          description: Type of the parent source (e.g. `file`, `slack`, `notion`).
          example: file
          type: string
        sub_tenant_id:
          deprecated: true
          example: sub_tenant_4567
          type: string
          x-deprecated: 'true'
        tenant_id:
          deprecated: true
          example: tenant_1234
          type: string
          x-deprecated: 'true'
      type: object
    handler.ErrorDetail:
      properties:
        deprecated:
          description: Whether this response concerns a deprecated field or route.
          example: true
          type: boolean
        deprecated_field:
          description: The deprecated field name.
          example: tenant_id
          type: string
        error_code:
          description: Machine-readable error classification code.
          example: VALIDATION_ERROR
          type: string
        message:
          description: Human-readable description of the error.
          example: Request validation failed
          type: string
        preferred_field:
          description: The canonical replacement for the deprecated field.
          example: database
          type: string
        success:
          description: Always false for error responses.
          example: true
          type: boolean
      type: object
    handler.deprecationNotice:
      properties:
        deprecated:
          description: Whether this response concerns a deprecated field or route.
          example: true
          type: boolean
        deprecated_field:
          description: The deprecated field name.
          example: tenant_id
          type: string
        deprecated_since:
          description: API version when the field was deprecated.
          example: 2.0.1
          type: string
        message:
          description: Migration guidance message.
          example: tenant_id is deprecated; use database instead.
          type: string
        preferred_field:
          description: The canonical replacement for the deprecated field.
          example: database
          type: string
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: API key
      description: 'API key sent as a Bearer token: "Bearer prefix.secret"'
      scheme: bearer
      type: http

````