Help us shape the future of Go! Take the 2026 Go Developer Survey

api

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 45 Imported by: 0

Documentation

Overview

Package api provides Forge-style HTTP handlers for the AuthSome engine. Routes are registered with struct-based request/response binding and full OpenAPI metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API wires all AuthSome HTTP handlers together.

func New

func New(engine *authsome.Engine, router ...forge.Router) *API

New creates an API from an Engine and an optional Forge router.

func (*API) Handler

func (a *API) Handler() http.Handler

Handler returns the fully assembled http.Handler with all routes. If route registration fails, it logs the error and returns a handler that responds with 503 Service Unavailable.

func (*API) RegisterRoutes

func (a *API) RegisterRoutes(router forge.Router) error

RegisterRoutes registers all AuthSome API routes into the given Forge router with full OpenAPI metadata.

type AddPermissionRequest

type AddPermissionRequest struct {
	RoleID   string `path:"roleId" description:"Role identifier"`
	Action   string `json:"action" description:"Permission action (e.g. read, write, delete, admin)"`
	Resource string `json:"resource" description:"Permission resource (e.g. user, org, document)"`
}

AddPermissionRequest binds path + body for POST /roles/:roleId/permissions.

type AdminAppResponse

type AdminAppResponse struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	Slug           string `json:"slug"`
	PublishableKey string `json:"publishable_key,omitempty"`
	IsPlatform     bool   `json:"is_platform"`
}

AdminAppResponse is the create response for POST /admin/apps. Includes the generated PublishableKey so the caller can hand it to the frontend without a follow-up read.

type AdminBanUserRequest

type AdminBanUserRequest struct {
	UserID    string  `path:"userId" description:"User identifier"`
	Reason    string  `json:"reason,omitempty" description:"Ban reason"`
	ExpiresAt *string `json:"expires_at,omitempty" description:"Ban expiration (RFC3339, omit for permanent)"`
}

AdminBanUserRequest binds path + body for POST /admin/users/:userId/ban.

type AdminCopyUserRequest

type AdminCopyUserRequest struct {
	SourceUserID string `json:"source_user_id" description:"User to duplicate"`
	TargetAppID  string `json:"target_app_id" description:"Authsome App that will hold the duplicate"`
	EnvID        string `json:"env_id,omitempty" description:"Optional target environment; falls back to the App's default environment"`
}

AdminCopyUserRequest binds the body for POST /admin/users/copy. Provisions a duplicate of source_user_id under target_app_id while reusing the source user's stored password hash so the copy can authenticate with the original password. Used by TwinOS studio's "Add existing user" flow to lift an end-user from one workspace's Authsome App into another's.

type AdminCreateAppRequest

type AdminCreateAppRequest struct {
	Name string `json:"name" description:"Human-readable app name"`
	Slug string `json:"slug" description:"URL-safe app slug (globally unique)"`
}

AdminCreateAppRequest binds the body for POST /admin/apps. Used by platform-admin clients (e.g. TwinOS studio) to spin up a fresh App per tenant. Slug must be globally unique within the Authsome instance — caller is responsible for adding a tenant-derived suffix to avoid collisions.

type AdminCreateServiceAccountAPIKeyRequest

type AdminCreateServiceAccountAPIKeyRequest struct {
	ServiceAccountID string   `path:"serviceAccountId" description:"Service account ID"`
	Name             string   `json:"name" description:"API key name"`
	Scopes           []string `json:"scopes,omitempty" description:"Scopes for this key"`
	ExpiresAt        *string  `json:"expires_at,omitempty" description:"Optional expiration time (RFC 3339)"`
}

AdminCreateServiceAccountAPIKeyRequest binds path + body for POST /admin/service-accounts/:serviceAccountId/api-keys.

type AdminCreateServiceAccountRequest

type AdminCreateServiceAccountRequest struct {
	AppID       string   `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	Name        string   `json:"name" description:"Service account name (unique per app)"`
	Description string   `json:"description,omitempty" description:"Human-readable description"`
	Scopes      []string `json:"scopes,omitempty" description:"Default scopes for API keys minted for this service account"`
}

AdminCreateServiceAccountRequest binds the body for POST /admin/service-accounts.

type AdminCreateUserRequest

type AdminCreateUserRequest struct {
	AppID     string `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	Email     string `json:"email" description:"User email address"`
	Password  string `json:"password" description:"User password"`
	FirstName string `json:"first_name,omitempty" description:"First/given name"`
	LastName  string `json:"last_name,omitempty" description:"Last/family name"`
	Username  string `json:"username,omitempty" description:"Unique username"`
}

AdminCreateUserRequest binds the body for POST /admin/users/create.

type AdminDeleteAppRequest

type AdminDeleteAppRequest struct {
	AppID string `path:"appId" description:"Application identifier to delete"`
}

AdminDeleteAppRequest binds the path for DELETE /admin/apps/:appId.

type AdminDeleteServiceAccountRequest

type AdminDeleteServiceAccountRequest struct {
	ServiceAccountID string `path:"serviceAccountId" description:"Service account ID"`
}

AdminDeleteServiceAccountRequest binds the path for DELETE /admin/service-accounts/:serviceAccountId.

type AdminDeleteUserRequest

type AdminDeleteUserRequest struct {
	UserID string `path:"userId" description:"User identifier"`
}

AdminDeleteUserRequest binds the path for DELETE /admin/users/:userId.

type AdminGetServiceAccountRequest

type AdminGetServiceAccountRequest struct {
	ServiceAccountID string `path:"serviceAccountId" description:"Service account ID"`
}

AdminGetServiceAccountRequest binds the path for GET /admin/service-accounts/:serviceAccountId.

type AdminGetUserRequest

type AdminGetUserRequest struct {
	UserID string `path:"userId" description:"User identifier"`
}

AdminGetUserRequest binds the path for GET /admin/users/:userId.

type AdminGrantPlatformOwnerRequest

type AdminGrantPlatformOwnerRequest struct {
	UserID string `json:"user_id,omitempty" description:"User identifier (mutually exclusive with email)"`
	Email  string `json:"email,omitempty" description:"User email address (mutually exclusive with user_id)"`
}

AdminGrantPlatformOwnerRequest binds the body for POST /admin/platform/owners. Either user_id or email must be provided.

