Skip to content

Add stripe sandbox delete to close a sandbox by its account id#1782

Open
shashwat-stripe wants to merge 1 commit into
sandboxes-clifrom
shashwat/sandbox-delete
Open

Add stripe sandbox delete to close a sandbox by its account id#1782
shashwat-stripe wants to merge 1 commit into
sandboxes-clifrom
shashwat/sandbox-delete

Conversation

@shashwat-stripe

Copy link
Copy Markdown

Reviewers

r? @
cc @stripe/developer-products

Summary

Adds stripe sandbox delete, rounding out the sandbox CRUD story (new/list/delete).

You pass the sandbox's own account via --stripe-account acct_... (the ACCOUNT shown by stripe sandbox list). The command resolves that account to the sandbox's testmode workspace by searching your accessible live parents' sandboxes, then closes it via POST /v2/workspaces/undocumented/testmode/:id/close, the same compartment endpoint the dashboard's delete action uses. "delete" here is a soft compartment close, testmode only, and never touches your live account. Org ids are rejected client-side, consistent with new/list. The call is self-scoped by the UAT (no Stripe-Context) and needs no backend or permission changes. Hidden subcommand, matching new/list.

Test plan

  • Unit tests (pkg/cmd/sandbox_test.go): success (asserts only the targeted sandbox's workspace is closed), not-found, org rejection, missing-account, no-UAT. Full TestSandbox suite passes; go vet and golangci-lint clean.
  • Verified end-to-end on QA: sandbox new --copy-live-account -> sandbox list (sandbox shown) -> sandbox delete --stripe-account acct_... (Deleted sandbox ...) -> sandbox list (No sandboxes found.).

Rollout / revert plan

Safe to revert. Additive, hidden CLI subcommand; no backend, schema, or flag changes.

Rounds out the sandbox CRUD story (new/list/delete). Takes the sandbox's
acct_ (the ACCOUNT shown by `sandbox list`), resolves it to the sandbox's
testmode workspace under the caller's accessible live parents, and closes it
via the same compartment endpoint the dashboard's delete action uses. The
call is self-scoped by the UAT, no backend or permission changes needed;
verified end-to-end on QA (new -> list -> delete -> list).

Committed-By-Agent: claude
@shashwat-stripe shashwat-stripe marked this pull request as ready for review July 13, 2026 17:05
@shashwat-stripe shashwat-stripe requested a review from a team as a code owner July 13, 2026 17:05

@echeng-stripe echeng-stripe left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor change.

Comment thread pkg/cmd/sandbox.go
return err
}
// Guard: only ever close a sandbox (testmode) workspace, never something else.
if !strings.HasPrefix(sandboxWorkspace, "wksp_") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`!strings.HasPrefix(sandboxWorkspace, "wksp_test")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants