delete-domain route added - #267

Merged
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route
Oct 10, 2025
Merged

delete-domain route added#267
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route

Conversation

@kuntlme

@kuntlmekuntlme commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Fixes#262

Changes made

  • Added delete domain route in public-api
  • Updated OpenAPI schema with delete configuration
  • Added support in:
    • JS SDK
    • Python SDK
    • Documentation

Summary by cubic

Adds DELETE /v1/domains/{id} to remove a domain via the Public API with API key scoping. JS/TS and Python SDKs and docs are updated so clients can delete domains programmatically.

  • New Features
    • Public API: DELETE /v1/domains/{id} to delete a team domain.
      • 403 if API key is restricted to another domain.
      • 404 if the domain does not exist.
      • 200 returns { success: boolean, message: string }.
    • SDKs: Domains.delete(id) in JS/TS; usesend.domains.delete(domain_id) in Python.
    • Docs and OpenAPI updated (new delete-domain reference).

Summary by CodeRabbit

  • New Features

    • Added DELETE /v1/domains/{id} API to remove a domain and return the deleted domain details.
    • Domain deletion supported in JavaScript/TypeScript and Python SDKs; JS SDK now exposes a Domains client and can derive the API key from environment variables when not provided.
  • Documentation

    • Updated API reference and OpenAPI spec entries for domain deletion.

@vercel

vercelBot commented Oct 3, 2025

Copy link
Copy Markdown

@kuntlme is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitaiBot commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a DELETE /v1/domains/{id} endpoint across the stack: OpenAPI docs (apps/docs/api-reference/openapi.json and apps/docs/api-reference/domains/delete-domain.mdx), TypeScript types (packages/sdk/types/schema.d.ts) declaring the delete operation with a 200 response returning the full domain object, a server handler (apps/web/src/server/public-api/api/domains/delete-domain.ts) that validates id, enforces API-key domain access, returns 404 if not found, deletes the domain, and registers the route, and client methods: TypeScript SDK Domains.delete and UseSend.domains exposure, plus Python SDK Domains.delete(domain_id).

Possibly related PRs

Suggested labels

codex

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningThe PR includes modifications to packages/sdk/src/usesend.ts that add environment variable–based API key resolution and formatting tweaks which are unrelated to implementing the delete-domain route or addressing the linked issue objectives.Please remove or isolate the environment-variable key logic changes and formatting adjustments into a separate pull request so that this one focuses solely on the delete-domain functionality.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe title “delete-domain route added” succinctly and accurately describes the primary change of this pull request, which is the addition of a new DELETE route for domain deletion in the Public API.
Linked Issues Check✅ PassedThe pull request delivers a DELETE /v1/domains/{id} endpoint along with corresponding OpenAPI schema and documentation, fulfilling the requirement in linked issue #262 to provide an API endpoint and reference for domain deletion.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f106574 and cb95486.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/docs/api-reference/openapi.json (1)

637-797: Consider aligning DELETE response with REST conventions.

The DELETE operation returns the full domain object (lines 640-796), which is unconventional. Most DELETE operations return either:

  • 204 No Content (most common)
  • 200 with a minimal payload like {success: true, id: number}

For consistency, note that the contact DELETE operation in this same API (lines 1989-2008) returns a simple {success: boolean} payload. Returning the full domain object adds unnecessary response size and deviates from the API's own patterns.

Consider refactoring to return a minimal success payload:

 "responses": {
"200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"+ "success": {+ "type": "boolean"
},
- ... (all other domain fields)+ "id": {+ "type": "number"+ }
},
"required": [
- "id",- "name",- ... (other fields)+ "success",+ "id"
]
}
}
}
}
}

Alternatively, if you need to return the deleted domain for audit purposes, keep the current response but add a comment explaining this design decision.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216b80 and acfccf3.

📒 Files selected for processing (8)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
  • apps/web/src/server/public-api/index.ts (2 hunks)
  • packages/python-sdk/usesend/domains.py (1 hunks)
  • packages/sdk/src/domain.ts (2 hunks)
  • packages/sdk/src/usesend.ts (4 hunks)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise

Files:

  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
🧬 Code graph analysis (5)
packages/python-sdk/usesend/domains.py (2)
packages/python-sdk/usesend/usesend.py (1)
  • delete (118-121)
packages/python-sdk/usesend/types.py (2)
  • Domain (41-60)
  • APIError (337-339)
packages/sdk/src/usesend.ts (1)
packages/sdk/src/domain.ts (1)
  • Domains (48-89)
packages/sdk/src/domain.ts (1)
packages/sdk/types/index.ts (1)
  • ErrorResponse (1-4)
apps/web/src/server/public-api/api/domains/delete-domain.ts (3)
apps/web/src/server/public-api/hono.ts (1)
  • PublicAPIApp (136-136)
apps/web/src/server/public-api/api-error.ts (1)
  • UnsendApiError (62-75)
apps/web/src/server/db.ts (1)
  • db (20-20)
apps/web/src/server/public-api/index.ts (2)
apps/web/src/server/aws/ses.ts (1)
  • deleteDomain (144-176)
apps/web/src/server/service/domain-service.ts (1)
  • deleteDomain (294-316)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
packages/sdk/types/schema.d.ts (1)

1-4: Auto-generated file; defer review to source OpenAPI spec.

This file is auto-generated from the OpenAPI specification. Any concerns about the DELETE operation should be addressed in the source OpenAPI document (apps/docs/api-reference/openapi.json).

apps/docs/api-reference/openapi.json (1)

625-636: Verify path parameter requirement.

The path parameter id is marked as required: false (line 632), which is unusual for a DELETE operation that requires a resource identifier. While the parameter is nullable, DELETE operations typically require the ID to be present in the path.

Ensure this aligns with the intended API behavior. If the ID must be provided, consider marking it as required: true even if it's nullable.

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 8 files

Prompt for AI agents (all 5 issues)

Understand the root cause of the following 5 issues and fix them.
<file name="apps/web/src/server/public-api/api/domains/delete-domain.ts">
<violation number="1" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:32">
Wrap the 403 response media type in a `content` property so the OpenAPI schema is valid.</violation>
<violation number="2" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:80">
Domain deletion logic duplicates `apps/web/src/server/service/domain-service.ts:deleteDomain()` function and omits critical side effects (SES deletion).</violation>
</file>
<file name="apps/docs/api-reference/openapi.json">
<violation number="1" location="apps/docs/api-reference/openapi.json:629">
The DELETE path parameter `id` is declared nullable, but a URL segment cannot be null and the backend expects a concrete number.</violation>
<violation number="2" location="apps/docs/api-reference/openapi.json:632">
Path parameters must be required in OpenAPI, but this DELETE operation marks `id` as optional, making the spec invalid for generators.</violation>
<violation number="3" location="apps/docs/api-reference/openapi.json:639">
The DELETE 200 response schema describes a full domain object, but the handler actually returns `{ success: true, message: &quot;Domain deleted successfully&quot; }`, so the OpenAPI contract is incorrect and will break generated clients.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acfccf3 and 5407a8d.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts
🔇 Additional comments (1)
packages/sdk/types/schema.d.ts (1)

372-372: Path parameter type is appropriately non-nullable.

Unlike the GET and verify endpoints that use number | null, the DELETE operation correctly uses number for the required id path parameter.

Comment threadpackages/sdk/types/schema.d.ts

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres lots of valid review comments, please address it

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/docs/api-reference/openapi.json (1)

637-795: Fix response schema to match actual handler payload.

The handler returns { success: boolean, message: string }, but the spec publishes a full Domain object. Generated clients will deserialize the wrong shape and break once the DELETE route is invoked. Update the schema to reflect the success/message contract.

 "200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
- "type": "object",- "properties": {- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"- },- "teamId": {- "type": "number",- "description": "The ID of the team",- "example": 1- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "region": {- "type": "string",- "default": "us-east-1"- },- "clickTracking": {- "type": "boolean",- "default": false- },- "openTracking": {- "type": "boolean",- "default": false- },- "publicKey": {- "type": "string"- },- "dkimStatus": {- "type": "string",- "nullable": true- },- "spfDetails": {- "type": "string",- "nullable": true- },- "createdAt": {- "type": "string"- },- "updatedAt": {- "type": "string"- },- "dmarcAdded": {- "type": "boolean",- "default": false- },- "isVerifying": {- "type": "boolean",- "default": false- },- "errorMessage": {- "type": "string",- "nullable": true- },- "subdomain": {- "type": "string",- "nullable": true- },- "verificationError": {- "type": "string",- "nullable": true- },- "lastCheckedTime": {- "type": "string",- "nullable": true- },- "dnsRecords": {- "type": "array",- "items": {- "type": "object",- "properties": {- "type": {- "type": "string",- "enum": [- "MX",- "TXT"- ],- "description": "DNS record type",- "example": "TXT"- },- "name": {- "type": "string",- "description": "DNS record name",- "example": "mail"- },- "value": {- "type": "string",- "description": "DNS record value",- "example": "v=spf1 include:amazonses.com ~all"- },- "ttl": {- "type": "string",- "description": "DNS record TTL",- "example": "Auto"- },- "priority": {- "type": "string",- "nullable": true,- "description": "DNS record priority",- "example": "10"- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "recommended": {- "type": "boolean",- "description": "Whether the record is recommended"- }- },- "required": [- "type",- "name",- "value",- "ttl",- "status"- ]- }- }- },- "required": [- "id",- "name",- "teamId",- "status",- "publicKey",- "createdAt",- "updatedAt",- "dnsRecords"- ]+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "example": true+ },+ "message": {+ "type": "string",+ "example": "Domain deleted successfully"+ }+ },+ "required": [+ "success",+ "message"+ ]
}
}
}
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5407a8d and f106574.

📒 Files selected for processing (3)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/api-reference/domains/delete-domain.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts

Comment threadapps/docs/api-reference/openapi.json
@kuntlme
kuntlme requested a review from KMKoushikOctober 3, 2025 20:51
@kuntlme

Copy link
Copy Markdown
ContributorAuthor

@KMKoushik Please review it.
I made changes as you instructed.

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

@kuntlme

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot for the confirmation and for helping me out.

@KMKoushik
KMKoushik merged commit 3f6a02a into usesend:mainOct 10, 2025
1 of 2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete domain API reference needed

2 participants

@kuntlme@KMKoushik
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

delete-domain route added - #267

Merged
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route
Oct 10, 2025
Merged

delete-domain route added#267
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route

Conversation

@kuntlme

@kuntlmekuntlme commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Fixes#262

