Skip to content
Terra WalletDevelopers

Early access. The Terra API and SDKs may change before launch, and the SDK packages are not published yet.

View as Markdown

API reference

Early access

Partner account and session

Sign-up, sign-in, two-factor authentication and the current user. The dashboard calls these routes on its own origin with a session cookie; server integrations never call them.

Authentication: Dashboard session cookie (__Host-terra_partner) plus the X-Terra-CSRF header on state-changing requests.

Guide: Authentication

MethodPathSummary
GET/v1/auth/providersWhich sign-in methods are on
GET/v1/auth/csrfThe CSRF token (also set as the __Host-terra_csrf cookie); send it as X-Terra-CSRF on every write
POST/v1/auth/signupCreate an account (sends a 6-digit code and a link; the answer is the same whether or not the email exists)
POST/v1/auth/verify-emailConfirm the sign-up code and start a session
POST/v1/auth/loginSign in with email and password
POST/v1/auth/mfa/verifyThe authenticator step of a sign-in (TOTP or a recovery code)
POST/v1/auth/logoutSign out (revokes this session)
POST/v1/auth/password/forgotSend a reset link (always the same answer)
POST/v1/auth/password/resetChoose a new password with the emailed token (signs out every session)
POST/v1/auth/mfa/totp/setupStart authenticator setup: returns the otpauth URL for the QR code
POST/v1/auth/mfa/totp/enableTurn on two-step sign-in; returns 10 recovery codes once
POST/v1/auth/mfa/totp/disableTurn off two-step sign-in (needs a current authenticator code)
POST/v1/auth/mfa/step-upConfirm with an authenticator code before live actions (valid 15 minutes)
POST/v1/auth/mfa/recovery-codesReplace the recovery codes (needs an authenticator code); shown once
GET/v1/auth/oauth/{provider}/startStart Google, GitHub or X sign-in (302 to the provider)
GET/v1/auth/oauth/{provider}/callbackThe provider's callback (302 to the dashboard, or to /signin?error=CODE)
POST/v1/auth/oauth/{provider}/linkLink Google, GitHub or X to the signed-in account: returns the provider URL to open
GET/v1/meThe signed-in account and its organizations
PATCH/v1/meChange the display name
POST/v1/me/emailAdd an email to an account without one (sends a code)
POST/v1/me/email/verifyConfirm the added email with its code
POST/v1/me/passwordChange (or set) the password; signs out the other sessions
GET/v1/me/sessionsActive sessions
DELETE/v1/me/sessions/{id}Sign out one session
POST/v1/me/sessions/revoke-othersSign out every other session
DELETE/v1/me/identities/{provider}Unlink Google, GitHub or X (one sign-in method must remain)
GET/v1/me/security-eventsRecent sign-ins and security changes of this account

GET/v1/auth/providers#

Which sign-in methods are on

  • Operation id: PlatformAuthController_providers (contract name: listAuthProviders)
  • Authentication: None (public)

Response#

Status 200.

NameTypeRequiredNotes
objectstring (auth_providers)yes
providersarray of objectyes
signupobjectyes

Notes#

  • A method that is switched off is hidden here, and its routes return 403 METHOD_DISABLED.

GET/v1/auth/csrf#

The CSRF token (also set as the __Host-terra_csrf cookie); send it as X-Terra-CSRF on every write

  • Operation id: PlatformAuthController_csrfToken
  • Authentication: None (public)

Response#

Status 200.

POST/v1/auth/signup#

Create an account (sends a 6-digit code and a link; the answer is the same whether or not the email exists)

  • Operation id: PlatformAuthController_signup (contract name: signUp)
  • Authentication: None (public)

Request body#

NameTypeRequiredNotes
emailstring (email)yeslength 3 to 254
passwordstringyeslength 10 to 128
namestringyeslength 1 to 100
turnstileTokenstringyeslength 1 to 2048

Response#

Status 201.

Errors#

StatusCodeWhen
403METHOD_DISABLEDEmail sign-up is switched off.

POST/v1/auth/verify-email#

