> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hiloop.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Post v1runs

> Start a new run: a new tree root, or a run that continues an existing tree when parent_run_id
 is set. The run begins executing immediately (status running, started_at stamped); record its
 outcome with CompleteRun.

 Retries are safe with an `idempotency-key` header: repeating the request with the same key
 returns the original run (in whatever state it has reached) instead of starting a second one,
 and reusing a key with a different request fails with `idempotency_conflict`. Without a key,
 every call starts a fresh run.



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/runs
openapi: 3.0.3
info:
  title: ''
  version: 0.0.1
servers: []
security:
  - bearerAuth: []
tags:
  - name: AnnotationSchemaService
    description: |-
      Org-scoped annotation-schema registry CRUD.

       Every RPC scopes to the caller's organization, derived from their credential; a request with no org
       scope is UNAUTHENTICATED. Registration runs a backward-compatibility check against the latest live
       version and REJECTS an incompatible change (FAILED_PRECONDITION). These endpoints are what the
       generated OpenAPI, SDKs, and CLI consume.
  - name: AnnotationService
    description: >-
      Typed annotation surface over the telemetry store: the annotate writes
      plus the one served
       annotation read every consumer shares. Organization scoping is enforced from request identity,
       not from the request body. Ingest of ordinary telemetry lives in TelemetryIngestService
       (telemetry.proto); the general event read surface lives in TelemetryQueryService (query.proto).
  - name: FeedbackService
    description: |-
      Product-feedback intake.

       The organization is derived from the caller's credential, never from the request body; a request with
       no org scope is UNAUTHENTICATED. Any org-scoped caller — a user session, a service key, or
       a sandbox-scoped credential — may submit feedback.
  - name: IdentityService
    description: Identity/health surface for the control-plane API.
  - name: MetaService
    description: Unauthenticated discovery surface for client-visible sibling service URLs.
  - name: ProjectService
    description: |-
      Org-scoped project CRUD.

       Every RPC scopes to the caller's organization, derived from their credential; a request with no org
       scope is UNAUTHENTICATED. These endpoints are what the generated OpenAPI, SDKs, and CLI consume.
  - name: RunService
    description: |-
      Org-scoped access to runs and their lineage.

       Every RPC scopes to the caller's organization, derived from their credential; a request with no org
       scope is UNAUTHENTICATED. These endpoints are what the generated OpenAPI, SDKs, and CLI consume.
  - name: SandboxService
    description: |-
      Org-scoped sandbox runtime API.

       The organization comes from the caller's credential. Org-scoped human and service credentials may
       use every route in their organization. A sandbox-scoped, lineage-confined credential may read its own
       sandbox and snapshot lineage and may exec or snapshot only that sandbox; it may not create,
       update, or delete sandboxes, delete snapshots, or exec into a sibling sandbox.

       State and verb rules are closed. Get and list serve every visible state. Failed and terminated
       rows remain available through GetSandbox for a server retention window, then return 404
       not_found. Update to stopped is accepted from ready or running and is idempotent from stopped;
       update to running wakes stopped and is idempotent from running. A wake racing an in-flight stop
       waits for stop to win before wake proceeds. Workspace growth is accepted only for a stable
       durable sandbox and is idempotent for the same target; lifecycle mutation and growth never
       overlap. An undurable snapshot, including one whose request timed out, fences growth and cannot
       be deleted because its seal may still publish a late receipt; repeat the same snapshot request
       (and idempotency key, if supplied) to resolve its outcome. Delete is accepted once for a
       nonterminal sandbox; a second delete returns 404
       not_found. Exec requires running and never wakes implicitly; any
       other non-quarantined state returns 409 sandbox_not_running. Snapshot is accepted from ready,
       running, or stopped; other non-quarantined states return 409 sandbox_not_ready. Every mutating
       verb on a quarantined sandbox returns 409 quarantined. A concurrent snapshot returns 409
       snapshot_in_progress.

       Every error uses the flat {code, message, request_id} envelope. Stable route codes are
       invalid_argument (400), not_found (404), idempotency_conflict, name_conflict, sandbox_not_running,
       sandbox_not_ready, quarantined, snapshot_in_progress, snapshot_in_use, and
       snapshot_not_restorable, workspace_shrink_unsupported, and operation_conflict (409),
       unsupported_capability (422), quota_exceeded (429; details.quota.metric names the limit —
       sandboxes.running, sandboxes.total, or sandboxes.workspace_capacity_gib), and unavailable
       (503). Exec transport failures use spawn_failed or sandbox_stopped and discard any partial
       output; both mean the command did not run. A command that WAS dispatched but whose outcome
       could not be read is never an error: it returns 200 with the indeterminate outcome, alongside
       whatever partial output was collected, as a timeout does.

       Capability-receipt observation has no route in this version and is explicitly NOTIMPL; it is not
       inferred from Sandbox fields.
  - name: SecretService
    description: |-
      Org-scoped sandbox-secret management.

       Every RPC scopes to the caller's organization, derived from their credential; a request with no org
       scope is UNAUTHENTICATED. Create/revoke/rotate require an owner/admin in the organization; these
       management RPCs never return the secret value.
  - name: TelemetryViewService
    description: >-
      Typed data-view surface over the telemetry store. Organization scoping is
      enforced from request
       identity, not from the request body. A data view's spec is the engine's `DataViewSpec` — a raw
       `Sql` `SELECT` — re-validated and compiled fresh on every run under the forced-organization
       safe-SQL gateway. The untrusted raw-SQL escape hatch is a separate `POST /v1/telemetry/sql`
       endpoint, intentionally kept off this typed wire.
  - name: UsageService
    description: Org-scoped product quota reads.
  - name: VolumeService
    description: |-
      Org-scoped volume CRUD.

       Every RPC scopes to the caller's organization, derived from their credential; a request with no org
       scope is UNAUTHENTICATED. These endpoints are what the generated OpenAPI, SDKs, and CLI consume.
  - name: WorkloadService
    description: |-
      Org-scoped workload registry management.

       The organization is derived from the caller's credential; a request with no org scope is
       UNAUTHENTICATED. Registering and reading workloads is open to any org member. Setting a launch
       ACL and deleting a workload are operator actions and require an owner or admin in the organization. A
       sandbox-scoped credential may not register, delete, or manage workloads.