Changes made

  • Added delete domain route in public-api
  • Updated OpenAPI schema with delete configuration
  • Added support in:
    • JS SDK
    • Python SDK
    • Documentation

Summary by cubic

Adds DELETE /v1/domains/{id} to remove a domain via the Public API with API key scoping. JS/TS and Python SDKs and docs are updated so clients can delete domains programmatically.

  • New Features
    • Public API: DELETE /v1/domains/{id} to delete a team domain.
      • 403 if API key is restricted to another domain.
      • 404 if the domain does not exist.
      • 200 returns { success: boolean, message: string }.
    • SDKs: Domains.delete(id) in JS/TS; usesend.domains.delete(domain_id) in Python.
    • Docs and OpenAPI updated (new delete-domain reference).

Summary by CodeRabbit

  • New Features

    • Added DELETE /v1/domains/{id} API to remove a domain and return the deleted domain details.
    • Domain deletion supported in JavaScript/TypeScript and Python SDKs; JS SDK now exposes a Domains client and can derive the API key from environment variables when not provided.
  • Documentation

    • Updated API reference and OpenAPI spec entries for domain deletion.

@vercel

vercelBot commented Oct 3, 2025

Copy link
Copy Markdown

@kuntlme is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitaiBot commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a DELETE /v1/domains/{id} endpoint across the stack: OpenAPI docs (apps/docs/api-reference/openapi.json and apps/docs/api-reference/domains/delete-domain.mdx), TypeScript types (packages/sdk/types/schema.d.ts) declaring the delete operation with a 200 response returning the full domain object, a server handler (apps/web/src/server/public-api/api/domains/delete-domain.ts) that validates id, enforces API-key domain access, returns 404 if not found, deletes the domain, and registers the route, and client methods: TypeScript SDK Domains.delete and UseSend.domains exposure, plus Python SDK Domains.delete(domain_id).

Possibly related PRs

Suggested labels

codex

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningThe PR includes modifications to packages/sdk/src/usesend.ts that add environment variable–based API key resolution and formatting tweaks which are unrelated to implementing the delete-domain route or addressing the linked issue objectives.Please remove or isolate the environment-variable key logic changes and formatting adjustments into a separate pull request so that this one focuses solely on the delete-domain functionality.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe title “delete-domain route added” succinctly and accurately describes the primary change of this pull request, which is the addition of a new DELETE route for domain deletion in the Public API.
Linked Issues Check✅ PassedThe pull request delivers a DELETE /v1/domains/{id} endpoint along with corresponding OpenAPI schema and documentation, fulfilling the requirement in linked issue #262 to provide an API endpoint and reference for domain deletion.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f106574 and cb95486.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/docs/api-reference/openapi.json (1)

637-797: Consider aligning DELETE response with REST conventions.

The DELETE operation returns the full domain object (lines 640-796), which is unconventional. Most DELETE operations return either:

  • 204 No Content (most common)
  • 200 with a minimal payload like {success: true, id: number}

For consistency, note that the contact DELETE operation in this same API (lines 1989-2008) returns a simple {success: boolean} payload. Returning the full domain object adds unnecessary response size and deviates from the API's own patterns.

Consider refactoring to return a minimal success payload:

 "responses": {
"200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"+ "success": {+ "type": "boolean"
},
- ... (all other domain fields)+ "id": {+ "type": "number"+ }
},
"required": [
- "id",- "name",- ... (other fields)+ "success",+ "id"
]
}
}
}
}
}

Alternatively, if you need to return the deleted domain for audit purposes, keep the current response but add a comment explaining this design decision.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216b80 and acfccf3.

📒 Files selected for processing (8)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
  • apps/web/src/server/public-api/index.ts (2 hunks)
  • packages/python-sdk/usesend/domains.py (1 hunks)
  • packages/sdk/src/domain.ts (2 hunks)
  • packages/sdk/src/usesend.ts (4 hunks)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise

Files:

  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
🧬 Code graph analysis (5)
packages/python-sdk/usesend/domains.py (2)
packages/python-sdk/usesend/usesend.py (1)
  • delete (118-121)
packages/python-sdk/usesend/types.py (2)
  • Domain (41-60)
  • APIError (337-339)
packages/sdk/src/usesend.ts (1)
packages/sdk/src/domain.ts (1)
  • Domains (48-89)
packages/sdk/src/domain.ts (1)
packages/sdk/types/index.ts (1)
  • ErrorResponse (1-4)
apps/web/src/server/public-api/api/domains/delete-domain.ts (3)
apps/web/src/server/public-api/hono.ts (1)
  • PublicAPIApp (136-136)
apps/web/src/server/public-api/api-error.ts (1)
  • UnsendApiError (62-75)
apps/web/src/server/db.ts (1)
  • db (20-20)
apps/web/src/server/public-api/index.ts (2)
apps/web/src/server/aws/ses.ts (1)
  • deleteDomain (144-176)
apps/web/src/server/service/domain-service.ts (1)
  • deleteDomain (294-316)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
packages/sdk/types/schema.d.ts (1)

1-4: Auto-generated file; defer review to source OpenAPI spec.

This file is auto-generated from the OpenAPI specification. Any concerns about the DELETE operation should be addressed in the source OpenAPI document (apps/docs/api-reference/openapi.json).

apps/docs/api-reference/openapi.json (1)

625-636: Verify path parameter requirement.

The path parameter id is marked as required: false (line 632), which is unusual for a DELETE operation that requires a resource identifier. While the parameter is nullable, DELETE operations typically require the ID to be present in the path.

Ensure this aligns with the intended API behavior. If the ID must be provided, consider marking it as required: true even if it's nullable.

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 8 files

Prompt for AI agents (all 5 issues)

Understand the root cause of the following 5 issues and fix them.
<file name="apps/web/src/server/public-api/api/domains/delete-domain.ts">
<violation number="1" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:32">
Wrap the 403 response media type in a `content` property so the OpenAPI schema is valid.</violation>
<violation number="2" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:80">
Domain deletion logic duplicates `apps/web/src/server/service/domain-service.ts:deleteDomain()` function and omits critical side effects (SES deletion).</violation>
</file>
<file name="apps/docs/api-reference/openapi.json">
<violation number="1" location="apps/docs/api-reference/openapi.json:629">
The DELETE path parameter `id` is declared nullable, but a URL segment cannot be null and the backend expects a concrete number.</violation>
<violation number="2" location="apps/docs/api-reference/openapi.json:632">
Path parameters must be required in OpenAPI, but this DELETE operation marks `id` as optional, making the spec invalid for generators.</violation>
<violation number="3" location="apps/docs/api-reference/openapi.json:639">
The DELETE 200 response schema describes a full domain object, but the handler actually returns `{ success: true, message: &quot;Domain deleted successfully&quot; }`, so the OpenAPI contract is incorrect and will break generated clients.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acfccf3 and 5407a8d.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts
🔇 Additional comments (1)
packages/sdk/types/schema.d.ts (1)

372-372: Path parameter type is appropriately non-nullable.

Unlike the GET and verify endpoints that use number | null, the DELETE operation correctly uses number for the required id path parameter.

Comment threadpackages/sdk/types/schema.d.ts

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres lots of valid review comments, please address it

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/docs/api-reference/openapi.json (1)

637-795: Fix response schema to match actual handler payload.

The handler returns { success: boolean, message: string }, but the spec publishes a full Domain object. Generated clients will deserialize the wrong shape and break once the DELETE route is invoked. Update the schema to reflect the success/message contract.

 "200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
- "type": "object",- "properties": {- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"- },- "teamId": {- "type": "number",- "description": "The ID of the team",- "example": 1- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "region": {- "type": "string",- "default": "us-east-1"- },- "clickTracking": {- "type": "boolean",- "default": false- },- "openTracking": {- "type": "boolean",- "default": false- },- "publicKey": {- "type": "string"- },- "dkimStatus": {- "type": "string",- "nullable": true- },- "spfDetails": {- "type": "string",- "nullable": true- },- "createdAt": {- "type": "string"- },- "updatedAt": {- "type": "string"- },- "dmarcAdded": {- "type": "boolean",- "default": false- },- "isVerifying": {- "type": "boolean",- "default": false- },- "errorMessage": {- "type": "string",- "nullable": true- },- "subdomain": {- "type": "string",- "nullable": true- },- "verificationError": {- "type": "string",- "nullable": true- },- "lastCheckedTime": {- "type": "string",- "nullable": true- },- "dnsRecords": {- "type": "array",- "items": {- "type": "object",- "properties": {- "type": {- "type": "string",- "enum": [- "MX",- "TXT"- ],- "description": "DNS record type",- "example": "TXT"- },- "name": {- "type": "string",- "description": "DNS record name",- "example": "mail"- },- "value": {- "type": "string",- "description": "DNS record value",- "example": "v=spf1 include:amazonses.com ~all"- },- "ttl": {- "type": "string",- "description": "DNS record TTL",- "example": "Auto"- },- "priority": {- "type": "string",- "nullable": true,- "description": "DNS record priority",- "example": "10"- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "recommended": {- "type": "boolean",- "description": "Whether the record is recommended"- }- },- "required": [- "type",- "name",- "value",- "ttl",- "status"- ]- }- }- },- "required": [- "id",- "name",- "teamId",- "status",- "publicKey",- "createdAt",- "updatedAt",- "dnsRecords"- ]+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "example": true+ },+ "message": {+ "type": "string",+ "example": "Domain deleted successfully"+ }+ },+ "required": [+ "success",+ "message"+ ]
}
}
}
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5407a8d and f106574.

📒 Files selected for processing (3)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/api-reference/domains/delete-domain.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts

Comment threadapps/docs/api-reference/openapi.json
@kuntlme
kuntlme requested a review from KMKoushikOctober 3, 2025 20:51
@kuntlme

Copy link
Copy Markdown
ContributorAuthor

@KMKoushik Please review it.
I made changes as you instructed.

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

@kuntlme

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot for the confirmation and for helping me out.

@KMKoushik
KMKoushik merged commit 3f6a02a into usesend:mainOct 10, 2025
1 of 2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete domain API reference needed

2 participants

@kuntlme@KMKoushik
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

delete-domain route added - #267

Merged
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route
Oct 10, 2025
Merged

delete-domain route added#267
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route

Conversation

@kuntlme

@kuntlmekuntlme commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Fixes#262

Changes made

  • Added delete domain route in public-api
  • Updated OpenAPI schema with delete configuration
  • Added support in:
    • JS SDK
    • Python SDK
    • Documentation

Summary by cubic

