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
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.principals.list(query) - Pages:
limit, 1 to 500, default 100. The answer holds up tolimititems; 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
trusted_caller_required(403)
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
devsecret key,sk_test_…, asAuthorization: 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[]. |
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[]. |
string |
Yes | 1–200 characters. |
principals[]. |
string |
No | 1–120 characters. |
principals[]. |
string |
No | A URL. |
principals[]. |
object |
No | |
principals[]. |
object[] |
Yes | At least 1. |
principals[]. |
"email" or "oauth" |
Yes | |
principals[]. |
string |
No | With type: "email"; up to 254 characters. |
principals[]. |
"twitch" |
No | With type: "oauth". |
principals[]. |
string |
No | With type: "oauth". |
principals[]. |
object |
No | With type: "oauth". |
principals[]. |
string |
No | |
principals[]. |
string |
No | |
principals[]. |
string |
No | |
principals[]. |
string |
No | |
principals[]. |
string[] |
No | Configured project roles to add. Existing roles stay; repeated roles add nothing. |
principals[]. |
object[] |
No | |
principals[]. |
string |
Yes | A workspace ID, wsp_…. |
principals[]. |
string |
Yes | A role key from the config, such as “member”. |
principals[]. |
object[] |
No | |
principals[]. |
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[]. |
object |
Yes | |
principals[]. |
string |
Yes | One of "entitlement" or "bundle". |
principals[]. |
string |
No | With kind: "entitlement". |
principals[]. |
object |
No | With kind: "entitlement". |
principals[]. |
string |
Yes | |
principals[]. |
string |
Yes | |
principals[]. |
string |
No | With kind: "bundle". |
principals[]. |
object |
Yes | |
principals[]. |
string |
Yes | Your app’s label for why the grant exists; 1–100 characters. |
principals[]. |
string |
No | Up to 200 characters. |
principals[]. |
string |
No | Up to 1000 characters. |
principals[]. |
object |
No | |
principals[]. |
string |
No | An ISO 8601 date and time. |
principals[]. |
string |
No | An ISO 8601 date and time. |
Response
200 OK, with ImportResponse.
Errors
entitlement_unknown(422)trusted_caller_required(403)
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
devsecret key,sk_test_…, asAuthorization: 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
devsecret key,sk_test_…, asAuthorization: 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
devsecret key,sk_test_…, asAuthorization: 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
not_found(404)trusted_caller_required(403)
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
devsecret key,sk_test_…, asAuthorization: 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
not_found(404)trusted_caller_required(403)
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
devsecret key,sk_test_…, asAuthorization: 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
not_found(404)trusted_caller_required(403)
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
devsecret key,sk_test_…, asAuthorization: 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
devsecret key,sk_test_…, asAuthorization: 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
conflict(409)forbidden(403)last_owner(409)not_found(404)
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
devsecret key,sk_test_…, asAuthorization: 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
devsecret key,sk_test_…, asAuthorization: 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
conflict(409)forbidden(403)last_owner(409)not_found(404)
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. |
string |
When set | |
guest. |
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. |
string |
When set | |
client. |
string |
When set | |
client. |
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[]. |
string |
Always | |
results[]. |
string |
When set | A principal ID, prn_…. |
results[]. |
string |
Always | One of "created", "existing", or "failed". |
results[]. |
object |
When set | |
results[]. |
string |
Always | |
results[]. |
string |
Always | |
principalIds |
object |
Always | externalRef to principalId for every item that did not fail. Each value is a string. |