paths:
  /v1/runs:
    post:
      tags:
        - RunService
      description: >-
        Start a new run: a new tree root, or a run that continues an existing
        tree when parent_run_id
         is set. The run begins executing immediately (status running, started_at stamped); record its
         outcome with CompleteRun.

         Retries are safe with an `idempotency-key` header: repeating the request with the same key
         returns the original run (in whatever state it has reached) instead of starting a second one,
         and reusing a key with a different request fails with `idempotency_conflict`. Without a key,
         every call starts a fresh run.
      operationId: RunService_StartRun
      parameters:
        - name: idempotency-key
          in: header
          required: false
          description: >-
            Optional idempotency key for this mutation. The server records the
            result from execution start. For at least 72 hours, reuse by the
            same organization and route replays the original status and body. A
            matching request still in flight or reuse for different input
            returns 409 idempotency_conflict. Keys are scoped by organization
            and route and contain 1-255 characters.
          schema:
            type: string
            minLength: 1
            maxLength: 255
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StartRunRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StartRunResponse'
        '429':
          $ref: '#/components/responses/RateLimited'
        default:
          $ref: '#/components/responses/Error'
components:
  schemas:
    StartRunRequest:
      type: object
      properties:
        project_id:
          type: string
          description: The project the new run belongs to.
        parent_run_id:
          type: string
          description: >-
            Optional parent run to continue the tree from. Empty starts a new
            tree root.
        label:
          type: string
          description: An optional human-readable label.
        execute_as_workload:
          type: string
          description: >-
            Optional registered workload name to run as. When set, the run is
            attributed to that workload
             (the caller must hold launch rights on it and the name must be registered); when empty, the run
             executes as the caller's own identity. The executing identity is always declared here, never
             inferred from the command.
    StartRunResponse:
      type: object
      properties:
        run:
          allOf:
            - $ref: '#/components/schemas/Run'
          description: The newly started run, with its lineage fields resolved.
    Run:
      type: object
      properties:
        id:
          type: string
          description: The run id (a client-supplied ULID, shared with telemetry).
        project_id:
          type: string
          description: The project the run belongs to.
        label:
          type: string
          description: An optional human-readable label.
        status:
          type: string
          description: >-
            The run lifecycle status: pending, running, succeeded, failed, or
            canceled.
        created_by:
          type: string
          description: >-
            The stable id of the principal that created the run — the API key
            (or user) that performed the
             start, recorded server-side. Empty when unrecorded.
        started_at:
          type: string
          description: >-
            When the run started executing (RFC 3339), empty if it has not
            started.
        ended_at:
          type: string
          description: When the run finished (RFC 3339), empty if it is still in flight.
        created_at:
          type: string
          description: When the run record was created (RFC 3339).
        parent_run_id:
          type: string
          description: The run this run continued from. Empty for a tree root.
        root_run_id:
          type: string
          description: >-
            The root of this run's tree (equal to id for a root). Lets the whole
            tree resolve in one
             indexed lookup.
        lineage_path:
          type: string
          description: >-
            The materialized path of run ids from the root to this run, as a
            dotted label (e.g.
             "root_ulid.child_ulid"). Sorts in creation order and addresses the subtree by prefix.
        last_activity_at:
          type: string
          description: >-
            When the run last showed a liveness signal (RFC 3339): the time of
            its most recent telemetry
             event, or started_at for a run that has emitted no events yet. Derived at read time, and only
             for a `running` run. Empty for every other run, and empty when the signal is temporarily
             unavailable.
        stale:
          type: boolean
          description: >-
            True when last_activity_at is older than the staleness window (15
            minutes): the run still
             reads `running` — no terminal state is ever recorded on the creator's behalf — but its creator
             has gone quiet, so readers should render it as `running (stale)`. Always false when
             last_activity_at is empty.
        executing_principal:
          type: string
          description: >-
            The stable id of the identity this run executes AS: the registered
            workload's id when the
             launch declared one, otherwise the launcher's own principal id (matching created_by). Empty on
             runs that predate executing-identity recording.
        executing_kind:
          type: string
          description: >-
            The executing identity's kind: `user`, `service_account`, or
            `workload`. Empty on runs that
             predate executing-identity recording.
      description: >-
        A run record (the subset the API returns). Intentionally carries no cost
        or spend roll-up: the
         product is generic and does not surface cost by default.
    ErrorBody:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Stable machine-readable error code in snake_case.
        message:
          type: string
          description: Human-readable description; clients must not parse it.
        details:
          $ref: '#/components/schemas/ErrorDetails'
        request_id:
          type: string
          description: Correlation id present on server faults.
    ErrorDetails:
      type: object
      properties:
        quota:
          $ref: '#/components/schemas/QuotaDetails'
    QuotaDetails:
      type: object
      required:
        - metric
        - limit
      properties:
        metric:
          type: string
        limit:
          type: integer
          format: uint64
        current:
          type: integer
          format: uint64
        reserved:
          type: integer
          format: uint64
        retry_after_seconds:
          type: integer
          format: uint64
  responses:
    RateLimited:
      description: A quota or rate-limit rejection.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
            format: uint64
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
    Error:
      description: An error using the standard hiloop error envelope.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
            format: uint64
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Hiloop API key sent as an HTTP Bearer token.

````