---
title: "Delete Graph"
method: POST
path: "/v1/graphs/{graph_id}/operations/delete-graph"
tags: ["Graph Operations"]
---

# Delete Graph

`POST /v1/graphs/{graph_id}/operations/delete-graph`

## Request

- Base URL: `https://api.robosystems.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.robosystems.ai/v1/graphs/{graph_id}/operations/delete-graph`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

Permanently destroys a user graph and cancels its subscription. Two modes via the `at_period_end` body flag: omit it (or pass `false`) to tear down immediately (~10 min); pass `true` to keep the graph usable through the current billing period and tear it down at the period boundary via the existing suspend → deprovision pipeline. Requires `confirm` to equal the URL `graph_id`. Caller must be both org owner (billing authority) and admin on the graph (operational authority). Not allowed on shared repositories.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

## Path parameters

- `graph_id` string, required

## Headers

- `Idempotency-Key` string, nullable

## Request body

- DeleteGraphOp: Body for the delete-graph operation. Permanently destroys the graph and cancels its subscription. Two modes: - **Immediate** (default): subscription canceled now (`ends_at = now`) and fast-path deprovisioning fires within ~10 minutes. Use when you want the data gone and the slot freed right away. - **At period end** (`at_period_end=true`): subscription canceled but `ends_at = current_period_end` so the graph stays usable through the paid period. The existing suspend → deprovision sensor pipeline tears it down after the retention window once the period closes. Requires `confirm` to equal the URL `graph_id` as a guard against accidental destructive calls.
  - `confirm` string, required: Must equal the graph_id in the URL — confirms the caller intends to destroy this specific graph.
  - `at_period_end` boolean: If true, defer cancellation and teardown to the end of the current billing period (graph stays usable until then). If false (default), cancel and tear down immediately.

## Response `202`

Successful Response

- OperationEnvelope: Uniform response shape for every operation endpoint. Every dispatch carries an `op_<ULID>` operation_id, which is the bridge to the monitoring surface: pass it to `GET /v1/operations/{operation_id}/stream` (see `routers/operations.py`) to subscribe to SSE progress events. Sync commands complete in the envelope itself (`status: "completed"`, HTTP 200); async commands (`status: "pending"`, HTTP 202) hand off to a background worker and stream their tail through that SSE endpoint. Failed dispatches still mint an `operation_id` so the audit log and any partial SSE events stay correlatable. `TResult` parameterizes `result` so per-op response shapes surface in OpenAPI. Operations that pin `OperationSpec.result_type` get `OperationEnvelope[YourEnvelope]` as their response model; the rest keep the default `Any` shape (`result: any | null` on the wire).
  - `operation` string, required: Kebab-case operation name
  - `operationId` string, required: op_-prefixed ULID for audit and SSE correlation
  - `status` 'completed' | 'pending' | 'failed', required: Operation lifecycle state
  - `result` unknown
  - `at` string, required: ISO-8601 UTC timestamp
  - `createdBy` string, nullable: User ID that initiated the operation
  - `idempotentReplay` boolean: True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions.

## Other responses

- `400`: Invalid request
- `401`: Authentication required
- `403`: Access denied
- `404`: Resource not found
- `409`: Idempotency-Key conflict — key reused with different body
- `422`: Validation error
- `429`: Rate limit exceeded
- `500`: Internal server error

---

[API](https://skmtc.dev/robosystems/apis/robosystems-api.md) · [All operations](https://skmtc.dev/robosystems/apis/robosystems-api/llms.txt) · [OpenAPI document](https://skmtc.dev/robosystems/apis/robosystems-api/revisions/e661e2d5ca6a?raw)
