Sign in
const url = 'https://api.emite.cr/v1/auth/login';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"email":"ventas@emite.cr","password":"S3guroPass!"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.emite.cr/v1/auth/login \ --header 'Content-Type: application/json' \ --data '{ "email": "ventas@emite.cr", "password": "S3guroPass!" }'Exchanges the email and password for a session token (JWT), returned in the body and in the X-Session-Token header. When the account has two-factor authentication enabled, it returns an MFA challenge instead of the token (mfaRequired: true): complete it at POST /v1/auth/2fa/challenge/verify. The token carries the company when the person belongs to exactly one; with several, choose one with POST /v1/auth/switch-tenant. 401 INVALID_CREDENTIALS for a wrong password or an email with no active account. At most 10 requests per minute per client IP: 429 AUTH_RATE_LIMITED, with Retry-After.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Email of the account, compared case-insensitively.
Example
ventas@emite.crPassword of the account. A wrong password and an email with no active account both answer 401 INVALID_CREDENTIALS, so the response never says which of the two failed.
Example
S3guroPass!Responses
Section titled “Responses”A session token (LoginResponseDto) or, when the account has two-factor authentication, the challenge that completes the sign-in (MfaRequiredResponseDto, with mfaRequired: true and no accessToken).
object
The session token, a signed JWT: send it as Authorization: Bearer <accessToken>. It acts for the person, in the company it names when it names one (currentTenantId in GET /v1/auth/me). The same token comes in the X-Session-Token response header.
Always Bearer: the scheme to send the token with in the Authorization header.
Remaining life of this token: whole seconds followed by s ("28800s" = 8 hours). It never reaches past the maximum of the session, which counts from the sign-in, so a re-issued token (switching company, renewing) lives less. Under a company inactivity rule it also ends that many minutes after it was issued, unless it is renewed with POST /v1/auth/sessions/renew.
The instant this token expires (ISO 8601, UTC): expiresIn as a date.
Present, and true, only in the answer of POST /v1/auth/login, when the password that just signed in does not meet the rule a new password must meet today (12 to 72 characters, nothing of the person, hard to guess: see POST /v1/auth/signup). A suggestion to change it, never a refusal: the sign-in went through.
object
Always true. The password was correct, but no session exists yet: the account has two-factor authentication, and the sign-in ends at POST /v1/auth/2fa/challenge/verify. Tells this response apart from a session token, which carries accessToken instead.
Opaque token that identifies this sign-in attempt: pass it to POST /v1/auth/2fa/challenge/verify, and to POST /v1/auth/2fa/challenge/email to have a code emailed. Single-use, valid for expiresIn seconds and for at most five verification attempts; the API keeps only a hash of it.
The active second-factor methods of the account, totp first. totp: a 6-digit code from an authenticator app. email: a 6-digit code sent to the account email; when it is the only method, that code is sent as soon as this challenge is created. A recovery code is accepted too, and is not listed here.
Seconds until the challenge expires (10 minutes). After that, sign in again to get a new one.
Present, and true, only in the answer of POST /v1/auth/login, when the password that just signed in does not meet the rule a new password must meet today (12 to 72 characters, nothing of the person, hard to guess: see POST /v1/auth/signup). A suggestion to change it, never a refusal: the sign-in went through.
Example
{ "tokenType": "Bearer", "expiresIn": "28800s", "expiresAt": "2026-10-22T22:30:00.000Z", "passwordChangeSuggested": true}