Skip to content

add sub account deletion - #259

Open
oshchyhol wants to merge 2 commits into
mainfrom
MT-23420-dotnet-delete-sub-account
Open

add sub account deletion#259
oshchyhol wants to merge 2 commits into
mainfrom
MT-23420-dotnet-delete-sub-account

Conversation

@oshchyhol

@oshchyhol oshchyhol commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Motivation

The organization client can list and create sub accounts but has no way to delete one. This adds the DELETE /api/organizations/{organization_id}/sub_accounts/{sub_account_id} operation.

Changes

  • new IOrganizationSubAccountResource with Delete(), reached via IOrganizationResource.SubAccount(long subAccountId)
  • SubAccount(id) rejects ids less than or equal to zero with ArgumentOutOfRangeException, like the other single-resource getters
  • XML docs cover the operation's behaviour – requires sub account management permissions, permanent and removes all sub account data, deleting the last sub account deletes the organization, repeated call returns 404, rate limit of 10 requests per minute per organization
  • Mailtrap.Example.SubAccount deletes the sub account it created

How to test

Use an organization API token with sub account management permissions and a fresh sub account created via organization.SubAccounts().Create(...).

  • await organizationClient.Organization(orgId).SubAccount(subAccountId).Delete() completes without an exception; the sub account is gone from SubAccounts().GetAll()
  • call Delete() again on the same id – HttpRequestFailedException with status 404
  • call Delete() with a sub account id that belongs to another organization, or with a token that lacks sub account management permissions – status 403
  • call Delete() with an invalid token – status 401
  • SubAccount(0) and SubAccount(-1) throw ArgumentOutOfRangeException before any request is sent
  • dotnet run --project examples/Mailtrap.Example.SubAccount lists, creates and then deletes the demo sub account, logging Deleted Sub Account: Id=...

Companion PRs

Caveat: merge and release only after the backend change ships; the endpoint is not in production yet.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 07a5d7e8-ab1c-446b-9665-dc3d55563ef9


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.

@oshchyhol oshchyhol changed the title MT-23420: add sub account deletion add sub account deletion Sep 8, 2026
@oshchyhol
oshchyhol force-pushed the MT-23420-dotnet-delete-sub-account branch from ca4fe0b to 2816c77 Compare September 9, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants