---
title: "Search app code"
method: POST
path: "/api/apps/{app_id}/code/search"
---

# Search app code

`POST /api/apps/{app_id}/code/search`

## Request

- Base URL: `https://app.base44.com`
- URL: `https://app.base44.com/api/apps/{app_id}/code/search`
- Auth: HTTP bearer

<Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>

Finds the lines in the app's source files that contain some text, the way the app editor's search does.

The text is matched literally, not as a pattern, and the match ignores case unless you set `case_sensitive`. Each result lists the matching lines of one file with their line numbers and up to 300 characters of the line around the match.

Search covers the files [List app code files](/api-reference/list-app-code-files) returns for the same `branch_id`. Files over 5 MB and files that aren't text are skipped and counted in `skipped_files`. A search stops after 500 matching lines or 10 seconds, and `truncated` is then `true`, so narrow the text if you need every match.

Reads come from the app's live sandbox, the same files the app editor shows, including changes that haven't been published yet. If no sandbox is running, the call starts one, so the first call after a quiet period takes noticeably longer than later ones.

Set `branch_id` to read a [branch](/developers/references/app-management/get-started/concepts#branches)'s files instead of main's. Each branch has its own sandbox, so the first read of a branch also takes longer. A merged branch can't be read: the call returns a 409. On an app imported from GitHub, reading a merged branch can instead return the files as they were when the branch was created, so don't rely on it there.

This is limited to 60 requests per minute per app for each workspace's personal API keys, so every key in a workspace shares one allowance. Some workspaces have a different limit.

<Note>This endpoint accepts a personal API key belonging to a user with editor access to the app. A read-only key is refused even though this endpoint only reads, and workspace API keys are not accepted.</Note>

## Path parameters

- `app_id` string, required: ID of the app whose code to read.

## Query parameters

- `branch_id` string: ID of the branch to work on, as returned by [List branches](/api-reference/list-branches). Omit it to work on the app's main branch.

## Request body

- SearchFiles: The text to find.
  - `query` string, required: Text to find, 2 to 200 characters on a single line. It's matched literally.
  - `case_sensitive` boolean: Whether the match respects case.

## Response `200`

The matching lines, grouped by file.

- SearchResults: The files that contain the text.
  - `files` SearchFileResult[], required: Each file with at least one match.
    - `path` string, required: Path of the file, relative to the app root.
    - `matches` SearchMatch[], required: The file's matching lines, in order.
      - `line_number` integer, required: Number of the line in the file, starting at 1.
      - `preview` string, required: The line, cut to at most 300 characters around the match.
  - `truncated` boolean, required: `true` when the search stopped at 500 matching lines or 10 seconds, so there can be more matches.
  - `skipped_files` integer, required: Number of files left out of the search because they're over 5 MB or aren't text.

## Other responses

- `401`: Missing or invalid credentials.
- `403`: You don't have editor access to this app, your API key is read-only, or you used a workspace API key.
- `404`: App not found, or no branch you can see has this `branch_id`.
- `409`: The branch in `branch_id` was merged (`extra_data.reason` is `branch_not_active`).
- `422`: `query` is missing, shorter than 2 or longer than 200 characters, only whitespace, or spans more than one line.
- `429`: Rate limit exceeded. The base limit is 60 requests per minute. See [Rate limits](/developers/references/apps-api/get-started/rate-limits) for the multiplier your plan gets.

## Changes

- **2026-10-21** `c23775445de2`: 2 info
  - added the new optional `query` request parameter `branch_id`
  - added the non-success response with the status `409`
- **2026-10-11** `80287813ab84`: 1 info
  - the endpoint scheme security `PersonalAccessTokenAuth` was added to the API
- **2026-10-10** `fc604cdcc3a2`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/idealspot/apis/base44-app-management-api/changes/api/apps/:app_id/code/search/post.md)

---

[API](https://skmtc.dev/idealspot/apis/base44-app-management-api.md) - [All operations](https://skmtc.dev/idealspot/apis/base44-app-management-api/llms.txt) - [OpenAPI document](https://skmtc.dev/idealspot/apis/base44-app-management-api/revisions/b5b4ebd82a1e?raw)