Adds DELETE /v1/domains/{id} to remove a domain via the Public API with API key scoping. JS/TS and Python SDKs and docs are updated so clients can delete domains programmatically.

  • New Features
    • Public API: DELETE /v1/domains/{id} to delete a team domain.
      • 403 if API key is restricted to another domain.
      • 404 if the domain does not exist.
      • 200 returns { success: boolean, message: string }.
    • SDKs: Domains.delete(id) in JS/TS; usesend.domains.delete(domain_id) in Python.
    • Docs and OpenAPI updated (new delete-domain reference).

Summary by CodeRabbit

  • New Features

    • Added DELETE /v1/domains/{id} API to remove a domain and return the deleted domain details.
    • Domain deletion supported in JavaScript/TypeScript and Python SDKs; JS SDK now exposes a Domains client and can derive the API key from environment variables when not provided.
  • Documentation

    • Updated API reference and OpenAPI spec entries for domain deletion.

@vercel

vercelBot commented Oct 3, 2025

Copy link
Copy Markdown

@kuntlme is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitaiBot commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a DELETE /v1/domains/{id} endpoint across the stack: OpenAPI docs (apps/docs/api-reference/openapi.json and apps/docs/api-reference/domains/delete-domain.mdx), TypeScript types (packages/sdk/types/schema.d.ts) declaring the delete operation with a 200 response returning the full domain object, a server handler (apps/web/src/server/public-api/api/domains/delete-domain.ts) that validates id, enforces API-key domain access, returns 404 if not found, deletes the domain, and registers the route, and client methods: TypeScript SDK Domains.delete and UseSend.domains exposure, plus Python SDK Domains.delete(domain_id).

Possibly related PRs

Suggested labels

codex

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningThe PR includes modifications to packages/sdk/src/usesend.ts that add environment variable–based API key resolution and formatting tweaks which are unrelated to implementing the delete-domain route or addressing the linked issue objectives.Please remove or isolate the environment-variable key logic changes and formatting adjustments into a separate pull request so that this one focuses solely on the delete-domain functionality.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe title “delete-domain route added” succinctly and accurately describes the primary change of this pull request, which is the addition of a new DELETE route for domain deletion in the Public API.
Linked Issues Check✅ PassedThe pull request delivers a DELETE /v1/domains/{id} endpoint along with corresponding OpenAPI schema and documentation, fulfilling the requirement in linked issue #262 to provide an API endpoint and reference for domain deletion.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f106574 and cb95486.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/docs/api-reference/openapi.json (1)

637-797: Consider aligning DELETE response with REST conventions.

The DELETE operation returns the full domain object (lines 640-796), which is unconventional. Most DELETE operations return either:

  • 204 No Content (most common)
  • 200 with a minimal payload like {success: true, id: number}

For consistency, note that the contact DELETE operation in this same API (lines 1989-2008) returns a simple {success: boolean} payload. Returning the full domain object adds unnecessary response size and deviates from the API's own patterns.

Consider refactoring to return a minimal success payload:

 "responses": {
"200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"+ "success": {+ "type": "boolean"
},
- ... (all other domain fields)+ "id": {+ "type": "number"+ }
},
"required": [
- "id",- "name",- ... (other fields)+ "success",+ "id"
]
}
}
}
}
}

Alternatively, if you need to return the deleted domain for audit purposes, keep the current response but add a comment explaining this design decision.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216b80 and acfccf3.

📒 Files selected for processing (8)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
  • apps/web/src/server/public-api/index.ts (2 hunks)
  • packages/python-sdk/usesend/domains.py (1 hunks)
  • packages/sdk/src/domain.ts (2 hunks)
  • packages/sdk/src/usesend.ts (4 hunks)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise

Files:

  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
🧬 Code graph analysis (5)
packages/python-sdk/usesend/domains.py (2)
packages/python-sdk/usesend/usesend.py (1)
  • delete (118-121)
packages/python-sdk/usesend/types.py (2)
  • Domain (41-60)
  • APIError (337-339)
packages/sdk/src/usesend.ts (1)
packages/sdk/src/domain.ts (1)
  • Domains (48-89)
packages/sdk/src/domain.ts (1)
packages/sdk/types/index.ts (1)
  • ErrorResponse (1-4)
apps/web/src/server/public-api/api/domains/delete-domain.ts (3)
apps/web/src/server/public-api/hono.ts (1)
  • PublicAPIApp (136-136)
apps/web/src/server/public-api/api-error.ts (1)
  • UnsendApiError (62-75)
apps/web/src/server/db.ts (1)
  • db (20-20)
apps/web/src/server/public-api/index.ts (2)
apps/web/src/server/aws/ses.ts (1)
  • deleteDomain (144-176)
apps/web/src/server/service/domain-service.ts (1)
  • deleteDomain (294-316)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
packages/sdk/types/schema.d.ts (1)

1-4: Auto-generated file; defer review to source OpenAPI spec.

This file is auto-generated from the OpenAPI specification. Any concerns about the DELETE operation should be addressed in the source OpenAPI document (apps/docs/api-reference/openapi.json).

apps/docs/api-reference/openapi.json (1)

625-636: Verify path parameter requirement.

The path parameter id is marked as required: false (line 632), which is unusual for a DELETE operation that requires a resource identifier. While the parameter is nullable, DELETE operations typically require the ID to be present in the path.

Ensure this aligns with the intended API behavior. If the ID must be provided, consider marking it as required: true even if it's nullable.

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 8 files

Prompt for AI agents (all 5 issues)

Understand the root cause of the following 5 issues and fix them.
<file name="apps/web/src/server/public-api/api/domains/delete-domain.ts">
<violation number="1" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:32">
Wrap the 403 response media type in a `content` property so the OpenAPI schema is valid.</violation>
<violation number="2" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:80">
Domain deletion logic duplicates `apps/web/src/server/service/domain-service.ts:deleteDomain()` function and omits critical side effects (SES deletion).</violation>
</file>
<file name="apps/docs/api-reference/openapi.json">
<violation number="1" location="apps/docs/api-reference/openapi.json:629">
The DELETE path parameter `id` is declared nullable, but a URL segment cannot be null and the backend expects a concrete number.</violation>
<violation number="2" location="apps/docs/api-reference/openapi.json:632">
Path parameters must be required in OpenAPI, but this DELETE operation marks `id` as optional, making the spec invalid for generators.</violation>
<violation number="3" location="apps/docs/api-reference/openapi.json:639">
The DELETE 200 response schema describes a full domain object, but the handler actually returns `{ success: true, message: &quot;Domain deleted successfully&quot; }`, so the OpenAPI contract is incorrect and will break generated clients.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acfccf3 and 5407a8d.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts
🔇 Additional comments (1)
packages/sdk/types/schema.d.ts (1)

372-372: Path parameter type is appropriately non-nullable.

Unlike the GET and verify endpoints that use number | null, the DELETE operation correctly uses number for the required id path parameter.

Comment threadpackages/sdk/types/schema.d.ts

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres lots of valid review comments, please address it

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/docs/api-reference/openapi.json (1)

637-795: Fix response schema to match actual handler payload.

The handler returns { success: boolean, message: string }, but the spec publishes a full Domain object. Generated clients will deserialize the wrong shape and break once the DELETE route is invoked. Update the schema to reflect the success/message contract.

 "200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
- "type": "object",- "properties": {- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"- },- "teamId": {- "type": "number",- "description": "The ID of the team",- "example": 1- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "region": {- "type": "string",- "default": "us-east-1"- },- "clickTracking": {- "type": "boolean",- "default": false- },- "openTracking": {- "type": "boolean",- "default": false- },- "publicKey": {- "type": "string"- },- "dkimStatus": {- "type": "string",- "nullable": true- },- "spfDetails": {- "type": "string",- "nullable": true- },- "createdAt": {- "type": "string"- },- "updatedAt": {- "type": "string"- },- "dmarcAdded": {- "type": "boolean",- "default": false- },- "isVerifying": {- "type": "boolean",- "default": false- },- "errorMessage": {- "type": "string",- "nullable": true- },- "subdomain": {- "type": "string",- "nullable": true- },- "verificationError": {- "type": "string",- "nullable": true- },- "lastCheckedTime": {- "type": "string",- "nullable": true- },- "dnsRecords": {- "type": "array",- "items": {- "type": "object",- "properties": {- "type": {- "type": "string",- "enum": [- "MX",- "TXT"- ],- "description": "DNS record type",- "example": "TXT"- },- "name": {- "type": "string",- "description": "DNS record name",- "example": "mail"- },- "value": {- "type": "string",- "description": "DNS record value",- "example": "v=spf1 include:amazonses.com ~all"- },- "ttl": {- "type": "string",- "description": "DNS record TTL",- "example": "Auto"- },- "priority": {- "type": "string",- "nullable": true,- "description": "DNS record priority",- "example": "10"- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "recommended": {- "type": "boolean",- "description": "Whether the record is recommended"- }- },- "required": [- "type",- "name",- "value",- "ttl",- "status"- ]- }- }- },- "required": [- "id",- "name",- "teamId",- "status",- "publicKey",- "createdAt",- "updatedAt",- "dnsRecords"- ]+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "example": true+ },+ "message": {+ "type": "string",+ "example": "Domain deleted successfully"+ }+ },+ "required": [+ "success",+ "message"+ ]
}
}
}
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5407a8d and f106574.

📒 Files selected for processing (3)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/api-reference/domains/delete-domain.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts

Comment threadapps/docs/api-reference/openapi.json
@kuntlme
kuntlme requested a review from KMKoushikOctober 3, 2025 20:51
@kuntlme

Copy link
Copy Markdown
ContributorAuthor

@KMKoushik Please review it.
I made changes as you instructed.

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

@kuntlme

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot for the confirmation and for helping me out.

@KMKoushik
KMKoushik merged commit 3f6a02a into usesend:mainOct 10, 2025
1 of 2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete domain API reference needed

2 participants

@kuntlme@KMKoushik
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

delete-domain route added - #267

Merged
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route
Oct 10, 2025
Merged

delete-domain route added#267
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route

Conversation

@kuntlme

@kuntlmekuntlme commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Fixes#262

Changes made

  • Added delete domain route in public-api
  • Updated OpenAPI schema with delete configuration
  • Added support in:
    • JS SDK
    • Python SDK
    • Documentation

Summary by cubic

