// This POST has no body
<?php
require_once 'vendor/autoload.php';
use MangoPay\MangoPayApi;
$api = new MangoPayApi();
$api->Config->ClientId = 'your-mangopay-client-id';
$api->Config->ClientPassword = 'your-mangopay-api-key';
$api->Config->TemporaryFolder = 'tmp/';
try {
$userId = 'user_m_01JZWV35ZQZF8T9BYQ3494N4R7';
$response = $api->Users->Enroll($userId);
print_r($response);
} catch(\MangoPay\Libraries\ResponseException $e) {
$errorDetails = $e->GetErrorDetails();
if ($errorDetails) {
error_log("Mangopay API error message: " . $errorDetails->Message);
error_log("Mangopay API error type: " . $errorDetails->Type);
}
error_log("HTTP status Code: " . $e->GetErrorCode());
error_log("Request URL: " . $e->RequestUrl);
return $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 enrollNaturalUser(userId)
begin
response = MangoPay::User.enroll_sca(userId)
puts response
return response
rescue MangoPay::ResponseError => error
puts "Failed to create User: #{error.message}"
puts "Error details: #{error.details}"
return false
end
end
enrollNaturalUser('user_m_01K85X5HKK3YD61Y3YXD9FHV7H')
using MangoPay.SDK;
using Newtonsoft.Json;
public class EnrollUser
{
public void Run()
{
Task.Run(async () =>
{
MangoPayApi api = new MangoPayApi();
api.Config.ClientId = "your-client-id";
api.Config.ClientPassword = "your-api-key";
var result =
await api.Users.EnrollSca("user_m_01K8B28H25JBHX1QFVC0T54S1Q");
string prettyPrint = JsonConvert.SerializeObject(result, Formatting.Indented);
Console.WriteLine(prettyPrint);
}).GetAwaiter().GetResult();
}
}
{
"PendingUserAction": {
"RedirectUrl": "https://sca.sandbox.mangopay.com/?token=0193cf51ed367151a0cb1c59def21e13"
}
}
Users
Enroll a User in SCA
Obtain an SCA redirection link to enroll an Owner user
POST
/
v2.01
/
{ClientId}
/
sca
/
users
/
{UserId}
/
enrollment
// This POST has no body
<?php
require_once 'vendor/autoload.php';
use MangoPay\MangoPayApi;
$api = new MangoPayApi();
$api->Config->ClientId = 'your-mangopay-client-id';
$api->Config->ClientPassword = 'your-mangopay-api-key';
$api->Config->TemporaryFolder = 'tmp/';
try {
$userId = 'user_m_01JZWV35ZQZF8T9BYQ3494N4R7';
$response = $api->Users->Enroll($userId);
print_r($response);
} catch(\MangoPay\Libraries\ResponseException $e) {
$errorDetails = $e->GetErrorDetails();
if ($errorDetails) {
error_log("Mangopay API error message: " . $errorDetails->Message);
error_log("Mangopay API error type: " . $errorDetails->Type);
}
error_log("HTTP status Code: " . $e->GetErrorCode());
error_log("Request URL: " . $e->RequestUrl);
return $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 enrollNaturalUser(userId)
begin
response = MangoPay::User.enroll_sca(userId)
puts response
return response
rescue MangoPay::ResponseError => error
puts "Failed to create User: #{error.message}"
puts "Error details: #{error.details}"
return false
end
end
enrollNaturalUser('user_m_01K85X5HKK3YD61Y3YXD9FHV7H')
using MangoPay.SDK;
using Newtonsoft.Json;
public class EnrollUser
{
public void Run()
{
Task.Run(async () =>
{
MangoPayApi api = new MangoPayApi();
api.Config.ClientId = "your-client-id";
api.Config.ClientPassword = "your-api-key";
var result =
await api.Users.EnrollSca("user_m_01K8B28H25JBHX1QFVC0T54S1Q");
string prettyPrint = JsonConvert.SerializeObject(result, Formatting.Indented);
Console.WriteLine(prettyPrint);
}).GetAwaiter().GetResult();
}
}
{
"PendingUserAction": {
"RedirectUrl": "https://sca.sandbox.mangopay.com/?token=0193cf51ed367151a0cb1c59def21e13"
}
}
If
To enroll a user whose
UserCategory is OWNER, this endpoint allows you to enroll a user in SCA. Your platform needs to retrieve the returned PendingUserAction.RedirectUrl, add an encoded returnUrl query parameter for them to be returned to after the SCA session, and redirect the user.
Read more about SCA redirection →
You can use this endpoint to obtain a new session RedirectUrl. This is useful to:
- Enroll Owners created without SCA enrollment
- Retry enrollment if a previous session was unsuccessful or expired (after 10 minutes)
UserStatus, even if the session expires or is unsuccessful.
Note – This endpoint doesn’t change UserStatusCalling this endpoint does not change the user’s status to
PENDING_USER_ACTION (it stays as ACTIVE) and no USER_ACCOUNT_VALIDATION_ASKED webhook notification is sent.This ensures that legacy users do not become blocked if they are unable to complete SCA successfully.Caution – Legal representative’s email requiredFor
OWNER users, the LegalRepresentative.Email address is required.SCA uses this email address to build a behavioral biometrics profile and as a backup communication channel.Prior to SCA, it was possible to create a Legal OWNER without the LegalRepresentativeEmail, so this data may be missing. Calling this endpoint without this data will return an error.Path parameters
string
required
The unique identifier of the user.
Responses
200
200
object
Object containing the link needed for SCA redirection if triggered by the API call (otherwise returned
null).Hide properties
Hide properties
string
The URL to which to redirect the user to perform strong customer authentication (SCA) via a Mangopay-hosted webpage. This value is a variable and should not be hardcoded.The SCA session link expires 10 minutes after it’s generated.Caution: Before redirecting the user on this URL, you must add the query parameter
ReturnUrl with the percent-encoded URL to which you want the SCA session to return the user after authentication (whether successful or not).For more details, see How to redirect a user for an SCA session.400 - Endpoint not allowed if category is PAYER
400 - Endpoint not allowed if category is PAYER
{
"Message": "This endpoint is not allowed for User categorized as PAYER",
"Type": "not_allowed_for_user_category_payer",
"Id": "4f848681-e524-403b-913a-12bf47095328",
"Date": 1736765347,
"errors": null
}
UserCategory is PAYER in SCA, use the endpoints PUT Categorize a Natural User or PUT Categorize a Legal User.{
"PendingUserAction": {
"RedirectUrl": "https://sca.sandbox.mangopay.com/?token=0193cf51ed367151a0cb1c59def21e13"
}
}
// This POST has no body
<?php
require_once 'vendor/autoload.php';
use MangoPay\MangoPayApi;
$api = new MangoPayApi();
$api->Config->ClientId = 'your-mangopay-client-id';
$api->Config->ClientPassword = 'your-mangopay-api-key';
$api->Config->TemporaryFolder = 'tmp/';
try {
$userId = 'user_m_01JZWV35ZQZF8T9BYQ3494N4R7';
$response = $api->Users->Enroll($userId);
print_r($response);
} catch(\MangoPay\Libraries\ResponseException $e) {
$errorDetails = $e->GetErrorDetails();
if ($errorDetails) {
error_log("Mangopay API error message: " . $errorDetails->Message);
error_log("Mangopay API error type: " . $errorDetails->Type);
}
error_log("HTTP status Code: " . $e->GetErrorCode());
error_log("Request URL: " . $e->RequestUrl);
return $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 enrollNaturalUser(userId)
begin
response = MangoPay::User.enroll_sca(userId)
puts response
return response
rescue MangoPay::ResponseError => error
puts "Failed to create User: #{error.message}"
puts "Error details: #{error.details}"
return false
end
end
enrollNaturalUser('user_m_01K85X5HKK3YD61Y3YXD9FHV7H')
using MangoPay.SDK;
using Newtonsoft.Json;
public class EnrollUser
{
public void Run()
{
Task.Run(async () =>
{
MangoPayApi api = new MangoPayApi();
api.Config.ClientId = "your-client-id";
api.Config.ClientPassword = "your-api-key";
var result =
await api.Users.EnrollSca("user_m_01K8B28H25JBHX1QFVC0T54S1Q");
string prettyPrint = JsonConvert.SerializeObject(result, Formatting.Indented);
Console.WriteLine(prettyPrint);
}).GetAwaiter().GetResult();
}
}
Was this page helpful?