type AdminImpersonateRequest

type AdminImpersonateRequest struct {
	UserID string `path:"userId" description:"User identifier to impersonate"`
}

AdminImpersonateRequest binds the path for POST /admin/impersonate/:userId.

type AdminListServiceAccountsRequest

type AdminListServiceAccountsRequest struct {
	AppID  string `query:"app_id" description:"Application ID"`
	Limit  int    `query:"limit,omitempty" description:"Maximum number of results (default 20, max 100)"`
	Cursor string `query:"cursor,omitempty" description:"Pagination cursor"`
}

AdminListServiceAccountsRequest binds query params for GET /admin/service-accounts.

type AdminListUsersRequest

type AdminListUsersRequest struct {
	AppID  string `query:"app_id" description:"Application ID"`
	Email  string `query:"email" description:"Filter by email (partial match)" optional:"true"`
	Cursor string `query:"cursor" description:"Pagination cursor" optional:"true"`
	Limit  int    `query:"limit" description:"Maximum number of results (default 20, max 100)" default:"20" optional:"true"`
}

AdminListUsersRequest binds query params for GET /admin/users.

type AdminPlatformOwnerResponse

type AdminPlatformOwnerResponse struct {
	UserID string `json:"user_id"`
	RoleID string `json:"role_id"`
	Status string `json:"status"`
}

AdminPlatformOwnerResponse is returned by grant/revoke platform owner endpoints.

type AdminRevokePlatformOwnerRequest

type AdminRevokePlatformOwnerRequest struct {
	UserID string `path:"userID" description:"User identifier to revoke platform-owner role from"`
}

AdminRevokePlatformOwnerRequest binds the path for DELETE /admin/platform/owners/:userID.

type AdminServiceAccountAPIKeyResponse

type AdminServiceAccountAPIKeyResponse struct {
	ID              string     `json:"id"`
	Key             string     `json:"key"`
	KeyPrefix       string     `json:"key_prefix"`
	PublicKey       string     `json:"public_key,omitempty"`
	PublicKeyPrefix string     `json:"public_key_prefix,omitempty"`
	Name            string     `json:"name"`
	Scopes          []string   `json:"scopes,omitempty"`
	ExpiresAt       *time.Time `json:"expires_at,omitempty"`
	CreatedAt       time.Time  `json:"created_at"`
}

AdminServiceAccountAPIKeyResponse is the response when minting a service account API key.

type AdminServiceAccountListResponse

type AdminServiceAccountListResponse struct {
	ServiceAccounts []*AdminServiceAccountResponse `json:"service_accounts"`
	Total           int                            `json:"total"`
	NextCursor      string                         `json:"next_cursor,omitempty"`
}

AdminServiceAccountListResponse is the response for listing service accounts.

type AdminServiceAccountResponse

type AdminServiceAccountResponse struct {
	ID          string    `json:"id"`
	AppID       string    `json:"app_id"`
	Name        string    `json:"name"`
	Description string    `json:"description,omitempty"`
	Scopes      []string  `json:"scopes,omitempty"`
	Active      bool      `json:"active"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

AdminServiceAccountResponse is the JSON representation of a service account.

type AdminStatsRequest

type AdminStatsRequest struct {
	AppID string `query:"app_id" description:"Application ID"`
}

AdminStatsRequest is an empty request for GET /admin/stats.

type AdminStatsResponse

type AdminStatsResponse struct {
	TotalUsers int `json:"total_users" description:"Total number of users"`
}

AdminStatsResponse returns basic analytics for an app.

type AdminStopImpersonationRequest

type AdminStopImpersonationRequest struct{}

AdminStopImpersonationRequest is an empty request for POST /admin/impersonate/stop.

type AdminUnbanUserRequest

type AdminUnbanUserRequest struct {
	UserID string `path:"userId" description:"User identifier"`
}

AdminUnbanUserRequest binds the path for POST /admin/users/:userId/unban.

type AdminUnlockUserRequest

type AdminUnlockUserRequest struct {
	UserID string `path:"userId" description:"User identifier"`
}

AdminUnlockUserRequest binds the path for POST /admin/users/:userId/unlock.

type AdminUpdateUserRequest

type AdminUpdateUserRequest struct {
	UserID        string  `path:"userId" description:"User identifier"`
	FirstName     *string `json:"first_name,omitempty" description:"First/given name"`
	LastName      *string `json:"last_name,omitempty" description:"Last/family name"`
	Username      *string `json:"username,omitempty" description:"Unique username"`
	EmailVerified *bool   `json:"email_verified,omitempty" description:"Email verification status"`
}

AdminUpdateUserRequest binds path + body for PATCH /admin/users/:userId.

type AdminUserListResponse

type AdminUserListResponse struct {
	Users      any    `json:"users" description:"List of users"`
	NextCursor string `json:"next_cursor,omitempty" description:"Pagination cursor for next page"`
	Total      int    `json:"total" description:"Total number of matching users"`
}

AdminUserListResponse wraps a paginated list of users.

type AssignRoleRequest

type AssignRoleRequest struct {
	RoleID string `path:"roleId" description:"Role identifier"`
	UserID string `json:"user_id" description:"User identifier"`
	OrgID  string `json:"org_id,omitempty" description:"Optional organization scope"`
}

AssignRoleRequest binds path + body for POST /roles/:roleId/assign.

type AuthResponse

type AuthResponse struct {
	User         any    `json:"user" description:"User object"`
	SessionToken string `json:"session_token" description:"JWT session token"`
	RefreshToken string `json:"refresh_token" description:"Refresh token"`
	ExpiresAt    string `json:"expires_at" description:"Token expiration time"`
}

AuthResponse is the standard response for signup/signin.

type BulkImportUser

type BulkImportUser struct {
	Email        string        `json:"email" description:"User email address"`
	FirstName    string        `json:"first_name,omitempty" description:"First/given name"`
	LastName     string        `json:"last_name,omitempty" description:"Last/family name"`
	Username     string        `json:"username,omitempty" description:"Unique username"`
	PasswordHash string        `json:"password_hash" description:"Pre-hashed password (bcrypt or argon2id)"`
	Metadata     user.Metadata `json:"metadata,omitempty" description:"Arbitrary user metadata"`
}

BulkImportUser represents a single user in a bulk import request.

type BulkImportUsersRequest

type BulkImportUsersRequest struct {
	AppID string           `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	Users []BulkImportUser `json:"users" description:"Array of users to import (max 1000)"`
}

