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

# Report sandboxes starting and stopping

> Records 1 to 100 sandbox events. started records the sandbox with the USD price per hour for its size at that moment; send size_class, or vcpus and memory_mib, or decision_id alone to use the size routed by that decision. A start with no size, from either, is priced at the provider's default size when the price list gives one, and the sandbox is listed with that size, where vcpus can be fractional, and default_size true. decision_id from a routing answer links the sandbox to it; an unknown decision_id is ignored. When that answer moved the sandbox off the team's first provider and the sandbox started there at the routed size, the first provider's price and billing rules are kept to measure savings. create_requested_at on a started event is when the create request was sent to the provider; the time from it to at is the sandbox's start time, and it is ignored when later than at or more than an hour before it. A repeated started event for a sandbox is ignored. stopped records when the sandbox stopped, never before it started, and reason says why: destroyed when the team ended it, timeout when the provider ended it at the end of its lifetime, lost when it disappeared otherwise; a stop that arrives before its start is kept until the start arrives, for up to 2 days, and a second stop is ignored. failed records a create the provider refused or did not finish in time, with no sandbox_id: failure_class is quota, capacity, auth, timeout (not ready within the readiness limit) or other, and detail holds the provider's error text, up to 2000 characters; failures are kept 90 days. at defaults to now and is moved into the last 24 hours. sandbox_id holds up to 256 characters; metadata holds at most 20 string tags, keys up to 64 and values up to 256 characters; none may contain control characters. An invalid event is skipped and listed in rejected with its index and the problem, and the others are recorded; the request is rejected only when no event is valid. Events are recorded even while the organization's billing needs attention. Too many requests in a short time answer 429.



## OpenAPI

````yaml /api-reference/costgraph/openapi.json post /api/v1/tenant/sandboxes/events
openapi: 3.0.0
info:
  description: Read and manage your CostGraph organization, spend, alerts, and settings.
  title: CostGraph API
  contact: {}
  version: '1.0'
servers:
  - url: https://api.costgraph.ai
security: []
tags:
  - name: ai
    x-group: AI
  - name: ai-serving
    x-group: AI serving
  - name: anomalies
    x-group: Anomalies
  - name: auth
    x-group: Auth
  - name: billing
    x-group: Billing
  - name: billing-export
    x-group: Billing export
  - name: budgets
    x-group: Budgets
  - name: ci
    x-group: CI
  - name: compute-recommendations
    x-group: Compute recommendations
  - name: config
    x-group: Config
  - name: context-graph
    x-group: Context graph
  - name: cost
    x-group: Cost
  - name: gpus
    x-group: GPUs
  - name: graphai
    x-group: Graph AI
  - name: integrations
    x-group: Integrations
  - name: invitations
    x-group: Invitations
  - name: kubernetes-clusters
    x-group: Kubernetes clusters
  - name: marketplace
    x-group: Marketplace
  - name: network
    x-group: Network
  - name: network-requests
    x-group: Network requests
  - name: notifications
    x-group: Notifications
  - name: oauth
    x-group: OAuth
  - name: oauth-clients
    x-group: OAuth clients
  - name: opencost
    x-group: OpenCost
  - name: operator
    x-group: Operator
  - name: organization
    x-group: Audit log
  - name: organizations
    x-group: Organizations
  - name: placement-alternatives
    x-group: Placement alternatives
  - name: reports
    x-group: Reports
  - name: sandboxes
    x-group: Sandboxes
  - name: settings
    x-group: Settings
  - name: sso
    x-group: Single sign-on
  - name: tenants
    x-group: Tenants
  - name: ticketing
    x-group: Ticketing
  - name: user
    x-group: Users
  - name: virtual-machines
    x-group: Virtual machines
  - name: virtual-tags
    x-group: Virtual tags
  - name: workflows
    x-group: Workflows
