# Delete a member account

Remove a member's Genuin account on their behalf, the same way the member can from the app, using your brand's API key.

Use this endpoint to honour a deletion request you received in your own product, or to clean up test accounts. It runs the same deletion as **Delete account** in the Genuin app and in your hosted social experience. The account is marked deleted at once. A background job then removes it from its groups, communities, and pending requests. The account has to belong to your brand.

Unlike the other third-party endpoints, this one doesn't take a bearer token. It authenticates with your brand's API key, the key the SDKs use, passed as a query parameter together with the member's id.

## Endpoint

`DELETE /api/thirdparty/user`

| Environment | Base URL |
| --- | --- |
| Production | https://api.begenuin.com |
| QA | https://api.qa.begenuin.com |

## Parameters

Both parameters go in the query string. The request has no body and no `Authorization` header.

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| api_key | string | Required | Your brand's API key, from Brand Control Center (BCC) under Build > Publish Brand Community > SDK Integration. The brand has to be active. |
| user_id | string | Required | UUID of the member to delete. The member has to be active and belong to your brand. |

A member belongs to your brand when they have an active brand membership. They get one by signing up through your hosted social experience, app, or SDK, or when you add them with [Add members to a community](https://begenuin.com/developers/developer-resources/api/add-members-to-a-community-programmatically-api). Members of other brands return `404`, even with a valid key.

## Returns

Returns `200 OK` with an empty `data` object. By the time the response arrives, the account's status is `deleted` and its cached profile is dropped. The member can't sign in, and lookups no longer return them.

The endpoint also publishes a `user_deleted` event, and a background job finishes the clean-up a moment later. It removes the member from every group they were in and deletes their pending join and participation requests. It also unsubscribes them from the groups they followed, detaches their brand and guest records, and removes their community join requests.

Calling the endpoint again for the same `user_id` returns `404` with code `5025`, because the account is no longer active.

## Request

```bash title="cURL"
curl -X DELETE "https://api.begenuin.com/api/thirdparty/user?api_key=<<YOUR_API_KEY>>&user_id={{USER_ID}}"
```

## Response

```json title="Response"
{
  "code": 200,
  "message": "Account deleted successfully.",
  "data": {}
}
```

## Errors

Every error response carries an HTTP status, a string `code`, a `message`, and a `data` object. Match on `code`.

| HTTP status | code | Cause | Fix |
| --- | --- | --- | --- |
| 401 Unauthorized | 1003 | api_key or user_id is missing, or the validation itself failed. Message: authentication is required. | Send both query parameters. |
| 404 Not Found | 5235 | No active brand matches api_key. Message: Brand not exists. | Check the key and that it belongs to the environment you're calling. |
| 404 Not Found | 5025 | No active member with that UUID belongs to your brand, or the account is already deleted. Message: The user you are looking for is no longer available. with data.err_msg set to Active User not found, or not associated with given brand. | Check user_id. It's the member UUID your sign-in flow and the member endpoints return. |
| 422 Unprocessable Entity | 5054 | The deletion couldn't be applied. Message: There was some error while deleting account. | Retry once. If it persists, contact the Genuin team with the request timestamp. |

## Limitations

- **The key travels in the URL.** Query strings end up in access logs and proxy logs. Call this endpoint only from your server, never from a browser or an app.
- **No undo.** There's no endpoint to restore a deleted account; the member signs up again as a new account.
- **One member per call.** Loop over ids to delete several.
- **No rate limit.** The backend applies no per-key rate limit to this route, unlike `community/add_users`.

## See also

- [Add members to a community](https://begenuin.com/developers/developer-resources/api/add-members-to-a-community-programmatically-api)
- [Generate an access token](https://begenuin.com/developers/developer-resources/api/generate-access-token-using-authentication-api)
- [Handle API errors](https://begenuin.com/developers/developer-resources/api/handle-api-errors)
