# Delete a member and all related records

`DELETE /api/members/{memberId}/profile`

- **Products:** Operator (`FOH`)
- **Features:** Front of House Generic Access (`FOHGENERIC`)

HTML version: [Delete a member and all related records](https://support.gladstonesoftware.cloud/reference/members/delete-a-member-and-all-related-records)

## Overview

Removes an unconfirmed member and the records hanging off them. Despite the title, this is not a general-purpose erasure endpoint and it will not satisfy a data deletion request against an established member: it refuses to delete anyone who is not flagged as pending confirmation. Its real job is clearing up sign-ups that were started and never completed — a join that was abandoned before payment, a duplicate created in error, a test registration.

All four of these must hold, and are checked before anything is written:

- the member exists;
- the member is pending confirmation — the flag you set by sending `pendingConfirmation: true` to `POST {base_url}/api/members/profile`, and which is cleared once the member confirms;
- none of the member's sales invoices has a non-zero amount paid — a single paid invoice blocks the delete permanently, and there is no override on this endpoint;
- no other member is linked to this one, which would make it a primary member; unlink the others first.

It is a hard delete, not an anonymisation. There is no soft-delete flag, no tombstone and no anonymised remnant: the records are removed. The member and the following related records are removed together as a single operation, so the operation either completes in full or leaves the member untouched:

- member user fields
- bank accounts
- event logs, and member event logs
- subscriptions, and for each of them its subscription products and its promotion usages
- sales invoices, and for each of them its invoice products
- member consents
- member agreements
- member personalisations

Nothing outside that list is removed explicitly.

The only trace kept is a system event log entry recording that an unconfirmed member was deleted, against the deleted member's id.

The call is not idempotent in its status codes: the first successful delete returns `204` with no body, and repeating it returns `404` because the member has gone. As for who may call it, the route id must match the member your access token identifies, or a member linked to them; a caller whose token does not identify a member — a server-to-server integration — is not subject to that check and can delete any member that meets the four conditions above.

## Endpoint

`DELETE {base_url}/api/members/{memberId}/profile`

`{base_url}` is the environment URL issued to your integration. See [Authenticating with Gladstone APIs](../../guides/authenticating-with-gladstone-apis.md).

## Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `memberId` | integer (int32) | Yes | The member to delete. Must be greater than zero: `0` (the reserved non-member id) and `-999` (a purged member) are rejected with `{memberId} is an invalid member ID`, as is any value that is not an integer. Where your access token identifies a member, the id must be that member or one linked to them, otherwise the request is refused with `403`. |

## Sample request

```bash title="cURL"
curl -X DELETE '{base_url}/api/members/{memberId}/profile' \
  -H 'Authorization: Bearer {accessToken}' \
  -H 'X-Use-SSO: true'
```

## Errors

| Status | Meaning | When |
|--------|---------|------|
| `400` | Bad request | The member exists but cannot be deleted: `The member with the ID {memberId} is not pending confirmation`, `The member with the ID {memberId} has paid sales and can not be deleted`, or `The member with the ID {memberId} is a primary member and before being deleted must be unlinked from other members`. Also returned when the route id is zero or negative (`{memberId} is an invalid member ID`) or is not a valid integer. |
| `404` | Not found | `The member with the ID {memberId} does not exist` — either the id was never issued, or a previous call already deleted the member. |
| `500` | Internal server error | An unexpected server-side failure, such as one part-way through the delete. The response has no body; none of the delete is applied, so the member remains. |
