Skip to content

add sub account deletion - #259

Merged
oshchyhol merged 7 commits into
mainfrom
MT-23420-dotnet-delete-sub-account
Nov 5, 2026
Merged

oshchyhol merged 7 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 organization admin permissions and the Organization & Sub-accounts feature (403 otherwise), permanent and removes all sub account data, deleting the last sub account deletes the organization, repeated call returns 404, concurrent call returns 409, rate limit of 10 requests per minute per organization
  • Mailtrap.Example.SubAccount deletes the sub account it created, with a comment that deleting needs an organization admin token and the Organization & Sub-accounts feature

How to test

Use an organization API token with organization admin 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 – status 404
  • call Delete() with a token that only has sub account management permissions – status 403
  • call Delete() in an organization without the Organization & Sub-accounts feature – 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

@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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fa5d7e96-6060-4f8f-b5bc-feea58735a57
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@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
@oshchyhol
oshchyhol force-pushed the MT-23420-dotnet-delete-sub-account branch from 1932b1e to 8d6993f Compare November 5, 2026 22:41
@oshchyhol
oshchyhol merged commit 79ab4e0 into main Nov 5, 2026
3 checks passed
@oshchyhol
oshchyhol deleted the MT-23420-dotnet-delete-sub-account branch November 5, 2026 22:44
@github-actions github-actions Bot mentioned this pull request Nov 9, 2026
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.

3 participants