BulkImportUsersRequest binds the body for POST /admin/bulk/users/import.

type BulkRevokeSessionsRequest

type BulkRevokeSessionsRequest struct {
	UserID string `query:"user_id" description:"User ID whose sessions to revoke"`
}

BulkRevokeSessionsRequest binds query params for DELETE /admin/bulk/sessions.

type BulkRevokeSessionsResponse

type BulkRevokeSessionsResponse struct {
	Revoked int    `json:"revoked" description:"Number of sessions revoked"`
	UserID  string `json:"user_id" description:"User whose sessions were revoked"`
}

BulkRevokeSessionsResponse returns the result of a bulk session revocation.

type ChangePasswordRequest

type ChangePasswordRequest struct {
	CurrentPassword string `json:"current_password" description:"Current password"`
	NewPassword     string `json:"new_password" description:"New password"`
}

ChangePasswordRequest binds the body for POST /change-password.

type CloneEnvironmentRequest

type CloneEnvironmentRequest struct {
	EnvID              string                `path:"envId" description:"Source environment identifier"`
	Name               string                `json:"name" description:"Name for the cloned environment"`
	Slug               string                `json:"slug" description:"URL-safe slug for the cloned environment"`
	Type               string                `json:"type" description:"Environment type (development, staging, production)"`
	Description        string                `json:"description,omitempty" description:"Description for the cloned environment"`
	Settings           *environment.Settings `json:"settings,omitempty" description:"Settings overrides for the cloned environment"`
	WebhookURLOverride string                `json:"webhook_url_override,omitempty" description:"Override URL for cloned webhooks"`
}

CloneEnvironmentRequest binds path + body for POST /environments/:envId/clone.

type CloneEnvironmentResponse

type CloneEnvironmentResponse struct {
	Environment       any               `json:"environment" description:"Newly created environment"`
	RolesCloned       int               `json:"roles_cloned" description:"Number of roles cloned"`
	PermissionsCloned int               `json:"permissions_cloned" description:"Number of permissions cloned"`
	WebhooksCloned    int               `json:"webhooks_cloned" description:"Number of webhooks cloned"`
	RoleIDMap         map[string]string `json:"role_id_map" description:"Mapping of old role IDs to new role IDs"`
}

CloneEnvironmentResponse wraps the result of a clone operation.

type CreateEnvironmentRequest

type CreateEnvironmentRequest struct {
	AppID       string                `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	Name        string                `json:"name" description:"Environment name"`
	Slug        string                `json:"slug" description:"URL-safe environment slug"`
	Type        string                `json:"type" description:"Environment type (development, staging, production)"`
	Color       string                `json:"color,omitempty" description:"UI badge color (hex, defaults to type color)"`
	Description string                `json:"description,omitempty" description:"Environment description"`
	Settings    *environment.Settings `json:"settings,omitempty" description:"Per-environment settings overrides"`
}

CreateEnvironmentRequest binds the body for POST /environments.

type CreateRoleRequest

type CreateRoleRequest struct {
	AppID       string `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	Name        string `json:"name" description:"Role name"`
	Slug        string `json:"slug" description:"URL-safe role slug"`
	Description string `json:"description,omitempty" description:"Role description"`
	ParentID    string `json:"parent_id,omitempty" description:"Must be omitted; creating a role with a parent is refused with 400"`
}

CreateRoleRequest binds the body for POST /roles.

type CreateWebhookRequest

