Test User Management

Introduction

Descope supports the ability to test end-to-end authentication via test users. Test users can be used for testing OTP and Magic Link via email or sms, as well as Enchanted Link via email. Utilizing test users, you can generate OTP codes and Magic or Enchanted link tokens for test users directly without integrating with SMS or Email through the Descope API and SDK. Once you have the generated code and token, you will verify them with the related OTP, Magic Link, or Enchanted Link verification functions in the SDK or API.

Test users can be generated via the management SDK's create test user function or by the management API create user function. When creating the test user via the API, you must ensure you pass the test=true attribute.

Test users are not audited, counted as active users, or monitored within your analytics.

Test User Limits

Free tier plans are limited to 5 test users per project. Pro-tier plans allow for 100 test users per project. Learn more about upgrading your tier within our pricing overview.

When the maximum number of test users has been reached, the user will be presented with the below error:

{
  "errorCode": "E111111",
  "errorDescription": "Failed to create user",
  "errorMessage": "... [E013002] Failed to create record [error: [E013002] Test users limit exceeded]",
  "message": "... [E013002] Failed to create record [error: [E013002] Test users limit exceeded]"
}

Test User JWT

When utilizing test users, their JWT can be identified by the "tu": true immutable claim.
{
  "amr": [
    "email"
  ],
  "drn": "DS",
  "exp": 1696964429,
  "iat": 1696963829,
  "iss": "xxxxx",
  "rexp": "2023-11-07T18:50:29Z",
  "sub": "xxxxxx",
  "tu": true
}

User management using the management SDK

You can use Descope management SDK for common user management operations like create user, update user, delete user, etc... The management SDK requires a management key, which can be generated here.

Install SDK

NodeJSPythonGoJavaRuby
npm i --save @descope/node-sdk
pip3 install descope
go get github.com/descope/go-sdk
// Include the following in your `pom.xml` (for Maven)
<dependency>
    <artifactId>java-sdk</artifactId>
    <groupId>com.descope</groupId>
    <version>sdk-version</version> // Check https://github.com/descope/descope-java/releases for the latest versions
</dependency>
gem install descope

Import and initialize Management SDK

NodeJSPythonGoJavaRuby
import DescopeClient from '@descope/node-sdk';

const managementKey = "xxxx"

try{
    //  baseUrl="<URL>" // When initializing the Descope clientyou can also configure the baseUrl ex: https://auth.company.com  - this is useful when you utilize CNAME within your Descope project.
    const descopeClient = DescopeClient({ projectId: '__ProjectID__', managementKey: managementKey });
} catch (error) {
    // handle the error
    console.log("failed to initialize: " + error)
}

// Note that you can handle async operation failures and capture specific errors to customize errors.
//     An example can be found here: https://github.com/descope/node-sdk?tab=readme-ov-file#error-handling
from descope import (
    REFRESH_SESSION_TOKEN_NAME,
    SESSION_TOKEN_NAME,
    AuthException,
    DeliveryMethod,
    DescopeClient,
    AssociatedTenant,
    RoleMapping,
    AttributeMapping
)

management_key = "xxxx"

try:
    # You can configure the baseURL by setting the env variable Ex: export DESCOPE_BASE_URI="https://auth.company.com  - this is useful when you utilize CNAME within your Descope project."
    descope_client = DescopeClient(project_id='__ProjectID__', management_key=management_key)
except Exception as error:
    # handle the error
    print ("failed to initialize. Error:")
    print (error)
import "github.com/descope/go-sdk/descope"
import "github.com/descope/go-sdk/descope/client"
import "fmt"

// Utilizing the context package allows for the transmission of context capabilities like cancellation
//      signals during the function call. In cases where context is absent, the context.Background()
//      function serves as a viable alternative.
//      Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
import (
	"context"
)

managementKey = "xxxx"

// DescopeBaseURL // within the client.Config, you can also configure the baseUrl ex: https://auth.company.com  - this is useful when you utilize CNAME within your Descope project.
descopeClient, err := client.NewWithConfig(&client.Config{ProjectID:"__ProjectID__", managementKey:managementKey})
if err != nil {
    // handle the error
    log.Println("failed to initialize: " + err.Error())
}
import com.descope.client;

