// DELETE has no body parameters
<?php
require_once 'vendor/autoload.php';
use MangoPay\Libraries\Exception as MGPException;
use MangoPay\Libraries\ResponseException as MGPResponseException;
use MangoPay\MangoPayApi;
$api = new MangoPayApi();
$api->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);
}
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')
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();
}
}
Users
Close a Legal User
Permanently close a user account so it can no longer be used
DELETE
/
v2.01
/
{ClientId}
/
users
/
legal
/
{UserId}
// DELETE has no body parameters
<?php
require_once 'vendor/autoload.php';
use MangoPay\Libraries\Exception as MGPException;
use MangoPay\Libraries\ResponseException as MGPResponseException;
use MangoPay\MangoPayApi;
$api = new MangoPayApi();
$api->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);
}
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')
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();
}
}
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.
Closure is only possible if all wallets held by the user are empty. Closure is allowed for both
Caution – Closure is irreversibleCalling 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).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
UserStatuschanges toCLOSED(and theUSER_ACCOUNT_CLOSEDwebhook is sent) - The user has inflows and outflows blocked (and the relevant webhooks are sent)
- The user object remains available via the API and Dashboard for historical purposes
Note – Do not overuse OAuth token endpoint if automating callsIf 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 guide.Overuse of the OAuth token endpoint is a security and performance risk and may result in preventative action from Mangopay.
Path parameters
string
required
The unique identifier of the user.
Responses
204 - No Content
204 - No Content
The 204 response code indicates that the closure request was successful.
400 - Wallets not empty
400 - Wallets not empty
{
"Message": "The user cannot be closed as one or several wallets are not empty",
"Type": "user_closure_not_possible",
"Id": "bcb91dae-bb4a-4f99-937c-8f8530c14a31#1744636047",
"Date": 1744636048,
"errors": null
}
400 - User already closed
400 - User already closed
{
"Message": "An error occurred while closing the user",
"Type": "user_closure_failed",
"Id": "8524ae5f-3232-4910-b9db-4ffd7f4be4ee",
"Date": 1744631045,
"errors": null
}
// DELETE has no body parameters
<?php
require_once 'vendor/autoload.php';
use MangoPay\Libraries\Exception as MGPException;
use MangoPay\Libraries\ResponseException as MGPResponseException;
use MangoPay\MangoPayApi;
$api = new MangoPayApi();
$api->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);
}
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')
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();
}
}
Was this page helpful?