type CreateWebhookRequest struct {
	AppID  string   `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	URL    string   `json:"url" description:"Webhook endpoint URL"`
	Events []string `json:"events" description:"Event types to subscribe to"`
}

CreateWebhookRequest binds the body for POST /webhooks.

type CreateWebhookResponse

type CreateWebhookResponse struct {
	Webhook any    `json:"webhook" description:"The created webhook"`
	Secret  string `json:"secret" description:"Signing secret, shown only in this response"`
}

CreateWebhookResponse is the answer to POST /webhooks: the webhook and its signing secret, shown this once and never again. Store it with the receiver; a lost secret is replaced through the rotate-secret route.

type DefinitionGroup

type DefinitionGroup struct {
	Namespace   string                 `json:"namespace" description:"Plugin namespace"`
	Category    string                 `json:"category" description:"Settings category"`
	Definitions []*settings.Definition `json:"definitions" description:"Setting definitions in this group"`
}

DefinitionGroup groups definitions by namespace and category for display.

type DelegationListResponse

type DelegationListResponse struct {
	Delegations []DelegationResponse `json:"delegations"`
}

DelegationListResponse wraps a list of delegation grants.

type DelegationResponse

type DelegationResponse struct {
	ID        string   `json:"id"`
	Actor     string   `json:"actor" description:"kind:id of the principal that may act"`
	Subject   string   `json:"subject" description:"kind:id of the principal being acted for"`
	GrantKind string   `json:"grant_kind"`
	Scopes    []string `json:"scopes,omitempty"`
	GrantedBy string   `json:"granted_by" description:"kind:id of who consented to this grant"`
	ExpiresAt string   `json:"expires_at,omitempty" description:"RFC 3339; absent means no expiry"`
	CreatedAt string   `json:"created_at"`
}

DelegationResponse is the wire shape of one delegation grant.

type DeleteAccountRequest

type DeleteAccountRequest struct{}

DeleteAccountRequest is an empty request for DELETE /me (user from context).

type DeleteAppClientConfigRequest

type DeleteAppClientConfigRequest struct {
	AppID string `path:"appId" description:"Application identifier"`
}

DeleteAppClientConfigRequest binds the path for DELETE /admin/apps/:appId/client-config.

type DeleteAppSessionConfigRequest

type DeleteAppSessionConfigRequest struct {
	AppID string `path:"appId" description:"Application identifier"`
}

DeleteAppSessionConfigRequest binds the path for DELETE /admin/apps/:appId/session-config.

type DeleteDeviceRequest

type DeleteDeviceRequest struct {
	DeviceID string `path:"deviceId" description:"Device identifier"`
}

DeleteDeviceRequest binds the path for DELETE /devices/:deviceId.

type DeleteEnvironmentRequest

type DeleteEnvironmentRequest struct {
	EnvID string `path:"envId" description:"Environment identifier"`
}

DeleteEnvironmentRequest binds the path for DELETE /environments/:envId.

type DeleteRoleRequest

type DeleteRoleRequest struct {
	RoleID string `path:"roleId" description:"Role identifier"`
}

DeleteRoleRequest binds the path for DELETE /roles/:roleId.

type DeleteSettingRequest

type DeleteSettingRequest struct {
	Key     string `path:"key" description:"Setting key"`
	Scope   string `query:"scope" description:"Target scope (global, app, org, user)"`
	ScopeID string `query:"scope_id" description:"Entity ID at the target scope"`
}

DeleteSettingRequest binds the path + query for DELETE /admin/settings/values/:key.

type DeleteWebhookRequest

type DeleteWebhookRequest struct {
	WebhookID string `path:"webhookId" description:"Webhook identifier"`
}

DeleteWebhookRequest binds the path for DELETE /webhooks/:webhookId.

type DeviceListResponse

type DeviceListResponse struct {
	Devices any `json:"devices" description:"List of devices"`
}

DeviceListResponse wraps a list of devices.

type EnforceSettingRequest

type EnforceSettingRequest struct {
	Key     string          `path:"key" description:"Setting key"`
	Value   json.RawMessage `json:"value" description:"Setting value (JSON)"`
	Scope   string          `json:"scope" description:"Target scope (global, app, org, user)"`
	ScopeID string          `json:"scope_id,omitempty" description:"Entity ID at the target scope"`
	AppID   string          `json:"app_id,omitempty" description:"Application ID"`
	OrgID   string          `json:"org_id,omitempty" description:"Organization ID"`
}

EnforceSettingRequest binds the path + body for PUT /admin/settings/enforce/:key.

type EnvironmentListResponse

type EnvironmentListResponse struct {
	Environments any `json:"environments" description:"List of environments"`
	Total        int `json:"total" description:"Total number of environments"`
}

EnvironmentListResponse wraps a list of environments.

type EnvironmentSettingsResponse

type EnvironmentSettingsResponse struct {
	Settings     *environment.Settings `json:"settings" description:"Resolved effective settings"`
	TypeDefaults *environment.Settings `json:"type_defaults" description:"Default settings for the environment type"`
	Overrides    *environment.Settings `json:"overrides" description:"Per-environment overrides (nil fields inherit type defaults)"`
}

EnvironmentSettingsResponse returns resolved settings with breakdown.

type ExportDataRequest

type ExportDataRequest struct{}

ExportDataRequest is an empty request for GET /me/export (user from context).

type ForgotPasswordRequest

type ForgotPasswordRequest struct {
	AppID string `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	Email string `json:"email" description:"Email address of the account"`
}

ForgotPasswordRequest binds the body for POST /forgot-password.

type ForgotPasswordResponse

type ForgotPasswordResponse struct {
	Status string `json:"status" description:"Always 'ok' regardless of email existence"`
}

ForgotPasswordResponse is returned for forgot password requests. Intentionally sparse to avoid email enumeration.

type GetAppClientConfigRequest

type GetAppClientConfigRequest struct {
	AppID string `path:"appId" description:"Application identifier"`
}

GetAppClientConfigRequest binds the path for GET /admin/apps/:appId/client-config.

type GetAppSessionConfigRequest

type GetAppSessionConfigRequest struct {
	AppID string `path:"appId" description:"Application identifier"`
}

GetAppSessionConfigRequest binds the path for GET /admin/apps/:appId/session-config.

type GetClientConfigRequest

type GetClientConfigRequest struct {
	Key string `query:"key" optional:"true" description:"Publishable key to resolve the app"`
}

GetClientConfigRequest binds query params for GET /client-config.

type GetDeviceRequest

type GetDeviceRequest struct {
	DeviceID string `path:"deviceId" description:"Device identifier"`
}

GetDeviceRequest binds the path for GET /devices/:deviceId.

type GetEnvironmentRequest

type GetEnvironmentRequest struct {
	EnvID string `path:"envId" description:"Environment identifier"`
}

GetEnvironmentRequest binds the path for GET /environments/:envId.

type GetEnvironmentSettingsRequest

type GetEnvironmentSettingsRequest struct {
	EnvID string `path:"envId" description:"Environment identifier"`
}

GetEnvironmentSettingsRequest binds the path for GET /environments/:envId/settings.

type GetMeRequest

type GetMeRequest struct{}

GetMeRequest is an empty request for GET /me (user from context).

type GetRoleRequest

type GetRoleRequest struct {
	RoleID string `path:"roleId" description:"Role identifier"`
}

GetRoleRequest binds the path for GET /roles/:roleId.

type GetWebhookRequest

type GetWebhookRequest struct {
	WebhookID string `path:"webhookId" description:"Webhook identifier"`
}

GetWebhookRequest binds the path for GET /webhooks/:webhookId.

type HealthResponse

type HealthResponse struct {
	Status string `json:"status" description:"Service health status"`
	Error  string `json:"error,omitempty" description:"Error details if unhealthy"`
}

HealthResponse is the response for the health check endpoint.

type IntrospectConfirmation

type IntrospectConfirmation struct {
	JKT string `json:"jkt" description:"RFC 7638 thumbprint of the confirmation key"`
}

IntrospectConfirmation is the RFC 7800 cnf claim. Only the jkt member is used, holding the RFC 7638 thumbprint of the key the token is bound to.

type IntrospectRequest

type IntrospectRequest struct {
	Token string `json:"token" description:"Token to introspect (JWT or opaque session token)"`
}

IntrospectRequest binds the body for POST /v1/introspect.

type IntrospectResponse

