Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Sign-in

Emailed codes, OAuth providers, guests, sign-out, and introspection. The session-start operations, and an invitation’s preview, are the only ones a publishable key reaches.

Sessions explains how a sign-in starts a session, how long it lasts, and what ends it.

Paths are relative to https://api.agentpost.tools/v1/identity, and every request follows the API basics. Who may call explains each kind of caller.

Send a sign-in code

POST /auth/email-code

Sends a 6-digit sign-in code to an email address that has an account or that the sign-up mode lets in. Always answers 202 the same way, so the answer never says which.

  • Who may call: Your server or anyone.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.auth.requestCode(input)
  • Idempotency-Key: optional. Retrying a write has the rule.

Body

Name Type Required Description
email string Yes An email address; up to 254 characters.

Response

202 Accepted, with CodeRequested.

Errors

Any operation can also answer with the codes Conventions lists.

Verify a sign-in code

POST /auth/email-code/verify

Checks the code and signs the principal in, or signs it up when the sign-up mode allows. Answers with a session token, shown once.

  • Who may call: Your server or anyone.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.auth.verifyCode(input)
  • Idempotency-Key: optional. Retrying a write has the rule.

Body

Name Type Required Description
email string Yes An email address; up to 254 characters.
code string Yes The 6-digit code from the email.
verificationId string Yes The verificationId the code request returned.
kind string No A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike. One of "human", "agent", or "service".

Response

200 OK, with SessionGrant.

Errors

Any operation can also answer with the codes Conventions lists.

Start an OAuth flow

POST /auth/oauth/:providerKey/start

Starts an OAuth flow with a configured provider. Answers with the provider’s authorize URL. returnTo must match a configured URL. With purpose: sign_in, set connect: true to also save this app’s connection. Connecting requests the app’s connectScopes and any extra scopes; sign-in also requests signInScopes. To keep what the principal’s other connections for this app hold, list them and pass their scopes.

  • Who may call: Your server, anyone, or a signed-in principal.
  • Access: Signing in needs no credential. Linking or connecting an account needs the signed-in principal.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.auth.oauthStart(providerKey, input)
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
providerKey string Yes A provider key: a key of the config’s signIn.providers, such as twitch.

Body

Name Type Required Description
kind string No A label the principal chooses for itself. Omit it to leave the kind unset. Roles, grants, and invitations treat every kind alike. One of "human", "agent", or "service".
purpose string Yes One of "sign_in", "link", or "connect".
returnTo string Yes A URL.
scopes string[] No
connect boolean No With sign_in, also save a connection for this provider app.
binding string No 1–256 characters.

Response

200 OK, with OAuthStartResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Finish an OAuth flow

POST /auth/oauth/:providerKey/callback

Finishes an OAuth flow with the provider’s code and state. Signs in, links an identity, or connects an account, depending on how the flow started. A sign-in started with connect: true also answers with its connection. If an existing connection needs more scopes, answers with purpose: reauthorize with a fresh authorize URL and state, without changing the connection or issuing a session. Send the browser to that URL, authorize the same provider account, and post the new code and state here with the original binding and credential. Repeat until the original purpose completes.

  • Who may call: Your server, anyone, or a signed-in principal.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.auth.oauthCallback(providerKey, input)
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
providerKey string Yes A provider key: a key of the config’s signIn.providers, such as twitch.

Body

Name Type Required Description
code string Yes
state string Yes
binding string No 1–256 characters.

Response

200 OK, with OAuthCallbackResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Start a guest session

POST /auth/guest

Creates a guest principal and its session, when the project allows guests. Throttled per IP.

  • Who may call: Your server or anyone.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.auth.startGuest(input)
  • Idempotency-Key: optional. Retrying a write has the rule.

Body

The body is optional.

Name Type Required Description
displayName string No 1–120 characters.

Response

201 Created, with SessionGrant.

Errors

Any operation can also answer with the codes Conventions lists.

Sign out

POST /auth/sign-out

Revokes the session or delegated token the call is made with.

  • Who may call: A signed-in principal.
  • Credential: the examples send a signed-in principal’s session token, agp_st_…, as Authorization: Bearer <token>.
  • SDK: client.auth.signOut()
  • Idempotency-Key: optional. Retrying a write has the rule.

Response

204 No Content, with no body.

Errors

Any operation can also answer with the codes Conventions lists.

Introspect a token

POST /auth/introspect

Says whether a session, API key, or delegated token is active, and who it acts for. verifyRequest in the SDK calls this. It counts as using the token, as a call made with it does: the idle limit of a session or delegated token moves forward, at most once a minute. So a server that checks the token on each request keeps the session alive while it is in use.

  • Who may call: Your server.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.auth.introspect(token)
  • Idempotency-Key: not taken. A retry only checks the token again, so IdentityHound runs it on every request and it takes no Idempotency-Key.

Body

Name Type Required Description
token string Yes 16–512 characters.

Response

200 OK, with IntrospectResponse.

Errors

Any operation can also answer with the codes Conventions lists.

The CodeRequested object

A code request’s answer. It is the same whether or not the address gets a code.

Name Type Present Description
verificationId string Always Send it back with the code. A request for the same address before resendAfter runs out sends no new code and answers with this same ID.
resendAfter number Always Whole seconds until a request for the same address sends a new code. A request that sends one answers with the config’s signIn.emailCode.resendAfter in seconds: "30s" answers 30. A request within that window answers with the seconds left.

The SessionGrant object

Name Type Present Description
token string Always The bearer token. Shown once.
session Session Always
principal Principal Always
signedUp boolean Always True when this sign-in created the principal.

The OAuthStartResponse object

Name Type Present Description
authorizeUrl string Always
state string Always
expiresAt string Always

The OAuthCallbackResponse object

Name Type Present Description
purpose string Always One of "sign_in", "reauthorize", "link", or "connect".
connection Connection When set With purpose: "sign_in" or purpose: "connect".
token string When set With purpose: "sign_in". The bearer token. Shown once.
session Session When set With purpose: "sign_in".
principal Principal When set With purpose: "sign_in" or purpose: "link".
signedUp boolean When set With purpose: "sign_in". True when this sign-in created the principal.
authorizeUrl string When set With purpose: "reauthorize".
state string When set With purpose: "reauthorize".
expiresAt string When set With purpose: "reauthorize".
identity Identity When set With purpose: "link".

The IntrospectResponse object

Name Type Present Description
active boolean Always
credential object When set
credential.kind string Always One of "session", "api_key", or "delegated_token".
credential.id string Always
actor Principal When set The principal that holds the credential and makes requests with it.
onBehalfOf Principal When set The delegator, for a delegated token. Authority comes from it, within the delegation.
delegation Delegation When set
restrictions object When set
restrictions.workspaceIds string[] When set
restrictions.permissions string[] When set
session Session When set