Adds DELETE /v1/domains/{id} to remove a domain via the Public API with API key scoping. JS/TS and Python SDKs and docs are updated so clients can delete domains programmatically.

  • New Features
    • Public API: DELETE /v1/domains/{id} to delete a team domain.
      • 403 if API key is restricted to another domain.
      • 404 if the domain does not exist.
      • 200 returns { success: boolean, message: string }.
    • SDKs: Domains.delete(id) in JS/TS; usesend.domains.delete(domain_id) in Python.
    • Docs and OpenAPI updated (new delete-domain reference).

Summary by CodeRabbit

  • New Features

    • Added DELETE /v1/domains/{id} API to remove a domain and return the deleted domain details.
    • Domain deletion supported in JavaScript/TypeScript and Python SDKs; JS SDK now exposes a Domains client and can derive the API key from environment variables when not provided.
  • Documentation

    • Updated API reference and OpenAPI spec entries for domain deletion.

@vercel

vercelBot commented Oct 3, 2025

Copy link
Copy Markdown

@kuntlme is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitaiBot commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a DELETE /v1/domains/{id} endpoint across the stack: OpenAPI docs (apps/docs/api-reference/openapi.json and apps/docs/api-reference/domains/delete-domain.mdx), TypeScript types (packages/sdk/types/schema.d.ts) declaring the delete operation with a 200 response returning the full domain object, a server handler (apps/web/src/server/public-api/api/domains/delete-domain.ts) that validates id, enforces API-key domain access, returns 404 if not found, deletes the domain, and registers the route, and client methods: TypeScript SDK Domains.delete and UseSend.domains exposure, plus Python SDK Domains.delete(domain_id).

Possibly related PRs

Suggested labels

codex

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningThe PR includes modifications to packages/sdk/src/usesend.ts that add environment variable–based API key resolution and formatting tweaks which are unrelated to implementing the delete-domain route or addressing the linked issue objectives.Please remove or isolate the environment-variable key logic changes and formatting adjustments into a separate pull request so that this one focuses solely on the delete-domain functionality.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe title “delete-domain route added” succinctly and accurately describes the primary change of this pull request, which is the addition of a new DELETE route for domain deletion in the Public API.
Linked Issues Check✅ PassedThe pull request delivers a DELETE /v1/domains/{id} endpoint along with corresponding OpenAPI schema and documentation, fulfilling the requirement in linked issue #262 to provide an API endpoint and reference for domain deletion.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f106574 and cb95486.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/docs/api-reference/openapi.json (1)

637-797: Consider aligning DELETE response with REST conventions.

The DELETE operation returns the full domain object (lines 640-796), which is unconventional. Most DELETE operations return either:

  • 204 No Content (most common)
  • 200 with a minimal payload like {success: true, id: number}

For consistency, note that the contact DELETE operation in this same API (lines 1989-2008) returns a simple {success: boolean} payload. Returning the full domain object adds unnecessary response size and deviates from the API's own patterns.

Consider refactoring to return a minimal success payload:

 "responses": {
"200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"+ "success": {+ "type": "boolean"
},
- ... (all other domain fields)+ "id": {+ "type": "number"+ }
},
"required": [
- "id",- "name",- ... (other fields)+ "success",+ "id"
]
}
}
}
}
}

Alternatively, if you need to return the deleted domain for audit purposes, keep the current response but add a comment explaining this design decision.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216b80 and acfccf3.

📒 Files selected for processing (8)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
  • apps/web/src/server/public-api/index.ts (2 hunks)
  • packages/python-sdk/usesend/domains.py (1 hunks)
  • packages/sdk/src/domain.ts (2 hunks)
  • packages/sdk/src/usesend.ts (4 hunks)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise

Files:

  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
🧬 Code graph analysis (5)
packages/python-sdk/usesend/domains.py (2)
packages/python-sdk/usesend/usesend.py (1)
  • delete (118-121)
packages/python-sdk/usesend/types.py (2)
  • Domain (41-60)
  • APIError (337-339)
packages/sdk/src/usesend.ts (1)
packages/sdk/src/domain.ts (1)
  • Domains (48-89)
packages/sdk/src/domain.ts (1)
packages/sdk/types/index.ts (1)
  • ErrorResponse (1-4)
apps/web/src/server/public-api/api/domains/delete-domain.ts (3)
apps/web/src/server/public-api/hono.ts (1)
  • PublicAPIApp (136-136)
apps/web/src/server/public-api/api-error.ts (1)
  • UnsendApiError (62-75)
apps/web/src/server/db.ts (1)
  • db (20-20)
apps/web/src/server/public-api/index.ts (2)
apps/web/src/server/aws/ses.ts (1)
  • deleteDomain (144-176)
apps/web/src/server/service/domain-service.ts (1)
  • deleteDomain (294-316)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
packages/sdk/types/schema.d.ts (1)

1-4: Auto-generated file; defer review to source OpenAPI spec.

This file is auto-generated from the OpenAPI specification. Any concerns about the DELETE operation should be addressed in the source OpenAPI document (apps/docs/api-reference/openapi.json).

apps/docs/api-reference/openapi.json (1)

625-636: Verify path parameter requirement.

The path parameter id is marked as required: false (line 632), which is unusual for a DELETE operation that requires a resource identifier. While the parameter is nullable, DELETE operations typically require the ID to be present in the path.

Ensure this aligns with the intended API behavior. If the ID must be provided, consider marking it as required: true even if it's nullable.

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 8 files

Prompt for AI agents (all 5 issues)

Understand the root cause of the following 5 issues and fix them.
<file name="apps/web/src/server/public-api/api/domains/delete-domain.ts">
<violation number="1" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:32">
Wrap the 403 response media type in a `content` property so the OpenAPI schema is valid.</violation>
<violation number="2" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:80">
Domain deletion logic duplicates `apps/web/src/server/service/domain-service.ts:deleteDomain()` function and omits critical side effects (SES deletion).</violation>
</file>
<file name="apps/docs/api-reference/openapi.json">
<violation number="1" location="apps/docs/api-reference/openapi.json:629">
The DELETE path parameter `id` is declared nullable, but a URL segment cannot be null and the backend expects a concrete number.</violation>
<violation number="2" location="apps/docs/api-reference/openapi.json:632">
Path parameters must be required in OpenAPI, but this DELETE operation marks `id` as optional, making the spec invalid for generators.</violation>
<violation number="3" location="apps/docs/api-reference/openapi.json:639">
The DELETE 200 response schema describes a full domain object, but the handler actually returns `{ success: true, message: &quot;Domain deleted successfully&quot; }`, so the OpenAPI contract is incorrect and will break generated clients.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acfccf3 and 5407a8d.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts
🔇 Additional comments (1)
packages/sdk/types/schema.d.ts (1)

372-372: Path parameter type is appropriately non-nullable.

Unlike the GET and verify endpoints that use number | null, the DELETE operation correctly uses number for the required id path parameter.

Comment threadpackages/sdk/types/schema.d.ts

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres lots of valid review comments, please address it

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/docs/api-reference/openapi.json (1)

637-795: Fix response schema to match actual handler payload.

The handler returns { success: boolean, message: string }, but the spec publishes a full Domain object. Generated clients will deserialize the wrong shape and break once the DELETE route is invoked. Update the schema to reflect the success/message contract.

 "200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
- "type": "object",- "properties": {- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"- },- "teamId": {- "type": "number",- "description": "The ID of the team",- "example": 1- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "region": {- "type": "string",- "default": "us-east-1"- },- "clickTracking": {- "type": "boolean",- "default": false- },- "openTracking": {- "type": "boolean",- "default": false- },- "publicKey": {- "type": "string"- },- "dkimStatus": {- "type": "string",- "nullable": true- },- "spfDetails": {- "type": "string",- "nullable": true- },- "createdAt": {- "type": "string"- },- "updatedAt": {- "type": "string"- },- "dmarcAdded": {- "type": "boolean",- "default": false- },- "isVerifying": {- "type": "boolean",- "default": false- },- "errorMessage": {- "type": "string",- "nullable": true- },- "subdomain": {- "type": "string",- "nullable": true- },- "verificationError": {- "type": "string",- "nullable": true- },- "lastCheckedTime": {- "type": "string",- "nullable": true- },- "dnsRecords": {- "type": "array",- "items": {- "type": "object",- "properties": {- "type": {- "type": "string",- "enum": [- "MX",- "TXT"- ],- "description": "DNS record type",- "example": "TXT"- },- "name": {- "type": "string",- "description": "DNS record name",- "example": "mail"- },- "value": {- "type": "string",- "description": "DNS record value",- "example": "v=spf1 include:amazonses.com ~all"- },- "ttl": {- "type": "string",- "description": "DNS record TTL",- "example": "Auto"- },- "priority": {- "type": "string",- "nullable": true,- "description": "DNS record priority",- "example": "10"- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "recommended": {- "type": "boolean",- "description": "Whether the record is recommended"- }- },- "required": [- "type",- "name",- "value",- "ttl",- "status"- ]- }- }- },- "required": [- "id",- "name",- "teamId",- "status",- "publicKey",- "createdAt",- "updatedAt",- "dnsRecords"- ]+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "example": true+ },+ "message": {+ "type": "string",+ "example": "Domain deleted successfully"+ }+ },+ "required": [+ "success",+ "message"+ ]
}
}
}
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5407a8d and f106574.

📒 Files selected for processing (3)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/api-reference/domains/delete-domain.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts

Comment threadapps/docs/api-reference/openapi.json
@kuntlme
kuntlme requested a review from KMKoushikOctober 3, 2025 20:51
@kuntlme

Copy link
Copy Markdown
ContributorAuthor

@KMKoushik Please review it.
I made changes as you instructed.

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

@kuntlme

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot for the confirmation and for helping me out.

@KMKoushik
KMKoushik merged commit 3f6a02a into usesend:mainOct 10, 2025
1 of 2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete domain API reference needed

2 participants

@kuntlme@KMKoushik
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

delete-domain route added - #267

Merged
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route
Oct 10, 2025
Merged

delete-domain route added#267
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route

Conversation

@kuntlme

@kuntlmekuntlme commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Fixes#262

Changes made

  • Added delete domain route in public-api
  • Updated OpenAPI schema with delete configuration
  • Added support in:
    • JS SDK
    • Python SDK
    • Documentation

Summary by cubic

Adds DELETE /v1/domains/{id} to remove a domain via the Public API with API key scoping. JS/TS and Python SDKs and docs are updated so clients can delete domains programmatically.

  • New Features
    • Public API: DELETE /v1/domains/{id} to delete a team domain.
      • 403 if API key is restricted to another domain.
      • 404 if the domain does not exist.
      • 200 returns { success: boolean, message: string }.
    • SDKs: Domains.delete(id) in JS/TS; usesend.domains.delete(domain_id) in Python.
    • Docs and OpenAPI updated (new delete-domain reference).