type IntrospectResponse struct {
	Active    bool            `json:"active" description:"Whether the token is valid and active"`
	UserID    string          `json:"user_id,omitempty" description:"Authenticated user ID"`
	AppID     string          `json:"app_id,omitempty" description:"Application ID"`
	OrgID     string          `json:"org_id,omitempty" description:"Organization ID"`
	EnvID     string          `json:"env_id,omitempty" description:"Environment ID"`
	SessionID string          `json:"session_id,omitempty" description:"Session ID"`
	ExpiresAt string          `json:"expires_at,omitempty" description:"Token expiration time (RFC 3339)"`
	Audience  []string        `json:"aud,omitempty" description:"Resource identifiers this token is valid for (RFC 8707)"`
	Scope     string          `json:"scope,omitempty" description:"Space-separated scopes the token was issued with"`
	User      *IntrospectUser `json:"user,omitempty" description:"Resolved user details (callers with manage on app only)"`

	// Confirmation carries the RFC 7800 cnf claim for a DPoP-bound token
	// (RFC 9449 section 7.3). A resource server that validates tokens by
	// introspection has no other way to learn the token is bound, so
	// omitting this leaves it accepting a stolen token as an ordinary
	// bearer token. Absent means unbound.
	Confirmation *IntrospectConfirmation `json:"cnf,omitempty" description:"Proof-of-possession confirmation for a DPoP-bound token"`
}

IntrospectResponse is the token introspection result. When the token is invalid or expired, Active is false and all other fields are empty. When valid, it contains the resolved identity claims.

type IntrospectUser

type IntrospectUser struct {
	ID        string `json:"id" description:"User ID"`
	Email     string `json:"email" description:"User email"`
	FirstName string `json:"first_name,omitempty" description:"First name"`
	LastName  string `json:"last_name,omitempty" description:"Last name"`
	Username  string `json:"username,omitempty" description:"Username"`
}

IntrospectUser holds basic user details returned by introspection.

type JWK

type JWK struct {
	KTY string `json:"kty"`
	Use string `json:"use"`
	KID string `json:"kid,omitempty"`
	ALG string `json:"alg,omitempty"`
	N   string `json:"n,omitempty"`   // RSA modulus
	E   string `json:"e,omitempty"`   // RSA exponent
	CRV string `json:"crv,omitempty"` // EC curve
	X   string `json:"x,omitempty"`   // EC x coordinate
	Y   string `json:"y,omitempty"`   // EC y coordinate
}

JWK represents a single JSON Web Key.

type JWKSResponse

type JWKSResponse struct {
	Keys []JWK `json:"keys"`
}

JWKSResponse is the JSON Web Key Set response.

type ListAuthMethodsRequest

type ListAuthMethodsRequest struct{}

ListAuthMethodsRequest is the (empty) request for listing auth methods.

type ListAuthMethodsResponse

type ListAuthMethodsResponse struct {
	Methods []*plugin.AuthMethod `json:"methods"`
}

ListAuthMethodsResponse contains all auth methods linked to the current user.

type ListDefinitionsResponse

type ListDefinitionsResponse struct {
	Groups []DefinitionGroup `json:"groups" description:"Definitions grouped by namespace and category"`
	Total  int               `json:"total" description:"Total number of definitions"`
}

ListDefinitionsResponse wraps grouped definitions.

type ListDevicesRequest

type ListDevicesRequest struct{}

ListDevicesRequest is an empty request for GET /devices (user from context).

type ListEnvironmentsRequest

type ListEnvironmentsRequest struct {
	AppID string `query:"app_id" description:"Application ID"`
}

ListEnvironmentsRequest binds query params for GET /environments.

type ListNamespaceDefinitionsRequest

type ListNamespaceDefinitionsRequest struct {
	Namespace string `path:"namespace" description:"Plugin namespace"`
}

ListNamespaceDefinitionsRequest binds the path for GET /admin/settings/definitions/:namespace.

type ListRolePermissionsRequest

type ListRolePermissionsRequest struct {
	RoleID string `path:"roleId" description:"Role identifier"`
}

ListRolePermissionsRequest binds the path for GET /roles/:roleId/permissions.

type ListRolesRequest

type ListRolesRequest struct {
	AppID string `query:"app_id" description:"Application ID"`
}

ListRolesRequest binds query params for GET /roles.

type ListSessionsRequest

type ListSessionsRequest struct {
	Limit  int    `query:"limit" description:"Page size (default 50, max 200)" optional:"true"`
	Cursor string `query:"cursor" description:"Cursor from the previous page's next_cursor" optional:"true"`
}

ListSessionsRequest binds the paging query params for GET /sessions (user from context).

type ListSettingsDefinitionsRequest

type ListSettingsDefinitionsRequest struct {
	Namespace string `query:"namespace" description:"Filter by plugin namespace"`
	Category  string `query:"category" description:"Filter by category"`
}

ListSettingsDefinitionsRequest binds query params for GET /admin/settings/definitions.

type ListUserRolesRequest

type ListUserRolesRequest struct {
	UserID string `path:"userId" description:"User identifier"`
	AppID  string `query:"app_id" description:"Optional app scope; defaults to the platform app" optional:"true"`
}

ListUserRolesRequest binds path + query for GET /users/:userId/roles. AppID is optional — when set the listing scopes to that app instead of the engine's platform app. Cross-app admin clients (e.g. TwinOS studio, where roles live in per-workspace apps but the calling API key authenticates against the platform app) MUST pass app_id; without it the engine queries the wrong tenant and returns an empty list.

type ListWebhooksRequest

type ListWebhooksRequest struct {
	AppID string `query:"app_id" description:"Application ID"`
}

ListWebhooksRequest binds query params for GET /webhooks.

type Manifest

type Manifest map[string]any

Manifest is the discovery document served at the API root: version, base path, endpoint list, and the platform app identifiers when there is a platform app to report.

type MeResponse

type MeResponse struct {
	*user.User

	// Roles are the slugs the user holds in the session's app right now.
	// Read live rather than off the session: a role change re-stamps every
	// live session (Engine.restampUserSessions), so the two agree, and the
	// live list is the one a client can rely on straight after a change.
	Roles []string `json:"roles"`
}

MeResponse is the authenticated user plus the roles their session carries.

user.User is embedded rather than nested, so every field this endpoint already returned keeps its place at the top level of the JSON and existing consumers see no change. Roles is the addition.

A generated client needs the principal before its capability surface can answer anything: canCall reads from whatever was last handed to setPrincipal, and until this endpoint returned roles, every caller had to assemble them from the admin role-listing endpoints by hand.

