/{app_slug}/v1/auth/email/verifyFinish a passwordless email sign-in with the code or the link
Send `flow_id` + `code`, or the link's `token` (+ `flow_id` when the app keeps links to the browser that asked, the default). Creates the account when the address had none and the flow allowed sign-up; the email is marked verified either way. Returns the same results as `/auth/signin`: a session (`amr: ["email","otp"]` for a code, `["email","link"]` for a link), an MFA challenge when the person holds a factor, or an enrolment demand when the app requires MFA. With `response_mode: "redirect"` (hosted pages) the result goes behind a `heimdall_code` and the response is `{ redirect_url }` instead. A flow dies after 5 wrong codes. Every failure is the same 401, so a wrong code, an unknown, used or expired flow and one that was never emailed look alike.
Path parameters
app_slug*stringSlug of the app.
Request body
flow_idstringThe `flow_id` from `/auth/email/start`. Required with `code`. With `token`, required when the app keeps links to the browser that asked (`require_same_browser`, the default).
codestringThe 6-digit code from the email. Send this or `token`.
Example: "482913"
tokenstringThe `token` query parameter the magic link opened your page with. Send this or `code`.
response_modeobject`tokens` (default) returns the sign-in result. `redirect` is for hosted pages: the result is put behind a single-use 60-second `heimdall_code` and the response is `{ redirect_url }`, the flow's `return_to` with the code appended. Needs a flow started with `return_to`.
Response · 200 A sign-in result (branch on `result`), or `{ redirect_url }` in redirect mode.
object
Example
Request
POST https://api.auth.productcraft.co/{app_slug}/v1/auth/email/verify
Content-Type: application/json
{
"flow_id": "string",
"code": "482913",
"token": "string",
"response_mode": {}
}import { Auth } from "@productcraft/auth";
// Admin routes read PRODUCTCRAFT_API_KEY; consumer routes need no key
const auth = new Auth();
const result = await auth.consumer("my-app").email.verify({ code: "482913" });auth.consumer(…).email.verify(params?, options?): Auth.EmailVerifyResponse
Response
{}