# Delete Sandbox

Source: https://recoupable.dev/docs/api-reference/sandboxes/delete

Delete a sandbox environment for the authenticated account. This permanently deletes the associated GitHub repository and removes the account's snapshot record from the database. By default, deletes the sandbox for the key owner's account. Pass account_id to target a specific account the API key has access to. Authentication is handled via the x-api-key header or Authorization Bearer token.

## DELETE /api/sandboxes

Full OpenAPI specification: https://recoupable.dev/docs/spec/content.json

## Authentication

The supplied specification does not declare an OpenAPI security object for this operation. Its declared headers and parameters still apply. Consult the authentication guide and the full specification before calling it.

[Authentication guide](https://recoupable.dev/docs/authentication)

## Operation and referenced schemas

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Recoup API - Content",
    "description": "API documentation for the Recoup platform - an AI agent platform for the music industry",
    "license": {
      "name": "MIT"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.recoupable.dev"
    }
  ],
  "paths": {
    "/api/sandboxes": {
      "delete": {
        "description": "Delete a sandbox environment for the authenticated account. This permanently deletes the associated GitHub repository and removes the account's snapshot record from the database. By default, deletes the sandbox for the key owner's account. Pass account_id to target a specific account the API key has access to. Authentication is handled via the x-api-key header or Authorization Bearer token.",
        "requestBody": {
          "description": "Optional account targeting parameters",
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteSandboxRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sandbox deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteSandboxResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - failed to delete sandbox",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SandboxErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SandboxErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - account_id is not a member of the organization or account tried to use an account_id they don't have access to",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SandboxErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DeleteSandboxRequest": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "string",
            "format": "uuid",
            "description": "UUID of the account to delete the sandbox for. Only applicable when the authenticated account has access to multiple accounts via organization membership. If not provided, deletes the sandbox for the API key's own account."
          }
        }
      },
      "DeleteSandboxResponse": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success",
              "error"
            ],
            "description": "Status of the delete operation"
          },
          "deleted_snapshot": {
            "nullable": true,
            "description": "The snapshot record that was deleted. Null if no snapshot existed for the account.",
            "$ref": "#/components/schemas/UpdateSnapshotResponse"
          },
          "error": {
            "type": "string",
            "description": "Error message (only present if status is error)"
          }
        }
      },
      "SandboxErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Error message describing what went wrong",
            "example": "Failed to create sandbox"
          }
        }
      },
      "UpdateSnapshotResponse": {
        "type": "object",
        "required": [
          "account_id",
          "snapshot_id",
          "expires_at",
          "github_repo",
          "created_at"
        ],
        "properties": {
          "account_id": {
            "type": "string",
            "format": "uuid",
            "description": "The account ID this snapshot belongs to",
            "example": "550e8400-e29b-41d4-a716-446655440000"
          },
          "snapshot_id": {
            "type": "string",
            "description": "The snapshot ID that was set for the account",
            "example": "snap_abc123def456"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the snapshot expires",
            "example": "2027-01-01T00:00:00.000Z"
          },
          "github_repo": {
            "type": "string",
            "nullable": true,
            "description": "The GitHub repository URL associated with the sandbox",
            "example": "https://github.com/org/repo"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the snapshot record was created",
            "example": "2025-01-01T00:00:00.000Z"
          }
        }
      }
    }
  }
}
```
