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

# Delete a sandbox preview

> Deletes a sandbox preview and revokes its tokens.



## OpenAPI

````yaml delete /v1/sandboxes/instances/{sandbox_name}/previews/{preview_name}
openapi: 3.1.0
info:
  description: REST API for management of Baseten resources
  title: Baseten management API
  version: 1.0.0
servers:
  - url: https://api.baseten.co
security:
  - BearerAuth: []
paths:
  /v1/sandboxes/instances/{sandbox_name}/previews/{preview_name}:
    parameters:
      - $ref: '#/components/parameters/SandboxName'
      - $ref: '#/components/parameters/PreviewName'
    delete:
      tags:
        - Previews
      summary: Delete a sandbox preview
      description: >-
        Delete the preview and revoke its tokens. The URL stops serving
        immediately. Return the deleted preview, with status TERMINATED, or
        DELETING while a preview with many tokens finishes in the background.
      operationId: DeleteSandboxPreview
      parameters:
        - $ref: '#/components/parameters/TeamId'
        - $ref: '#/components/parameters/TeamIdHeader'
      responses:
        '200':
          description: Successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxPreviewV1'
              examples:
                complete:
                  $ref: '#/components/examples/SandboxPreviewDeleted'
        '401':
          $ref: '#/components/responses/SandboxError401'
        '403':
          $ref: '#/components/responses/SandboxError403'
        '404':
          $ref: '#/components/responses/SandboxError404'
        '429':
          $ref: '#/components/responses/SandboxError429'
        '500':
          $ref: '#/components/responses/SandboxError500'
