Skip to content

add sub account deletion - #30

Merged
izikaj merged 2 commits into
mainfrom
MT-23420-go-delete-sub-account
Oct 7, 2026
Merged

izikaj merged 2 commits into
mainfrom
MT-23420-go-delete-sub-account

Conversation

@oshchyhol

@oshchyhol oshchyhol commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The API is getting DELETE /api/organizations/{organization_id}/sub_accounts/{sub_account_id}. The SDK already lists and creates sub-accounts, so deletion is the missing piece.

Changes

  • SubAccounts.Delete(ctx, subAccountID) – sends the DELETE request for the organization set with WithOrganizationID, returns *Response and error; same errNoOrganizationID guard as List and Create
  • examples/sub-accounts deletes the sub-account it created after listing
  • README lists delete for organization sub-accounts

How to test

Use an organization token with sub-account management permissions and a client created with WithOrganizationID.

  • create a sub-account, then call client.SubAccounts.Delete(ctx, id) – returns err == nil, resp.StatusCode == 204; the id is no longer in client.SubAccounts.List
  • call Delete again with the same id – returns an error with status 404
  • call Delete with an id from another organization, or with a token without sub-account management permissions – error with status 403
  • call Delete with an invalid token – error with status 401
  • create the client without WithOrganizationID and call Delete – returns errNoOrganizationID without sending a request
  • MAILTRAP_API_TOKEN=... MAILTRAP_ORGANIZATION_ID=... go run ./examples/sub-accounts – prints the created sub-account, the count, then deleted sub-account
  • README renders Organization sub-accounts — list, create & delete

Companion PRs

terraform-provider-mailtrap consumes this module; the change is additive and safe.

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: fdcd2f20-7ac8-4294-9af3-a42ca49c1521


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.

@izikaj
izikaj merged commit 5361ee2 into main Oct 7, 2026
4 checks passed
@izikaj
izikaj deleted the MT-23420-go-delete-sub-account branch October 7, 2026 06:49
@github-actions github-actions Bot mentioned this pull request Oct 7, 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.

4 participants