WorkspacesDelete workspace (owner only)

Delete workspace (owner only)

Hard-deletes the workspace and cascades deletion across all child collections. Only the workspace owner can perform this action. Requires a platform API key (sk_user_...).

What is deleted

The workspace document itself plus all rows in the following collections matching workspaceId: campaigns, campaignleads, leads, mailboxes, domains, webhooks, workspaceinvites, unsubscribed, agents. Returned counts are reported in data.deletedCounts.

Side effects

  • The workspace is removed from every user's workspaces[] array via $pull.
  • The caller's currentWorkspaceId is reassigned to a remaining workspace (returned as data.newCurrentWorkspaceId).
  • The owner's subscription.usage.leads counter is resynced to the actual count across the owner's remaining workspaces.

Guards

  • Returns 400 LAST_WORKSPACE if this is the caller's only workspace.
  • Returns 403 WORKSPACE_FORBIDDEN if the caller is not the owner.

Irreversibility

This is a hard delete. There is no recovery. Frees the apiKey and warmupCode unique-index slots immediately.

curl -X DELETE "https://api.sendkit.ai/v1/workspaces/example_string" \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: YOUR_API_KEY"
{
  "success": true,
  "data": {
    "message": "Workspace and all related data deleted",
    "workspaceId": "665a1b2c3d4e5f6a7b8c9d0e",
    "newCurrentWorkspaceId": "665b2c3d4e5f6a7b8c9d0e1f",
    "deletedCounts": {
      "campaignLeads": 1428,
      "campaigns": 12,
      "leads": 980,
      "mailboxes": 4,
      "domains": 2,
      "webhooks": 1,
      "invites": 0,
      "unsubscribed": 37,
      "agents": 0
    }
  }
}
DELETE
/v1/workspaces/{workspaceId}
DELETE
Base URLstring

Target server for requests. Edit to use your own host.

API Key (header: X-Api-Key)
X-Api-Keystring
Required

Platform API key (sk_user_...) or Workspace API key (sk_...)

Platform API key (sk_user_...) or Workspace API key (sk_...)
Request Preview
Response

Response will appear here after sending the request

Authentication

header
X-Api-Keystring
Required

API Key for authentication. Platform API key (sk_user_...) or Workspace API key (sk_...)

Path Parameters

Responses

successboolean
dataobject