// Initialized after setting the DESCOPE_PROJECT_ID env var (and optionally DESCOPE_MANAGEMENT_KEY)
var descopeClient = new DescopeClient();

// ** Or directly **
var descopeClient = new DescopeClient(Config.builder()
        .projectId("__ProjectID__")
        .managementKey("management-key")
        .build());
require 'descope'


descope_client = Descope::Client.new(
  {
    project_id: '__ProjectID__',
    management_key: 'management_key'
  }
)

Create Test User

This operation creates a new test user within the project with the details provided.

NodeJSPythonGoJava
// Args:
//   loginId (str): The login ID of the test user to be created.
const loginId = "xxxx"
//   email (str): Optional user email address of the test user to be created.
const email = "email@company.com"
//   phone (str): Optional user phone number of the test user to be created.
const phone = "+12223334455"
//   displayName (str): Optional user display name of the test user to be created.
const displayName = "Joe Person"
//    roles (List[str]): An optional list of the user's roles without tenant association. These roles are mutually exclusive with the `user_tenant` roles, which take precedence over them.
const roles = ["TestRole1"]
//    userTenants (List[UserTenants]): An optional list of the user's tenants, and optionally, their roles per tenant. These roles are mutually exclusive with the general `role_names`, and take precedence over them.
const userTenants = [{ tenantId: 'TestTenant', roleNames: ['TestRole'] }]
//   customAttributes (dict): Optional, set the different custom attributes values of the keys that were previously configured in Descope console app
const customAttributes = {"Attribute 1": "Value 1", "Attribute 2": "Value 2"}
//   picture (str): Optional url for user picture
const picture = "xxxx"
//   verifiedEmail (bool): Set to true for the user to be able to login with the email address.
const verifiedEmail = true // or false
//   verifiedPhone (bool): Set to true for the user to be able to login with the phone number.
const verifiedPhone = true // or false
//   additionalLoginIds (optional List[str]): An optional list of additional login IDs to associate with the user
const additionalLoginIds = ["MyUserName", "+12223334455"]

const resp = await descopeClient.management.user.createTestUser(
  loginId,
  email,
  phone,
  displayName,
  roles,
  userTenants,
  customAttributes,
  picture,
  verifiedEmail,
  verifiedPhone,
  null,
  null,
  null,
  additionalLoginIds
);
if (!resp.ok) {
  console.log("Failed to create test user")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully created test user")
  console.log(resp.data)
}
# Args:
#   login_id (str): The login ID of the test user to be created.
login_id = "xxxx"
#   email (str): Optional user email address of the test user to be created.
email = "email@company.com"
#   phone (str): Optional user phone number of the test user to be created.
phone = "+12223334455"
#   display_name (str): Optional user display name of the test user to be created.
display_name = "Joe Person"
#   role_names (List[str]): An optional list of the user's roles without tenant association. These roles are mutually exclusive with the `user_tenant` roles.
role_names = ["TestRole"]
#   user_tenants (List[AssociatedTenant]): An optional list of the user's tenants, and optionally, their roles per tenant. These roles are mutually exclusive with the general `role_names`.
user_tenants = [AssociatedTenant("TestTenant")]
#   picture (str): Optional url for user picture
picture = "xxxx"
#   custom_attributes (dict): Optional, set the different custom attributes values of the keys that were previously configured in Descope console app
custom_attributes = {"Attribute 1": "Value 1", "Attribute 2": "Value 2"}
#   verified_email (bool): Set to true for the user to be able to login with the email address.
verified_email = true // or false
#   verifiedPhone (bool): Set to true for the user to be able to login with the phone number.
verified_phone = true // or false
#   additional_login_ids (optional List[str]): An optional list of additional login IDs to associate with the user
additional_login_ids = ["MyUserName", "+12223334455"]

try:
  resp = descope_client.mgmt.user.create_test_user(
    login_id=login_id,
    email=email,
    phone=phone,
    display_name=display_name,
    role_names=role_names,
    user_tenants=user_tenants,
    picture=picture,
    custom_attributes=custom_attributes,
    verified_email=verified_email,
    verified_phone=verified_phone,
    additional_login_ids=additional_login_ids
  )
  print("Successfully created user.")
  print(resp)