type MintChildRequest

type MintChildRequest struct {
	ID         string   `path:"id" description:"The calling parent principal's own ID"`
	Name       string   `json:"name" description:"Name for the ephemeral child"`
	Scopes     []string `json:"scopes,omitempty" description:"Scopes for the child; must be a subset of the parent's own scopes"`
	TTLSeconds int      `json:"ttl_seconds" description:"How long the child may live, in seconds. Capped by the parent's own expiry, if it has one"`
}

MintChildRequest binds the path + body for POST /principals/:id/children. ID is the calling principal's own id: a parent may only mint children under itself, and the handler checks that against the authenticated caller rather than trusting this field for anything but routing.

type MintChildResponse

type MintChildResponse struct {
	ID        string     `json:"id"`
	ParentID  string     `json:"parent_id"`
	Name      string     `json:"name"`
	Scopes    []string   `json:"scopes,omitempty"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
	Key       string     `json:"key" description:"Plaintext API key secret; returned once and never stored"`
	KeyPrefix string     `json:"key_prefix"`
	CreatedAt time.Time  `json:"created_at"`
}

MintChildResponse is the wire shape of a newly minted ephemeral child principal, including its one-time credential.

type OpenAPIDocument

type OpenAPIDocument map[string]any

OpenAPIDocument is the OpenAPI spec this API serves for itself.

type PermissionListResponse

type PermissionListResponse struct {
	Permissions any `json:"permissions" description:"List of permissions"`
}

PermissionListResponse wraps a list of permissions.

type RefreshRequest

type RefreshRequest struct {
	RefreshToken string `` /* 135-byte string literal not displayed */
}

RefreshRequest binds the body for POST /refresh. The token is optional at the binding layer: a request with a valid session cookie can refresh without one (the handler falls back to the cookie). Absence of both is rejected there.

type RemovePermissionRequest

type RemovePermissionRequest struct {
	RoleID       string `path:"roleId" description:"Role identifier"`
	PermissionID string `path:"permissionId" description:"Permission identifier"`
}

RemovePermissionRequest binds the path for DELETE /roles/:roleId/permissions/:permissionId.

type ResendVerificationRequest

type ResendVerificationRequest struct {
	AppID string `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	Email string `json:"email" description:"Email address of the account requesting a fresh verification token"`
}

ResendVerificationRequest binds the body for POST /verify-email/resend.

The endpoint always returns 200 — caller cannot tell whether the email is registered or already verified — so this struct deliberately has no hard-required fields. An empty body is accepted (and silently no-ops).

type ResetPasswordRequest

type ResetPasswordRequest struct {
	Token       string `json:"token" description:"Password reset token"`
	NewPassword string `json:"new_password" description:"New password"`
}

ResetPasswordRequest binds the body for POST /reset-password.

type ResolveSettingRequest

type ResolveSettingRequest struct {
	Key    string `path:"key" description:"Setting key (e.g. password.min_length)"`
	AppID  string `query:"app_id" description:"Application ID for scope context"`
	OrgID  string `query:"org_id" description:"Organization ID for scope context"`
	UserID string `query:"user_id" description:"User ID for scope context"`
}

ResolveSettingRequest binds the path + query for GET /admin/settings/resolve/:key.

type ResolveSettingsRequest

type ResolveSettingsRequest struct {
	Namespace string `query:"namespace" description:"Filter by plugin namespace"`
	AppID     string `query:"app_id" description:"Application ID for scope context"`
	OrgID     string `query:"org_id" description:"Organization ID for scope context"`
	UserID    string `query:"user_id" description:"User ID for scope context"`
}

ResolveSettingsRequest binds query params for GET /admin/settings/resolve.

type ResolvedSettingResponse

type ResolvedSettingResponse struct {
	Setting *settings.ResolvedSetting `json:"setting" description:"Resolved setting with scope cascade details"`
}

ResolvedSettingResponse wraps a single resolved setting.

type ResolvedSettingsResponse

type ResolvedSettingsResponse struct {
	Settings []*settings.ResolvedSetting `json:"settings" description:"Resolved settings with scope cascade details"`
}

ResolvedSettingsResponse wraps resolved settings with full cascade details.

type RevokeOtherSessionsRequest

type RevokeOtherSessionsRequest struct{}

RevokeOtherSessionsRequest binds DELETE /sessions, which takes no input.

type RevokeSessionRequest

type RevokeSessionRequest struct {
	SessionID string `path:"sessionId" description:"Session identifier"`
}

RevokeSessionRequest binds the path for DELETE /sessions/:sessionId.

type RoleListResponse

type RoleListResponse struct {
	Roles any `json:"roles" description:"List of roles"`
}

RoleListResponse wraps a list of roles.

type RotateWebhookSecretRequest

type RotateWebhookSecretRequest struct {
	WebhookID string `path:"webhookId" description:"Webhook identifier"`
}

RotateWebhookSecretRequest binds the path for POST /webhooks/:webhookId/rotate-secret.

type RotateWebhookSecretResponse

type RotateWebhookSecretResponse struct {
	Secret string `json:"secret" description:"New signing secret, shown only in this response"`
}

RotateWebhookSecretResponse carries the new signing secret, shown once. Deliveries are signed with it from this moment; the old secret stops verifying at once.

type SessionListResponse

type SessionListResponse struct {
	Sessions any `json:"sessions" description:"List of sessions"`
	// NextCursor is set when more remain; pass it as cursor to continue.
	NextCursor string `json:"next_cursor,omitempty" description:"Cursor for the next page, absent on the last"`
}

SessionListResponse wraps a list of sessions.

type SetAppClientConfigRequest