Summary by CodeRabbit

  • New Features

    • Added DELETE /v1/domains/{id} API to remove a domain and return the deleted domain details.
    • Domain deletion supported in JavaScript/TypeScript and Python SDKs; JS SDK now exposes a Domains client and can derive the API key from environment variables when not provided.
  • Documentation

    • Updated API reference and OpenAPI spec entries for domain deletion.

@vercel

vercelBot commented Oct 3, 2025

Copy link
Copy Markdown

@kuntlme is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitaiBot commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a DELETE /v1/domains/{id} endpoint across the stack: OpenAPI docs (apps/docs/api-reference/openapi.json and apps/docs/api-reference/domains/delete-domain.mdx), TypeScript types (packages/sdk/types/schema.d.ts) declaring the delete operation with a 200 response returning the full domain object, a server handler (apps/web/src/server/public-api/api/domains/delete-domain.ts) that validates id, enforces API-key domain access, returns 404 if not found, deletes the domain, and registers the route, and client methods: TypeScript SDK Domains.delete and UseSend.domains exposure, plus Python SDK Domains.delete(domain_id).

Possibly related PRs

Suggested labels

codex

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningThe PR includes modifications to packages/sdk/src/usesend.ts that add environment variable–based API key resolution and formatting tweaks which are unrelated to implementing the delete-domain route or addressing the linked issue objectives.Please remove or isolate the environment-variable key logic changes and formatting adjustments into a separate pull request so that this one focuses solely on the delete-domain functionality.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe title “delete-domain route added” succinctly and accurately describes the primary change of this pull request, which is the addition of a new DELETE route for domain deletion in the Public API.
Linked Issues Check✅ PassedThe pull request delivers a DELETE /v1/domains/{id} endpoint along with corresponding OpenAPI schema and documentation, fulfilling the requirement in linked issue #262 to provide an API endpoint and reference for domain deletion.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f106574 and cb95486.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/docs/api-reference/openapi.json (1)

637-797: Consider aligning DELETE response with REST conventions.

The DELETE operation returns the full domain object (lines 640-796), which is unconventional. Most DELETE operations return either:

  • 204 No Content (most common)
  • 200 with a minimal payload like {success: true, id: number}

For consistency, note that the contact DELETE operation in this same API (lines 1989-2008) returns a simple {success: boolean} payload. Returning the full domain object adds unnecessary response size and deviates from the API's own patterns.

Consider refactoring to return a minimal success payload:

 "responses": {
"200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"+ "success": {+ "type": "boolean"
},
- ... (all other domain fields)+ "id": {+ "type": "number"+ }
},
"required": [
- "id",- "name",- ... (other fields)+ "success",+ "id"
]
}
}
}
}
}

Alternatively, if you need to return the deleted domain for audit purposes, keep the current response but add a comment explaining this design decision.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216b80 and acfccf3.

📒 Files selected for processing (8)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
  • apps/web/src/server/public-api/index.ts (2 hunks)
  • packages/python-sdk/usesend/domains.py (1 hunks)
  • packages/sdk/src/domain.ts (2 hunks)
  • packages/sdk/src/usesend.ts (4 hunks)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise

Files:

  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
🧬 Code graph analysis (5)
packages/python-sdk/usesend/domains.py (2)
packages/python-sdk/usesend/usesend.py (1)
  • delete (118-121)
packages/python-sdk/usesend/types.py (2)
  • Domain (41-60)
  • APIError (337-339)
packages/sdk/src/usesend.ts (1)
packages/sdk/src/domain.ts (1)
  • Domains (48-89)
packages/sdk/src/domain.ts (1)
packages/sdk/types/index.ts (1)
  • ErrorResponse (1-4)
apps/web/src/server/public-api/api/domains/delete-domain.ts (3)
apps/web/src/server/public-api/hono.ts (1)
  • PublicAPIApp (136-136)
apps/web/src/server/public-api/api-error.ts (1)
  • UnsendApiError (62-75)
apps/web/src/server/db.ts (1)
  • db (20-20)
apps/web/src/server/public-api/index.ts (2)
apps/web/src/server/aws/ses.ts (1)
  • deleteDomain (144-176)
apps/web/src/server/service/domain-service.ts (1)
  • deleteDomain (294-316)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
packages/sdk/types/schema.d.ts (1)

1-4: Auto-generated file; defer review to source OpenAPI spec.

This file is auto-generated from the OpenAPI specification. Any concerns about the DELETE operation should be addressed in the source OpenAPI document (apps/docs/api-reference/openapi.json).

apps/docs/api-reference/openapi.json (1)

625-636: Verify path parameter requirement.

The path parameter id is marked as required: false (line 632), which is unusual for a DELETE operation that requires a resource identifier. While the parameter is nullable, DELETE operations typically require the ID to be present in the path.

Ensure this aligns with the intended API behavior. If the ID must be provided, consider marking it as required: true even if it's nullable.

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 8 files

Prompt for AI agents (all 5 issues)

Understand the root cause of the following 5 issues and fix them.
<file name="apps/web/src/server/public-api/api/domains/delete-domain.ts">
<violation number="1" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:32">
Wrap the 403 response media type in a `content` property so the OpenAPI schema is valid.</violation>
<violation number="2" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:80">
Domain deletion logic duplicates `apps/web/src/server/service/domain-service.ts:deleteDomain()` function and omits critical side effects (SES deletion).</violation>
</file>
<file name="apps/docs/api-reference/openapi.json">
<violation number="1" location="apps/docs/api-reference/openapi.json:629">
The DELETE path parameter `id` is declared nullable, but a URL segment cannot be null and the backend expects a concrete number.</violation>
<violation number="2" location="apps/docs/api-reference/openapi.json:632">
Path parameters must be required in OpenAPI, but this DELETE operation marks `id` as optional, making the spec invalid for generators.</violation>
<violation number="3" location="apps/docs/api-reference/openapi.json:639">
The DELETE 200 response schema describes a full domain object, but the handler actually returns `{ success: true, message: &quot;Domain deleted successfully&quot; }`, so the OpenAPI contract is incorrect and will break generated clients.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acfccf3 and 5407a8d.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts
🔇 Additional comments (1)
packages/sdk/types/schema.d.ts (1)

372-372: Path parameter type is appropriately non-nullable.

Unlike the GET and verify endpoints that use number | null, the DELETE operation correctly uses number for the required id path parameter.

Comment threadpackages/sdk/types/schema.d.ts

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres lots of valid review comments, please address it

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/docs/api-reference/openapi.json (1)

637-795: Fix response schema to match actual handler payload.

The handler returns { success: boolean, message: string }, but the spec publishes a full Domain object. Generated clients will deserialize the wrong shape and break once the DELETE route is invoked. Update the schema to reflect the success/message contract.

 "200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
- "type": "object",- "properties": {- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"- },- "teamId": {- "type": "number",- "description": "The ID of the team",- "example": 1- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "region": {- "type": "string",- "default": "us-east-1"- },- "clickTracking": {- "type": "boolean",- "default": false- },- "openTracking": {- "type": "boolean",- "default": false- },- "publicKey": {- "type": "string"- },- "dkimStatus": {- "type": "string",- "nullable": true- },- "spfDetails": {- "type": "string",- "nullable": true- },- "createdAt": {- "type": "string"- },- "updatedAt": {- "type": "string"- },- "dmarcAdded": {- "type": "boolean",- "default": false- },- "isVerifying": {- "type": "boolean",- "default": false- },- "errorMessage": {- "type": "string",- "nullable": true- },- "subdomain": {- "type": "string",- "nullable": true- },- "verificationError": {- "type": "string",- "nullable": true- },- "lastCheckedTime": {- "type": "string",- "nullable": true- },- "dnsRecords": {- "type": "array",- "items": {- "type": "object",- "properties": {- "type": {- "type": "string",- "enum": [- "MX",- "TXT"- ],- "description": "DNS record type",- "example": "TXT"- },- "name": {- "type": "string",- "description": "DNS record name",- "example": "mail"- },- "value": {- "type": "string",- "description": "DNS record value",- "example": "v=spf1 include:amazonses.com ~all"- },- "ttl": {- "type": "string",- "description": "DNS record TTL",- "example": "Auto"- },- "priority": {- "type": "string",- "nullable": true,- "description": "DNS record priority",- "example": "10"- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "recommended": {- "type": "boolean",- "description": "Whether the record is recommended"- }- },- "required": [- "type",- "name",- "value",- "ttl",- "status"- ]- }- }- },- "required": [- "id",- "name",- "teamId",- "status",- "publicKey",- "createdAt",- "updatedAt",- "dnsRecords"- ]+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "example": true+ },+ "message": {+ "type": "string",+ "example": "Domain deleted successfully"+ }+ },+ "required": [+ "success",+ "message"+ ]
}
}
}
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5407a8d and f106574.

📒 Files selected for processing (3)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/api-reference/domains/delete-domain.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts

Comment threadapps/docs/api-reference/openapi.json
@kuntlme
kuntlme requested a review from KMKoushikOctober 3, 2025 20:51
@kuntlme

Copy link
Copy Markdown
ContributorAuthor

@KMKoushik Please review it.
I made changes as you instructed.

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

@kuntlme

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot for the confirmation and for helping me out.

@KMKoushik
KMKoushik merged commit 3f6a02a into usesend:mainOct 10, 2025
1 of 2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete domain API reference needed

2 participants

@kuntlme@KMKoushik
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

delete-domain route added - #267

Merged
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route
Oct 10, 2025
Merged

delete-domain route added#267
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route

Conversation

@kuntlme

@kuntlmekuntlme commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Fixes#262

Changes made

  • Added delete domain route in public-api
  • Updated OpenAPI schema with delete configuration
  • Added support in:
    • JS SDK
    • Python SDK
    • Documentation

Summary by cubic

Adds DELETE /v1/domains/{id} to remove a domain via the Public API with API key scoping. JS/TS and Python SDKs and docs are updated so clients can delete domains programmatically.

  • New Features
    • Public API: DELETE /v1/domains/{id} to delete a team domain.
      • 403 if API key is restricted to another domain.
      • 404 if the domain does not exist.
      • 200 returns { success: boolean, message: string }.
    • SDKs: Domains.delete(id) in JS/TS; usesend.domains.delete(domain_id) in Python.
    • Docs and OpenAPI updated (new delete-domain reference).