components:
  parameters:
    SandboxName:
      name: sandbox_name
      in: path
      required: true
      description: Immutable sandbox name returned by creation.
      schema:
        type: string
        minLength: 1
        example: baseten-api-review-0916
    PreviewName:
      name: preview_name
      in: path
      required: true
      description: Preview name returned by creation.
      schema:
        type: string
        minLength: 1
        example: web
    TeamId:
      name: team_id
      in: query
      required: false
      description: >-
        Optional team ID. Must match X-Team-Id when both are supplied. If
        neither selector is supplied, defaults to the caller's only accessible
        team. Callers with multiple accessible teams must select a team.
        Requests without access to any team are forbidden.
      schema:
        minLength: 1
        type: string
    TeamIdHeader:
      name: X-Team-Id
      in: header
      required: false
      description: >-
        Optional team ID. Must match the team_id query parameter when both are
        supplied. If neither selector is supplied, defaults to the caller's only
        accessible team. Callers with multiple accessible teams must select a
        team. Requests without access to any team are forbidden.
      schema:
        minLength: 1
        type: string
  schemas:
    SandboxPreviewV1:
      description: >-
        Sandbox preview with configuration and server-managed fields at the
        root.
      allOf:
        - $ref: '#/components/schemas/SandboxPreviewConfigurationV1'
        - type: object
          properties:
            name:
              type: string
              description: Preview name, used in preview_name path parameters.
              readOnly: true
              example: web
            port:
              type: integer
              description: Exposed sandbox port.
              readOnly: true
              example: 3000
            url:
              type: string
              format: uri
              description: >-
                HTTPS URL serving the port, including the region label. Use this
                exact URL. Requests to a private preview need a token.
              readOnly: true
              example: https://a1b2c3d4e5f6g7h8.us-pdx-1.preview.b10.co
            status:
              $ref: '#/components/schemas/SandboxPreviewStatusV1'
            region:
              type: string
              description: Region serving the preview, the sandbox's region.
              readOnly: true
              example: us-pdx-1
            created_at:
              type: string
              format: date-time
              readOnly: true
              example: '2026-10-12T12:00:00Z'
            updated_at:
              type: string
              format: date-time
              readOnly: true
              example: '2026-10-12T12:00:00Z'
            created_by:
              type: string
              readOnly: true
              example: sandbox-automation
            updated_by:
              type: string
              readOnly: true
              example: sandbox-automation
          required:
            - name
            - port
            - url
            - status
            - public
    SandboxPreviewConfigurationV1:
      type: object
      description: >-
        Mutable preview configuration. ttl and expires_at are mutually
        exclusive; supplying both returns 400.
      properties:
        public:
          type: boolean
          description: >-
            Whether the URL is reachable without a preview token. Defaults to
            false.
          default: false
          example: true
        response_headers:
          description: >-
            Headers added to every response served by the preview, for example
            CORS headers.
          allOf:
            - $ref: '#/components/schemas/SandboxPreviewHeadersV1'
        request_headers:
          description: >-
            Headers added to every request forwarded to the sandbox, for example
            an Authorization header expected by the application. Responses
            return each name with the value "****", except a GET with
            show_secrets=true by a workspace administrator. Sending "****" back
            as a value returns 400. A PATCH replaces the whole set.
          allOf:
            - $ref: '#/components/schemas/SandboxPreviewHeadersV1'
          example:
            Authorization: Bearer app-internal-token
        ttl:
          $ref: '#/components/schemas/SandboxPreviewTtlV1'
        expires_at:
          type: string
          format: date-time
          description: Time at which the preview is deleted. Must be in the future.
          example: '2026-10-19T12:00:00Z'
    SandboxPreviewStatusV1:
      type: string
      description: Preview status, always uppercase.
      enum:
        - DEPLOYING
        - DEPLOYED
        - FAILED
        - DELETING
        - TERMINATED
      readOnly: true
      example: DEPLOYED
    SandboxPreviewHeadersV1:
      type: object
      description: HTTP headers as name-value pairs.
      additionalProperties:
        type: string
      example:
        Access-Control-Allow-Origin: '*'
    SandboxPreviewTtlV1:
      type: string
      description: >-
        Lifetime counted from the request, using seconds, minutes, hours or
        composite durations such as 1h30m. Whole days are also supported, for
        example 7d; days cannot be combined with other units. The preview is
        deleted when it elapses.
      pattern: ^([0-9]+d|(([0-9]+(\.[0-9]*)?|\.[0-9]+)(ns|us|µs|μs|ms|s|m|h))+)$
      example: 24h
  examples:
    SandboxPreviewDeleted:
      summary: Deleted preview
      value:
        name: web
        port: 3000
        public: true
        url: https://a1b2c3d4e5f6g7h8.us-pdx-1.preview.b10.co
        status: TERMINATED
        region: us-pdx-1
        created_at: '2026-10-12T12:00:00Z'
        updated_at: '2026-10-12T12:00:00Z'
        created_by: sandbox-automation
        updated_by: sandbox-automation
  responses:
    SandboxError401:
      description: >-
        Missing or invalid authentication. Returns a JSON error with code,
        message, and optional details.
      content:
        application/json:
          example:
            code: UNAUTHORIZED
            message: Provide a valid authentication token in the Authorization header.
            details:
              header: Authorization
    SandboxError403:
      description: >-
        Insufficient permissions. Returns a JSON error with code, message, and
        optional details.
      content:
        application/json:
          example:
            code: FORBIDDEN
            message: >-
              This authentication token does not grant permission to perform
              this operation.
            details:
              request_id: a3b7c4d2-91e6-4f08-9b5a-2c6d7e8f1043
    SandboxError404:
      description: >-
        Resource not found. Returns a JSON error with code, message, and
        optional details.
      content:
        application/json:
          example:
            code: NOT_FOUND
            message: The requested resource was not found.
            details:
              request_id: a3b7c4d2-91e6-4f08-9b5a-2c6d7e8f1043
    SandboxError429:
      description: >-
        Request limit exceeded. Returns a JSON error with code, message, and
        optional details.
      content:
        application/json:
          example:
            code: RATE_LIMITED
            message: Too many requests. Try again in 30 seconds.
            details:
              retry_after_seconds: 30
    SandboxError500:
      description: >-
        Internal server error. Returns a JSON error with code, message, and
        optional details.
      content:
        application/json:
          example:
            code: INTERNAL_ERROR
            message: The request could not be completed. Try again later.
            details:
              request_id: a3b7c4d2-91e6-4f08-9b5a-2c6d7e8f1043
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send `Authorization: Bearer <api_key>`. The legacy `Authorization:
        Api-Key <api_key>` scheme is also accepted.

````