paths:
  /api/v1/tenant/sandboxes/events:
    post:
      tags:
        - sandboxes
      summary: Report sandboxes starting and stopping
      description: >-
        Records 1 to 100 sandbox events. started records the sandbox with the
        USD price per hour for its size at that moment; send size_class, or
        vcpus and memory_mib, or decision_id alone to use the size routed by
        that decision. A start with no size, from either, is priced at the
        provider's default size when the price list gives one, and the sandbox
        is listed with that size, where vcpus can be fractional, and
        default_size true. decision_id from a routing answer links the sandbox
        to it; an unknown decision_id is ignored. When that answer moved the
        sandbox off the team's first provider and the sandbox started there at
        the routed size, the first provider's price and billing rules are kept
        to measure savings. create_requested_at on a started event is when the
        create request was sent to the provider; the time from it to at is the
        sandbox's start time, and it is ignored when later than at or more than
        an hour before it. A repeated started event for a sandbox is ignored.
        stopped records when the sandbox stopped, never before it started, and
        reason says why: destroyed when the team ended it, timeout when the
        provider ended it at the end of its lifetime, lost when it disappeared
        otherwise; a stop that arrives before its start is kept until the start
        arrives, for up to 2 days, and a second stop is ignored. failed records
        a create the provider refused or did not finish in time, with no
        sandbox_id: failure_class is quota, capacity, auth, timeout (not ready
        within the readiness limit) or other, and detail holds the provider's
        error text, up to 2000 characters; failures are kept 90 days. at
        defaults to now and is moved into the last 24 hours. sandbox_id holds up
        to 256 characters; metadata holds at most 20 string tags, keys up to 64
        and values up to 256 characters; none may contain control characters. An
        invalid event is skipped and listed in rejected with its index and the
        problem, and the others are recorded; the request is rejected only when
        no event is valid. Events are recorded even while the organization's
        billing needs attention. Too many requests in a short time answer 429.
      parameters:
        - description: Tenant ID
          name: X-CostGraph-Tenant-ID
          in: header
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/sandbox.EventsRequest'
        description: Sandbox events
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/sandbox.EventsResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    sandbox.EventsRequest:
      type: object
      required:
        - events
      properties:
        events:
          type: array
          maxItems: 100
          minItems: 1
          items:
            $ref: '#/components/schemas/sandbox.Event'
    responses.SuccessResponse:
      type: object
      required:
        - message
        - status
      properties:
        data: {}
        message:
          type: string
          example: some message
        status:
          type: string
          example: success
    sandbox.EventsResponse:
      type: object
      required:
        - accepted
        - rejected
      properties:
        accepted:
          type: integer
        rejected:
          type: array
          items:
            $ref: '#/components/schemas/sandbox.RejectedEvent'
    responses.ErrorResponse:
      type: object
      required:
        - message
        - status
      properties:
        message:
          type: string
          example: some message
        status:
          type: string
          example: error
    sandbox.Event:
      type: object
      required:
        - provider
        - type
      properties:
        at:
          type: string
          nullable: true
        create_requested_at:
          type: string
          nullable: true
        decision_id:
          type: string
        detail:
          type: string
          maxLength: 2000
        failure_class:
          type: string
          enum:
            - ''
            - quota
            - capacity
            - auth
            - timeout
            - other
        memory_mib:
          type: integer
          maximum: 4194304
          minimum: 1
        metadata:
          type: object
          additionalProperties:
            type: string
        provider:
          type: string
          example: e2b
        reason:
          type: string
          enum:
            - ''
            - destroyed
            - timeout
            - lost
        sandbox_id:
          type: string
          maxLength: 256
        size_class:
          type: string
          enum:
            - ''
            - xs
            - sm
            - md
            - lg
            - xl
            - 2xl
        type:
          type: string
          enum:
            - started
            - stopped
            - failed
        vcpus:
          type: integer
          maximum: 1024
          minimum: 1
    sandbox.RejectedEvent:
      type: object
      required:
        - index
        - problem
      properties:
        index:
          type: integer
        problem:
          type: string
  securitySchemes:
    ApiKeyAuth:
      description: API key for machine-to-machine authentication
      type: apiKey
      name: X-API-Key
      in: header

````

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