create_user
POST
/api/v1/admin/users
const url = 'https://example.com/api/v1/admin/users';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"email":"example","must_change_password":true,"password":"example","username":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://example.com/api/v1/admin/users";
let payload = json!({ "email": "example", "must_change_password": true, "password": "example", "username": "example" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://example.com/api/v1/admin/users \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "email": "example", "must_change_password": true, "password": "example", "username": "example" }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
Create a new user (admin operation).
object
email
required
string
must_change_password
boolean | null
password
string | null
username
required
string
Examplegenerated
{ "email": "example", "must_change_password": true, "password": "example", "username": "example"}Responses
Section titled “Responses”User created
Media typeapplication/json
统一 API 响应格式
成功: { "code": "success", "msg": "", "data": {...} }
失败: { "code": "auth.credentials_failed", "msg": "Invalid Credentials" }
object
code
required
string
data
object
generated_password
string | null
user
required
通用用户响应:核心字段 + profile
object
created_at
required
string
email
required
string
email_verified
required
boolean
id
required
integer format: int64
must_change_password
required
boolean
pending_email
string | null
policy_group_id
integer | null format: int64
profile
required
object
avatar
required
object
source
required
用户头像来源
string
url_1024
string | null
url_512
string | null
version
required
integer format: int32
display_name
string | null
role
required
用户角色
string
status
required
用户状态
string
storage_quota
required
integer format: int64
storage_used
required
integer format: int64
updated_at
required
string
username
required
string
error
msg
required
string
Example
{ "code": "success", "data": { "user": { "profile": { "avatar": { "source": "none" } }, "role": "admin", "status": "active" } }}Validation error
Unauthorized
Forbidden