except AuthException as error:
  print("Unable to create user.")
  print("Status Code: " + str(error.status_code))
  print("Error: " + str(error.error_message))
// Args:
//  ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//  loginID (str): The login ID of the user to be deactivated.
loginID := "xxxx"
//  userReq (&descope.UserRequest): A list of the user's details.
userReq := &descope.UserRequest{}
userReq.Email = "email@company.com"
userReq.Name = "Joe Person"
userReq.Tenants = []*descope.AssociatedTenant{
    {TenantID: "tenant-ID1", Roles: []string{"role-name1"}},
    {TenantID: "tenant-ID2"},
}
VerifiedEmail := true // or false
userReq.VerifiedEmail = &VerifiedEmail
VerifiedPhone := true // or false
userReq.VerifiedPhone = &VerifiedPhone
userReq.AdditionalLoginIds = ["MyUserName", "+12223334455"]

res, err := descopeClient.Management.User().CreateTestUser(ctx, loginID, userReq)
if  (err != nil){
  fmt.Println("Unable to create test user.", err)
} else {
  fmt.Println("Successfully created test user.")
  fmt.Println(res)
}
// User for test can be created, this user will be able to generate code/link without
// the need of 3rd party messaging services.
// Test user must have a loginID, other fields are optional.
// Roles should be set directly if no tenants exist, otherwise set
// on a per-tenant basis.
UserService us = descopeClient.getManagementServices().getUserService();
try {
    UserResponseDetails resp = us.createTestUser("email@company.com", UserRequest.builder()
            .email("email@company.com")
            .displayName("Joe Person")
            .tenants(Arrays.asList(
                AssociatedTenant.builder()
                    .tenantId("tenant-ID1")
                    .roleNames(Arrays.asList("role-name1"),
                AssociatedTenant.builder()
                    .tenantId("tenant-ID2"))));
              .additionalLoginIDs("MyUserName", "+12223334455"));
} catch (DescopeException de) {
    // Handle the error
}

Generate OTP For Test User

This operation generates an OTP code for authenticating a test user.

Note that signin is not complete without the user verification step, which can be performed using the backend SDKs.

NodeJSPythonGoJava
// Args:
//    deliveryMethod: Delivery method to use to send OTP. Supported values include "email" or "sms"
const deliveryMethod = "email"
//    loginId (str): The login ID of the user.
const loginId = "xxxx"


const resp = await descopeClient.management.user.generateOTPForTestUser(deliveryMethod, loginId);
if (!resp.ok) {
  console.log("Failed to generate test user OTP")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully generated test user OTP")
  console.log("OTP Code: " + resp.data.code)
}
# Args:
#   login_id (str): The login ID of the user.
login_id = "xxxx"
#   delivery_method: Method used to deliver the OTP. Supported delivery methods - DeliveryMethod.SMS or DeliveryMethod.EMAIL
delivery_method = DeliveryMethod.EMAIL

try:
  resp = descope_client.mgmt.user.generate_otp_for_test_user(method=delivery_method, login_id=login_id)
  code = resp.get("code", "")
  print("Successfully generated OTP code for test user")
  print("OTP Code: " + code)
except AuthException as error:
  print("Unable to generate test OTP.")
  print("Status Code: " + str(error.status_code))
  print("Error: " + str(error.error_message))
// Args:
//   ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//    deliveryMethod: Delivery method to use to send OTP. Supported values include descope.MethodEmail or descope.MethodSMS
deliveryMethod := descope.MethodEmail
//    loginID (str): The login ID of the user.
loginID := "xxxx"

code, err := descopeClient.Management.User().GenerateOTPForTestUser(ctx, deliveryMethod, loginID)
if  (err != nil){
  fmt.Println("Unable to generate test OTP.", err)
} else {
  fmt.Println("Successfully generated test OTP.")
  fmt.Println(code)
}
UserService us = descopeClient.getManagementServices().getUserService();
// OTP code can be generated for test user, for example:
try {
    OTPTestUserResponse res = us.generateOtpForTestUser("email@company.com", DeliveryMethod.EMAIL);
    // Use res.getCode() for verify and establishing a session
} catch (DescopeException de) {
    // Handle the error
}

