Management API
Kullanıcılar
Kullanıcılar tek bir uygulamaya aittir ve o uygulamanın bölgesinde saklanır. Bu uç noktalar okuma için users:read, oluşturma için users:write gerektirir. Her gizli anahtar rolü kullanıcıları okuyabilir. admin ve editor anahtarları kullanıcı da oluşturabilir.
Örnekler, TR bölgesindeki app_8f2c91a7 uygulamasını ve bu uygulamanın FOXLOGIN_SECRET_KEY içindeki gizli anahtarını kullanır.
Kullanıcı nesnesi
{
"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
}| Alan | Anlamı |
|---|---|
id |
Kullanıcı ID'si. Öneki bölgeyi belirtir: usr_tr_… TR bölgesinde bulunur. |
region |
Kullanıcının kişisel verilerini saklayan bölge. |
email, email_verified |
Adres ve kullanıcının adresi onaylayıp onaylamadığı. |
name |
Görünen ad veya null. |
country |
Kullanıcının seçtiği veya sizin belirlediğiniz ISO 3166-1 alpha-2 kodu. |
status |
active veya locked. Yalnızca active kullanıcılar giriş yapabilir. |
labels |
Sizin belirlediğiniz anahtar-değer çiftleri. Oturum tokenında da görünür. |
created_at, last_sign_in_at |
UTC zaman damgaları. |
Kullanıcı oluşturma
Bu uç noktayı mevcut kullanıcıları içe aktarmak veya kendi kayıt akışınızdan hesap oluşturmak için kullanın. email ve country zorunludur. Parolasız hesap oluşturmak için password alanını göndermeyin. Bu kullanıcı e-posta koduyla giriş yapar.
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
}'Yanıt, kullanıcı nesnesiyle birlikte 201 olur.
| Alan | Zorunlu | Notlar |
|---|---|---|
email |
Evet | Uygulama içinde benzersizdir. |
country |
Evet | ISO 3166-1 alpha-2. |
name |
Hayır | Görünen ad. |
labels |
Hayır | { "store": "kadikoy" } gibi string değerlerden oluşan bir nesne. |
password |
Hayır | 8 ile 256 karakter arası. Parolasız hesap için göndermeyin. |
email_verified |
Hayır | Varsayılan false. Adresi zaten doğruladıysanız true yapın. |
| Hata | Ne zaman |
|---|---|
409 email_exists |
E-posta bu uygulamanın bir kullanıcısına zaten ait. error.details.user_id o kullanıcının ID'sini içerir. |
422 country_not_allowed |
Uygulama yalnızca listelenen ülkeleri kabul ediyor ve country bunlardan biri değil. |
400 invalid_email, 400 invalid_country, 400 weak_password |
E-posta, ülke kodu veya parola geçerli değil. |
400 invalid_body |
Zorunlu bir alan eksik veya JSON hatalı biçimli. |
403 missing_scope |
Gizli anahtar viewer rolüne sahip. |
Kullanıcıları bir döngü içinde içe aktarırken 409 email_exists yanıtını "zaten var" olarak değerlendirin ve ID'yi details içinden okuyun:
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()),
}Kullanıcı getirme
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"Kullanıcı ID'sinin öneki uygulamanın bölgesiyle eşleşmelidir (TR uygulaması için usr_tr_…). Eşleşmezse ve var olmayan ID'ler için yanıt 404 not_found olur.
E-postayla kullanıcı bulma
GET /applications/{app_id}/users?email=…, e-posta adresi tam olarak eşleşen kullanıcıları döndürür. Eşleştirme büyük/küçük harf ve aksan farklarını yok sayar.
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"Kullanıcıları listeleme
Kullanıcılar en yeniden eskiye sıralanır. Varsayılan olarak sayfa başına 50, limit ile en fazla 100 kullanıcı gelir. next_cursor değeri null olana kadar onu izleyin.
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
}Bölge yanıt vermezse liste boş data ve partial: true ile 200 döndürür. Bunu boş bir uygulama olarak değerlendirmek yerine daha sonra yeniden deneyin.
Yalnızca ID'yi saklayın
Kullanıcı ID'sini kendi kayıtlarınızın yanında tutun ve bir ad veya e-posta adresi göstermeniz gerektiğinde bu API'ye sorun. Böylece adlar ve e-posta adresleri kullanıcının bölgesinde kalır. Bir kullanıcı unutulmayı istediğinde de veritabanınızda bulup silmeniz gereken hiçbir şey olmaz.