> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.mangopay.com/api-reference/users/close-legal-user/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mangopay.com/_mcp/server. # Close a Legal User DELETE https://api.sandbox.mangopay.com/v2.01/{ClientId}/users/legal/{UserId} Permanently close a user account so it can no longer be used. This endpoint allows your platform to close a Mangopay Account, as per Mangopay's terms and conditions, in the event that the agreement between the user and the platform comes to an end. **Caution – Closure is irreversible** Calling this endpoint immediately and permanently changes the `UserStatus` to `CLOSED` if the API call is successful. This cannot be undone, even by Mangopay. Your platform can re-register the user using [POST Create a Legal User (SCA)](/api-reference/users/create-legal-user-sca). Closure is only possible if all wallets held by the user are empty. Closure is allowed for both `UserCategory` `OWNER` and `PAYER` and for all types of Legal user (Business, Partnership, Organization, Soletrader). When a User is closed (whether via this endpoint or by Mangopay): * The `UserStatus` changes to `CLOSED` (and the `USER_ACCOUNT_CLOSED` [webhook](/webhooks/event-types#account-closure) is sent) * The user has inflows and outflows [blocked](/guides/users/blocked-users) (and the relevant [webhooks](/webhooks/event-types#user-regulatory-status) are sent) * The user object remains available via the API and Dashboard for historical purposes Closing a user account does not affect Mangopay's data retention obligations or processes. Personal data associated with the closed account will be retained in accordance with Mangopay's data retention policies. **Note – Do not overuse OAuth token endpoint if automating calls** If you are writing a script to close a set of users, ensure you do not call the OAuth token endpoint before each DELETE call. You must use your authentication for the full duration of its lifetime, as described in the [authentication](/api-reference/overview/authentication#2-use-the-bearer-token-for-its-full-lifetime) guide. Overuse of the OAuth token endpoint is a security and performance risk and may result in preventative action from Mangopay. Reference: https://docs.mangopay.com/api-reference/users/close-legal-user ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. If your platform is using a [proxy](/guides/sca/proxy-management) to take SCA-triggering action on behalf of users, you also need to integrate [mTLS authentication](/guides/sca/platform) and use the `api-mtls` base URL. ## Servers - `https://api.sandbox.mangopay.com` (Sandbox, default) - `https://api.mangopay.com` (Production) - `https://api-mtls.sandbox.mangopay.com` (mTLS Sandbox) - `https://api-mtls.mangopay.com` (mTLS Production) ## Request ### Path parameters - `ClientId` (string, required) — Platform's API account identifier, associated with the API key. - `UserId` (string, required) — The unique identifier of the user. ## Response ### 204 No Content – Closure was successful ## Errors ### 400 Bad Request Error Bad Request - `Message` (string, optional) — Description of the error. - `Type` (string, optional) — The category of the error. - `Id` (string, optional) — Unique identifier of the error instance, useful when contacting Mangopay for support. - `Date` (double, optional) — Unix timestamp (UTC) of the date and time the error was triggered. - `errors` (map from string to string, optional, nullable) — Object containing one or more field-level errors. ## Examples **SDK Code** ```php Config->ClientId = 'your-client-id'; $api->Config->ClientPassword = 'your-mangopay-api-key'; $api->Config->TemporaryFolder = 'tmp/'; try { $userLegal = $api->Users->GetLegalSca('user_m_01K8932FJ54AF8BY7PY80G0JG1'); $api->Users->Close($userLegal); $afterClose = $api->Users->GetLegalSca('user_m_01K8932FJ54AF8BY7PY80G0JG1'); print_r($afterClose); } catch (MGPResponseException $e) { print_r($e); } catch (MGPException $e) { print_r($e); } ``` ```ruby require 'mangopay' MangoPay.configure do |client| client.preproduction = true client.client_id = 'your-mangopay-client-id' client.client_apiKey = 'your-mangopay-api-key' client.log_file = File.join(Dir.pwd, 'mangopay.log') end def closeLegalUserSca(userId) begin response = MangoPay::LegalUser.close(userId) puts response return response rescue MangoPay::ResponseError => error puts "Failed to close User: #{error.message}" puts "Error details: #{error.details}" return false end end closeLegalUserSca('user_m_01K85X5HKK3YD61Y3YXD9FHV7H') ``` ```csharp using MangoPay.SDK; using Newtonsoft.Json; public class CloseUser { public void Run() { Task.Run(async () => { MangoPayApi api = new MangoPayApi(); api.Config.ClientId = "your-client-id"; api.Config.ClientPassword = "your-api-key"; await api.Users.CloseLegalAsync("user_m_01K8B3WYXFGHKZZSN4DCEDJC69"); var closed = await api.Users.GetScaAsync("user_m_01K8B3WYXFGHKZZSN4DCEDJC69"); string prettyPrint = JsonConvert.SerializeObject(closed, Formatting.Indented); Console.WriteLine(prettyPrint); }).GetAwaiter().GetResult(); } } ```