---
title: "Search within a repo session using rg-style lexical matching over the live session workspace."
method: GET
path: "/v1/repo-sessions/{session_id}/search"
tags: ["repos"]
---

# Search within a repo session using rg-style lexical matching over the live session workspace.

`GET /v1/repo-sessions/{session_id}/search`

## Request

- Base URL: `https://api.kody.codes`
- URL: `https://api.kody.codes/v1/repo-sessions/{session_id}/search`
- Auth: HTTP bearer

Search within a repo session using rg-style lexical matching over the live session workspace. This is scoped code/file search, not semantic retrieval. When mode=regex, patterns must be valid JavaScript RegExp syntax (not Python/PCRE inline flags).

Org permission: `package:read`.

## Path parameters

- `session_id` string, required: Active repo session id from repoOpenSession or repoListSessions.

## Query parameters

- `pattern` string, required: Literal text or regex to search for. In regex mode this must be valid JavaScript RegExp syntax (no Python/PCRE inline flags such as (?s) or (?i)).
- `mode` 'literal' | 'regex': Search mode. Defaults to literal. regex uses JavaScript RegExp syntax.
- `glob` string: Optional glob filter for files to search.
- `path` string: Optional repo-relative subpath to scope the search to.
- `case_sensitive` boolean: Whether matching should be case-sensitive.
- `before` integer: Lines of context to include before each match.
- `after` integer: Lines of context to include after each match.
- `limit` integer: Maximum number of matches to return before truncation.
- `output_mode` 'content' | 'files': Whether to return match content or just files with matches.

## Response `200`

Success.

- object
  - `files` object[], required
    - `path` string, required
    - `matches` object[], required
      - `line` integer, required
      - `column` integer, required
      - `match` string, required
      - `lineText` string, required
      - `beforeLines` string[], required
      - `afterLines` string[], required
  - `total_files` integer, required
  - `total_matches` integer, required
  - `output_mode` 'content' | 'files', required
  - `truncated` boolean, required

## Other responses

- `400`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `401`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `403`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `404`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `409`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `413`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `429`: Too many requests (edge IP/token limit) or an entitlement / plan-cap limit. Wait at least `Retry-After` seconds before retrying.
- `500`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `503`: Error envelope `{ "error": { "code", "message", "details"? } }`.
- `default`: Error envelope `{ "error": { "code", "message", "details"? } }`.

---

[API](https://skmtc.dev/kody/apis/kody-api.md) · [All operations](https://skmtc.dev/kody/apis/kody-api/llms.txt) · [OpenAPI document](https://skmtc.dev/kody/apis/kody-api/revisions/705f4f022728?raw)
