Source code

Search source files

Finds text across every source file and returns one entry per matching line with its file name, line, and column. Call this first to locate code, then read only the files it names with websiteSourceCode.files.read. pattern is literal text unless isRegex is set, and matching is line by line, so a pattern cannot span a newline. Narrow with nameGlob and type, ask for surrounding lines with contextLines, or set filesOnly for the cheapest orientation. Results are cursor-paginated over matches.

post/websiteSourceCode/files/search

Request

  • Base URL: https://api.cactal.ai/v1
  • URL: https://api.cactal.ai/v1/websiteSourceCode/files/search
  • Auth: HTTP bearer

Request body

websiteIdstring required
target'head' | 'published'

Version alias to read: head (default) or published.

versioninteger

Explicit source version. Takes precedence over target.

patternstring required

Text to find. Literal unless isRegex is set. Matched line by line, so ^ and $ anchor to line boundaries and a pattern cannot span a newline.

isRegexboolean

Read pattern as a regular expression. JavaScript syntax works, including \b, \d, lookahead, and lazy quantifiers; named capture groups are not supported.

caseSensitiveboolean

Match case exactly. Defaults to true.

nameGlobstring

Only search names matching this glob. * and ? stop at a /; ** crosses them, for example blog/**.

type'page' | 'component' | 'module' | 'server_function' | 'global_css' | 'not_found' | 'website_config' | 'custom_head_start' | 'custom_head_end' | 'custom_body_start' | 'custom_body_end'

Only search files of this type.

filesOnlyboolean

Return one entry per matching file, with no line detail.

contextLinesinteger

Surrounding lines to return on each side of a match (0 to 3). Defaults to 0.

maxMatchesPerFileinteger

Maximum matches from any one file (up to 50). Defaults to 10.

cursorstring

Opaque cursor from the previous page. Pass the returned version too to keep the search pinned.

limitinteger

Maximum matches to return per page. Defaults to 20, maximum 100.

Response

A page of matches for the requested source version.

nextCursorstring nullable required

Opaque cursor for the next page. Pass it as the cursor parameter on the next request. null when this is the last page.

websiteIdstring required

Id of the website.

versioninteger required

Source version that was searched. Pass it as version when continuing.

truncatedboolean

true when a file on this page had more matches than maxMatchesPerFile. Raise it, or narrow the pattern, to see the rest.

Changes

No recorded changes to this operation across all 1 revision of this API.