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

> ## Agent Instructions
> To set Ambral up in a project, run `npx ambral@latest skill install` in the project's root. It installs Ambral's skill, matched to the CLI's version, and the skill says how to do everything these pages describe with the `ambral` CLI. Prefer it to working from these pages. Never ask anyone for an Ambral API key, and never handle one: the person creates it in the web app and stores it where their app reads its secrets.

# Close an offline run

> Closes the run for `opener`, the opener its open answered (`OfflineRunOpenerNotFound` for another), once the reports in flight are stored. The last of its openers to close completes it, and it takes no more reports until one opens it again by its key; its result is stored on it as it completes. Closing again for an opener that closed, or a completed run, answers as the first close did, so a close can be sent again. An opener that never closes leaves the run open.



## OpenAPI

````yaml /api-reference/report.json post /api/report/v1/runs/{run}/close
openapi: 3.1.0
info:
  title: Ambral Report API
  version: '1'
servers:
  - url: https://app.ambral.ai
security: []
tags:
  - name: Runs
    description: >-
      Offline runs: a suite's scenarios, run and scored by its own harness,
      reported as they finish
paths:
  /api/report/v1/runs/{run}/close:
    post:
      tags:
        - Runs
      summary: Close an offline run
      description: >-
        Closes the run for `opener`, the opener its open answered
        (`OfflineRunOpenerNotFound` for another), once the reports in flight are
        stored. The last of its openers to close completes it, and it takes no
        more reports until one opens it again by its key; its result is stored
        on it as it completes. Closing again for an opener that closed, or a
        completed run, answers as the first close did, so a close can be sent
        again. An opener that never closes leaves the run open.
      operationId: runs.close
      parameters:
        - name: run
          in: path
          schema:
            $ref: '#/components/schemas/RunId'
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CloseOfflineRun'
        required: true
      responses:
        '200':
          description: The run is closed for this opener. The body is empty.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OfflineRunClosed'
        '401':
          description: >-
            No API key, or one that is unknown or revoked, or whose org isn't
            active.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedEncoded'
        '404':
          description: >-
            No score run with this id exists. | The run has no opener by this
            id: its open answered another.
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/RunNotFoundEncoded'
                  - $ref: '#/components/schemas/OfflineRunOpenerNotFoundEncoded'
        '409':
          description: >-
            The run can't be closed: it isn't an offline run, or it is neither
            open nor completed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OfflineRunNotOpenEncoded'
        '413':
          description: >-
            The request's body is larger than the report API takes, `limit`
            bytes: nothing in it was stored.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OfflineRequestTooLargeEncoded'
        '429':
          description: >-
            Too many requests. Send the request again after `retryAfter`
            seconds, which the `Retry-After` header also gives.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyAttemptsEncoded'
        '503':
          description: Something the request needs couldn't be reached. Retry the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceUnavailableEncoded'
      security:
        - bearer: []
components:
  schemas:
    RunId:
      type: string
      pattern: >-
        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$
      format: uuid
    CloseOfflineRun:
      type: object
      properties:
        opener:
          $ref: '#/components/schemas/OfflineRunOpenerId'
      required:
        - opener
      additionalProperties: false
    OfflineRunClosed:
      not:
        type: 'null'
      description: The run is closed for this opener. The body is empty.
    UnauthorizedEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - Unauthorized
      required:
        - _tag
      additionalProperties: false
    RunNotFoundEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - RunNotFound
        run:
          $ref: '#/components/schemas/RunId'
      required:
        - _tag
        - run
      additionalProperties: false
    OfflineRunOpenerNotFoundEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - OfflineRunOpenerNotFound
        run:
          $ref: '#/components/schemas/RunId'
        opener:
          $ref: '#/components/schemas/OfflineRunOpenerId'
      required:
        - _tag
        - run
        - opener
      additionalProperties: false
    OfflineRunNotOpenEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - OfflineRunNotOpen
        run:
          $ref: '#/components/schemas/RunId'
      required:
        - _tag
        - run
      additionalProperties: false
    OfflineRequestTooLargeEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - OfflineRequestTooLarge
        limit:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
      required:
        - _tag
        - limit
      additionalProperties: false
    TooManyAttemptsEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - TooManyAttempts
        message:
          type: string
        retryAfter:
          $ref: '#/components/schemas/Seconds'
      required:
        - _tag
        - message
        - retryAfter
      additionalProperties: false
    ServiceUnavailableEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - ServiceUnavailable
      required:
        - _tag
      additionalProperties: false
    OfflineRunOpenerId:
      type: string
      pattern: >-
        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$
      format: uuid
    Seconds:
      type: integer
      minimum: 0
      maximum: 9007199254740991
      description: A duration, in whole seconds
  securitySchemes:
    bearer:
      description: 'The org''s API key: the one its agent calls the Gateway with.'
      type: http
      scheme: Bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.