Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Principals

Principals and their sign-in methods. A principal may declare a kind, human, agent, or service, as a label it can change at any time. Roles, grants, and invitations treat every kind alike.

Principals explains optional principal kinds, sign-in methods, guests, and what suspending or deleting one stops.

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 principals

GET /principals

Finds principals by kind, status, name or email, or externalRef. kind matches a declared label, or guest.

  • Who may call: Your server.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.principals.list(query)
  • Pages: limit, 1 to 500, default 100. The answer holds up to limit items; narrow the query’s filters to reach others.

Query parameters

Name Type Required Description
kind string No A kind: guest, which IdentityHound sets, or a label a principal declared itself: human, agent, or service. Every setting treats the declared kinds alike. One of "human", "guest", "agent", or "service".
status string No One of "active", "suspended", or "deleted".
q string No 1–120 characters.
externalRef string No 1–200 characters.
limit integer No 1–500; default 100.

Response

200 OK, with:

Name Type Present Description
principals Principal array Always

Errors

Any operation can also answer with the codes Conventions lists.

Import principals

POST /principals/import

Brings up to 500 existing principals across at once, with their identities, project roles, memberships, and grants. Idempotent by externalRef: a re-run adds what is missing and changes nothing else. Each grant has its own externalRef, so one principal may hold two grants of the same target. Reusing a grant’s externalRef with changed grant fields fails that principal with idempotency_mismatch. Each principal commits with its role events or rolls back on failure. A request body is at most 1 MiB, so a batch whose principals carry large metadata may need splitting into smaller calls even under 500; a larger body answers payload_too_large.

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

Body

Name Type Required Description
principals object[] Yes 1–500 items.
principals[].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".
principals[].externalRef string Yes 1–200 characters.
principals[].displayName string No 1–120 characters.
principals[].avatarUrl string No A URL.
principals[].metadata object No
principals[].identities object[] Yes At least 1.
principals[].identities[].type "email" or "oauth" Yes
principals[].identities[].email string No With type: "email"; up to 254 characters.
principals[].identities[].provider "twitch" No With type: "oauth".
principals[].identities[].subject string No With type: "oauth".
principals[].identities[].profile object No With type: "oauth".
principals[].identities[].profile.login string No
principals[].identities[].profile.displayName string No
principals[].identities[].profile.email string No
principals[].identities[].profile.avatarUrl string No
principals[].projectRoles string[] No Configured project roles to add. Existing roles stay; repeated roles add nothing.
principals[].memberships object[] No
principals[].memberships[].workspaceId string Yes A workspace ID, wsp_….
principals[].memberships[].role string Yes A role key from the config, such as “member”.
principals[].grants object[] No
principals[].grants[].externalRef string Yes Your system’s reference for this grant, such as its row ID. One principal’s grants with the same externalRef are one grant, so a re-import adds no second one; 1–200 characters.
principals[].grants[].target object Yes
principals[].grants[].target.kind string Yes One of "entitlement" or "bundle".
principals[].grants[].target.entitlement string No With kind: "entitlement".
principals[].grants[].target.resource object No With kind: "entitlement".
principals[].grants[].target.resource.type string Yes
principals[].grants[].target.resource.id string Yes
principals[].grants[].target.bundle string No With kind: "bundle".
principals[].grants[].provenance object Yes
principals[].grants[].provenance.source string Yes Your app’s label for why the grant exists; 1–100 characters.
principals[].grants[].provenance.reference string No Up to 200 characters.
principals[].grants[].provenance.note string No Up to 1000 characters.
principals[].grants[].metadata object No
principals[].grants[].startsAt string No An ISO 8601 date and time.
principals[].grants[].expiresAt string No An ISO 8601 date and time.

Response

200 OK, with ImportResponse.

Errors

Any operation can also answer with the codes Conventions lists.

Create a principal

POST /principals

Creates a principal and answers with its first API key. The token is shown once.

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

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".
displayName string No 1–120 characters.
avatarUrl string No A URL.
description string No Up to 1000 characters.
externalRef string No 1–200 characters.
metadata object No

Response

201 Created, with PrincipalCreated.

Errors

Any operation can also answer with the codes Conventions lists.

Get a principal

GET /principals/:id

One principal.

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

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
principal Principal Always

Errors

Any operation can also answer with the codes Conventions lists.

List a principal’s identities

GET /principals/:id/identities

A principal’s sign-in identities.

  • Who may call: Your server.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.principals.identities(id)

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
identities Identity array Always

Errors

Any operation can also answer with the codes Conventions lists.

List a principal’s sessions

GET /principals/:id/sessions

