Management API
Users
Users belong to one application and are stored in that application's region. These endpoints need users:read to read and users:write to create. Every secret key role can read users; admin and editor keys can create them.
The examples use an application app_8f2c91a7 in the TR region and its secret key in FOXLOGIN_SECRET_KEY.
The user object
{
"id": "usr_tr_8f2c91a7",
"region": "TR",
"email": "elif@example.com",
"email_verified": true,
"name": "Elif Kaya",
"country": "TR",
"status": "active",
"labels": { "store": "kadikoy" },
"created_at": "2026-12-02T09:14:00Z",
"last_sign_in_at": null
}| Field | Meaning |
|---|---|
id |
User ID. Its prefix names the region: usr_tr_… lives in TR. |
region |
Region that stores the user's personal data. |
email, email_verified |
The address and whether the user confirmed it. |
name |
Display name, or null. |
country |
ISO 3166-1 alpha-2 code the user chose or you set. |
status |
active or locked. Only active users can sign in. |
labels |
Key-value pairs you set. They also appear in the session token. |
created_at, last_sign_in_at |
Timestamps in UTC. |
Create a user
Use this to import existing users or to create accounts from your own sign-up flow. email and country are required. Leave out password to create a passwordless account; that user signs in with an email code.
import { FoxLoginAdmin } from "foxlogin/server";
const admin = new FoxLoginAdmin({ secretKey: process.env.FOXLOGIN_SECRET_KEY });
const user = await admin.users.create("app_8f2c91a7", {
email: "elif@example.com",
country: "TR",
name: "Elif Kaya",
labels: { store: "kadikoy" },
emailVerified: true,
});
console.log(user.id); // "usr_tr_8f2c91a7"import os
from foxlogin import FoxLoginAdmin
admin = FoxLoginAdmin(secret_key=os.environ["FOXLOGIN_SECRET_KEY"])
user = admin.users.create(
"app_8f2c91a7",
email="elif@example.com",
country="TR",
name="Elif Kaya",
labels={"store": "kadikoy"},
email_verified=True,
)
print(user["id"]) # "usr_tr_8f2c91a7"admin, err := foxlogin.NewAdminClient(foxlogin.AdminOptions{SecretKey: os.Getenv("FOXLOGIN_SECRET_KEY")})
if err != nil {
return err
}
user, err := admin.Users.Create(ctx, "app_8f2c91a7", foxlogin.CreateUserInput{
Email: "elif@example.com",
Country: "TR",
Name: "Elif Kaya",
Labels: map[string]string{"store": "kadikoy"},
EmailVerified: true,
})
if err != nil {
return err
}
fmt.Println(user.ID) // "usr_tr_8f2c91a7"use FoxLogin\FoxLoginAdmin;
$admin = new FoxLoginAdmin(['secretKey' => getenv('FOXLOGIN_SECRET_KEY')]);
$user = $admin->createUser('app_8f2c91a7', [
'email' => 'elif@example.com',
'country' => 'TR',
'name' => 'Elif Kaya',
'labels' => ['store' => 'kadikoy'],
'emailVerified' => true,
]);
echo $user->id; // "usr_tr_8f2c91a7"import app.foxlogin.FoxLoginAdmin;
import app.foxlogin.User;
import java.util.Map;
FoxLoginAdmin admin = FoxLoginAdmin.builder(System.getenv("FOXLOGIN_SECRET_KEY")).build();
// appId, email, country, name, labels, password (null: passwordless), emailVerified
User user = admin.users().create("app_8f2c91a7", "elif@example.com", "TR", "Elif Kaya",
Map.of("store", "kadikoy"), null, true);
System.out.println(user.id()); // "usr_tr_8f2c91a7"using FoxLogin;
var admin = new FoxLoginAdminClient(new FoxLoginAdminClientOptions
{
SecretKey = Environment.GetEnvironmentVariable("FOXLOGIN_SECRET_KEY"),
});
var user = await admin.CreateUserAsync("app_8f2c91a7", new CreateUserRequest
{
Email = "elif@example.com",
Country = "TR",
Name = "Elif Kaya",
Labels = new() { ["store"] = "kadikoy" },
EmailVerified = true,
});
Console.WriteLine(user.Id); // "usr_tr_8f2c91a7"require "foxlogin"
admin = FoxLogin::Admin.new(secret_key: ENV.fetch("FOXLOGIN_SECRET_KEY"))
user = admin.users.create(
"app_8f2c91a7",
email: "elif@example.com",
country: "TR",
name: "Elif Kaya",
labels: { "store" => "kadikoy" },
email_verified: true
)
puts user["id"] # "usr_tr_8f2c91a7"use foxlogin::{AdminClient, CreateUserInput};
let admin = AdminClient::new(std::env::var("FOXLOGIN_SECRET_KEY")?)?;
let user = admin
.create_user("app_8f2c91a7", CreateUserInput {
email: "elif@example.com".into(),
country: "TR".into(),
name: Some("Elif Kaya".into()),
labels: [("store".to_string(), "kadikoy".to_string())].into(),
email_verified: true,
..Default::default()
})
.await?;
println!("{}", user.id); // "usr_tr_8f2c91a7"curl https://api.foxlogin.app/v1/applications/app_8f2c91a7/users \
-H "Authorization: Bearer $FOXLOGIN_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "elif@example.com",
"country": "TR",
"name": "Elif Kaya",
"labels": { "store": "kadikoy" },
"email_verified": true
}'The answer is 201 with the user object.
| Field | Required | Notes |
|---|---|---|
email |
Yes | Unique within the application. |
country |
Yes | ISO 3166-1 alpha-2. |
name |
No | Display name. |
labels |
No | Object of string values, such as { "store": "kadikoy" }. |
password |
No | 8 to 256 characters. Leave it out for a passwordless account. |
email_verified |
No | Default false. Set true when you have already confirmed the address. |
| Error | When |
|---|---|
409 email_exists |
The email already belongs to a user of this application. error.details.user_id holds that user's ID. |
422 country_not_allowed |
The application accepts only listed countries and country is not one of them. |
400 invalid_email, 400 invalid_country, 400 weak_password |
The email, the country code or the password is not valid. |
400 invalid_body |
A required field is missing or the JSON is malformed. |
403 missing_scope |
The secret key has the viewer role. |
When you import users in a loop, treat 409 email_exists as "already there" and read the ID from details:
import { FoxLoginError } from "foxlogin/server";
try {
await admin.users.create("app_8f2c91a7", { email, country });
} catch (e) {
if (e instanceof FoxLoginError && e.code === "email_exists") {
console.log("exists as", e.details.user_id);
} else {
throw e;
}
}from foxlogin import FoxLoginError
try:
admin.users.create("app_8f2c91a7", email=email, country=country)
except FoxLoginError as e:
if e.code != "email_exists":
raise
print("exists as", e.details["user_id"])_, err := admin.Users.Create(ctx, "app_8f2c91a7", foxlogin.CreateUserInput{Email: email, Country: country})
var fe *foxlogin.Error
if errors.As(err, &fe) && fe.Code == "email_exists" {
fmt.Println("exists as", fe.Details["user_id"])
} else if err != nil {
return err
}use FoxLogin\FoxLoginError;
try {
$admin->createUser('app_8f2c91a7', ['email' => $email, 'country' => $country]);
} catch (FoxLoginError $e) {
if ($e->getErrorCode() !== 'email_exists') {
throw $e;
}
echo 'exists as ', $e->getDetails()['user_id'], "\n";
}import app.foxlogin.FoxLoginException;
try {
admin.users().create("app_8f2c91a7", email, country, null, null, null, false);
} catch (FoxLoginException e) {
if (!"email_exists".equals(e.getCode())) throw e;
System.out.println("exists as " + e.getDetails().get("user_id"));
}try
{
await admin.CreateUserAsync("app_8f2c91a7", new CreateUserRequest { Email = email, Country = country });
}
catch (FoxLoginError e) when (e.Code == "email_exists")
{
Console.WriteLine($"exists as {e.Details?["user_id"]}");
}begin
admin.users.create("app_8f2c91a7", email: email, country: country)
rescue FoxLogin::Error => e
raise unless e.code == "email_exists"
puts "exists as #{e.details["user_id"]}"
enduse foxlogin::CreateUserInput;
match admin.create_user("app_8f2c91a7", CreateUserInput { email, country, ..Default::default() }).await {
Ok(_) => {}
Err(e) if e.code == "email_exists" => println!("exists as {:?}", e.details_str("user_id")),
Err(e) => return Err(e.into()),
}Get a user
const user = await admin.users.get("app_8f2c91a7", "usr_tr_8f2c91a7");user = admin.users.get("app_8f2c91a7", "usr_tr_8f2c91a7")user, err := admin.Users.Get(ctx, "app_8f2c91a7", "usr_tr_8f2c91a7")$user = $admin->getUser('app_8f2c91a7', 'usr_tr_8f2c91a7');User user = admin.users().get("app_8f2c91a7", "usr_tr_8f2c91a7");var user = await admin.GetUserAsync("app_8f2c91a7", "usr_tr_8f2c91a7");user = admin.users.get("app_8f2c91a7", "usr_tr_8f2c91a7")let user = admin.get_user("app_8f2c91a7", "usr_tr_8f2c91a7").await?;curl https://api.foxlogin.app/v1/applications/app_8f2c91a7/users/usr_tr_8f2c91a7 \
-H "Authorization: Bearer $FOXLOGIN_SECRET_KEY"The user ID's prefix has to match the application's region (usr_tr_… for a TR application). Otherwise, and for IDs that do not exist, the answer is 404 not_found.
Find a user by email
GET /applications/{app_id}/users?email=… returns the users whose email matches exactly. The match ignores case and accents.
const url = new URL("https://api.foxlogin.app/v1/applications/app_8f2c91a7/users");
url.searchParams.set("email", "elif@example.com");
const res = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.FOXLOGIN_SECRET_KEY}` },
});
const { data } = await res.json();
const user = data[0] ?? null;curl "https://api.foxlogin.app/v1/applications/app_8f2c91a7/users?email=elif%40example.com" \
-H "Authorization: Bearer $FOXLOGIN_SECRET_KEY"List users
Users come newest first, 50 per page by default and up to 100 with limit. Follow next_cursor until it is null.
const headers = { Authorization: `Bearer ${process.env.FOXLOGIN_SECRET_KEY}` };
let cursor: string | null = null;
do {
const url = new URL("https://api.foxlogin.app/v1/applications/app_8f2c91a7/users");
url.searchParams.set("limit", "100");
if (cursor) url.searchParams.set("cursor", cursor);
const page = await (await fetch(url, { headers })).json();
if (page.partial) throw new Error(`Region did not answer: ${page.regions_unavailable}`);
for (const u of page.data) console.log(u.id, u.email, u.created_at);
cursor = page.next_cursor;
} while (cursor);curl "https://api.foxlogin.app/v1/applications/app_8f2c91a7/users?limit=100" \
-H "Authorization: Bearer $FOXLOGIN_SECRET_KEY"{
"data": [
{
"id": "usr_tr_8f2c91a7",
"region": "TR",
"email": "elif@example.com",
"email_verified": true,
"name": "Elif Kaya",
"country": "TR",
"status": "active",
"labels": { "store": "kadikoy" },
"created_at": "2026-12-02T09:14:00Z",
"last_sign_in_at": "2026-12-02T11:40:00Z"
}
],
"next_cursor": "eyJUUiI6InVzcl90cl84ZjJjOTFhNyJ9",
"regions_unavailable": [],
"partial": false
}If the region does not answer, the list returns 200 with empty data and partial: true. Retry later instead of treating it as an empty application.
Store only the ID
Keep the user ID next to your own records and ask this API when you need to show a name or email. Names and emails then stay in the user's region, and your database holds nothing you would have to find and erase when a user asks to be forgotten.