Auth 与身份
终端用户身份认证即服务——用户、会话、JWT/JWKS 校验、OAuth 与 GDPR/CCPA 同意——基于 infrai 自研身份引擎,一把 key 打通。
1. 概览
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"2. 方法 (17)
2.1auth.user.create
在 infrai 自研身份引擎中创建终端用户。支持 idempotency_key。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 必填 | 用户邮箱地址。format: email |
password | string | 可选 | 可选的初始密码(依赖 vendor)。 |
metadata | Record<string, unknown> | 可选 | 存储在用户上的任意键值元数据。 |
vendor | "infrai_native" | null | 可选 | 可选的显式 vendor 锁定。 |
mode | "default_vendor" | "verified_account" | 可选 | 预置模式——managed。default: "default_vendor" |
idempotency_key | string | 可选 | 客户端提供的幂等键。 |
返回
AuthUser { user_id, email, email_verified, created_at }| 名称 | 类型 | 说明 |
|---|---|---|
user_id | string | 关联此资源的用户标识pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
email | string | 邮箱地址format: email |
email_verified | boolean | 邮箱地址是否已验证default: false |
phone | string | null | E.164 格式的电话号码 |
mfa_enabled | boolean | 该用户是否启用了多因素认证default: false |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
last_login_at | string | null | ISO 8601 时间戳:the last successful login(ISO 8601)format: date-time |
metadata | object | null | 附加在此资源上的任意键值元数据 |
vendor | string | null | 粘滞:该用户的记录供应商。 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/auth/user/create \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'user@example.com'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "user@example.com"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "user@example.com"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"email": "user@example.com"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/auth/user/create", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/user/create"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"email\": \"user@example.com\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/auth/user/create");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"email\": \"user@example.com\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/user/create");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"email\": \"user@example.com\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/user/create")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"email": "user@example.com"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/auth/user/create")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"email": "user@example.com"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.2auth.user.get
按 user_id 获取单个认证用户。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。 |
返回
AuthUser| 名称 | 类型 | 说明 |
|---|---|---|
user_id | string | 关联此资源的用户标识pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
email | string | 邮箱地址format: email |
email_verified | boolean | 邮箱地址是否已验证default: false |
phone | string | null | E.164 格式的电话号码 |
mfa_enabled | boolean | 该用户是否启用了多因素认证default: false |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
last_login_at | string | null | ISO 8601 时间戳:the last successful login(ISO 8601)format: date-time |
metadata | object | null | 附加在此资源上的任意键值元数据 |
vendor | string | null | 粘滞:该用户的记录供应商。 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/auth/user/get/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
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())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/auth/user/get/USER_ID", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/user/get/USER_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/auth/user/get/USER_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/user/get/USER_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/user/get/USER_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/auth/user/get/USER_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.3auth.user.get_by_email
按邮箱地址查找认证用户。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 必填 | 用户邮箱地址。 |
返回
AuthUser| 名称 | 类型 | 说明 |
|---|---|---|
user_id | string | 关联此资源的用户标识pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
email | string | 邮箱地址format: email |
email_verified | boolean | 邮箱地址是否已验证default: false |
phone | string | null | E.164 格式的电话号码 |
mfa_enabled | boolean | 该用户是否启用了多因素认证default: false |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
last_login_at | string | null | ISO 8601 时间戳:the last successful login(ISO 8601)format: date-time |
metadata | object | null | 附加在此资源上的任意键值元数据 |
vendor | string | null | 粘滞:该用户的记录供应商。 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/auth/user/get_by_email \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
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())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/auth/user/get_by_email", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/user/get_by_email"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/auth/user/get_by_email");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/user/get_by_email");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/user/get_by_email")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/auth/user/get_by_email")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.4auth.user.list
按游标分页列出账户下的认证用户。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
cursor | string | 可选 | 不透明分页游标。 |
limit | number | 可选 | 返回条目的最大数量。 |
返回
{ items: AuthUser[], next_cursor?: string }| 名称 | 类型 | 说明 |
|---|---|---|
items | object[] | user records列表 |
next_cursor | string | null | 下一页游标;null 表示最后一页 |
total | integer | items in this page数量 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/auth/user/list \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
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())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/auth/user/list", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/user/list"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/auth/user/list");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/user/list");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/user/list")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/auth/user/list")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.5auth.user.update
更新已有认证用户的可变字段(metadata、手机号、MFA)。支持 idempotency_key。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
metadata | Record<string, unknown> | 可选 | 存储在用户上的任意键值元数据。 |
email_verified | boolean | 可选 | 将用户邮箱标记为已验证。 |
mfa_enabled | boolean | 可选 | 为用户启用或停用 MFA。 |
idempotency_key | string | 可选 | 客户端提供的幂等键。 |
返回
AuthUser| 名称 | 类型 | 说明 |
|---|---|---|
user_id | string | 关联此资源的用户标识pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
email | string | 邮箱地址format: email |
email_verified | boolean | 邮箱地址是否已验证default: false |
phone | string | null | E.164 格式的电话号码 |
mfa_enabled | boolean | 该用户是否启用了多因素认证default: false |
created_at | string | 资源创建时间(ISO 8601)format: date-time |
last_login_at | string | null | ISO 8601 时间戳:the last successful login(ISO 8601)format: date-time |
metadata | object | null | 附加在此资源上的任意键值元数据 |
vendor | string | null | 粘滞:该用户的记录供应商。 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."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": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"user_id": "sample"}`)
req, _ := http.NewRequest("PATCH", "https://api.infrai.cc/v1/auth/user/update/USER_ID", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/user/update/USER_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString("{\"user_id\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("PATCH"), "https://api.infrai.cc/v1/auth/user/update/USER_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"user_id\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/user/update/USER_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"user_id\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/user/update/USER_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Patch.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"user_id": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.patch("https://api.infrai.cc/v1/auth/user/update/USER_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"user_id": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.6auth.user.delete
删除认证用户并级联吊销其会话。支持 idempotency_key。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。 |
返回
{ ok: boolean }| 名称 | 类型 | 说明 |
|---|---|---|
ok | boolean | 用户是否已删除 |
user_id | string | null | 已删除的用户标识符 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X DELETE https://api.infrai.cc/v1/auth/user/delete/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
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())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("DELETE", "https://api.infrai.cc/v1/auth/user/delete/USER_ID", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/user/delete/USER_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("DELETE"), "https://api.infrai.cc/v1/auth/user/delete/USER_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/user/delete/USER_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/user/delete/USER_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Delete.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.delete("https://api.infrai.cc/v1/auth/user/delete/USER_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.7auth.session.create
为用户签发已认证会话。可能返回 AUTH_MFA_REQUIRED。支持 idempotency_key。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
method | "password" | "magic_link" | "otp" | "oauth" | "passkey" | 可选 | 会话使用的认证方式。default: "password" |
mfa_factor | string | 可选 | 设置 require_mfa 时的 MFA 因子 / 验证码。 |
require_mfa | boolean | 可选 | 签发会话需要 MFA 因子。default: false |
idempotency_key | string | 可选 | 客户端提供的幂等键。 |
返回
Session { session_id, access_token, refresh_token, expires_at }| 名称 | 类型 | 说明 |
|---|---|---|
challenge_id | string | 认证挑战标识符 |
method | "password" | "magic_link" | "otp" | "oauth" | "passkey" | 所用的认证方式(如 email_otp、oauth、password) |
redirect_uri | string | null | 用于 oauth 方式。 |
expires_at | string | 资源或令牌过期时间(ISO 8601)format: date-time |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."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": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"user_id": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/auth/session/create", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/session/create"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"user_id\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/auth/session/create");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"user_id\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/session/create");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"user_id\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/session/create")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"user_id": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/auth/session/create")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"user_id": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.8auth.session.verify
依据 infrai JWKS 校验 session_id / JWT,并返回 Session。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
session_id | string | 必填 | 会话 id。 |
返回
{ valid: boolean, user_id?, expires_at? }| 名称 | 类型 | 说明 |
|---|---|---|
session_id | string | session的唯一标识符 |
user_id | string | 关联此资源的用户标识pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
started_at | string | 执行开始时间(ISO 8601)format: date-time |
expires_at | string | 资源或令牌过期时间(ISO 8601)format: date-time |
ip | string | null | 创建会话的 IP 地址 |
ua | string | null | 会话创建请求中的 User-Agent 字符串 |
mfa_factor | string | null | 活跃 MFA 因子(参见 enums/AuthFactor)。 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/auth/session/verify/SESSION_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
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())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/auth/session/verify/SESSION_ID", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/session/verify/SESSION_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/auth/session/verify/SESSION_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/session/verify/SESSION_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/session/verify/SESSION_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/auth/session/verify/SESSION_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.9auth.session.refresh
用 refresh token 换取新会话;强制 5 分钟冷却(AUTH_REFRESH_TOO_FREQUENT)。支持 idempotency_key。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
refresh_token | string | 必填 | 用于换取新会话的有效 refresh token。≥ 1 chars |
idempotency_key | string | 可选 | 客户端提供的幂等键。 |
返回
Session| 名称 | 类型 | 说明 |
|---|---|---|
access_token | string | 用于 API 认证的短期访问令牌 |
refresh_token | string | 用于获取新访问令牌的长期令牌 |
expires_in | integer | 访问令牌过期倒计时(秒)。≥ 1 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."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": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"refresh_token": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/auth/session/refresh", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/session/refresh"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"refresh_token\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/auth/session/refresh");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"refresh_token\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/session/refresh");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"refresh_token\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/session/refresh")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"refresh_token": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/auth/session/refresh")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"refresh_token": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.10auth.session.revoke
按 session_id 吊销单个会话。支持 idempotency_key。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
session_id | string | 必填 | 会话 id。≥ 1 chars |
idempotency_key | string | 可选 | 客户端提供的幂等键。 |
返回
{ ok: boolean }| 名称 | 类型 | 说明 |
|---|---|---|
ok | boolean | 会话是否已吊销 |
count | integer | sessions revoked (auth.session.revoke_all_for_user only)数量 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."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": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"session_id": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"session_id\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"session_id\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"session_id\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"session_id": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"session_id": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.11auth.session.revoke_all_for_user
吊销某用户的全部活跃会话(如改密 / 全端登出)。支持 idempotency_key。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
except_session_id | string | 可选 | 保留此会话;吊销其余全部。 |
返回
{ revoked: number }| 名称 | 类型 | 说明 |
|---|---|---|
ok | boolean | 会话是否已吊销 |
count | integer | sessions revoked (auth.session.revoke_all_for_user only)数量 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."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": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"user_id": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"user_id\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"user_id\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"user_id\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"user_id": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"user_id": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.12auth.session.list_for_user
列出指定用户的活跃会话。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。 |
返回
{ items: Session[] }| 名称 | 类型 | 说明 |
|---|---|---|
items | object[] | session records列表 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
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())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.13auth.consent.grant
为用户 / 类别记录一条 GDPR/CCPA 同意授予。支持 idempotency_key。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
category | "marketing" | "analytics" | "essential" | "third_party" | 必填 | 同意类别,如 marketing 或 analytics。 |
source | string | 可选 | 同意的采集来源。default: "explicit" |
idempotency_key | string | 可选 | 客户端提供的幂等键。 |
返回
{ ok: boolean }| 名称 | 类型 | 说明 |
|---|---|---|
ok | boolean | 操作是否成功 |
consent_id | string | 同意记录的标识符(仅 auth.consent.grant) |
user_id | string | 用户标识 |
category | string | 受影响的同意类别 |
granted | boolean | 是否已授予同意(仅 auth.consent.grant) |
granted_at | string | null | 授予同意的 ISO 8601 时间戳(仅 auth.consent.grant) |
revoked_at | string | null | 撤销同意的 ISO 8601 时间戳(如有)(仅 auth.consent.grant) |
source | string | 同意的采集方式,如 "explicit"(仅 auth.consent.grant) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."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": "sample", "category": "marketing"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'sample', 'category': 'marketing'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample", "category": "marketing"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample", "category": "marketing"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"user_id": "sample", "category": "marketing"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/auth/consent/grant/USER_ID", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/consent/grant/USER_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"user_id\": \"sample\", \"category\": \"marketing\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/auth/consent/grant/USER_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"user_id\": \"sample\", \"category\": \"marketing\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/consent/grant/USER_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"user_id\": \"sample\", \"category\": \"marketing\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/consent/grant/USER_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"user_id": "sample", "category": "marketing"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/auth/consent/grant/USER_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"user_id": "sample", "category": "marketing"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.14auth.consent.revoke
撤回此前为用户 / 类别授予的同意。支持 idempotency_key。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
category | "marketing" | "analytics" | "essential" | "third_party" | 必填 | 同意类别,如 marketing 或 analytics。 |
idempotency_key | string | 可选 | 客户端提供的幂等键。 |
返回
{ ok: boolean }| 名称 | 类型 | 说明 |
|---|---|---|
ok | boolean | 操作是否成功 |
consent_id | string | 同意记录的标识符(仅 auth.consent.grant) |
user_id | string | 用户标识 |
category | string | 受影响的同意类别 |
granted | boolean | 是否已授予同意(仅 auth.consent.grant) |
granted_at | string | null | 授予同意的 ISO 8601 时间戳(仅 auth.consent.grant) |
revoked_at | string | null | 撤销同意的 ISO 8601 时间戳(如有)(仅 auth.consent.grant) |
source | string | 同意的采集方式,如 "explicit"(仅 auth.consent.grant) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."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": "sample", "category": "marketing"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'sample', 'category': 'marketing'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample", "category": "marketing"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample", "category": "marketing"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"user_id": "sample", "category": "marketing"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/auth/consent/revoke/USER_ID", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/consent/revoke/USER_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"user_id\": \"sample\", \"category\": \"marketing\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/auth/consent/revoke/USER_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"user_id\": \"sample\", \"category\": \"marketing\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/consent/revoke/USER_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"user_id\": \"sample\", \"category\": \"marketing\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/consent/revoke/USER_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"user_id": "sample", "category": "marketing"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/auth/consent/revoke/USER_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"user_id": "sample", "category": "marketing"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.15auth.consent.check
检查用户当前是否持有某类别的同意(布尔)。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。 |
category | string | 必填 | 同意类别,如 marketing 或 analytics。 |
返回
{ granted: boolean, source?, granted_at? }| 名称 | 类型 | 说明 |
|---|---|---|
result | boolean | 该用户/类别当前是否已授予同意 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
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())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.16auth.consent.list_for_user
列出某用户跨 GDPR 类别的全部同意记录。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | 用户 id。 |
返回
{ items: Array<{ category, granted, source?, granted_at? }> }| 名称 | 类型 | 说明 |
|---|---|---|
items | object[] | consent records列表 |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
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())// Zero-install REST call — no SDK required (short-term the API is REST-only).
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());// Zero-install REST call — no SDK required (short-term the API is REST-only).
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);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("GET"), "https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.get("https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.17auth.identity.resolve
用你已自行验证的第三方身份,解析或创建统一终端用户——租户背书模型(对齐 Auth0/Clerk)。原生 Sign in with Apple 场景:你的后端先验 Apple identityToken(用 Apple JWKS 验签 + 校 iss/aud),再用 Apple sub 调用本接口,绑定并返回稳定的 infrai 用户。幂等:同一 (provider, value) 始终解析为同一 user_id。无需在 infrai 侧登记你的 app。
参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
type | "email" | "phone" | "external" | 必填 | 身份类型:"external"(第三方 provider 主体)、"email" 或 "phone"。e.g. email |
value | string | 必填 | 身份值——external 时为 provider 主体(如 Apple 的 `sub`)。e.g. user@example.com |
provider | string | 可选 | external 身份的 provider,如 "apple"、"google"、"wechat"。 |
create | boolean | 可选 | 无匹配身份时是否创建新身份。default: true |
verified | boolean | 可选 | 标记身份已验证——你的后端验过 provider token 后置 true。 |
account_id | string | 可选 | 解析身份时关联的账户 ID。 |
返回
{ user: AuthUser, identity: Identity, created: boolean }| 名称 | 类型 | 说明 |
|---|---|---|
user | object | 已解析的终端用户记录 |
identity | object | 匹配到的身份记录(type/provider/value/user_id/verified/created_at) |
created | boolean | 本次调用是否创建了新用户(仅 auth.identity.resolve) |
示例
一次性前置(每个范例都假定已完成):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/auth/identity/resolve \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "email", "value": "user@example.com"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/auth/identity/resolve",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'type': 'email', 'value': 'user@example.com'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/auth/identity/resolve",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"type": "email", "value": "user@example.com"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/auth/identity/resolve",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"type": "email", "value": "user@example.com"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"type": "email", "value": "user@example.com"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/auth/identity/resolve", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/auth/identity/resolve"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"type\": \"email\", \"value\": \"user@example.com\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/auth/identity/resolve");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"type\": \"email\", \"value\": \"user@example.com\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/auth/identity/resolve");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"type\": \"email\", \"value\": \"user@example.com\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/auth/identity/resolve")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"type": "email", "value": "user@example.com"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/auth/identity/resolve")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"type": "email", "value": "user@example.com"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}高级:指定 vendor
默认情况下 infrai 会把每次调用智能路由到最佳可用供应商——无需自己挑选 vendor。作为高级逃生口,本能力支持可选的 vendor 入参以锁定某个供应商。本能力当前所有可用 vendor 可通过该能力 id 对应的 discovery 端点实时获取——参见 discovery API。
GET /v1/discovery/{capability}auth.user.create
3. 全部能力
本模块全部已路由能力——完整的对外 REST 契约。上方方法是带讲解的入门示例,此表是完整参考。
auth.consent.checkGET /v1/auth/consent/check/{user_id}/{category}Check whether a user currently holds consent for a given category (boolean).
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
category | string | 必填 | Path parameter. |
user_id | string | 必填 | Path parameter. |
auth.consent.grantPOST /v1/auth/consent/grant/{user_id}Record a GDPR/CCPA consent grant for a user/category. Accepts idempotency_key.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path param.pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
category | "marketing" | "analytics" | "essential" | "third_party" | 必填 | Consent category (e.g. marketing, analytics) |
source | string | 可选 | How consent was captured.default: "explicit" |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.consent.list_for_userGET /v1/auth/consent/list_for_user/{user_id}List all consent records for a user across GDPR categories.
参数 (1)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path parameter. |
auth.consent.revokePOST /v1/auth/consent/revoke/{user_id}Revoke a previously granted consent for a user/category. Accepts idempotency_key.
参数 (3)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path param.pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
category | "marketing" | "analytics" | "essential" | "third_party" | 必填 | Consent category (e.g. marketing, analytics) |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.email.change_confirmPOST /v1/auth/email/change_confirmConfirm an email change with the single-use token from the new address; switches the user's email. Returns AUTH_TOKEN_REUSED on replay. Accepts idempotency_key.
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
token | string | 必填 | Authentication or verification token≥ 1 chars |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.email.change_requestPOST /v1/auth/email/change_requestStart an email change for a user; sends a single-use signed verification token to the NEW address (self-built, no BYOK). Accepts idempotency_key.
参数 (3)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | User identifier associated with this resource≥ 1 chars |
new_email | string | 必填 | New email address; the signed verification link is sent here.≥ 3 charsformat: email |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.email.send_codePOST /v1/auth/email/send_codeSend a short-lived single-use email OTP to a user for verification or passwordless login (self-built). Accepts idempotency_key.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 必填 | Email address≥ 3 charsformat: email |
purpose | "verify" | "login" | 可选 | Purpose of the DNS recorddefault: "verify" |
locale | string | 可选 | End-user's current language (BCP-47, e.g. 'zh-CN' / 'en'); the OTP email is rendered in it (zh/en supported, default en). Pass your app's UI locale so the code reaches the user in their language.e.g. zh-CN |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.email.verifyPOST /v1/auth/email/verifyVerify an email OTP AND log in: on success resolves-or-creates the unified user (passwordless signup) and mints a session, returning {verified, user_id, created, session_id, access_token, refresh_token, expires_at} — a one-call login matching Auth0/Clerk/Supabase verifyOtp. Pass login=false for a bare code-check. Wrong/expired returns AUTH_CODE_INVALID. Accepts idempotency_key.
参数 (3)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 必填 | Email address≥ 3 charsformat: email |
code | string | 必填 | Authorization code from the OAuth provider≥ 1 chars |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.identity.addPOST /v1/auth/identity/add/{user_id}Bind an additional login identity (email/phone/external) to an existing user. Idempotent if already this user's; IDENTITY_ALREADY_LINKED if another user owns it (no auto-merge).
参数 (7)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path parameter. |
type | "email" | "phone" | "external" | 必填 | Identity kind.e.g. email |
value | string | 必填 | The identity address/subject — an email, an E.164 phone, or a provider subject id (must match `type`).e.g. user@example.com |
provider | string | null | 可选 | For type=external: the provider id (e.g. wechat, google, github). |
create | boolean | null | 可选 | resolve(): create a unified user when none matches (default true).default: true |
verified | boolean | null | 可选 | Mark the identity verified on attach (e.g. a tenant-vouched external subject). |
account_id | string | null | 可选 | Tenant scope (defaults to the authenticated account). |
auth.identity.getPOST /v1/auth/identity/getLook up the end-user that owns a given identity (email/phone/external subject) without creating one; returns IDENTITY_NOT_FOUND if unknown.
参数 (6)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
type | "email" | "phone" | "external" | 必填 | Identity kind.e.g. email |
value | string | 必填 | The identity address/subject — an email, an E.164 phone, or a provider subject id (must match `type`).e.g. user@example.com |
provider | string | null | 可选 | For type=external: the provider id (e.g. wechat, google, github). |
create | boolean | null | 可选 | resolve(): create a unified user when none matches (default true).default: true |
verified | boolean | null | 可选 | Mark the identity verified on attach (e.g. a tenant-vouched external subject). |
account_id | string | null | 可选 | Tenant scope (defaults to the authenticated account). |
auth.identity.listGET /v1/auth/identity/list/{user_id}List every login identity (email/phone/external) attached to a user.
参数 (1)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path parameter. |
auth.identity.removeDELETE /v1/auth/identity/remove/{user_id}/{identity_id}Unlink one identity from a user; refuses IDENTITY_LAST_REMAINING when it is the user's only remaining identity.
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
identity_id | string | 必填 | Path parameter. |
user_id | string | 必填 | Path parameter. |
auth.identity.resolvePOST /v1/auth/identity/resolveUnified login/register: resolve a (tenant-vouched) email, phone, or external-provider identity to its end-user, minting the user + identity if unknown. type=external + provider (e.g. 'wechat') + value=<subject> handles any third-party login; one person who arrives via different identities maps to the SAME user_id.
参数 (6)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
type | "email" | "phone" | "external" | 必填 | Identity kind.e.g. email |
value | string | 必填 | The identity address/subject — an email, an E.164 phone, or a provider subject id (must match `type`).e.g. user@example.com |
provider | string | null | 可选 | For type=external: the provider id (e.g. wechat, google, github). |
create | boolean | null | 可选 | resolve(): create a unified user when none matches (default true).default: true |
verified | boolean | null | 可选 | Mark the identity verified on attach (e.g. a tenant-vouched external subject). |
account_id | string | null | 可选 | Tenant scope (defaults to the authenticated account). |
auth.oauth.authorize_urlGET /v1/auth/oauth/authorize_urlBuild the provider authorize URL (provider must be one of the enabled set — see auth.oauth.providers) with state, nonce and PKCE challenge; return_to/redirect_uri must be in the account's registered allowlist.
参数 (3)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
provider | "google" | "github" | "apple" | "facebook" | 必填 | OAuth provider name (e.g. google, github) |
return_to | string | null | 可选 | Unified-brand transit (preferred): final web URL or app deep link to 302 back to after Infrai's transit endpoint completes the flow. Must be in the account's allowlist.e.g. https://app.example.com/auth/done |
redirect_uri | string | null | 可选 | Legacy customer-BFF: the caller's own provider redirect URI (used when `return_to` is absent). Must be in the account's allowlist.format: urie.g. https://app.example.com/oauth/callback |
auth.oauth.callbackPOST /v1/auth/oauth/callbackComplete the OAuth flow: validate state + redirect_uri, exchange the code, link/create the user and mint a session. Honest typed error if the provider is not configured.
参数 (6)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
provider | "google" | "github" | "apple" | "facebook" | 必填 | OAuth provider name (e.g. google, github) |
code | string | 必填 | Authorization code from the OAuth provider≥ 1 chars |
state | string | 必填 | Current lifecycle state of this resource≥ 1 chars |
redirect_uri | string | 必填 | Redirect URI registered with the OAuth provider≥ 1 charsformat: uri |
code_verifier | string | null | 可选 | PKCE verifier matching the challenge from authorize_url. |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.oauth.providersGET /v1/auth/oauth/providersList the OAuth providers an end user can sign in with right now, each flagged ready (real client_id configured), plus the unified consent-screen brand. The runtime companion to the AuthProvider enum in discovery.
无请求参数。
auth.password.changePOST /v1/auth/password/changeChange a user's password after verifying the current one (AUTH_INVALID_CREDENTIALS on mismatch); argon2id re-hash. Accepts idempotency_key.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | User identifier associated with this resource≥ 1 chars |
current_password | string | 必填 | Current password for verification≥ 1 chars |
new_password | string | 必填 | New password for the account≥ 1 chars |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.password.reset_confirmPOST /v1/auth/password/reset_confirmConfirm a password reset with {email, code, new_password} — verifies the 6-digit code from reset_request, re-hashes (argon2id) and revokes all sessions. Wrong/expired code returns AUTH_CODE_INVALID; weak password returns AUTH_PASSWORD_TOO_WEAK. Accepts idempotency_key.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 必填 | Email addressformat: email |
code | string | 必填 | Authorization code from the OAuth provider4–8 chars |
new_password | string | 必填 | New password for the account≥ 1 chars |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.password.reset_requestPOST /v1/auth/password/reset_requestRequest a password reset (code-style, Supabase pattern); always returns 200 (no user-existence leak) and emails a single-use 6-digit code when the email is known. Accepts idempotency_key.
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 必填 | Email address≥ 3 charsformat: email |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.phone.send_codePOST /v1/auth/phone/send_codeSend a short-lived single-use phone (SMS) OTP to a user (self-built; SMS delivery depends on infra.sms). Accepts idempotency_key.
参数 (4)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
phone | string | 必填 | Phone number in E.164 format≥ 3 chars |
purpose | "verify" | "login" | 可选 | Purpose of the DNS recorddefault: "verify" |
locale | string | 可选 | End-user's current language (BCP-47, e.g. 'zh-CN' / 'en'); the OTP SMS is rendered in it (zh/en supported, default en). Pass your app's UI locale so the code reaches the user in their language.e.g. zh-CN |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.phone.verifyPOST /v1/auth/phone/verifyVerify a phone OTP AND log in: on success resolves-or-creates the unified user (passwordless signup) and mints a session, returning {verified, user_id, created, session_id, access_token, refresh_token, expires_at} — a one-call login matching Auth0/Clerk/Supabase. Pass login=false for a bare code-check. Wrong/expired returns AUTH_CODE_INVALID. Accepts idempotency_key.
参数 (3)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
phone | string | 必填 | Phone number in E.164 format≥ 3 chars |
code | string | 必填 | Authorization code from the OAuth provider≥ 1 chars |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.session.createPOST /v1/auth/session/createMint an authenticated session for a user; routes to the user's pinned vendor. May return AUTH_MFA_REQUIRED. Accepts idempotency_key.
参数 (5)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | User identifier associated with this resourcepattern: ^au_usr_[A-Za-z0-9]{20,}$ |
method | "password" | "magic_link" | "otp" | "oauth" | "passkey" | 可选 | Authentication method used (e.g. email_otp, oauth, password)default: "password" |
mfa_factor | string | null | 可选 | MFA factor / code when require_mfa. |
require_mfa | boolean | 可选 | Whether MFA is required to complete authenticationdefault: false |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.session.list_for_userGET /v1/auth/session/list_for_user/{user_id}List active sessions for a given user.
参数 (1)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path parameter. |
auth.session.refreshPOST /v1/auth/session/refreshExchange a refresh token for a new session; enforces 5-min cooldown (AUTH_REFRESH_TOO_FREQUENT). Accepts idempotency_key.
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
refresh_token | string | 必填 | Long-lived token used to obtain new access tokens≥ 1 chars |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.session.revokePOST /v1/auth/session/revoke/{session_id}Revoke a single session by session_id. Accepts idempotency_key.
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
session_id | string | 必填 | Path param; the session to revoke.≥ 1 chars |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.session.revoke_all_for_userPOST /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.
参数 (2)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path param; revoke all this user's active sessions.pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
except_session_id | string | null | 可选 | Keep this one session alive (e.g. the current browser). |
auth.session.verifyGET /v1/auth/session/verify/{session_id}Verify a session_id / JWT against the vendor JWKS (RS256+ES256) and return the Session.
参数 (1)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
session_id | string | 必填 | Path parameter. |
auth.token.jwksGET /v1/auth/token/jwksReturn the public JWKS (EdDSA) for offline verification of Infrai-issued access JWTs — clients verify tokens with zero round-trips.
无请求参数。
auth.user.createPOST /v1/auth/user/createCreate an auth user across a vendor (Clerk/WorkOS/Supabase Auth). Pins the vendor of record (sticky-on-resource). Accepts idempotency_key.
参数 (6)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 必填 | Email addressformat: email |
password | string | null | 可选 | Optional initial password (vendor-dependent). |
metadata | object | null | 可选 | Arbitrary key-value metadata attached to this resource |
vendor | "infrai_native" | null | 可选 | Explicit vendor pin (auth is self-operated: infrai_native only). |
mode | "default_vendor" | "verified_account" | 可选 | Delivery mode or operation modedefault: "default_vendor" |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
auth.user.deleteDELETE /v1/auth/user/delete/{user_id}Delete an auth user and cascade-revoke its sessions. Accepts idempotency_key.
参数 (1)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path parameter. |
auth.user.getGET /v1/auth/user/get/{user_id}Fetch a single auth user by user_id from its pinned vendor.
参数 (1)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path parameter. |
auth.user.get_by_emailGET /v1/auth/user/get_by_emailLook up an auth user by email address.
无请求参数。
auth.user.listGET /v1/auth/user/listCursor-paginated list of auth users for the account.
无请求参数。
auth.user.updatePATCH /v1/auth/user/update/{user_id}Update mutable fields (metadata, phone, MFA) of an existing auth user. Accepts idempotency_key.
参数 (5)
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
user_id | string | 必填 | Path param; the user to update.pattern: ^au_usr_[A-Za-z0-9]{20,}$ |
metadata | object | null | 可选 | Arbitrary key-value metadata attached to this resource |
email_verified | boolean | null | 可选 | Whether the email address has been verified |
mfa_enabled | boolean | null | 可选 | Whether multi-factor authentication is enabled for this user |
idempotency_key | string | null | 可选 | Client-provided idempotency key; prevents duplicate execution on retry |
4. 完整示例
本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。
单文件可运行 Python 程序(仅标准库、无 SDK):拷贝后填入 INFRAI_API_KEY 运行,即可按真实业务流逐步体验本模块核心 API——每一步都真实调用并计费,后续步骤复用前一步返回的真实字段。12 行 helper 就是全部集成代码。
#!/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://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. 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_..." # <- 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":"user@example.com"}))
# 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":"sample"}))
# 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 https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."# 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 https://infrai.cc/login for a
# project key + $2 free credit (email sign-in starts at $0). On 402
# INSUFFICIENT_CREDIT, add funds at https://infrai.cc/billing (or POST
# /v1/account/topup and open the returned checkout_url).
export INFRAI_API_KEY="ifr_..." # from https://infrai.cc/login
# 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": "user@example.com"}'
# 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": "sample"}'
# 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": "sample"}'
# 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
# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'user@example.com'},
)
resp.raise_for_status()
print(resp.json())
# 3) auth.user.get
# Zero-install REST call — no SDK required (short-term the API is REST-only).
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
# Zero-install REST call — no SDK required (short-term the API is REST-only).
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
# Zero-install REST call — no SDK required (short-term the API is REST-only).
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
# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'sample'},
)
resp.raise_for_status()
print(resp.json())
# 7) auth.user.delete
# Zero-install REST call — no SDK required (short-term the API is REST-only).
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
# Zero-install REST call — no SDK required (short-term the API is REST-only).
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': 'sample'},
)
resp.raise_for_status()
print(resp.json())
# 9) auth.session.verify
# Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "user@example.com"}),
},
);
console.log(await resp.json());
// 3) auth.user.get
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
console.log(await resp.json());
// 7) auth.user.delete
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
console.log(await resp.json());
// 9) auth.session.verify
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "user@example.com"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 3) auth.user.get
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 7) auth.user.delete
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 9) auth.session.verify
// Zero-install REST call — no SDK required (short-term the API is REST-only).
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);