Generate Magic Link For Test User

This operation generates an Magic Link for authenticating a test user. The response contains the link, which contains the token needed to verify the user within the user verification step, which can be performed using the backend SDKs. The token arrives as a query parameter named 't' which can be parse out of the link, see examples below.

NodeJSPythonGoJava
// Args:
//  deliveryMethod: Delivery method to use to send OTP. Supported values include "email" or "sms"
const deliveryMethod = "email"
//  loginId (str): The login ID of the user.
const loginId = "xxxx"
//  uri: this is the link that user is sent (code appended) for verification. Your application needs to host this page and extract the token for verification. The token arrives as a query parameter named 't'
const uri = "" // This can be an empty string for testing purposes

const resp = await descopeClient.management.user.generateMagicLinkForTestUser(deliveryMethod,loginId, uri);
if (!resp.ok) {
  console.log("Failed to generate test user Magic Link")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  const token = resp.data.link.split("?t=")[1]
  console.log("Successfully generated test user Magic Link")
  console.log("Magic Link Token: " + token)
}
# Args:
#   login_id (str): The login ID of the user.
login_id = "xxxx"
#   delivery_method: Method used to deliver the OTP. Supported delivery methods - DeliveryMethod.SMS or DeliveryMethod.EMAIL
delivery_method = DeliveryMethod.EMAIL
#   uri: this is the link that user is sent (code appended) for verification. Your application needs to host this page and extract the token for verification. The token arrives as a query parameter named 't'
uri = "" # This can be an empty string for testing purposes

try:
  resp = descope_client.mgmt.user.generate_magic_link_for_test_user(method=delivery_method, login_id=login_id, uri=uri)
  token = resp.get("link", "").split("?t=")[1]
  print("Successfully generated Magic Link for test user")
  print("Magic Link Token: " + token)
except AuthException as error:
  print("Unable to generate test Magic Link.")
  print("Status Code: " + str(error.status_code))
  print("Error: " + str(error.error_message))
// Args:
//  ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//  loginID (str): The login ID of the user.
loginID := "xxxx"
//    deliveryMethod: Delivery method to use to send OTP. Supported values include descope.MethodEmail or descope.MethodSMS
deliveryMethod := descope.MethodEmail
//    uri: this is the link that user is sent (code appended) for verification. Your application needs to host this page and extract the token for verification. The token arrives as a query parameter named 't'
uri := "" // This can be an empty string for testing purposes

link, err := descopeClient.Management.User().GenerateMagicLinkForTestUser(ctx, deliveryMethod, loginID, uri)
if  (err != nil){
  fmt.Println("Unable to generate test Magic Link.", err)
} else {
  token := strings.Split(link, "?t=")[1]
  fmt.Println("Successfully generated test Magic Link.")
  fmt.Println("Magic Link Token: " + token)
}
UserService us = descopeClient.getManagementServices().getUserService();
// Same as OTP, magic link can be generated for test user, for example:
try {
    MagicLinkTestUserResponse res = us.generateMagicLinkForTestUser("email@company.com", "", DeliveryMethod.EMAIL);
    // Use res.getLink() to get the generated link. To get the actual token, use:
    // var params = UriUtils.splitQuery("https://example.com" + res.getLink());
    // var authInfo = magicLinkService.verify(params.get("t").get(0));

} catch (DescopeException de) {
    // Handle the error
}

Generate Enchanted Link For Test User

This operation generates an Enchanted Link for authenticating a test user.

The generate Enchanted Link for test user call returns a pendingRef and a link. Parse the link to capture the token, then utilize the backend SDK to verify the token. You will also need to utilize the pendingRef to poll for verification status in order to receive the test user's JWT.
NodeJSPythonGoJava
// Args:
//  loginId (str): The login ID of the user.
const loginId = "xxxx"
//  uri: this is the link that user is sent (code appended) for verification. Your application needs to host this page and extract the token for verification. The token arrives as a query parameter named 't'
const uri = "" // This can be an empty string for testing purposes

