Skip to main content
DELETE
/
api
/
services
/
[id]
Delete Service
curl --request DELETE \
  --url 'https://api.example.com/api/services/[id]'
{
  "ok": true
}
Deletes a service account from the system. This operation cascades and removes all associated data including categories, email threads, messages, and drafts.

Authentication

Requires a valid session. User must be authenticated via NextAuth.
This operation is irreversible. All emails, threads, drafts, and categories associated with this service will be permanently deleted.

Path parameters

id
string
required
The unique identifier of the service to delete

Response

ok
boolean
required
Always true on successful deletion

Response examples

{
  "ok": true
}

Code examples

curl --request DELETE \
  --url 'https://your-domain.com/api/services/service-123' \
  --cookie 'authjs.session-token=YOUR_SESSION_TOKEN'

Cascade deletion

Deleting a service triggers cascading deletes for all related data:

Automatically deleted

  • Categories: All categories associated with the service
  • Email threads: All email conversations
  • Emails: All individual messages within threads
  • Drafts: All AI-generated draft responses
This is enforced by the database schema using onDelete: 'cascade' foreign key constraints.

Database constraints

The following tables have foreign keys to gmailAccounts with cascade delete:
// categories table
accountId references gmailAccounts.id (onDelete: cascade)

// emailThreads table
accountId references gmailAccounts.id (onDelete: cascade)

// emails table
threadId references emailThreads.id (onDelete: cascade)

// drafts table
threadId references emailThreads.id (onDelete: cascade)
There is no confirmation prompt at the API level. Implement confirmation dialogs in your client application before calling this endpoint.

Error handling

The endpoint returns success even if the service doesn’t exist. This is idempotent behavior - deleting a non-existent service is considered successful.
Consider implementing soft deletes or archiving if you need to preserve historical data.

Build docs developers (and LLMs) love