resource-tokens

Create Resource Token

Create a new resource token.

Issue #242: Owner-only access. Returns plaintext token ONLY once. Issue #276: Uses WorkspaceOwner dependency for DRY principle.

The token cap is the WORKSPACE's (#1919): the count of active, non-connector tokens of the workspace — whoever minted them — must be under the plan's max_resource_tokens. It used to be counted per creator, while the quota ceiling on PATCH was summed per workspace, so two owners could each mint a full set and leave the workspace with no quota raise that fitted. The population is the ceiling's (auth.resource_tokens.workspace_regular_active_tokens); the sum itself is not checked here because count <= cap and quota <= 10000 per token already keep it at or under max_resource_tokens * 10000.

Args: data: Token creation request owner: Workspace owner (user_id, workspace_id) from dependency manager: ResourceTokenManager instance db: Database session

Returns: Token metadata + plaintext token (shown ONLY once)

Raises: 400: Invalid resource_id 403: Not workspace owner, plan without the feature, or the workspace is at its token cap (QUOTA-001) 500: Failed to create token

post/api/v1/resource-tokens

Request

  • Base URL: https://memory.kagura-ai.com (the document declares no server; this is the origin it was published from)
  • URL: https://memory.kagura-ai.com/api/v1/resource-tokens
  • Auth: none declared

Headers

authorizationstring nullable

Request body

resource_idstring required

Resource identifier this token is scoped to

descriptionstring nullable

Human-readable description

quota_events_per_hourinteger

Event ingestion quota per hour (default: 1000)

Response

Successful Response

idunknown required
resource_idunknown required
descriptionunknown
quota_events_per_hourunknown required
created_byunknown
created_atunknown required
last_used_atunknown
is_activeunknown required
statusunknown required
tokenunknown required

Changes

No recorded changes to this operation across all 2 revisions of this API.