type SetAppClientConfigRequest struct {
	AppID                    string   `path:"appId" description:"Application identifier"`
	SignupEnabled            *bool    `json:"signup_enabled,omitempty" description:"Enable new user signup (nil = enabled by default)"`
	PasswordEnabled          *bool    `json:"password_enabled,omitempty" description:"Enable password auth (nil = inherit)"`
	PasskeyEnabled           *bool    `json:"passkey_enabled,omitempty" description:"Enable passkey auth (nil = inherit)"`
	MagicLinkEnabled         *bool    `json:"magic_link_enabled,omitempty" description:"Enable magic link auth (nil = inherit)"`
	MFAEnabled               *bool    `json:"mfa_enabled,omitempty" description:"Enable MFA (nil = inherit)"`
	MFARequired              *bool    `json:"mfa_required,omitempty" description:"Require MFA on every sign-in (nil = false)"`
	SSOEnabled               *bool    `json:"sso_enabled,omitempty" description:"Enable SSO (nil = inherit)"`
	SocialEnabled            *bool    `json:"social_enabled,omitempty" description:"Enable social auth (nil = inherit)"`
	WaitlistEnabled          *bool    `json:"waitlist_enabled,omitempty" description:"Enable waitlist (nil = inherit)"`
	RequireEmailVerification *bool    `json:"require_email_verification,omitempty" description:"Block sign-in until email is verified (nil = inherit)"`
	SocialProviders          []string `json:"social_providers,omitempty" description:"Allowed social providers"`
	MFAMethods               []string `json:"mfa_methods,omitempty" description:"Allowed MFA methods"`
	AppName                  *string  `json:"app_name,omitempty" description:"Branding app name override"`
	LogoURL                  *string  `json:"logo_url,omitempty" description:"Branding logo URL override"`
}

SetAppClientConfigRequest binds the path + body for PUT /admin/apps/:appId/client-config.

type SetAppSessionConfigRequest

type SetAppSessionConfigRequest struct {
	AppID                   string `path:"appId" description:"Application identifier"`
	TokenTTLSeconds         *int   `json:"token_ttl_seconds,omitempty" description:"Token TTL in seconds (nil = inherit)"`
	RefreshTokenTTLSeconds  *int   `json:"refresh_token_ttl_seconds,omitempty" description:"Refresh token TTL in seconds (nil = inherit)"`
	TokenExchangeTTLSeconds *int   `json:"token_exchange_ttl_seconds,omitempty" description:"RFC 8693 token exchange TTL in seconds (nil = inherit)"`
	MaxActiveSessions       *int   `json:"max_active_sessions,omitempty" description:"Maximum active sessions per user (nil = inherit)"`
	RotateRefreshToken      *bool  `json:"rotate_refresh_token,omitempty" description:"Rotate refresh token on use (nil = inherit)"`
	BindToIP                *bool  `json:"bind_to_ip,omitempty" description:"Bind sessions to IP address (nil = inherit)"`
	BindToDevice            *bool  `json:"bind_to_device,omitempty" description:"Bind sessions to device (nil = inherit)"`
	TokenFormat             string `json:"token_format,omitempty" description:"Token format: opaque or jwt (empty = inherit)"`
}

SetAppSessionConfigRequest binds the path and body for PUT /admin/apps/:appId/session-config.

type SetDefaultEnvironmentRequest

type SetDefaultEnvironmentRequest struct {
	EnvID string `path:"envId" description:"Environment identifier"`
}

SetDefaultEnvironmentRequest binds the path for POST /environments/:envId/set-default.

type SetSettingRequest

type SetSettingRequest struct {
	Key     string          `path:"key" description:"Setting key"`
	Value   json.RawMessage `json:"value" description:"Setting value (JSON)"`
	Scope   string          `json:"scope" description:"Target scope (global, app, org, user)"`
	ScopeID string          `json:"scope_id,omitempty" description:"Entity ID at the target scope"`
	AppID   string          `json:"app_id,omitempty" description:"Application ID"`
	OrgID   string          `json:"org_id,omitempty" description:"Organization ID"`
}

SetSettingRequest binds the path + body for PUT /admin/settings/values/:key.

type SettingValueResponse

type SettingValueResponse struct {
	Key     string          `json:"key" description:"Setting key"`
	Value   json.RawMessage `json:"value" description:"Setting value"`
	Scope   string          `json:"scope" description:"Scope where the value was set"`
	ScopeID string          `json:"scope_id,omitempty" description:"Scope entity ID"`
	Status  string          `json:"status" description:"Operation status"`
}

SettingValueResponse wraps a setting write result.

type SignInRequest