const resp = await descopeClient.management.user.generateEnchantedLinkForTestUser(loginId, uri);
if (!resp.ok) {
  console.log("Failed to generate test user Enchanted Link")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  const token = resp.data.link.split("?t=")[1]
  console.log("Successfully generated test user Enchanted Link")
  console.log("Enchanted Link Token: " + token)
  console.log("Enchanted Link Pending Ref: " + resp.get("pendingRef", ""))
}
# Args:
#   login_id (str): The login ID of the user.
login_id = "xxxx"
#   uri: this is the link that user is sent (code appended) for verification. Your application needs to host this page and extract the token for verification. The token arrives as a query parameter named 't'
uri = "" # This can be an empty string for testing purposes

try:
  resp = descope_client.mgmt.user.generate_enchanted_link_for_test_user(login_id=login_id, uri=uri)
  token = resp.get("link", "").split("?t=")[1]
  print("Successfully generated Enchanted Link for test user")
  print("Enchanted Link Token: " + token)
  print("Enchanted Link Pending Ref: " + resp.get("pendingRef", ""))
except AuthException as error:
  print("Unable to generate test Enchanted Link.")
  print("Status Code: " + str(error.status_code))
  print("Error: " + str(error.error_message))
// Args:
//  ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//  loginId (str): The login ID of the user.
loginId := "xxxx"
//  uri: this is the link that user is sent (code appended) for verification. Your application needs to host this page and extract the token for verification. The token arrives as a query parameter named 't'
uri := "" // This can be an empty string for testing purposes

link, pendingRef, err := descopeClient.Management.User().GenerateEnchantedLinkForTestUser(ctx, loginID, uri)
if  (err != nil){
  fmt.Println("Unable to generate test Enchanted Link.", err)
} else {
  token := strings.Split(link2, "?t=")[1]
  fmt.Println("Successfully generated test Enchanted Link.")
  fmt.Println("Enchanted Link Token: " + token)
  fmt.Println("Enchanted Link Pending Ref: " + pendingRef)
}
UserService us = descopeClient.getManagementServices().getUserService();
// Enchanted link can be generated for test user, for example:
try {
    EnchantedLinkTestUserResponse res = us.generateEnchantedLinkForTestUser("email@company.com", "");
    // Use res.getLink() to get the generated link. To get the actual token, use:
    // var params = UriUtils.splitQuery("https://example.com" + res.getLink());
    // enchantedLinkService.verify(params.get("t").get(0));
    // var authInfo = enchantedLinkService.getSession(res.getPendingRef());
} catch (DescopeException de) {
    // Handle the error
}

Generate Embedded Link For Test User

This operation generates an Embedded Link for authenticating a test user. The response returns the token to be used in the user verification step, which can be performed using the backend SDKs.

NodeJSPythonGoJava
// Args:
//  loginId (str): The login ID of the user.
const loginId = "xxxx"
//   customClaims (dict): Custom claims to add to JWT, system claims will be filtered out
const customClaims = {"custom-key1": "custom-value1", "custom-key2": "custom-value2"}

const resp = await descopeClient.management.user.generateEmbeddedLinkForTestUser(loginId, customClaims);
if (!resp.ok) {
  console.log("Failed to generate test user Embedded Link")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  const token = resp.data.token;
  console.log("Successfully generated test user Embedded Link")
  console.log("Embedded Link Token: " + token)
}
# Args:
#   login_id (str): The login ID of the user.
login_id = "xxxx"
#   custom_claims (dict): Custom claims to add to JWT, system claims will be filtered out
custom_claims = {"custom-key1": "custom-value1", "custom-key2": "custom-value2"}

try:
  token = descope_client.mgmt.user.generate_embedded_link_for_test_user(login_id=login_id, custom_claims=custom_claims)
  print("Successfully generated Embedded Link for test user")
  print("Embedded Link Token: " + token)
except AuthException as error:
  print("Unable to generate test Embedded Link.")
  print("Status Code: " + str(error.status_code))
  print("Error: " + str(error.error_message))
