Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Connected accounts

A principal’s accounts at OAuth providers, such as Twitch, held so a trusted caller or a delegate can act for it there. Connect one with auth.oauthStart and purpose: connect.

Delegations explains how a delegate acting for a principal may use the principal’s connected accounts.

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.

List connected accounts

GET /principals/:id/connections

A principal’s connected accounts, without their tokens.

  • Who may call: Your server or a signed-in principal.
  • Access: A principal may list only its own.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.connections.list(principalId)

Path parameters

Name Type Required Description
id string Yes A principal ID, prn_…. The id of a Principal.

Response

200 OK, with:

Name Type Present Description
connections Connection array Always

Errors

Any operation can also answer with the codes Conventions lists.

Remove a connected account

DELETE /connections/:id

Removes a connected account and revokes its tokens at the provider, such as Twitch, so they stop working there too. If the provider doesn’t revoke them, the account is still removed.

  • Who may call: Your server or a signed-in principal.
  • Access: A principal may remove only its own.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.connections.remove(id)
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A connection ID, con_…. The id of a Connection.

Response

204 No Content, with no body.

Errors

Any operation can also answer with the codes Conventions lists.

Get a provider access token

POST /connections/:id/token

A short-lived access token for the provider, refreshed first when it’s about to expire. Each active connection’s token is also checked with the provider hourly, and a token the provider rejects is refreshed. A connection becomes needs_reauth, with a connection.needs_reauth event, only when the provider refuses its refresh token. A timeout, a 5xx, or a 429 from the provider never changes a connection; this call then answers provider_error, and a retry may succeed.

  • Who may call: Your server or a signed-in principal.
  • Access: Trusted callers, or a principal with a delegated token whose delegation holds identity.connection:use for the provider. Not the principal’s own session.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.connections.token(id)
  • Idempotency-Key: optional. Retrying a write has the rule.

Path parameters

Name Type Required Description
id string Yes A connection ID, con_…. The id of a Connection.

Response

200 OK, with ConnectionTokenResponse.

Errors

Any operation can also answer with the codes Conventions lists.

The Connection object

A connected account as the API shows it: never with its tokens.

Name Type Present Description
id string Always A connection ID, con_….
principalId string Always A principal ID, prn_….
providerKey string Always
subject string Always
identityId string When set An identity ID, idn_….
scopes string[] Always
accessTokenExpiresAt string When set An ISO 8601 date and time.
status string Always One of "active" or "needs_reauth".
createdAt string Always An ISO 8601 date and time.
lastRefreshedAt string When set An ISO 8601 date and time.
lastUsedAt string When set An ISO 8601 date and time.

The ConnectionTokenResponse object

Name Type Present Description
accessToken string Always
expiresAt string When set
scopes string[] Always