Auth & identity
End-user authentication as a service — users, sessions, JWT verification, OAuth and GDPR/CCPA consent — across Clerk / WorkOS / Supabase Auth behind one key.
Overview
https://api.infrai.cc/v1/authAuthorization: Bearer $INFRAI_API_KEY# Call any /v1/auth capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/auth/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"Methods
auth.user.create
Create an auth user across a vendor (Clerk/WorkOS/Supabase Auth). Pins the vendor of record (sticky-on-resource). Accepts idempotency_key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email | string | Required | User email address. |
password | string | Optional | Optional initial password (vendor-dependent). |
metadata | Record<string, unknown> | Optional | Arbitrary key/value metadata stored on the user. |
vendor | string | Optional | Explicit vendor pin; required when mode=byok. |
mode | "managed" | "byok" | Optional | Provisioning mode — managed or byok. |
idempotency_key | string | Optional | Client-supplied key to make the call idempotent. |
Returns
AuthUser { user_id, email, email_verified, created_at }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/auth/user/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "..."}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/user/create",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'email': '...'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"email": "..."}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"email": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.user.get
Fetch a single auth user by user_id from its pinned vendor.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
Returns
AuthUserExample
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/auth/user/get/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/user/get/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/get/USER_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/get/USER_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.user.get_by_email
Look up an auth user by email address.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
email | string | Required | User email address. |
Returns
AuthUserExample
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/auth/user/get_by_email \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/user/get_by_email",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/get_by_email",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/get_by_email",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.user.list
Cursor-paginated list of auth users for the account.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
cursor | string | Optional | Opaque pagination cursor. |
limit | number | Optional | Maximum number of items to return. |
Returns
{ items: AuthUser[], next_cursor?: string }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/auth/user/list \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/user/list",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.user.update
Update mutable fields (metadata, phone, MFA) of an existing auth user. Accepts idempotency_key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
metadata | Record<string, unknown> | Optional | Arbitrary key/value metadata stored on the user. |
email_verified | boolean | Optional | Mark the user email as verified. |
mfa_enabled | boolean | Optional | Enable or disable MFA for the user. |
idempotency_key | string | Optional | Client-supplied key to make the call idempotent. |
Returns
AuthUserExample
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X PATCH https://api.infrai.cc/v1/auth/user/update/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"user_id": "..."}'import os, requests
resp = requests.patch(
"https://api.infrai.cc/v1/auth/user/update/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'user_id': '...'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/update/USER_ID",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/update/USER_ID",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.user.delete
Delete an auth user and cascade-revoke its sessions. Accepts idempotency_key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X DELETE https://api.infrai.cc/v1/auth/user/delete/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/auth/user/delete/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/delete/USER_ID",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/delete/USER_ID",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.session.create
Mint an authenticated session for a user; routes to the user's pinned vendor. May return AUTH_MFA_REQUIRED. Accepts idempotency_key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
method | string | Optional | Authentication method used for the session. |
mfa_factor | string | Optional | MFA factor / code when require_mfa is set. |
require_mfa | boolean | Optional | Require an MFA factor to issue the session. |
idempotency_key | string | Optional | Client-supplied key to make the call idempotent. |
Returns
Session { session_id, access_token, refresh_token, expires_at }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/auth/session/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"user_id": "..."}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/session/create",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'user_id': '...'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.session.verify
Verify a session_id / JWT against the vendor JWKS (RS256+ES256) and return the Session.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
session_id | string | Required | The session id. |
Returns
{ valid: boolean, user_id?, expires_at? }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/auth/session/verify/SESSION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/session/verify/SESSION_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/verify/SESSION_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/verify/SESSION_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.session.refresh
Exchange a refresh token for a new session; enforces 5-min cooldown (AUTH_REFRESH_TOO_FREQUENT). Accepts idempotency_key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
refresh_token | string | Required | A valid refresh token to exchange for a new session. |
idempotency_key | string | Optional | Client-supplied key to make the call idempotent. |
Returns
SessionExample
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/auth/session/refresh \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"refresh_token": "..."}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/session/refresh",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'refresh_token': '...'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/refresh",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"refresh_token": "..."}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/refresh",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"refresh_token": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.session.revoke
Revoke a single session by session_id. Accepts idempotency_key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
session_id | string | Required | The session id. |
idempotency_key | string | Optional | Client-supplied key to make the call idempotent. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"session_id": "..."}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'session_id': '...'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"session_id": "..."}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"session_id": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.session.revoke_all_for_user
Revoke all active sessions for a user (e.g. password reset / logout-everywhere). Accepts idempotency_key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
except_session_id | string | Optional | Keep this session; revoke all others. |
Returns
{ revoked: number }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"user_id": "..."}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'user_id': '...'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.session.list_for_user
List active sessions for a given user.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
Returns
{ items: Session[] }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.consent.grant
Record a GDPR/CCPA consent grant for a user/category. Accepts idempotency_key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
category | string | Required | Consent category, e.g. marketing or analytics. |
source | string | Optional | How the consent was captured. |
idempotency_key | string | Optional | Client-supplied key to make the call idempotent. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/auth/consent/grant/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"user_id": "...", "category": "marketing"}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/consent/grant/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'user_id': '...', 'category': 'marketing'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/consent/grant/USER_ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "...", "category": "marketing"}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/consent/grant/USER_ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "...", "category": "marketing"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.consent.revoke
Revoke a previously granted consent for a user/category. Accepts idempotency_key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
category | string | Required | Consent category, e.g. marketing or analytics. |
idempotency_key | string | Optional | Client-supplied key to make the call idempotent. |
Returns
{ ok: boolean }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X POST https://api.infrai.cc/v1/auth/consent/revoke/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"user_id": "...", "category": "marketing"}'import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/consent/revoke/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'user_id': '...', 'category': 'marketing'},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/consent/revoke/USER_ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "...", "category": "marketing"}),
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/consent/revoke/USER_ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "...", "category": "marketing"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.consent.check
Check whether a user currently holds consent for a given category (boolean).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
category | string | Required | Consent category, e.g. marketing or analytics. |
Returns
{ granted: boolean, source?, granted_at? }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);auth.consent.list_for_user
List all consent records for a user across GDPR categories.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | string | Required | The user id. |
Returns
{ items: Array<{ category, granted, source?, granted_at? }> }Example
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."curl -X GET https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())const resp = await fetch(
"https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());const resp = await fetch(
"https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);Advanced: pin a vendor
By default infrai routes each call to the best available provider — you do not pick a vendor. As an escape hatch, this capability accepts an optional vendor parameter to pin one specific provider. Every live vendor for this capability is available in real time from the discovery endpoint for the capability id — see the discovery API.
GET /v1/discovery/{capability}auth.user.create
All capabilities
Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.
| Capability | Endpoint | Description |
|---|---|---|
auth.consent.check | GET /v1/auth/consent/check/{user_id}/{category} | Check whether a user currently holds consent for a given category (boolean). |
auth.consent.grant | POST /v1/auth/consent/grant/{user_id} | Record a GDPR/CCPA consent grant for a user/category. Accepts idempotency_key. |
auth.consent.list_for_user | GET /v1/auth/consent/list_for_user/{user_id} | List all consent records for a user across GDPR categories. |
auth.consent.revoke | POST /v1/auth/consent/revoke/{user_id} | Revoke a previously granted consent for a user/category. Accepts idempotency_key. |
auth.session.create | POST /v1/auth/session/create | Mint an authenticated session for a user; routes to the user's pinned vendor. May return AUTH_MFA_REQUIRED. Accepts idempotency_key. |
auth.session.list_for_user | GET /v1/auth/session/list_for_user/{user_id} | List active sessions for a given user. |
auth.session.refresh | POST /v1/auth/session/refresh | Exchange a refresh token for a new session; enforces 5-min cooldown (AUTH_REFRESH_TOO_FREQUENT). Accepts idempotency_key. |
auth.session.revoke | POST /v1/auth/session/revoke/{session_id} | Revoke a single session by session_id. Accepts idempotency_key. |
auth.session.revoke_all_for_user | POST /v1/auth/session/revoke_all_for_user/{user_id} | Revoke all active sessions for a user (e.g. password reset / logout-everywhere). Accepts idempotency_key. |
auth.session.verify | GET /v1/auth/session/verify/{session_id} | Verify a session_id / JWT against the vendor JWKS (RS256+ES256) and return the Session. |
auth.user.create | POST /v1/auth/user/create | Create an auth user across a vendor (Clerk/WorkOS/Supabase Auth). Pins the vendor of record (sticky-on-resource). Accepts idempotency_key. |
auth.user.delete | DELETE /v1/auth/user/delete/{user_id} | Delete an auth user and cascade-revoke its sessions. Accepts idempotency_key. |
auth.user.get | GET /v1/auth/user/get/{user_id} | Fetch a single auth user by user_id from its pinned vendor. |
auth.user.get_by_email | GET /v1/auth/user/get_by_email | Look up an auth user by email address. |
auth.user.list | GET /v1/auth/user/list | Cursor-paginated list of auth users for the account. |
auth.user.update | PATCH /v1/auth/user/update/{user_id} | Update mutable fields (metadata, phone, MFA) of an existing auth user. Accepts idempotency_key. |
End-to-end example
A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.
A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.
#!/usr/bin/env python3
"""Infrai · auth — runnable real-app example (single file, zero deps).
Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://console.infrai.cc (Google/
GitHub sign-in grants $2 free credit). No SDK — the 12-line helper
below is the entire integration."""
import json
import os
from urllib import error, request
KEY = os.environ.get("INFRAI_API_KEY") or "ifr_pk_proj_..." # <- your key
BASE = "https://api.infrai.cc"
# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
req = request.Request(
BASE + path, method=method,
data=json.dumps(body).encode() if body is not None else None,
headers={"Authorization": f"Bearer {KEY}",
"Content-Type": "application/json"})
try:
with request.urlopen(req, timeout=60) as r:
return json.loads(r.read())
except error.HTTPError as e:
return json.loads(e.read())
def show(label, resp):
print(f"\n== {label} ==")
print(json.dumps(resp, indent=2, ensure_ascii=False))
return resp
# 1) auth.user.create — POST /v1/auth/user/create · Create an auth user across a vendor (Clerk/WorkOS/Supabase Auth). Pins the vendor of record (sticky-on-resource). Accepts idempotency_key.
r1 = show("auth.user.create", infrai("POST", "/v1/auth/user/create", {"email":"..."}))
# 2) auth.session.create — POST /v1/auth/session/create · Mint an authenticated session for a user; routes to the user's pinned vendor. May return AUTH_MFA_REQUIRED. Accepts idempotency_key.
r2 = show("auth.session.create", infrai("POST", "/v1/auth/session/create", {"user_id":"..."}))
# 3) auth.user.get_by_email — GET /v1/auth/user/get_by_email · Look up an auth user by email address.
r3 = show("auth.user.get_by_email", infrai("GET", "/v1/auth/user/get_by_email"))
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at the console for a project key
# + $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..." # from the console
# 2) auth.user.create
curl -X POST https://api.infrai.cc/v1/auth/user/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "..."}'
# 3) auth.user.get
curl -X GET https://api.infrai.cc/v1/auth/user/get/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 4) auth.user.get_by_email
curl -X GET https://api.infrai.cc/v1/auth/user/get_by_email \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 5) auth.user.list
curl -X GET https://api.infrai.cc/v1/auth/user/list \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 6) auth.user.update
curl -X PATCH https://api.infrai.cc/v1/auth/user/update/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"user_id": "..."}'
# 7) auth.user.delete
curl -X DELETE https://api.infrai.cc/v1/auth/user/delete/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 8) auth.session.create
curl -X POST https://api.infrai.cc/v1/auth/session/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"user_id": "..."}'
# 9) auth.session.verify
curl -X GET https://api.infrai.cc/v1/auth/session/verify/SESSION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 1) Auth: every call is a raw HTTPS request carrying only your project key.
# No SDK to install — just the `requests` library.
import os, requests
BASE = "https://api.infrai.cc"
HEADERS = {
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
"Content-Type": "application/json",
}
# 2) auth.user.create
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/user/create",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'email': '...'},
)
resp.raise_for_status()
print(resp.json())
# 3) auth.user.get
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/user/get/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 4) auth.user.get_by_email
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/user/get_by_email",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 5) auth.user.list
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/user/list",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 6) auth.user.update
import os, requests
resp = requests.patch(
"https://api.infrai.cc/v1/auth/user/update/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'user_id': '...'},
)
resp.raise_for_status()
print(resp.json())
# 7) auth.user.delete
import os, requests
resp = requests.delete(
"https://api.infrai.cc/v1/auth/user/delete/USER_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
# 8) auth.session.create
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/session/create",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
json={'user_id': '...'},
)
resp.raise_for_status()
print(resp.json())
# 9) auth.session.verify
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/auth/session/verify/SESSION_ID",
headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"},
)
resp.raise_for_status()
print(resp.json())
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch().
const BASE = "https://api.infrai.cc";
const HEADERS = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) auth.user.create
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"email": "..."}),
},
);
console.log(await resp.json());
// 3) auth.user.get
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/get/USER_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 4) auth.user.get_by_email
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/get_by_email",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 5) auth.user.list
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 6) auth.user.update
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/update/USER_ID",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
console.log(await resp.json());
// 7) auth.user.delete
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/delete/USER_ID",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 8) auth.session.create
const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
console.log(await resp.json());
// 9) auth.session.verify
const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/verify/SESSION_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch(), typed.
const BASE = "https://api.infrai.cc";
const HEADERS: Record<string, string> = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) auth.user.create
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"email": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 3) auth.user.get
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/get/USER_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 4) auth.user.get_by_email
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/get_by_email",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 5) auth.user.list
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 6) auth.user.update
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/update/USER_ID",
{
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 7) auth.user.delete
const resp = await fetch(
"https://api.infrai.cc/v1/auth/user/delete/USER_ID",
{
method: "DELETE",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 8) auth.session.create
const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/create",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"user_id": "..."}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 9) auth.session.verify
const resp = await fetch(
"https://api.infrai.cc/v1/auth/session/verify/SESSION_ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);