Skip to content

Accept a tenant invitation

POST
/v1/auth/accept-invitation
curl --request POST \
--url https://api.emite.cr/v1/auth/accept-invitation \
--header 'Content-Type: application/json' \
--data '{ "email": "newhire@example.com", "code": "123456", "name": "Carla Soto", "password": "example", "legal": { "acceptances": [ { "documentType": "terminos-y-condiciones", "documentVersion": "3.0", "documentHash": "sha256:abcdef0123456789..." } ] } }'

Three flows depending on whether the email already has an EmiteCR account:

  • New user: provide name, password and legal. The endpoint creates the user (with its acceptance of the legal documents), the membership, and issues a JWT scoped to the new tenant.
  • Existing user, authenticated: omit name/password; the membership is added to the caller, whose session is re-issued for the new tenant (same sign-in time, so it expires no later than before).
  • Existing user, NOT authenticated: responds 409 INVITE_USER_EXISTS_LOGIN_FIRST. The web redirects the recipient to /login preserving ?code=....

The token is returned in the body and in the X-Session-Token header. When the company’s session rules do not admit the caller’s current sign-in, the membership is still created and the answer is { reauthRequired: true, reason, tenantId, role } with no token: signing in again enters the company. A request whose session belongs to another email answers 409 INVITE_AUTH_MISMATCH.

Media typeapplication/json
object
email
required

The email the invitation was sent to, compared case-insensitively. When the request carries a session, it must be the email of the signed-in account (409 INVITE_AUTH_MISMATCH otherwise).

string
Example
newhire@example.com
code
required

6-digit code from the invitation email.

string
Example
123456
name

Name of the new account. Required, together with password and legal, only when the email has no EmiteCR account yet (400 INVITE_NEW_USER_REQUIRES_CREDENTIALS without it); ignored for an existing account.

string
<= 80 characters
Example
Carla Soto
password

Password for the new account (only when the email is new). A password the person chooses: 12 to 72 characters, not built on the name or the email of the account, and hard to guess (no common or leaked password, sequence, keyboard pattern or date; the same estimator the app shows under the field). Upper case, digits and symbols are neither required nor refused. Refused with 400 PASSWORD_TOO_WEAK, whose params.reason is too_short, too_long, personal_info or too_guessable. Passwords set before this rule keep working to sign in.

string
>= 12 characters <= 72 characters
legal

For a new account only: the person's acceptance of the legal documents required at signup (the Terms and the Privacy Policy, version and hash of each), written with the account in the same transaction. Required when name and password are (400 INVITE_NEW_USER_REQUIRES_ACCEPTANCE without it); ignored for an existing account.

object
acceptances
required

One entry per document, at most 10. Every document the catalog requires at signup must be present (400 LEGAL_ACCEPTANCE_INCOMPLETE names the missing ones); an empty list is 400 LEGAL_SIGNUP_ACCEPTANCE_REQUIRED. Recorded as the person's own acceptance, with the IP, browser and instant of this request, in the same transaction that creates the account.

Array<object>
object
documentType
required

Slug of the legal document accepted, as GET /v1/legal/required-for-signup lists it: today terminos-y-condiciones (Terms and Conditions) and politica-de-privacidad (Privacy Policy). An unknown slug is 400 UNKNOWN_DOCUMENT; the Cookie Policy (politica-de-cookies) is only announced, never accepted (400 LEGAL_DOCUMENT_NOT_REQUIRED).

string
Example
terminos-y-condiciones
documentVersion
required

The version of the document the API serves today (its version), up to 32 characters. Any other version is 409 OUTDATED_VERSION: fetch the documents again and show the current text.

string
Example
3.0
documentHash
required

The SHA-256 of the exact Markdown text shown to the person: sha256: followed by 64 hex digits, copied verbatim from the hash the API serves with the document. It is the proof of which text was accepted; one that differs from the served text is 409 HASH_MISMATCH.

string
Example
sha256:abcdef0123456789...

The invitation was accepted. Usually a session token for the company (AcceptInvitationResponseDto); { reauthRequired: true, … } (AcceptInvitationReauthResponseDto) when the company does not admit the current sign-in.

Media typeapplication/json
One of:
object
accessToken
required

Session token (JWT) scoped to the company of the invitation — send it as Authorization: Bearer <token>. Also returned in the X-Session-Token response header. For an account that was already signed in it is the same session re-issued: it keeps the original sign-in time, so it ends no later than before.

string
tokenType
required

Always Bearer.

string
Allowed values: Bearer
expiresIn
required

Remaining life of this token, in seconds with an explicit unit (28800s).

string
expiresAt
required

When this token expires.

string format: date-time
tenantId
required

The company the invitation belongs to — the one the token is scoped to.

string format: uuid
role
required

The member's role in that company: the invitation's, or the one the account already held when it was a member already (the invitation is then just used up). A system role (owner, admin, billing_manager, accountant, issuer, viewer) or the slug of one of the company's custom roles (GET /v1/tenants/me/roles).

string
Example
{
"tokenType": "Bearer",
"expiresIn": "28800s",
"role": "issuer"
}
X-Session-Token
string

The same token as accessToken. Absent from a reauthRequired answer.

X-Session-State
string

When the session will be refused if nothing happens, as <deadline>:<absolute|idle>:<window> (deadline in seconds since the epoch, window in seconds): for the new token when one is issued, otherwise for the token the request came with.

INVITE_NEW_USER_REQUIRES_CREDENTIALS — new email but no name/password provided; INVITE_NEW_USER_REQUIRES_ACCEPTANCE — new email without legal.acceptances (the person's acceptance of the legal documents, written with the account).

INVITE_USER_EXISTS_LOGIN_FIRST (existing email, no JWT) or MEMBER_ALREADY_EXISTS.