// Args:
//  ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//  loginId (str): The login ID of the user.
loginId := "xxxx"
//   customClaims (map[string]): Custom claims to add to JWT, system claims will be filtered out
customClaims := map[string]any{"custom-key1": "custom-value1", "custom-key2": "custom-value2"}

token, err := descopeClient.Management.User().GenerateEmbeddedLinkForTestUser(ctx, loginID, customClaims)
if  (err != nil){
  fmt.Println("Unable to generate test Embedded Link.", err)
} else {
  fmt.Println("Successfully generated Embedded Link for test user")
  fmt.Println("Embedded Link Token: " + token)
}
// Args:
//  loginID: email or phone - Used as the unique ID for the user from here on and also used for delivery
String loginId = "email@company.com";
//  customClaims: Additional claims to place on the jwt after verification
Map<String, Object> customClaims = new HashMap<String, Object>() {{
                put("custom-key1", "custom-value1");}}

UserService us = descopeClient.getManagementServices().getUserService();
// Embedded link can be generated for test user, for example:
try {
    String token = us.generateEmbeddedLinkForTestUser(loginID, customClaims);
} catch (DescopeException de) {
    // Handle the error
}

Delete a Test User

This operation allows administrators to delete an existing test user. This action will delete the users forever and they will not be recoverable.

NodeJSPythonGoJava
// Args:
//    login_id (str): The login_id of the user to be deleted.
const loginId = "email@company.com"

const resp = await descopeClient.management.user.delete(loginId);
if (!resp.ok) {
  console.log("Failed to delete user.")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully deleted user.")
  console.log(resp.data)
}
# Args:
#   login_id (str): The login_id of the user that's to be deleted.
login_id = "xxxxx"

try:
  resp = descope_client.mgmt.user.delete(login_id=login_id)
  print(json.dumps(resp, indent=2))
except AuthException as error:
  print ("Unable to update user.")
  print ("Status Code: " + str(error.status_code))
  print ("Error: " + str(error.error_message))
// Args:
//   ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()
//    loginID (str): The loginID of the user to be deleted.
var loginID = "email@company.com"

err := descopeClient.Management.User().Delete(ctx, loginID)
if (err != nil){
  fmt.Println("Unable to delete user: ", err)
} else {
  fmt.Println("User Successfully deleted")
}
UserService us = descopeClient.getManagementServices().getUserService();
try {
    us.delete("email@company.com");
} catch (DescopeException de) {
    // Handle the error
}

Delete All Test Users

This operation deletes all test users within the project. This action will delete these users forever and they will not be recoverable.

NodeJSPythonGoJava
// Args:
//  None

const resp = await descopeClient.management.user.deleteAllTestUsers();
if (!resp.ok) {
  console.log("Failed to delete test users")
  console.log("Status Code: " + resp.code)
  console.log("Error Code: " + resp.error.errorCode)
  console.log("Error Description: " + resp.error.errorDescription)
  console.log("Error Message: " + resp.error.errorMessage)
}
else {
  console.log("Successfully deleted test users")
}
# Args:
#   None

try:
  descope_client.mgmt.user.delete_all_test_users()
  print ("Successfully deleted test users")
except AuthException as error:
  print ("Failed to delete test users")
  print ("Status Code: " + str(error.status_code))
  print ("Error: " + str(error.error_message))
// Args:
//   ctx: context.Context - Application context for the transmission of context capabilities like
//        cancellation signals during the function call. In cases where context is absent, the context.Background()
//        function serves as a viable alternative.
//        Utilizing context within the Descope GO SDK is supported within versions 1.6.0 and higher.
ctx := context.Background()

err := descopeClient.Management.User().DeleteAllTestUsers(ctx)
if  (err != nil){
  fmt.Println("Unable to delete test users.", err)
} else {
  fmt.Println("Successfully deleted test users.")
}
UserService us = descopeClient.getManagementServices().getUserService();
// Now test user got created, and this user will be available until you delete it,
// you can use any management operation for test user CRUD.
// You can also delete all test users.
try {
    us.deleteAllTestUsers();
} catch (DescopeException de) {
    // Handle the error
}