Confirm the sign-up code and start a session

  • Operation id: PlatformAuthController_verifyEmail (contract name: verifyEmail)
  • Authentication: None (public)

Request body#

NameTypeRequiredNotes
emailstring (email)yeslength 3 to 254
codestringyespattern ^\d{6}$

Response#

Status 200.

NameTypeRequiredNotes
objectstring (session)yes
sessionobjectyes
userobjectyes
csrf_tokenstringyes

POST/v1/auth/login#

Sign in with email and password

  • Operation id: PlatformAuthController_login (contract name: logIn)
  • Authentication: None (public)

Request body#

NameTypeRequiredNotes
emailstring (email)yeslength 3 to 254
passwordstringyeslength 1 to 128
turnstileTokenstringyeslength 1 to 2048

Response#

Status 200.

Notes#

  • Lockout after 10 failures in 15 minutes per account, plus exponential backoff.

POST/v1/auth/mfa/verify#

The authenticator step of a sign-in (TOTP or a recovery code)

  • Operation id: PlatformAuthController_mfaVerify (contract name: verifyMfa)
  • Authentication: None (public)

Request body#

NameTypeRequiredNotes
mfa_tokenstringyespattern ^[A-Za-z0-9_-]{43}$
codestringyeslength 6 to 32

Response#

Status 200.

NameTypeRequiredNotes
objectstring (session)yes
sessionobjectyes
userobjectyes
csrf_tokenstringyes

POST/v1/auth/logout#

Sign out (revokes this session)

  • Operation id: PlatformAuthController_logout (contract name: logOut)
  • Authentication: Dashboard session

Response#

Status 200.

POST/v1/auth/password/forgot#

Send a reset link (always the same answer)

  • Operation id: PlatformAuthController_forgot (contract name: forgotPassword)
  • Authentication: None (public)

Request body#

NameTypeRequiredNotes
emailstring (email)yeslength 3 to 254
turnstileTokenstringyeslength 1 to 2048

Response#

Status 200.

POST/v1/auth/password/reset#

Choose a new password with the emailed token (signs out every session)

  • Operation id: PlatformAuthController_reset (contract name: resetPassword)
  • Authentication: None (public)

Request body#

NameTypeRequiredNotes
tokenstringyeslength 0 to 128
passwordstringyeslength 10 to 128

Response#

Status 200.

POST/v1/auth/mfa/totp/setup#

Start authenticator setup: returns the otpauth URL for the QR code

  • Operation id: PlatformAuthController_totpSetup (contract name: setupTotp)
  • Authentication: Dashboard session

Response#

Status 200.

POST/v1/auth/mfa/totp/enable#

Turn on two-step sign-in; returns 10 recovery codes once

  • Operation id: PlatformAuthController_totpEnable (contract name: enableTotp)
  • Authentication: Dashboard session

Request body#

NameTypeRequiredNotes
codestringyespattern ^\d{6}$

Response#

Status 200.

POST/v1/auth/mfa/totp/disable#

Turn off two-step sign-in (needs a current authenticator code)

  • Operation id: PlatformAuthController_totpDisable (contract name: disableTotp)
  • Authentication: Dashboard session

Request body#

NameTypeRequiredNotes
codestringyespattern ^\d{6}$

Response#

Status 200.

POST/v1/auth/mfa/step-up#

Confirm with an authenticator code before live actions (valid 15 minutes)

  • Operation id: PlatformAuthController_stepUp
  • Authentication: Dashboard session

Request body#

NameTypeRequiredNotes
codestringyespattern ^\d{6}$

Response#

Status 200.

POST/v1/auth/mfa/recovery-codes#

Replace the recovery codes (needs an authenticator code); shown once

  • Operation id: PlatformAuthController_recoveryCodes
  • Authentication: Dashboard session

Request body#

NameTypeRequiredNotes
codestringyespattern ^\d{6}$

Response#

Status 200.

GET/v1/auth/oauth/{provider}/start#

