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
currentWorkspaceIdis reassigned to a remaining workspace (returned asdata.newCurrentWorkspaceId). - The owner's
subscription.usage.leadscounter is resynced to the actual count across the owner's remaining workspaces.
Guards
- Returns 400
LAST_WORKSPACEif this is the caller's only workspace. - Returns 403
WORKSPACE_FORBIDDENif 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"
import requests
import json
url = "https://api.sendkit.ai/v1/workspaces/example_string"
headers = {
"Content-Type": "application/json",
"X-Api-Key": "YOUR_API_KEY"
}
response = requests.delete(url, headers=headers)
print(response.json())
const response = await fetch("https://api.sendkit.ai/v1/workspaces/example_string", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"X-Api-Key": "YOUR_API_KEY"
}
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
)
func main() {
req, err := http.NewRequest("DELETE", "https://api.sendkit.ai/v1/workspaces/example_string", nil)
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Api-Key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.sendkit.ai/v1/workspaces/example_string')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['Content-Type'] = 'application/json'
request['X-Api-Key'] = 'YOUR_API_KEY'
response = http.request(request)
puts response.body
{
"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
}
}
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"error": "Forbidden",
"message": "You don't have permission to access this resource",
"code": 403
}
{
"error": "Not Found",
"message": "The requested resource was not found",
"code": 404
}
/v1/workspaces/{workspaceId}Target server for requests. Edit to use your own host.
Platform API key (sk_user_...) or Workspace API key (sk_...)
Workspace ID
Request Preview
Response
Response will appear here after sending the request
Authentication
API Key for authentication. Platform API key (sk_user_...) or Workspace API key (sk_...)
Path Parameters
Workspace ID