in packages/better-auth/src/plugins/admin/admin.ts [330:401]
createUser: createAuthEndpoint(
"/admin/create-user",
{
method: "POST",
body: z.object({
email: z.string({
description: "The email of the user",
}),
password: z.string({
description: "The password of the user",
}),
name: z.string({
description: "The name of the user",
}),
role: z
.union([
z.string({
description: "The role of the user",
}),
z.array(
z.string({
description: "The roles of user",
}),
),
])
.optional(),
/**
* extra fields for user
*/
data: z.optional(
z.record(z.any(), {
description:
"Extra fields for the user. Including custom additional fields.",
}),
),
}),
metadata: {
openapi: {
operationId: "createUser",
summary: "Create a new user",
description: "Create a new user",
responses: {
200: {
description: "User created",
content: {
"application/json": {
schema: {
type: "object",
properties: {
user: {
$ref: "#/components/schemas/User",
},
},
},
},
},
},
},
},
$Infer: {
body: {} as {
email: string;
password: string;
name: string;
role?:
| InferAdminRolesFromOption<O>
| InferAdminRolesFromOption<O>[];
data?: Record<string, any>;
},
},
},
},