Skip to main content

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, prefer POST /search instead.
repository can be either a full HTTPS repository URL or owner/repo shorthand. If you use shorthand, the optional provider field defaults to github.

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 and stream 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.
  • jobid, status, query, createdAt, optional startedAt / 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, optional name, code, stack, details, etc.
Statuses evolve from provisioning through running to 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.
Send "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)

Or keep default 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 as nia search sandbox. It streams progress by default and formats output for interactive terminals.

Flags

Examples

Search a repository (streams by default):
Search a specific ref:
Disable streaming for a single JSON response:
Re-fetch a previous job:
Pipe structured output to jq:
On interactive terminals the CLI prints a clean text answer. When piped or redirected, it emits structured JSON — useful for composing with other tools.

Errors

Common API error codes for this module: See API Guide — Error handling for HTTP status conventions.

API reference

Full request/response schemas for these routes live in the API Reference under the Sandbox tag.