Start Google, GitHub or X sign-in (302 to the provider)

  • Operation id: PlatformAuthController_start (contract name: startOAuth)
  • Authentication: None (public)

Path parameters#

NameTypeRequiredNotes
providerstringyesgoogle | github | x

Query parameters#

NameTypeRequiredNotes
redirectstringno

Response#

Status 302.

Redirect

GET/v1/auth/oauth/{provider}/callback#

The provider's callback (302 to the dashboard, or to /signin?error=CODE)

  • Operation id: PlatformAuthController_callback (contract name: oauthCallback)
  • Authentication: None (public)

Path parameters#

NameTypeRequiredNotes
providerstringyesgoogle | github | x

Response#

Status 302.

Redirect

Notes#

  • An OAuth identity links to an existing account only when the provider's email is verified and equals the account's verified email.
  • Identities are keyed by provider and provider user id, never by email.
  • X may return no email: the account is then created without one, and an email must be added and verified before creating keys.

POST/v1/auth/oauth/{provider}/link#

Link Google, GitHub or X to the signed-in account: returns the provider URL to open

  • Operation id: PlatformAuthController_link
  • Authentication: Dashboard session

Path parameters#

NameTypeRequiredNotes
providerstringyesgoogle | github | x

Request body#

NameTypeRequiredNotes
redirectstringnolength 0 to 512

Response#

Status 200.

GET/v1/me#

The signed-in account and its organizations

  • Operation id: PlatformMeController_me (contract name: getMe)
  • Authentication: Dashboard session

Response#

Status 200.

NameTypeRequiredNotes
userobjectyes
orgsarray of objectyes

PATCH/v1/me#

Change the display name

  • Operation id: PlatformMeController_update
  • Authentication: Dashboard session

Request body#

NameTypeRequiredNotes
namestringyeslength 1 to 100

Response#

Status 200.

NameTypeRequiredNotes
userobjectyes
orgsarray of objectyes

POST/v1/me/email#

Add an email to an account without one (sends a code)

  • Operation id: PlatformMeController_addEmail
  • Authentication: Dashboard session

Request body#

NameTypeRequiredNotes
emailstring (email)yeslength 3 to 254

Response#

Status 200.

POST/v1/me/email/verify#

Confirm the added email with its code

  • Operation id: PlatformMeController_confirmEmail
  • Authentication: Dashboard session

Request body#

NameTypeRequiredNotes
codestringyespattern ^\d{6}$

Response#

Status 200.

NameTypeRequiredNotes
userobjectyes
orgsarray of objectyes

POST/v1/me/password#

Change (or set) the password; signs out the other sessions

  • Operation id: PlatformMeController_changePassword
  • Authentication: Dashboard session

Request body#

NameTypeRequiredNotes
current_passwordstringnolength 1 to 128
new_passwordstringyeslength 10 to 128

Response#

Status 200.

GET/v1/me/sessions#

Active sessions

  • Operation id: PlatformMeController_listSessions
  • Authentication: Dashboard session

Response#

Status 200.

NameTypeRequiredNotes
dataarray of objectno

DELETE/v1/me/sessions/{id}#

Sign out one session

  • Operation id: PlatformMeController_revokeSession
  • Authentication: Dashboard session

Path parameters#

NameTypeRequiredNotes
idstringyesses_...

Response#

Status 200.

POST/v1/me/sessions/revoke-others#

Sign out every other session

  • Operation id: PlatformMeController_revokeOthers
  • Authentication: Dashboard session

Response#

Status 200.

DELETE/v1/me/identities/{provider}#

Unlink Google, GitHub or X (one sign-in method must remain)

  • Operation id: PlatformMeController_unlink
  • Authentication: Dashboard session

Path parameters#

NameTypeRequiredNotes
providerstringyesgoogle | github | x

Response#

Status 200.

GET/v1/me/security-events#

Recent sign-ins and security changes of this account

  • Operation id: PlatformMeController_securityEvents
  • Authentication: Dashboard session

Query parameters#

NameTypeRequiredNotes
limitintegerno
starting_afterstringno

Response#

Status 200.