Summary by CodeRabbit

  • New Features

    • Added DELETE /v1/domains/{id} API to remove a domain and return the deleted domain details.
    • Domain deletion supported in JavaScript/TypeScript and Python SDKs; JS SDK now exposes a Domains client and can derive the API key from environment variables when not provided.
  • Documentation

    • Updated API reference and OpenAPI spec entries for domain deletion.

@vercel

vercelBot commented Oct 3, 2025

Copy link
Copy Markdown

@kuntlme is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitaiBot commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a DELETE /v1/domains/{id} endpoint across the stack: OpenAPI docs (apps/docs/api-reference/openapi.json and apps/docs/api-reference/domains/delete-domain.mdx), TypeScript types (packages/sdk/types/schema.d.ts) declaring the delete operation with a 200 response returning the full domain object, a server handler (apps/web/src/server/public-api/api/domains/delete-domain.ts) that validates id, enforces API-key domain access, returns 404 if not found, deletes the domain, and registers the route, and client methods: TypeScript SDK Domains.delete and UseSend.domains exposure, plus Python SDK Domains.delete(domain_id).

Possibly related PRs

Suggested labels

codex

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningThe PR includes modifications to packages/sdk/src/usesend.ts that add environment variable–based API key resolution and formatting tweaks which are unrelated to implementing the delete-domain route or addressing the linked issue objectives.Please remove or isolate the environment-variable key logic changes and formatting adjustments into a separate pull request so that this one focuses solely on the delete-domain functionality.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe title “delete-domain route added” succinctly and accurately describes the primary change of this pull request, which is the addition of a new DELETE route for domain deletion in the Public API.
Linked Issues Check✅ PassedThe pull request delivers a DELETE /v1/domains/{id} endpoint along with corresponding OpenAPI schema and documentation, fulfilling the requirement in linked issue #262 to provide an API endpoint and reference for domain deletion.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f106574 and cb95486.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/docs/api-reference/openapi.json (1)

637-797: Consider aligning DELETE response with REST conventions.

The DELETE operation returns the full domain object (lines 640-796), which is unconventional. Most DELETE operations return either:

  • 204 No Content (most common)
  • 200 with a minimal payload like {success: true, id: number}

For consistency, note that the contact DELETE operation in this same API (lines 1989-2008) returns a simple {success: boolean} payload. Returning the full domain object adds unnecessary response size and deviates from the API's own patterns.

Consider refactoring to return a minimal success payload:

 "responses": {
"200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"+ "success": {+ "type": "boolean"
},
- ... (all other domain fields)+ "id": {+ "type": "number"+ }
},
"required": [
- "id",- "name",- ... (other fields)+ "success",+ "id"
]
}
}
}
}
}

Alternatively, if you need to return the deleted domain for audit purposes, keep the current response but add a comment explaining this design decision.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216b80 and acfccf3.

📒 Files selected for processing (8)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
  • apps/web/src/server/public-api/index.ts (2 hunks)
  • packages/python-sdk/usesend/domains.py (1 hunks)
  • packages/sdk/src/domain.ts (2 hunks)
  • packages/sdk/src/usesend.ts (4 hunks)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise

Files:

  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
🧬 Code graph analysis (5)
packages/python-sdk/usesend/domains.py (2)
packages/python-sdk/usesend/usesend.py (1)
  • delete (118-121)
packages/python-sdk/usesend/types.py (2)
  • Domain (41-60)
  • APIError (337-339)
packages/sdk/src/usesend.ts (1)
packages/sdk/src/domain.ts (1)
  • Domains (48-89)
packages/sdk/src/domain.ts (1)
packages/sdk/types/index.ts (1)
  • ErrorResponse (1-4)
apps/web/src/server/public-api/api/domains/delete-domain.ts (3)
apps/web/src/server/public-api/hono.ts (1)
  • PublicAPIApp (136-136)
apps/web/src/server/public-api/api-error.ts (1)
  • UnsendApiError (62-75)
apps/web/src/server/db.ts (1)
  • db (20-20)
apps/web/src/server/public-api/index.ts (2)
apps/web/src/server/aws/ses.ts (1)
  • deleteDomain (144-176)
apps/web/src/server/service/domain-service.ts (1)
  • deleteDomain (294-316)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
packages/sdk/types/schema.d.ts (1)

1-4: Auto-generated file; defer review to source OpenAPI spec.

This file is auto-generated from the OpenAPI specification. Any concerns about the DELETE operation should be addressed in the source OpenAPI document (apps/docs/api-reference/openapi.json).

apps/docs/api-reference/openapi.json (1)

625-636: Verify path parameter requirement.

The path parameter id is marked as required: false (line 632), which is unusual for a DELETE operation that requires a resource identifier. While the parameter is nullable, DELETE operations typically require the ID to be present in the path.

Ensure this aligns with the intended API behavior. If the ID must be provided, consider marking it as required: true even if it's nullable.

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 8 files

Prompt for AI agents (all 5 issues)

Understand the root cause of the following 5 issues and fix them.
<file name="apps/web/src/server/public-api/api/domains/delete-domain.ts">
<violation number="1" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:32">
Wrap the 403 response media type in a `content` property so the OpenAPI schema is valid.</violation>
<violation number="2" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:80">
Domain deletion logic duplicates `apps/web/src/server/service/domain-service.ts:deleteDomain()` function and omits critical side effects (SES deletion).</violation>
</file>
<file name="apps/docs/api-reference/openapi.json">
<violation number="1" location="apps/docs/api-reference/openapi.json:629">
The DELETE path parameter `id` is declared nullable, but a URL segment cannot be null and the backend expects a concrete number.</violation>
<violation number="2" location="apps/docs/api-reference/openapi.json:632">
Path parameters must be required in OpenAPI, but this DELETE operation marks `id` as optional, making the spec invalid for generators.</violation>
<violation number="3" location="apps/docs/api-reference/openapi.json:639">
The DELETE 200 response schema describes a full domain object, but the handler actually returns `{ success: true, message: &quot;Domain deleted successfully&quot; }`, so the OpenAPI contract is incorrect and will break generated clients.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acfccf3 and 5407a8d.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts
🔇 Additional comments (1)
packages/sdk/types/schema.d.ts (1)

372-372: Path parameter type is appropriately non-nullable.

Unlike the GET and verify endpoints that use number | null, the DELETE operation correctly uses number for the required id path parameter.

Comment threadpackages/sdk/types/schema.d.ts

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres lots of valid review comments, please address it

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/docs/api-reference/openapi.json (1)

637-795: Fix response schema to match actual handler payload.

The handler returns { success: boolean, message: string }, but the spec publishes a full Domain object. Generated clients will deserialize the wrong shape and break once the DELETE route is invoked. Update the schema to reflect the success/message contract.

 "200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
- "type": "object",- "properties": {- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"- },- "teamId": {- "type": "number",- "description": "The ID of the team",- "example": 1- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "region": {- "type": "string",- "default": "us-east-1"- },- "clickTracking": {- "type": "boolean",- "default": false- },- "openTracking": {- "type": "boolean",- "default": false- },- "publicKey": {- "type": "string"- },- "dkimStatus": {- "type": "string",- "nullable": true- },- "spfDetails": {- "type": "string",- "nullable": true- },- "createdAt": {- "type": "string"- },- "updatedAt": {- "type": "string"- },- "dmarcAdded": {- "type": "boolean",- "default": false- },- "isVerifying": {- "type": "boolean",- "default": false- },- "errorMessage": {- "type": "string",- "nullable": true- },- "subdomain": {- "type": "string",- "nullable": true- },- "verificationError": {- "type": "string",- "nullable": true- },- "lastCheckedTime": {- "type": "string",- "nullable": true- },- "dnsRecords": {- "type": "array",- "items": {- "type": "object",- "properties": {- "type": {- "type": "string",- "enum": [- "MX",- "TXT"- ],- "description": "DNS record type",- "example": "TXT"- },- "name": {- "type": "string",- "description": "DNS record name",- "example": "mail"- },- "value": {- "type": "string",- "description": "DNS record value",- "example": "v=spf1 include:amazonses.com ~all"- },- "ttl": {- "type": "string",- "description": "DNS record TTL",- "example": "Auto"- },- "priority": {- "type": "string",- "nullable": true,- "description": "DNS record priority",- "example": "10"- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "recommended": {- "type": "boolean",- "description": "Whether the record is recommended"- }- },- "required": [- "type",- "name",- "value",- "ttl",- "status"- ]- }- }- },- "required": [- "id",- "name",- "teamId",- "status",- "publicKey",- "createdAt",- "updatedAt",- "dnsRecords"- ]+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "example": true+ },+ "message": {+ "type": "string",+ "example": "Domain deleted successfully"+ }+ },+ "required": [+ "success",+ "message"+ ]
}
}
}
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5407a8d and f106574.

📒 Files selected for processing (3)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/api-reference/domains/delete-domain.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts

Comment threadapps/docs/api-reference/openapi.json
@kuntlme
kuntlme requested a review from KMKoushikOctober 3, 2025 20:51
@kuntlme

Copy link
Copy Markdown
ContributorAuthor

@KMKoushik Please review it.
I made changes as you instructed.

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

@kuntlme

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot for the confirmation and for helping me out.

@KMKoushik
KMKoushik merged commit 3f6a02a into usesend:mainOct 10, 2025
1 of 2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete domain API reference needed

2 participants

@kuntlme@KMKoushik
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

delete-domain route added - #267

Merged
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route
Oct 10, 2025
Merged

delete-domain route added#267
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route

Conversation

@kuntlme

@kuntlmekuntlme commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Fixes#262

Changes made

  • Added delete domain route in public-api
  • Updated OpenAPI schema with delete configuration
  • Added support in:
    • JS SDK
    • Python SDK
    • Documentation

Summary by cubic

Adds DELETE /v1/domains/{id} to remove a domain via the Public API with API key scoping. JS/TS and Python SDKs and docs are updated so clients can delete domains programmatically.

  • New Features
    • Public API: DELETE /v1/domains/{id} to delete a team domain.
      • 403 if API key is restricted to another domain.
      • 404 if the domain does not exist.
      • 200 returns { success: boolean, message: string }.
    • SDKs: Domains.delete(id) in JS/TS; usesend.domains.delete(domain_id) in Python.
    • Docs and OpenAPI updated (new delete-domain reference).

Summary by CodeRabbit

  • New Features

    • Added DELETE /v1/domains/{id} API to remove a domain and return the deleted domain details.
    • Domain deletion supported in JavaScript/TypeScript and Python SDKs; JS SDK now exposes a Domains client and can derive the API key from environment variables when not provided.
  • Documentation

    • Updated API reference and OpenAPI spec entries for domain deletion.

@vercel

