Skip to content

API reference

Email sign-in API

Sign in with an emailed 6-digit code or magic link.

On this page

Send a sign-in code

POST /v1/auth/email/start

  • Authentication: none on this route.
  • Who: No authentication.

Request body (application/json, EmailStartRequest)

FieldTypeRequiredDescription
emailstringYes
return_tostring | nullNoSame-origin UI path to open after sign-in; invalid values become /.

Responses

StatusDescriptionBody
202Sent if the address can receive email; the answer never depends on whether an account existsEmailStarted
404unsupported_provider: email sign-in is not configuredProblemDetails
422Invalid request (invalid_request); field_errors names the fields.ProblemDetails
429rate_limited per address or client IP, with Retry-AfterProblemDetails
503email_unavailableProblemDetails
Request
curl -X POST "$VMYARD_API_URL/v1/auth/email/start" \
  -H "Content-Type: application/json" \
  -d '{
  "email": "ada@example.com",
  "return_to": "/"
}'
Response 202
{
  "message": "If the address can receive email, a code is on its way."
}

Verify a code

POST /v1/auth/email/verify

Signs in with an emailed code, creating the user on the first verified sign-in. A code requested through POST /v1/auth/link/email instead links the address to the signed-in user and needs that session's cookie and CSRF token.

  • Authentication: none on this route.
  • Who: No authentication.

Request body (application/json, EmailVerifyRequest)

FieldTypeRequiredDescription
codestringYesThe 6-digit code from the email.
emailstringYes

Responses

StatusDescriptionBody
200Signed in (session and CSRF cookies set) or address linkedEmailVerified
400invalid_code: wrong, expired, used, or supersededProblemDetails
401A linking code without a sessionProblemDetails
403A linking code with another user's session, a missing CSRF token, or an API keyProblemDetails
404unsupported_providerProblemDetails
409identity_in_use: the address is another user's sign-in methodProblemDetails
429Too many requests; wait for Retry-After.ProblemDetails
Request
curl -X POST "$VMYARD_API_URL/v1/auth/email/verify" \
  -H "Content-Type: application/json" \
  -d '{
  "email": "ada@example.com",
  "code": "123456"
}'
Response 200
{
  "return_to": "string"
}

GET /v1/auth/email/callback

Completes a magic link. It works once, within ten minutes, and only in the browser that requested it (vmyard_email_state); on another device type the code instead. A linking link also needs the requesting user's session.

  • Authentication: none on this route.
  • Who: No authentication.

Parameters

NameInTypeRequiredDescription
tokenquerystringNoThe magic-link token from the email.

Responses

StatusDescriptionBody
303Success: redirect to the stored return_to on the UI origin. Failure: redirect to <ui>/sign-in?error=session_expired|identity_in_use|unsupported_provider—
Request
curl "$VMYARD_API_URL/v1/auth/email/callback"