Overview
Sandbox search provisions an isolated runtime, clones a public Git repository (GitHub, GitLab, or Bitbucket), and runs a read-only agent that answers your question using local files only (no web fetch, no repository edits). When the job finishes, the sandbox is destroyed. Use sandbox search when you want a deep, file-grounded answer against a specific ref without adding the repo as an indexed source. For multi-source or already-indexed content, preferPOST /search instead.
When to use what
Authentication
Same as the rest of the API:Authorization: Bearer YOUR_API_KEY. See the API Guide.
Endpoints
Base URL:
https://apigcp.trynia.ai/v2 (see API Guide).
Request body (POST /sandbox/search)
JSON response
By default the handler returns JSON when the client does not ask for SSE andstream is not true. The payload describes the job, sandbox lifecycle, optional git cache metadata, and (when complete) the execution result:
workspaceKind— e.g. git repository workspace.job—id,status,query,createdAt, optionalstartedAt/completedAt.sandbox— Sandbox identifiers, runtime status, workspace path, preparation and deletion timestamps when applicable.repository— Present for git workspaces when cache metadata exists (canonical URL, ref, commit SHA, volume hints, etc.).result— When the job completed successfully:answer,rawOutput,command,exitCode,workspacePath,volumeName,cacheSubpath.error— When the job failed:message, optionalname,code,stack,details, etc.
completed, failed, or cancelled. Poll GET /sandbox/jobs/{jobId} with the job.id from the response if you need updates from another process.
Streaming
The API returns Server-Sent Events when either:- the client sends
Accept: text/event-stream, or - the JSON body includes
"stream": true.
"stream": false" to force a JSON response even if Accept prefers SSE.
SSE payloads are JSON objects per event, one per data: line. Event type values include:
The server may emit
: keep-alive comment lines every few seconds to keep connections open.
Closing the HTTP client cancels the in-flight request; the pipeline treats that as cancellation where supported.
Examples
Search (JSON)
Search (SSE)
Accept and set "stream": true in the body. If you send a full URL and provider, the URL takes precedence.
Poll job by id
CLI usage
The Nia CLI exposes sandbox search asnia search sandbox. It streams progress by default and formats output for interactive terminals.
Flags
Examples
Search a repository (streams by default):jq:
Errors
Common API error codes for this module:
See API Guide — Error handling for HTTP status conventions.