vercelBot commented Oct 3, 2025

Copy link
Copy Markdown

@kuntlme is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitaiBot commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a DELETE /v1/domains/{id} endpoint across the stack: OpenAPI docs (apps/docs/api-reference/openapi.json and apps/docs/api-reference/domains/delete-domain.mdx), TypeScript types (packages/sdk/types/schema.d.ts) declaring the delete operation with a 200 response returning the full domain object, a server handler (apps/web/src/server/public-api/api/domains/delete-domain.ts) that validates id, enforces API-key domain access, returns 404 if not found, deletes the domain, and registers the route, and client methods: TypeScript SDK Domains.delete and UseSend.domains exposure, plus Python SDK Domains.delete(domain_id).

Possibly related PRs

Suggested labels

codex

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningThe PR includes modifications to packages/sdk/src/usesend.ts that add environment variable–based API key resolution and formatting tweaks which are unrelated to implementing the delete-domain route or addressing the linked issue objectives.Please remove or isolate the environment-variable key logic changes and formatting adjustments into a separate pull request so that this one focuses solely on the delete-domain functionality.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe title “delete-domain route added” succinctly and accurately describes the primary change of this pull request, which is the addition of a new DELETE route for domain deletion in the Public API.
Linked Issues Check✅ PassedThe pull request delivers a DELETE /v1/domains/{id} endpoint along with corresponding OpenAPI schema and documentation, fulfilling the requirement in linked issue #262 to provide an API endpoint and reference for domain deletion.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f106574 and cb95486.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/docs/api-reference/openapi.json (1)

637-797: Consider aligning DELETE response with REST conventions.

The DELETE operation returns the full domain object (lines 640-796), which is unconventional. Most DELETE operations return either:

  • 204 No Content (most common)
  • 200 with a minimal payload like {success: true, id: number}

For consistency, note that the contact DELETE operation in this same API (lines 1989-2008) returns a simple {success: boolean} payload. Returning the full domain object adds unnecessary response size and deviates from the API's own patterns.

Consider refactoring to return a minimal success payload:

 "responses": {
"200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"+ "success": {+ "type": "boolean"
},
- ... (all other domain fields)+ "id": {+ "type": "number"+ }
},
"required": [
- "id",- "name",- ... (other fields)+ "success",+ "id"
]
}
}
}
}
}

Alternatively, if you need to return the deleted domain for audit purposes, keep the current response but add a comment explaining this design decision.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216b80 and acfccf3.

📒 Files selected for processing (8)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
  • apps/web/src/server/public-api/index.ts (2 hunks)
  • packages/python-sdk/usesend/domains.py (1 hunks)
  • packages/sdk/src/domain.ts (2 hunks)
  • packages/sdk/src/usesend.ts (4 hunks)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise

Files:

  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
🧬 Code graph analysis (5)
packages/python-sdk/usesend/domains.py (2)
packages/python-sdk/usesend/usesend.py (1)
  • delete (118-121)
packages/python-sdk/usesend/types.py (2)
  • Domain (41-60)
  • APIError (337-339)
packages/sdk/src/usesend.ts (1)
packages/sdk/src/domain.ts (1)
  • Domains (48-89)
packages/sdk/src/domain.ts (1)
packages/sdk/types/index.ts (1)
  • ErrorResponse (1-4)
apps/web/src/server/public-api/api/domains/delete-domain.ts (3)
apps/web/src/server/public-api/hono.ts (1)
  • PublicAPIApp (136-136)
apps/web/src/server/public-api/api-error.ts (1)
  • UnsendApiError (62-75)
apps/web/src/server/db.ts (1)
  • db (20-20)
apps/web/src/server/public-api/index.ts (2)
apps/web/src/server/aws/ses.ts (1)
  • deleteDomain (144-176)
apps/web/src/server/service/domain-service.ts (1)
  • deleteDomain (294-316)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
packages/sdk/types/schema.d.ts (1)

1-4: Auto-generated file; defer review to source OpenAPI spec.

This file is auto-generated from the OpenAPI specification. Any concerns about the DELETE operation should be addressed in the source OpenAPI document (apps/docs/api-reference/openapi.json).

apps/docs/api-reference/openapi.json (1)

625-636: Verify path parameter requirement.

The path parameter id is marked as required: false (line 632), which is unusual for a DELETE operation that requires a resource identifier. While the parameter is nullable, DELETE operations typically require the ID to be present in the path.

Ensure this aligns with the intended API behavior. If the ID must be provided, consider marking it as required: true even if it's nullable.

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 8 files

Prompt for AI agents (all 5 issues)

Understand the root cause of the following 5 issues and fix them.
<file name="apps/web/src/server/public-api/api/domains/delete-domain.ts">
<violation number="1" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:32">
Wrap the 403 response media type in a `content` property so the OpenAPI schema is valid.</violation>
<violation number="2" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:80">
Domain deletion logic duplicates `apps/web/src/server/service/domain-service.ts:deleteDomain()` function and omits critical side effects (SES deletion).</violation>
</file>
<file name="apps/docs/api-reference/openapi.json">
<violation number="1" location="apps/docs/api-reference/openapi.json:629">
The DELETE path parameter `id` is declared nullable, but a URL segment cannot be null and the backend expects a concrete number.</violation>
<violation number="2" location="apps/docs/api-reference/openapi.json:632">
Path parameters must be required in OpenAPI, but this DELETE operation marks `id` as optional, making the spec invalid for generators.</violation>
<violation number="3" location="apps/docs/api-reference/openapi.json:639">
The DELETE 200 response schema describes a full domain object, but the handler actually returns `{ success: true, message: &quot;Domain deleted successfully&quot; }`, so the OpenAPI contract is incorrect and will break generated clients.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acfccf3 and 5407a8d.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts
🔇 Additional comments (1)
packages/sdk/types/schema.d.ts (1)

372-372: Path parameter type is appropriately non-nullable.

Unlike the GET and verify endpoints that use number | null, the DELETE operation correctly uses number for the required id path parameter.

Comment threadpackages/sdk/types/schema.d.ts

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres lots of valid review comments, please address it

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/docs/api-reference/openapi.json (1)

637-795: Fix response schema to match actual handler payload.

The handler returns { success: boolean, message: string }, but the spec publishes a full Domain object. Generated clients will deserialize the wrong shape and break once the DELETE route is invoked. Update the schema to reflect the success/message contract.

 "200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
- "type": "object",- "properties": {- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"- },- "teamId": {- "type": "number",- "description": "The ID of the team",- "example": 1- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "region": {- "type": "string",- "default": "us-east-1"- },- "clickTracking": {- "type": "boolean",- "default": false- },- "openTracking": {- "type": "boolean",- "default": false- },- "publicKey": {- "type": "string"- },- "dkimStatus": {- "type": "string",- "nullable": true- },- "spfDetails": {- "type": "string",- "nullable": true- },- "createdAt": {- "type": "string"- },- "updatedAt": {- "type": "string"- },- "dmarcAdded": {- "type": "boolean",- "default": false- },- "isVerifying": {- "type": "boolean",- "default": false- },- "errorMessage": {- "type": "string",- "nullable": true- },- "subdomain": {- "type": "string",- "nullable": true- },- "verificationError": {- "type": "string",- "nullable": true- },- "lastCheckedTime": {- "type": "string",- "nullable": true- },- "dnsRecords": {- "type": "array",- "items": {- "type": "object",- "properties": {- "type": {- "type": "string",- "enum": [- "MX",- "TXT"- ],- "description": "DNS record type",- "example": "TXT"- },- "name": {- "type": "string",- "description": "DNS record name",- "example": "mail"- },- "value": {- "type": "string",- "description": "DNS record value",- "example": "v=spf1 include:amazonses.com ~all"- },- "ttl": {- "type": "string",- "description": "DNS record TTL",- "example": "Auto"- },- "priority": {- "type": "string",- "nullable": true,- "description": "DNS record priority",- "example": "10"- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "recommended": {- "type": "boolean",- "description": "Whether the record is recommended"- }- },- "required": [- "type",- "name",- "value",- "ttl",- "status"- ]- }- }- },- "required": [- "id",- "name",- "teamId",- "status",- "publicKey",- "createdAt",- "updatedAt",- "dnsRecords"- ]+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "example": true+ },+ "message": {+ "type": "string",+ "example": "Domain deleted successfully"+ }+ },+ "required": [+ "success",+ "message"+ ]
}
}
}
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5407a8d and f106574.

📒 Files selected for processing (3)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/api-reference/domains/delete-domain.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts

Comment threadapps/docs/api-reference/openapi.json
@kuntlme
kuntlme requested a review from KMKoushikOctober 3, 2025 20:51
@kuntlme

Copy link
Copy Markdown
ContributorAuthor

@KMKoushik Please review it.
I made changes as you instructed.

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

@kuntlme

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot for the confirmation and for helping me out.

@KMKoushik
KMKoushik merged commit 3f6a02a into usesend:mainOct 10, 2025
1 of 2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete domain API reference needed

2 participants

@kuntlme@KMKoushik
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

delete-domain route added - #267

Merged
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route
Oct 10, 2025
Merged

delete-domain route added#267
KMKoushik merged 7 commits into
usesend:mainfrom
kuntlme:delete-domain-route

Conversation

@kuntlme

@kuntlmekuntlme commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Fixes#262

Changes made

  • Added delete domain route in public-api
  • Updated OpenAPI schema with delete configuration
  • Added support in:
    • JS SDK
    • Python SDK
    • Documentation

Summary by cubic

Adds DELETE /v1/domains/{id} to remove a domain via the Public API with API key scoping. JS/TS and Python SDKs and docs are updated so clients can delete domains programmatically.

  • New Features
    • Public API: DELETE /v1/domains/{id} to delete a team domain.
      • 403 if API key is restricted to another domain.
      • 404 if the domain does not exist.
      • 200 returns { success: boolean, message: string }.
    • SDKs: Domains.delete(id) in JS/TS; usesend.domains.delete(domain_id) in Python.
    • Docs and OpenAPI updated (new delete-domain reference).

Summary by CodeRabbit

  • New Features

    • Added DELETE /v1/domains/{id} API to remove a domain and return the deleted domain details.
    • Domain deletion supported in JavaScript/TypeScript and Python SDKs; JS SDK now exposes a Domains client and can derive the API key from environment variables when not provided.
  • Documentation

    • Updated API reference and OpenAPI spec entries for domain deletion.

@vercel

vercelBot commented Oct 3, 2025

Copy link
Copy Markdown

