<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 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'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>

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

Path parameters

app_idstring required

ID of the app whose code to read.

Query parameters

branch_idstring

ID of the branch to work on, as returned by List branches. Omit it to work on the app's main branch.

Request body

querystring required

Text to find, 2 to 200 characters on a single line. It's matched literally.

case_sensitiveboolean

Whether the match respects case.

Example request

{
  "query": "useState("
}

Response

The matching lines, grouped by file.

truncatedboolean required

true when the search stopped at 500 matching lines or 10 seconds, so there can be more matches.

skipped_filesinteger required

Number of files left out of the search because they're over 5 MB or aren't text.

Example response

{
  "files": [
    {
      "matches": [
        {
          "line_number": 12,
          "preview": "  const [count, setCount] = useState(0);"
        }
      ],
      "path": "src/pages/Home.jsx"
    }
  ]
}

Changes