type SignInRequest struct {
	AppID        string `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	Email        string `json:"email,omitempty" description:"User email address"`
	Username     string `json:"username,omitempty" description:"Username (alternative to email)"`
	Password     string `json:"password" description:"User password"`
	CaptchaToken string `` /* 213-byte string literal not displayed */
}

SignInRequest binds the body for POST /signin.

type SignOutRequest

type SignOutRequest struct{}

SignOutRequest is an empty request for POST /signout (session from context).

type SignUpRequest

type SignUpRequest struct {
	AppID        string            `json:"app_id,omitempty" description:"Application ID (optional, uses default)"`
	Email        string            `json:"email" description:"User email address"`
	Password     string            `json:"password" description:"User password"`
	FirstName    string            `json:"first_name,omitempty" description:"First/given name"`
	LastName     string            `json:"last_name,omitempty" description:"Last/family name"`
	Username     string            `json:"username,omitempty" description:"Unique username"`
	Metadata     map[string]string `json:"metadata,omitempty" description:"Custom signup form field values"`
	CaptchaToken string            `` /* 213-byte string literal not displayed */
}

SignUpRequest binds the body for POST /signup.

type StatusResponse

type StatusResponse struct {
	Status string `json:"status" description:"Operation status"`
}

StatusResponse is a generic status response.

type SwitchOrgRequest

type SwitchOrgRequest struct {
	OrgID string `json:"org_id" description:"Organization ID to activate; empty to clear"`
}

SwitchOrgRequest binds the body for POST /me/switch-org. An empty org_id clears the active organization on the session (legitimate "leave org" flow without logging out).

type SwitchOrgResponse

type SwitchOrgResponse struct {
	SessionID string `json:"session_id"`
	OrgID     string `json:"org_id,omitempty"`
}

SwitchOrgResponse is the body returned by POST /me/switch-org.

type TokenExchangeRequest

type TokenExchangeRequest struct {
	Subject string   `json:"subject" description:"User ID the exchanged session should act on behalf of"`
	Scopes  []string `` /* 180-byte string literal not displayed */
}

TokenExchangeRequest binds the body for POST /token/exchange, an RFC 8693 shaped grant_type=token-exchange call scoped to this engine's own delegation grants. The caller's own credential (resolved from the request's auth, not carried in the body) is the RFC's subject_token; Subject here is the RFC's requested actor target.

type TokenExchangeResponse

type TokenExchangeResponse struct {
	AccessToken     string   `json:"access_token" description:"The exchanged session token"`
	IssuedTokenType string   `json:"issued_token_type" description:"RFC 8693 token type URN"`
	TokenType       string   `json:"token_type" description:"Always \"Bearer\""`
	ExpiresIn       int64    `json:"expires_in" description:"Seconds until the exchanged token expires"`
	Scopes          []string `json:"scopes,omitempty" description:"Scopes granted on the exchanged session"`
	Subject         string   `json:"subject" description:"The principal this session acts for"`
	Actor           string   `json:"actor" description:"The principal exercising the delegation"`
}

TokenExchangeResponse is the RFC 8693 (section 2.2.1) shaped response for a successful exchange.

type TokenResponse

type TokenResponse struct {
	SessionToken string `json:"session_token" description:"New session token"`
	RefreshToken string `json:"refresh_token" description:"New refresh token"`
	ExpiresAt    string `json:"expires_at" description:"Token expiration time"`
}

TokenResponse is the response for token refresh.

type TrustDeviceRequest

type TrustDeviceRequest struct {
	DeviceID string `path:"deviceId" description:"Device identifier"`
}

TrustDeviceRequest binds the path for PATCH /devices/:deviceId/trust.

type UnassignRoleRequest

type UnassignRoleRequest struct {
	RoleID string `path:"roleId" description:"Role identifier"`
	UserID string `json:"user_id" description:"User identifier"`
}

UnassignRoleRequest binds path + body for POST /roles/:roleId/unassign.

type UnenforceSettingRequest

type UnenforceSettingRequest struct {
	Key     string `path:"key" description:"Setting key"`
	Scope   string `query:"scope" description:"Target scope (global, app, org, user)"`
	ScopeID string `query:"scope_id" description:"Entity ID at the target scope"`
}

UnenforceSettingRequest binds the path + query for DELETE /admin/settings/enforce/:key.

type UnlinkAuthMethodRequest

type UnlinkAuthMethodRequest struct {
	Provider string `path:"provider" description:"Auth method provider (password, google, ...)"`
}

UnlinkAuthMethodRequest carries the provider name to unlink.

type UnlinkAuthMethodResponse

type UnlinkAuthMethodResponse struct {
	Status string `json:"status"`
}

UnlinkAuthMethodResponse confirms the unlink operation.

type UpdateEnvironmentRequest

type UpdateEnvironmentRequest struct {
	EnvID       string  `path:"envId" description:"Environment identifier"`
	Name        *string `json:"name,omitempty" description:"Environment name"`
	Description *string `json:"description,omitempty" description:"Environment description"`
	Color       *string `json:"color,omitempty" description:"UI badge color (hex)"`
}

UpdateEnvironmentRequest binds path + body for PATCH /environments/:envId.

type UpdateEnvironmentSettingsRequest

type UpdateEnvironmentSettingsRequest struct {
	EnvID string `path:"envId" description:"Environment identifier"`
	environment.Settings
}

UpdateEnvironmentSettingsRequest binds path + body for PATCH /environments/:envId/settings.

type UpdateMeRequest

type UpdateMeRequest struct {
	FirstName *string `json:"first_name,omitempty" description:"First/given name"`
	LastName  *string `json:"last_name,omitempty" description:"Last/family name"`
	Image     *string `json:"image,omitempty" description:"Profile image URL"`
	Username  *string `json:"username,omitempty" description:"Unique username"`
}

UpdateMeRequest binds the body for PATCH /me.

type UpdateRoleRequest

type UpdateRoleRequest struct {
	RoleID      string  `path:"roleId" description:"Role identifier"`
	Name        *string `json:"name,omitempty" description:"Role name"`
	Description *string `json:"description,omitempty" description:"Role description"`
	ParentID    *string `json:"parent_id,omitempty" description:"Must be omitted or equal the role's current parent; re-parenting is refused with 400"`
}

UpdateRoleRequest binds path + body for PATCH /roles/:roleId.

type UpdateWebhookRequest

type UpdateWebhookRequest struct {
	WebhookID string   `path:"webhookId" description:"Webhook identifier"`
	URL       *string  `json:"url,omitempty" description:"Webhook endpoint URL"`
	Events    []string `json:"events,omitempty" description:"Event types to subscribe to"`
	Active    *bool    `json:"active,omitempty" description:"Whether the webhook is active"`
}

UpdateWebhookRequest binds path + body for PATCH /webhooks/:webhookId.

type UserDataExport

type UserDataExport map[string]any

UserDataExport is everything held about one user, assembled at export time. The keys follow whatever the engine has stored, so they are not fixed here.

type UserRoleListResponse

type UserRoleListResponse struct {
	Roles any `json:"roles" description:"List of roles assigned to the user"`
}

UserRoleListResponse wraps a list of roles for a user.

type VerifyEmailRequest

type VerifyEmailRequest struct {
	Code  string `json:"code,omitempty" description:"6-digit OTP code (verifies the authenticated user's email)"`
	Token string `json:"token,omitempty" description:"Email verification token (link-based flows)"`
	// Email scopes an OTP code to a specific user when the request is not
	// authenticated (e.g. cross-origin signup where the session cookie is not
	// carried). The code is still verified against that user's active
	// verification with per-user attempt limiting, so it is not brute-forceable.
	// Enables auto-login: on success a fresh session is issued and returned.
	Email string `json:"email,omitempty" description:"Email to scope the OTP code to when unauthenticated (enables auto-login)"`
	AppID string `json:"app_id,omitempty" description:"App ID (optional; resolved from publishable key when omitted)"`
}

VerifyEmailRequest binds the body for POST /verify-email.

Two modes are supported:

  • Code: the 6-digit OTP emailed to the user. Verifies the email of the authenticated session user (the account just created at signup).
  • Token: a long verification token (link-based flows, e.g. magic link).

type WebhookListResponse

type WebhookListResponse struct {
	Webhooks any `json:"webhooks" description:"List of webhooks"`
}

WebhookListResponse wraps a list of webhooks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL