account.createEmailCodeSession
import { Client, Orvano } from '@orvano/js'
const orvano = new Orvano(new Client({ endpoint: 'https://orvano.example.com' }))
const authResult = await orvano.account.createEmailCodeSession({ email: 'ada@example.com', code: '428613',})console.log(authResult)// app/page.tsx, a server component. Route handlers and server actions use createServerClient too.import { cookies } from 'next/headers'import { createServerClient } from '@orvano/nextjs'
export default async function Page() { const orvano = createServerClient({ endpoint: process.env.ORVANO_ENDPOINT!, cookies: await cookies(), }) const authResult = await orvano.account.createEmailCodeSession({ email: 'ada@example.com', code: '428613', }) return <pre>{JSON.stringify(authResult, null, 2)}</pre>}import 'package:orvano_flutter/orvano_flutter.dart';
Future<void> main() async { final orvano = Orvano(Client(endpoint: 'https://orvano.example.com')); final authResult = await orvano.account.createEmailCodeSession( CreateEmailCodeSessionRequest(email: 'ada@example.com', code: '428613'), ); print(authResult.toJson());}Signs a user in with an emailed code. After 5 wrong tries the code stops working; ask for a new one.
Client SDKs: JavaScript in the browser, Next.js, and Flutter call it for the signed in user, or with no credential. A failure answers with a problem details body; its code has a page under Errors.
Request Bodyrequired
Section titled “Request Bodyrequired”A sign in with an emailed code.
object
The email the code was sent to; case does not matter.
The 6 digit code from the email.
Responses
Section titled “Responses”The request has succeeded and a new resource has been created as a result.
A signed in user and their new session.
object
The user.
object
The user ID.
Whether the email has been verified. Also the access token’s email_verified claim.
Whether the user may sign in.
Your own data about the user: a JSON object of at most 16 KB.
object
When the user signed up.
The new session’s tokens.
object
An ES256 JWT, valid for 15 minutes.
When the access token expires.
Trades itself for a new pair once; keep it secret.
When the session ends unless it refreshes first: 30 days idle, or 365 days after sign in.
The session ID, also the sid claim of the access token.
Whether this call created the user: true from sign up, and from a magic link or email code for a new email.
Example
{ "user": { "id": "01924f5e-8d2b-7c4d-8e21-3d5e6f7a8b9c", "email": "ada@example.com", "emailVerified": false, "name": "Ada Lovelace", "status": "active" }, "session": { "accessToken": "eyJhbGciOiJFUzI1NiIsImtpZCI6Ii4uLiJ9.e30.c2ln", "refreshToken": "orv_rt_AZJPXo0rfE2OIT1ebzqLnA.Zm9vYmFyZm9vYmFyZm9vYmFyZm9vYmFyZm9vYmFyZm9v", "sessionId": "01924f5e-9a1b-7c4d-8e21-3d5e6f7a8b9c" }, "isNewUser": false, "verificationEmail": "queued"}default
Section titled “default”An unexpected error response.
An RFC 9457 problem details body. Every operation declares it as its default response, sent
as application/problem+json.
object
Identifies the error: https://orvano.dev/errors/<code>.
The standard HTTP reason phrase for the status.
The HTTP status code.
A short, safe sentence about this occurrence, when the server has one.
Orvano’s stable error code, from the ErrorCode catalog. SDKs treat it as a plain string.
The request ID to quote when reporting a problem; also sent as X-Request-Id.
Example
{ "type": "https://orvano.dev/errors/not_found", "title": "Not Found", "status": 404, "code": "not_found", "requestId": "4bf92f3577b34da6a3ce929d0e0e4736"}