api.auth

Overview

The current session, and the profile behind it. Three methods — there is no sign-in here, because the SDK authenticates with a key.

3 methodssession-scopedfree
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Signing in with an email and a password belongs to an account surface, not to an SDK: a program holds a key, not a password. What is here is what a program needs — end this session, end another one, change the profile it belongs to.

The methods

MethodDoesReturns
logout()Ends the session this client is using.{ ok: true }
revokeSession(id)Ends another session of the same account, by id.{ ok: true } · 404
updateProfile(updates)Changes writable profile fields.{ ok, user }

Key, session, request

Three things sit between your code and an answer, and each is revoked differently. Knowing which one you are holding is most of what this resource is about.

What it isEnds when
The keyWhat the account issued to your program.You revoke it.
The sessionWhat the key was exchanged for.logout(), revokeSession(), or it expires.
The tokenThe short-lived proof on each request.It expires, and is renewed from the session.
A session and a key are two different things

Ending a session does not stop the key: the next call exchanges it again and you are back, under a new session. To cut access, revoke the key.

What is not here, and where it is

What you wantWhere
Who this key belongs toapi.getUser()
Which session this isapi.session()
Stop a key from working at allapi.keys.revoke(id)
The balance and the planapi.getUser()
Sign in with an email and passwordNot an SDK operation. Your account surface does it.

Choosing between the three

// This process should stop being this session
await api.auth.logout();

// That machine over there should be signed out
await api.auth.revokeSession(itsSessionId);

// That machine should not be able to come back at all
await api.keys.revoke(itsKeyId);

// All of the above, for a machine you no longer trust:
await api.keys.revoke(itsKeyId);
await api.auth.revokeSession(itsSessionId);
# This process should stop being this session
api.auth.logout()

# That machine over there should be signed out
api.auth.revoke_session(its_session_id)

# That machine should not be able to come back at all
api.keys.revoke(its_key_id)

# All of the above, for a machine you no longer trust:
api.keys.revoke(its_key_id)
api.auth.revoke_session(its_session_id)

The order is deliberate. Revoking the key first closes the door; revoking the session then removes whoever was already inside. Doing it the other way round leaves a window in which the key is used to exchange a fresh session.