A principal’s live sessions, direct and delegated, newest first. A server that keeps data per session checks its copies against this.

  • Who may call: Your server.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.principals.sessions(id)

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
sessions Session array Always

Errors

Any operation can also answer with the codes Conventions lists.

Get a session

GET /sessions/:id

One session, live or ended. An ended session has revokedAt and revokeReason, or an expiresAt or idleExpiresAt that has passed. It is kept until 30 days after its expiresAt, then answers not_found.

  • Who may call: Your server.
  • Credential: the examples send your project’s dev secret key, sk_test_…, as Authorization: Bearer <token>.
  • SDK: client.sessions.get(id)

Path parameters

Name Type Required Description
id string Yes A session ID, ses_…. The id of a Session.

Response

200 OK, with:

Name Type Present Description
session Session Always

Errors

Any operation can also answer with the codes Conventions lists.

Update a principal

PATCH /principals/:id

Changes a principal’s kind, name, avatar, description, or metadata. Send null to clear the kind. A kind is a label, and roles, grants, and invitations treat every kind alike.

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

Path parameters

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

Body

Name Type Required Description
kind string or null No One of "human", "agent", or "service".
displayName string or null No A supplied name, 1 to 120 characters. Send null to clear it.
avatarUrl string or null No
description string or null No
metadata object No

Response

200 OK, with:

Name Type Present Description
principal Principal Always

Errors

Any operation can also answer with the codes Conventions lists.

Suspend a principal

POST /principals/:id/suspend

Suspends a principal. Its sessions and delegated tokens end at once, its API keys stop working while it is suspended, and every delegation it is a party to is revoked.

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

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
principal Principal Always

Errors

Any operation can also answer with the codes Conventions lists.

Reactivate a principal

POST /principals/:id/reactivate

Lifts a suspension. Its live API keys work again. Its ended sessions and delegations stay revoked.

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

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
principal Principal Always

Errors

Any operation can also answer with the codes Conventions lists.

Delete a principal

DELETE /principals/:id

Deletes a principal with its identities, sessions, keys, and connections, and revokes the connections’ tokens at the provider.

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

Path parameters

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

Response

204 No Content, with no body.

Errors

Any operation can also answer with the codes Conventions lists.

The Principal object

Name Type Present Description
id string Always A principal ID, prn_….
kind string When set A principal’s kind: guest, which IdentityHound sets while someone uses a product before signing in, or a label the principal chose for itself (human, agent, or service), or none. A principal can change its label at any time, and every setting treats the declared kinds alike. One of "human", "guest", "agent", or "service".
status string Always One of "active", "suspended", or "deleted".
displayName string When set A supplied name, 1 to 120 characters. Your app decides what to show when absent.
avatarUrl string When set
projectRoles string[] Always
description string When set
guest object When set
guest.createdIp string When set
guest.upgradedAt string When set An ISO 8601 date and time.
mergedInto string When set A principal ID, prn_….
lastActiveAt string When set An ISO 8601 date and time.
externalRef string When set
metadata object Always
createdAt string Always An ISO 8601 date and time.
createdBy string When set A principal ID, prn_….
updatedAt string Always An ISO 8601 date and time.
suspendedAt string When set An ISO 8601 date and time.
deletedAt string When set An ISO 8601 date and time.

The Session object

A session as the API shows it: never with its token or hash.

Name Type Present Description
id string Always A session ID, ses_….
kind "direct" or "delegated" Always
principalId string Always Whose session it is: for a delegated session, the delegator.
delegateId string When set The delegate holding a delegated session.
delegationId string When set A delegation ID, dlg_….
authMethods string[] Always Each is oauth:…, or one of "email_code", "api_key", or "guest".
client object When set
client.ip string When set
client.userAgent string When set
client.platform string When set
createdAt string Always An ISO 8601 date and time.
lastSeenAt string Always An ISO 8601 date and time.
idleExpiresAt string Always An ISO 8601 date and time.
expiresAt string Always An ISO 8601 date and time.
revokedAt string When set An ISO 8601 date and time.
revokeReason string When set One of "sign_out", "self", "api_key_revoked", "principal_suspended", "identity_removed", "principal_deleted", "delegation_revoked", "upgraded", or "merged".
current boolean When set True for the session the request was made with.

The ImportResponse object

Name Type Present Description
results object[] Always
results[].externalRef string Always
results[].principalId string When set A principal ID, prn_….
results[].outcome string Always One of "created", "existing", or "failed".
results[].error object When set
results[].error.code string Always
results[].error.message string Always
principalIds object Always externalRef to principalId for every item that did not fail. Each value is a string.

The PrincipalCreated object

Name Type Present Description
apiKey ApiKey Always
token string Always The bearer token. Shown once.
principal Principal Always