@kuntlme is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitaiBot commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a DELETE /v1/domains/{id} endpoint across the stack: OpenAPI docs (apps/docs/api-reference/openapi.json and apps/docs/api-reference/domains/delete-domain.mdx), TypeScript types (packages/sdk/types/schema.d.ts) declaring the delete operation with a 200 response returning the full domain object, a server handler (apps/web/src/server/public-api/api/domains/delete-domain.ts) that validates id, enforces API-key domain access, returns 404 if not found, deletes the domain, and registers the route, and client methods: TypeScript SDK Domains.delete and UseSend.domains exposure, plus Python SDK Domains.delete(domain_id).

Possibly related PRs

Suggested labels

codex

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Out of Scope Changes Check⚠️ WarningThe PR includes modifications to packages/sdk/src/usesend.ts that add environment variable–based API key resolution and formatting tweaks which are unrelated to implementing the delete-domain route or addressing the linked issue objectives.Please remove or isolate the environment-variable key logic changes and formatting adjustments into a separate pull request so that this one focuses solely on the delete-domain functionality.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe title “delete-domain route added” succinctly and accurately describes the primary change of this pull request, which is the addition of a new DELETE route for domain deletion in the Public API.
Linked Issues Check✅ PassedThe pull request delivers a DELETE /v1/domains/{id} endpoint along with corresponding OpenAPI schema and documentation, fulfilling the requirement in linked issue #262 to provide an API endpoint and reference for domain deletion.
Docstring Coverage✅ PassedNo functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f106574 and cb95486.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/docs/api-reference/openapi.json (1)

637-797: Consider aligning DELETE response with REST conventions.

The DELETE operation returns the full domain object (lines 640-796), which is unconventional. Most DELETE operations return either:

  • 204 No Content (most common)
  • 200 with a minimal payload like {success: true, id: number}

For consistency, note that the contact DELETE operation in this same API (lines 1989-2008) returns a simple {success: boolean} payload. Returning the full domain object adds unnecessary response size and deviates from the API's own patterns.

Consider refactoring to return a minimal success payload:

 "responses": {
"200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"+ "success": {+ "type": "boolean"
},
- ... (all other domain fields)+ "id": {+ "type": "number"+ }
},
"required": [
- "id",- "name",- ... (other fields)+ "success",+ "id"
]
}
}
}
}
}

Alternatively, if you need to return the deleted domain for audit purposes, keep the current response but add a comment explaining this design decision.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1216b80 and acfccf3.

📒 Files selected for processing (8)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
  • apps/web/src/server/public-api/index.ts (2 hunks)
  • packages/python-sdk/usesend/domains.py (1 hunks)
  • packages/sdk/src/domain.ts (2 hunks)
  • packages/sdk/src/usesend.ts (4 hunks)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/src/usesend.ts
  • packages/sdk/types/schema.d.ts
  • packages/sdk/src/domain.ts
  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise

Files:

  • apps/web/src/server/public-api/api/domains/delete-domain.ts
  • apps/web/src/server/public-api/index.ts
🧬 Code graph analysis (5)
packages/python-sdk/usesend/domains.py (2)
packages/python-sdk/usesend/usesend.py (1)
  • delete (118-121)
packages/python-sdk/usesend/types.py (2)
  • Domain (41-60)
  • APIError (337-339)
packages/sdk/src/usesend.ts (1)
packages/sdk/src/domain.ts (1)
  • Domains (48-89)
packages/sdk/src/domain.ts (1)
packages/sdk/types/index.ts (1)
  • ErrorResponse (1-4)
apps/web/src/server/public-api/api/domains/delete-domain.ts (3)
apps/web/src/server/public-api/hono.ts (1)
  • PublicAPIApp (136-136)
apps/web/src/server/public-api/api-error.ts (1)
  • UnsendApiError (62-75)
apps/web/src/server/db.ts (1)
  • db (20-20)
apps/web/src/server/public-api/index.ts (2)
apps/web/src/server/aws/ses.ts (1)
  • deleteDomain (144-176)
apps/web/src/server/service/domain-service.ts (1)
  • deleteDomain (294-316)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
packages/sdk/types/schema.d.ts (1)

1-4: Auto-generated file; defer review to source OpenAPI spec.

This file is auto-generated from the OpenAPI specification. Any concerns about the DELETE operation should be addressed in the source OpenAPI document (apps/docs/api-reference/openapi.json).

apps/docs/api-reference/openapi.json (1)

625-636: Verify path parameter requirement.

The path parameter id is marked as required: false (line 632), which is unusual for a DELETE operation that requires a resource identifier. While the parameter is nullable, DELETE operations typically require the ID to be present in the path.

Ensure this aligns with the intended API behavior. If the ID must be provided, consider marking it as required: true even if it's nullable.

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@cubic-dev-aicubic-dev-aiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 8 files

Prompt for AI agents (all 5 issues)

Understand the root cause of the following 5 issues and fix them.
<file name="apps/web/src/server/public-api/api/domains/delete-domain.ts">
<violation number="1" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:32">
Wrap the 403 response media type in a `content` property so the OpenAPI schema is valid.</violation>
<violation number="2" location="apps/web/src/server/public-api/api/domains/delete-domain.ts:80">
Domain deletion logic duplicates `apps/web/src/server/service/domain-service.ts:deleteDomain()` function and omits critical side effects (SES deletion).</violation>
</file>
<file name="apps/docs/api-reference/openapi.json">
<violation number="1" location="apps/docs/api-reference/openapi.json:629">
The DELETE path parameter `id` is declared nullable, but a URL segment cannot be null and the backend expects a concrete number.</violation>
<violation number="2" location="apps/docs/api-reference/openapi.json:632">
Path parameters must be required in OpenAPI, but this DELETE operation marks `id` as optional, making the spec invalid for generators.</violation>
<violation number="3" location="apps/docs/api-reference/openapi.json:639">
The DELETE 200 response schema describes a full domain object, but the handler actually returns `{ success: true, message: &quot;Domain deleted successfully&quot; }`, so the OpenAPI contract is incorrect and will break generated clients.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acfccf3 and 5407a8d.

📒 Files selected for processing (1)
  • packages/sdk/types/schema.d.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Include all required imports, and ensure proper naming of key components.

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)

Files:

  • packages/sdk/types/schema.d.ts
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (AGENTS.md)

Format code and docs with Prettier 3

Files:

  • packages/sdk/types/schema.d.ts
🔇 Additional comments (1)
packages/sdk/types/schema.d.ts (1)

372-372: Path parameter type is appropriately non-nullable.

Unlike the GET and verify endpoints that use number | null, the DELETE operation correctly uses number for the required id path parameter.

Comment threadpackages/sdk/types/schema.d.ts

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres lots of valid review comments, please address it

Comment threadapps/docs/api-reference/domains/delete-domain.mdx
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/docs/api-reference/openapi.json Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts Outdated
Comment threadapps/web/src/server/public-api/api/domains/delete-domain.ts

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/docs/api-reference/openapi.json (1)

637-795: Fix response schema to match actual handler payload.

The handler returns { success: boolean, message: string }, but the spec publishes a full Domain object. Generated clients will deserialize the wrong shape and break once the DELETE route is invoked. Update the schema to reflect the success/message contract.

 "200": {
"description": "Domain deleted successfully",
"content": {
"application/json": {
"schema": {
- "type": "object",- "properties": {- "id": {- "type": "number",- "description": "The ID of the domain",- "example": 1- },- "name": {- "type": "string",- "description": "The name of the domain",- "example": "example.com"- },- "teamId": {- "type": "number",- "description": "The ID of the team",- "example": 1- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "region": {- "type": "string",- "default": "us-east-1"- },- "clickTracking": {- "type": "boolean",- "default": false- },- "openTracking": {- "type": "boolean",- "default": false- },- "publicKey": {- "type": "string"- },- "dkimStatus": {- "type": "string",- "nullable": true- },- "spfDetails": {- "type": "string",- "nullable": true- },- "createdAt": {- "type": "string"- },- "updatedAt": {- "type": "string"- },- "dmarcAdded": {- "type": "boolean",- "default": false- },- "isVerifying": {- "type": "boolean",- "default": false- },- "errorMessage": {- "type": "string",- "nullable": true- },- "subdomain": {- "type": "string",- "nullable": true- },- "verificationError": {- "type": "string",- "nullable": true- },- "lastCheckedTime": {- "type": "string",- "nullable": true- },- "dnsRecords": {- "type": "array",- "items": {- "type": "object",- "properties": {- "type": {- "type": "string",- "enum": [- "MX",- "TXT"- ],- "description": "DNS record type",- "example": "TXT"- },- "name": {- "type": "string",- "description": "DNS record name",- "example": "mail"- },- "value": {- "type": "string",- "description": "DNS record value",- "example": "v=spf1 include:amazonses.com ~all"- },- "ttl": {- "type": "string",- "description": "DNS record TTL",- "example": "Auto"- },- "priority": {- "type": "string",- "nullable": true,- "description": "DNS record priority",- "example": "10"- },- "status": {- "type": "string",- "enum": [- "NOT_STARTED",- "PENDING",- "SUCCESS",- "FAILED",- "TEMPORARY_FAILURE"- ]- },- "recommended": {- "type": "boolean",- "description": "Whether the record is recommended"- }- },- "required": [- "type",- "name",- "value",- "ttl",- "status"- ]- }- }- },- "required": [- "id",- "name",- "teamId",- "status",- "publicKey",- "createdAt",- "updatedAt",- "dnsRecords"- ]+ "type": "object",+ "properties": {+ "success": {+ "type": "boolean",+ "example": true+ },+ "message": {+ "type": "string",+ "example": "Domain deleted successfully"+ }+ },+ "required": [+ "success",+ "message"+ ]
}
}
}
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5407a8d and f106574.

📒 Files selected for processing (3)
  • apps/docs/api-reference/domains/delete-domain.mdx (1 hunks)
  • apps/docs/api-reference/openapi.json (1 hunks)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/api-reference/domains/delete-domain.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/server/public-api/api/domains/delete-domain.ts

Comment threadapps/docs/api-reference/openapi.json
@kuntlme
kuntlme requested a review from KMKoushikOctober 3, 2025 20:51
@kuntlme

Copy link
Copy Markdown
ContributorAuthor

@KMKoushik Please review it.
I made changes as you instructed.

@KMKoushikKMKoushik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, lgtm

@kuntlme

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot for the confirmation and for helping me out.

@KMKoushik
KMKoushik merged commit 3f6a02a into usesend:mainOct 10, 2025
1 of 2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete domain API reference needed

2 participants

@kuntlme@KMKoushik