Skip to main content
Delete a code execution context and all its associated variables and state.

Basic Request

curl -X DELETE https://api.gravixlayer.com/v1/agents/sandboxes/{sandbox_id}/code/contexts/{context_id} \
  -H "Authorization: Bearer YOUR_API_KEY"

Path Parameters

ParameterTypeRequiredDescription
sandbox_idstringYesSandbox ID (UUID)
context_idstringYesContext ID (UUID)

Response

{
  "message": "Code context deleted successfully",
  "context_id": "ctx_550e8400-e29b-41d4-a716-446655440000"
}

Response Fields

FieldTypeDescription
messagestringSuccess message
context_idstringID of the deleted context

When to Delete Contexts

  • Task completion: When analysis or processing is finished
  • Memory cleanup: Free up resources from unused contexts
  • Error recovery: Remove corrupted or problematic contexts
  • Sandbox cleanup: Before terminating sandbox

Example: Cleanup Workflow

# List all contexts
curl -X GET https://api.gravixlayer.com/v1/agents/sandboxes/{sandbox_id}/code/contexts \
  -H "Authorization: Bearer YOUR_API_KEY"

# Delete specific context
curl -X DELETE https://api.gravixlayer.com/v1/agents/sandboxes/{sandbox_id}/code/contexts/{context_id} \
  -H "Authorization: Bearer YOUR_API_KEY"

Safety Notes

  • Permanent deletion: Context and all variables are permanently lost
  • No recovery: Deleted contexts cannot be restored
  • Active executions: Ensure no code is currently running in the context

Next Steps