openapi: '3.0.3' info: version: 1.0.0 title: Agent Factory API description: | Public REST API for the Agent Factory workspace - agents, conversations, messages, tools, artifacts, sharing, ratings, and discovery. Powered by Prisme.ai's runtime; all endpoints are exposed under each workspace's webhook namespace. contact: name: Prisme.ai url: https://prisme.ai servers: - url: https://{host}/v2/workspaces/slug:agent-factory/webhooks description: Prisme.ai workspace webhooks variables: host: default: api.studio.prisme.ai description: API host (override for self-hosted or sandbox) security: - BearerAuth: [] - OrgApiKeyAuth: [] tags: - name: Agents description: Agent CRUD, discovery, AGENTS.md import/export. - name: Access description: Agent access bindings, sharing, and access requests. - name: ApiKeys description: Agent-scoped API key management (mint, revoke, rotate). - name: Publishing description: Publish or discard draft changes on an agent. - name: Ratings description: User ratings on published agents. - name: Profiles description: Agent profiles/presets catalog (simple, workflow, agent_light, agent_full, orchestrator). - name: Activity description: Activity feed for agents (events, errors, lifecycle changes). - name: Analytics description: Agent usage analytics (series + summary). - name: Conversations description: Conversations on an agent (CRUD, archive, star). - name: Messages description: Send messages to an agent (synchronous send + SSE stream). - name: Tasks description: Async task lifecycle (list, fetch, cancel, resolve, subscribe). - name: Artifacts description: Generated artifacts (files, code, content) attached to a task. - name: Shares description: Conversation, message, and artifact share-link snapshots. - name: A2A description: Agent-to-agent JSON-RPC 2.0 gateway (well-known agent.json + RPC). - name: Tools description: Per-agent tool catalogue (system tools, MCP servers, function tools). - name: Retention description: Per-agent and org-wide conversation retention policies. - name: Traces description: Execution traces of agent turns (editor debugging, `agent-factory:traces:read`). - name: Evaluations description: Agent evaluation runs and results. - name: Push description: Mobile device registration for push notifications. - name: Admin description: | GDPR operations called by the AI Insights admin screens. They require elevated permissions: the caller must be a platform administrator (`platformRole` `superadmin` or `root`). The export route also lets a user export their own data. Each route is rate limited to 10 calls per hour per caller. paths: /v1/profiles: get: tags: [Profiles] operationId: listProfiles summary: List available agent profiles (presets) description: | Returns the catalog of agent profiles (`simple`, `workflow`, `agent_light`, `agent_full`, `orchestrator`) with their feature flags, limits, and recommended use cases. responses: '200': description: Catalog of agent profiles. content: application/json: schema: $ref: '#/components/schemas/ProfileListResponse' '400': description: Invalid arguments. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only GET is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/activity: get: tags: [Activity] operationId: getActivity summary: Get the activity feed for an agent description: | Activity feed of agent interactions, errors, lifecycle and config changes, conversations, artifacts, ratings, access changes, and share events. Backed by Elasticsearch. parameters: - name: agent_id in: query required: true schema: type: string maxLength: 64 description: Agent identifier (required). - name: groups in: query required: false schema: type: string maxLength: 256 description: Comma-separated list of activity groups (`message`, `error`, `agent_lifecycle`, `conversation`, `artifact`, `rating`, `access`, `share`). - name: since in: query required: false schema: type: string maxLength: 64 description: ISO timestamp lower bound. - name: until in: query required: false schema: type: string maxLength: 64 description: ISO timestamp upper bound. - name: correlationId in: query required: false schema: type: string maxLength: 128 description: Filter by correlationId to trace a single workflow. - name: limit in: query required: false schema: type: string description: Page size (default 25). - name: page in: query required: false schema: type: string description: Page number (1-indexed, default 1). responses: '200': description: Page of activity items. content: application/json: schema: $ref: '#/components/schemas/ActivityListResponse' '400': description: Missing `agent_id` or invalid arguments. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only GET is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/analytics: get: tags: [Analytics] operationId: getAgentAnalytics summary: Get analytics (series + summary) for an agent description: | Returns metrics series and an aggregated summary for a single agent. Series is read from Mongo; summary is cached and recomputed from Elasticsearch on miss/stale (custom date ranges always recompute). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: period in: query required: false schema: type: string maxLength: 16 enum: [15m, 30m, 1h, 1d, 7d, 30d, 90d] description: Preset period. Default `30d`. - name: start in: query required: false schema: type: string maxLength: 64 description: ISO start (custom range). Overrides `period`. - name: end in: query required: false schema: type: string maxLength: 64 description: ISO end (custom range, exclusive). - name: granularity in: query required: false schema: type: string maxLength: 16 enum: [5m, hourly, daily] description: Override granularity (auto-picked from period otherwise). responses: '200': description: Analytics payload. content: application/json: schema: $ref: '#/components/schemas/AgentAnalytics' '400': description: Invalid arguments. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents: get: tags: [Agents] operationId: listAgents summary: List agents description: | List agents with multi-scope filter. Supported scopes (comma-separated): `own`, `shared`, `published`, `all`. Default `own`. The reserved action `?action=explore` returns all public+restricted published agents in the caller's organization. The `shared` scope also lists agents with no published version that were explicitly shared with the caller, served as their draft at the role the share carries. An agent from another organization is listed under `shared` only when someone else created it and shared it with the caller; agents the caller created in another organization stay in that organization's lists. parameters: - name: scope in: query required: false schema: type: string maxLength: 64 description: Comma-separated list (`own`, `shared`, `published`, `all`). - name: action in: query required: false schema: type: string maxLength: 32 enum: [explore, write] description: Reserved action (`explore` for store-style discovery, `write` to filter to writable scope). - name: status in: query required: false schema: type: string maxLength: 32 - name: category in: query required: false schema: type: string maxLength: 128 - name: search in: query required: false schema: type: string maxLength: 200 - name: sort in: query required: false schema: type: string maxLength: 32 enum: [updatedAt, createdAt] - name: limit in: query required: false schema: type: string description: Page size (max 100, default 20). - name: page in: query required: false schema: type: string description: 1-indexed page number. - name: last_message_before in: query required: false schema: type: string maxLength: 32 description: Inactive filter - agents with no message since this date (never-used agents included). - name: last_message_after in: query required: false schema: type: string maxLength: 32 description: Active filter - agents with a message at or after this date (never-used agents excluded). responses: '200': description: Page of agents (with `published_config` stripped on list rows). content: application/json: schema: $ref: '#/components/schemas/AgentListResponse' '400': description: Invalid arguments. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' post: tags: [Agents] operationId: createAgent summary: Create a new agent description: | Create a new agent in the caller's organization. The agent starts in `draft` status and `private` visibility. A service account is provisioned automatically; failure to provision rolls back the creation. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AgentCreateInput' example: name: Test Agent description: Agent created by automated test instructions: You are a helpful test assistant. model: gpt-4o-mini temperature: 0.7 responses: '200': description: Agent created. content: application/json: schema: $ref: '#/components/schemas/AgentCreateResponse' '400': description: Validation error (e.g. missing `instructions`, too many sub_agents/starters). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' '502': description: Service account provisioning failed (agent record rolled back). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}: get: tags: [Agents] operationId: getAgent summary: Get a single agent by ID description: | Returns the agent record. Owners see the full record (including `published_config`). Non-owners with binding receive the record with `published_config` stripped. Restricted agents seen by callers without binding return only public-facing fields. An agent with no published version is served (as its draft) to its editors and to callers it was explicitly shared with; anyone else gets 404. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Agent record. content: application/json: schema: $ref: '#/components/schemas/Agent' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found, or the agent has no published version and the caller is neither an editor nor an explicit grantee. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' patch: tags: [Agents] operationId: updateAgent summary: Update an agent (partial update) description: | Partially update agent fields. Setting `status: draft` clears the `published_config` snapshot. If the agent is `published`, `has_draft_changes` is automatically set to `true`. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AgentUpdateInput' example: description: Updated description by test temperature: 0.5 responses: '200': description: Updated agent record. content: application/json: schema: $ref: '#/components/schemas/Agent' '400': description: Validation error (invalid visibility, status, sub_agents, starters, etc.). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' delete: tags: [Agents] operationId: deleteAgent summary: Delete an agent and its associated data description: | Cascading delete: removes IAM service account, conversations, tasks, access bindings, artifact versions, artifacts, ratings, agent metrics, shares, and retention policy. Cross-workspace storage cleanup runs best-effort. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Agent deleted. content: application/json: schema: $ref: '#/components/schemas/DeletedResult' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/discovery: get: tags: [Agents] operationId: discoverAgents summary: Get featured agents and categories description: | Discovery endpoint for the store homepage. Returns up to 10 featured published agents (sorted by rating), and the list of distinct categories with counts. responses: '200': description: Featured agents + categories. content: application/json: schema: $ref: '#/components/schemas/DiscoveryResponse' '400': description: Invalid arguments. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/import: post: tags: [Agents] operationId: importAgent summary: Import an agent from AGENTS.md description: | Parse an `AGENTS.md` document (YAML front matter + markdown instructions) and either create a new agent from it or patch an existing one. Create vs update is decided solely by `target_agent_id`: - omitted: CREATE (new agent, fresh id, SA provisioned) - present: PATCH the matching agent (404 if not found in the caller's org, 403 if the caller is neither the owner nor an agent-factory admin) Any `id:` carried by the file's frontmatter is ignored - round-trip re-imports always create a new agent unless the caller explicitly opts into a patch. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AgentImportInput' example: agents_md: | --- name: "_test_import_export_agent" description: "A test agent for import/export round-trip" model: "gpt-4o-mini" temperature: 0.7 max_tokens: 2048 --- You are a test assistant created via AGENTS.md import. responses: '200': description: Agent imported. content: application/json: schema: $ref: '#/components/schemas/AgentImportResponse' '400': description: Validation error (missing or unparseable `agents_md`). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only POST is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' '502': description: Service account provisioning failed (agent record rolled back). content: application/json: schema: $ref: '#/components/schemas/Error' '503': description: Governance service is not configured. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/citations/source_url: get: tags: [Agents] operationId: resolveCitationSourceUrl summary: Resolve a file_search citation link (302 redirect) description: | Stable, permanent link embedded in file_search `url_citation` annotations for `uploaded_file` documents (web pages carry their real `source_url` and never route here). On click: authorizes the end user against the agent (`read`), verifies `knowledge_base_id` is a file_search KB the agent uses (draft or published), resolves a fresh short-lived URL from storage as a trusted source, and 302-redirects to it. Minting happens per click, so this link never expires even though the native URL it resolves to is short-lived. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: knowledge_base_id in: query required: true schema: type: string maxLength: 128 description: The file_search knowledge base the cited document belongs to. - name: document_id in: query required: true schema: type: string maxLength: 128 description: The cited document id. responses: '302': description: | Redirect to the freshly-minted short-lived native URL (`Location` header). The target URL expires; re-click to re-resolve. headers: Location: schema: type: string format: uri '400': description: Missing knowledge_base_id or document_id. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: | The end user is not authorized on the agent, or the knowledge_base_id is not attached to it as a file_search tool in either its draft or published config. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: | Citation source unavailable (dangling native file, or storage could not resolve it). content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only GET is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' '502': description: Upstream storage resolution failed (technical error). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/export: get: tags: [Agents] operationId: exportAgent summary: Export an agent as AGENTS.md description: | Returns the agent's portable AGENTS.md document (YAML front matter + markdown instructions). Response media type is `text/markdown`; the response is sent with `Content-Disposition: attachment; filename="agent-export.agents.md"`. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: AGENTS.md document. content: text/markdown: schema: type: string '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only GET is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/access: get: tags: [Access] operationId: listAgentBindings summary: List access bindings for an agent description: List user/group/org bindings on this agent. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: limit in: query required: false schema: type: string description: Page size (default 100). - name: page in: query required: false schema: type: string description: 1-indexed page number. responses: '200': description: List of bindings. content: application/json: schema: $ref: '#/components/schemas/AccessBindingListResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' post: tags: [Access] operationId: shareAgent summary: Share an agent with a principal (create binding) description: | Create a binding granting a user, group, or org access to this agent. User and group principals are validated against the agent's organization via `ai-governance-v2`. An `org` target may be the agent's own org (no extra requirement), another organization, or the literal wildcard `*` meaning every authenticated member of at least one org. Any target beyond the agent's own org requires the `agent-factory:sharing:cross-org` permission (403 without it), and a specific foreign org is only accepted when the sharer is an active member of it (uniform 400 otherwise; platform admins bypass). Default role when `role_slug` is omitted: `admin` for same-org shares (historical default), `user` for any org target beyond the agent's own org. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AccessShareInput' responses: '200': description: Binding created. content: application/json: schema: $ref: '#/components/schemas/AccessShareResponse' '400': description: Validation error (invalid principal_type, missing principal_id, unknown or `owner` role_slug, sharer not a member of the target org, etc.). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden - including an org target beyond the agent's own org without the `agent-factory:sharing:cross-org` permission. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' '409': description: Binding already exists (the unique tuple distinguishes each org target, `*` included). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/access/{principalType}/{principalId}: patch: tags: [Access] operationId: updateAgentAccess summary: Change an agent share's role description: >- Change the role of the binding for the given (principal_type, principal_id) pair, in place. Revoking and re-creating is not equivalent: the two calls have no transaction around them, and the revoke half is refused when the binding is the resource's last one. `owner` is not accepted, although it is a defined agent role: it is the only share role carrying `delete`, and this endpoint is reachable by anyone holding `share`. It also never conferred ownership - an agent's owner is its `owner_id`, and a binding with that role resolves to `admin`. The caller's own access cannot be changed, for the same reason it cannot be revoked: lowering one's own role drops them out of the panel they are acting from, on an agent they may be the only administrator of. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: principalType in: path required: true schema: type: string enum: [user, group, org] maxLength: 32 - name: principalId in: path required: true schema: type: string maxLength: 128 requestBody: required: true content: application/json: schema: type: object required: [role_slug] properties: role_slug: type: string enum: [user, admin] maxLength: 64 responses: '200': description: Binding updated. content: application/json: schema: type: object properties: updated: type: boolean binding: $ref: '#/components/schemas/AccessBinding' '400': description: >- Invalid `principal_type`, unknown or forbidden `role_slug`, or an attempt to change the caller's own access (`CANNOT_MODIFY_OWN_ACCESS`). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: No binding found for this principal. content: application/json: schema: $ref: '#/components/schemas/Error' delete: tags: [Access] operationId: revokeAgentAccess summary: Revoke an agent access binding description: >- Delete the binding for the given (principal_type, principal_id) pair. The caller's own access cannot be revoked here (`CANNOT_MODIFY_OWN_ACCESS`): it would drop them out of the panel they are acting from, on an agent they may be the only administrator of. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: principalType in: path required: true schema: type: string enum: [user, group, org] maxLength: 32 - name: principalId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Binding deleted. content: application/json: schema: $ref: '#/components/schemas/DeletedResult' '400': description: >- Invalid `principal_type`, or an attempt to revoke the caller's own access (`CANNOT_MODIFY_OWN_ACCESS`). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: No binding found for this principal. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only PATCH and DELETE are accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/access/request: post: tags: [Access] operationId: requestAgentAccess summary: Request access to a published restricted agent description: | Submit an access request for a published `restricted` agent. The agent owner / admins can approve or reject via `/v1/agents/{agentId}/access/requests/{requestId}`. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/AccessRequestInput' responses: '201': description: Access request created (pending). content: application/json: schema: $ref: '#/components/schemas/AccessRequest' '400': description: Cannot request access (e.g. self-owned agent). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden - agent must be published and restricted. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' '409': description: Existing binding or pending request already present. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/access/requests: get: tags: [Access] operationId: listAgentAccessRequests summary: List access requests for an agent parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: status in: query required: false schema: type: string enum: [pending, approved, rejected] maxLength: 32 - name: limit in: query required: false schema: type: string description: Page size (default 100). - name: page in: query required: false schema: type: string responses: '200': description: Page of access requests. content: application/json: schema: $ref: '#/components/schemas/AccessRequestListResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only GET is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/access/requests/{requestId}: post: tags: [Access] operationId: respondToAccessRequest summary: Approve or reject an access request description: | Resolve a pending access request. On `approve`, a binding is created for the requester with `roleSlug: user`. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: requestId in: path required: true schema: type: string maxLength: 128 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AccessRequestResolveInput' responses: '200': description: Resolved request. content: application/json: schema: $ref: '#/components/schemas/AccessRequestResolveResponse' '400': description: Validation error (invalid action, request already resolved). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Access request not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only POST is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/api-keys: get: tags: [ApiKeys] operationId: listAgentApiKeys summary: List agent-scoped API keys description: | List org API keys owned by this agent. Requires `share` on the agent and the `agent-factory:apikeys:read` org permission, owners included (403 otherwise). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: limit in: query required: false schema: type: string description: Page size (default 100). - name: page in: query required: false schema: type: string responses: '200': description: List of API keys (secrets are not returned). content: application/json: schema: type: object additionalProperties: true description: Result of `access-manager.listOrgApiKeys`. '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '503': description: The API key permission could not be checked (`ACCESS_CHECK_FAILED`); retry later. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' post: tags: [ApiKeys] operationId: createAgentApiKey summary: Mint a new agent-scoped API key description: | Create an org-scoped API key owned by this agent. Permissions are prefixed with `agent-factory:` server-side. The secret is returned once on creation. Requires `share` on the agent and the `agent-factory:apikeys:create` org permission, owners included (403 otherwise; a key scoped to an agent is refused unless it also carries the `agent-factory:apikeys:*` scope). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AgentApiKeyCreateInput' responses: '201': description: API key created (secret returned once). content: application/json: schema: type: object additionalProperties: true description: Result of `access-manager.createOrgApiKey` - includes the one-time secret. '400': description: Validation error (missing fields, empty permissions). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '503': description: The API key permission could not be checked (`ACCESS_CHECK_FAILED`); retry later. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/api-keys/{keyId}: delete: tags: [ApiKeys] operationId: revokeAgentApiKey summary: Revoke an agent API key description: | Requires `share` on the agent and the `agent-factory:apikeys:delete` org permission, owners included (403 otherwise). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: keyId in: path required: true schema: type: string maxLength: 96 responses: '200': description: API key revoked. content: application/json: schema: type: object additionalProperties: true description: Result of `access-manager.deleteOrgApiKey`. '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '503': description: The API key permission could not be checked (`ACCESS_CHECK_FAILED`); retry later. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: API key not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only DELETE is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/api-keys/{keyId}/rotate: post: tags: [ApiKeys] operationId: rotateAgentApiKey summary: Rotate (regenerate) an agent API key secret description: | Requires `share` on the agent and the `agent-factory:apikeys:create` org permission, owners included (403 otherwise). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: keyId in: path required: true schema: type: string maxLength: 96 requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/AgentApiKeyRotateInput' responses: '200': description: API key rotated (new secret returned once). content: application/json: schema: type: object additionalProperties: true description: Result of `access-manager.rotateOrgApiKey` - includes the new one-time secret. '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '503': description: The API key permission could not be checked (`ACCESS_CHECK_FAILED`); retry later. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: API key not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only POST is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/publish: post: tags: [Publishing] operationId: publishAgent summary: Publish an agent description: | Snapshot the agent's current runtime fields into `published_config`, flip status to `published`, and set the visibility (default `public`). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/AgentPublishInput' example: category: testing tags: - test - automation responses: '200': description: Publication summary. content: application/json: schema: $ref: '#/components/schemas/AgentPublishResponse' '400': description: Invalid visibility. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/unpublish: post: tags: [Publishing] operationId: unpublishAgent summary: Unpublish an agent description: | Revert a published agent to `draft`: clears `published_config` and `published_at`, resets visibility to `private` and `has_draft_changes` to `false`. The live agent fields (the current draft) are kept as-is. Requires publish rights on the agent. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Agent reverted to draft. content: application/json: schema: $ref: '#/components/schemas/AgentUnpublishResponse' '400': description: Validation error - the agent is not published. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/discard-draft: post: tags: [Publishing] operationId: discardAgentDraft summary: Discard draft changes and revert to the published snapshot description: | Reverts live fields from `published_config`. Requires an agent in `published` status with `has_draft_changes: true`. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Draft discarded. content: application/json: schema: $ref: '#/components/schemas/AgentDiscardDraftResponse' '400': description: No published snapshot or no draft changes to discard. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/ratings: post: tags: [Ratings] operationId: rateAgent summary: Rate an agent (1-5) description: | Upserts the caller's rating on the agent and recomputes the average from the ratings collection (source of truth). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/RatingInput' example: rating: 5 responses: '200': description: Updated rating aggregates. content: application/json: schema: $ref: '#/components/schemas/RatingResult' example: rating: 5 ratings_count: 1 '400': description: Rating must be an integer between 1 and 5. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/refresh-metrics: post: tags: [Analytics] operationId: refreshAgentAnalytics summary: On-demand metrics refresh for an agent description: | Re-aggregates the cached analytics for the requested period. The front-end passes `period_start` / `period_end` / `granularity` for the window currently being viewed. The legacy fallback uses `hours_back` (1..168) ending at the current hour boundary at hourly granularity. Available to agent owners and writers. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: hours_back in: query required: false schema: type: string description: Legacy fallback - number of hours back from now (max 168). requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/RefreshMetricsInput' responses: '200': description: Refresh result. content: application/json: schema: $ref: '#/components/schemas/RefreshMetricsResult' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only POST is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/conversations: get: tags: [Conversations] operationId: listConversations summary: List conversations for an agent description: | List the caller's conversations on this agent. Supports filtering by archive/star state and a specific `contextId`. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: is_archived in: query required: false schema: type: string description: Filter by archive state (`true`/`false`). - name: is_starred in: query required: false schema: type: string description: Filter by star state (`true`/`false`). - name: contextId in: query required: false schema: type: string maxLength: 64 description: Filter to a single conversation by context id. - name: limit in: query required: false schema: type: string description: Page size (default 20, max 100). - name: page in: query required: false schema: type: string description: 1-indexed page number. - name: scope in: query required: false schema: type: string maxLength: 8 description: | `org` widens the listing to all users of the agent. Honoured only for privileged callers (trusted source, platform admin, org admin); otherwise the listing stays self-scoped. - name: from_date in: query required: false schema: type: string maxLength: 64 description: ISO lower bound on `last_message_at`. - name: to_date in: query required: false schema: type: string maxLength: 64 description: ISO upper bound on `last_message_at`. responses: '200': description: Page of conversations. content: application/json: schema: $ref: '#/components/schemas/ConversationListResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' post: tags: [Conversations] operationId: createConversation summary: Create a new conversation parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/ConversationCreateInput' example: title: Test Conversation responses: '200': description: Created conversation. content: application/json: schema: $ref: '#/components/schemas/Conversation' '400': description: Validation error. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' delete: tags: [Conversations] operationId: deleteAllConversations summary: Delete all conversations for the caller on this agent description: | Cascades a bulk delete: all caller-owned conversations on this agent, their tasks, and their artifact versions / artifacts. Emits `conversations.deleted.all` for cache invalidation. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Bulk delete summary. content: application/json: schema: $ref: '#/components/schemas/ConversationsBulkDeleteResult' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/conversations/{contextId}: get: tags: [Conversations] operationId: getConversation summary: Get a single conversation with its message history description: | Returns the conversation envelope plus a paginated slice of its task-message history (ordered most-recent first). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: contextId in: path required: true schema: type: string maxLength: 64 - name: limit in: query required: false schema: type: string description: Page size for the task-message history (default 100). - name: page in: query required: false schema: type: string description: 1-indexed page number for the task-message history. responses: '200': description: Conversation + messages. content: application/json: schema: $ref: '#/components/schemas/ConversationDetailResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Conversation not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' patch: tags: [Conversations] operationId: updateConversation summary: Update conversation metadata (title, archive, star) parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: contextId in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ConversationUpdateInput' example: is_starred: true title: Updated Title responses: '200': description: Updated conversation. content: application/json: schema: $ref: '#/components/schemas/Conversation' '400': description: Validation error. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Conversation not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' delete: tags: [Conversations] operationId: deleteConversation summary: Delete a single conversation (cascades to tasks + artifacts) parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: contextId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Conversation deleted. content: application/json: schema: $ref: '#/components/schemas/DeletedResult' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Conversation not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/conversations/{contextId}/usage: get: tags: [Conversations] operationId: getConversationUsage summary: Usage totals for one conversation description: | Tokens, cost, carbon and message count for one conversation, aggregated from each turn's `task.metadata.usage` (the same source as the per-message usage shown in chat, so per-message lines always sum to these totals). Broken down per model in `by_model`, an array because model names contain dots. Self-scoped: a user only reads their own conversation. Privileged and trusted-monitoring callers may read any user's conversation of this agent. At most 500 turns are aggregated. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: contextId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Conversation usage totals. content: application/json: schema: $ref: '#/components/schemas/ConversationUsage' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent or conversation not found (`CONVERSATION_NOT_FOUND`) in the caller's scope. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/connector_accounts: get: tags: [Conversations] operationId: listConnectorAccounts summary: List the caller's connector accounts for an agent's knowledge bases description: | For each `file_search` knowledge base the agent draws on, returns the connector accounts the calling user has (or can connect), so a chat surface can offer to connect or disconnect one. Answers about the caller only. A knowledge base whose connector cannot be queried contributes nothing (no error). Disconnecting through `disconnect_url` drops only the credential the reader connected for this agent. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Connector accounts of the caller. content: application/json: schema: $ref: '#/components/schemas/ConnectorAccountList' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only GET is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/traces/{correlationId}: get: tags: [Traces] operationId: getAgentTrace summary: Execution trace of one agent turn description: | Assembles the trace of one agent turn (identified by its `correlationId`) for the agent's editor: knowledge-base passages retrieved and their scores, tool calls, the chronology of what ran, errors, and the model, tokens, cost and latency of the turn (merged from the LLM Gateway). Step inputs and outputs are not included; fetch one on demand with `GET /v1/agents/{agentId}/traces/{correlationId}/events/{eventId}`. Requires the `agent-factory:traces:read` org permission (or the `agent-factory:*` / `*` wildcards, or platform admin). Owning or editing the agent is not enough. Caveats reported in the payload: `retrieval` is only populated for turns run from the editing surface, and `summary.details_expired` flags traces older than the 14-day cleanup of step details. The timeline is capped at 2000 events (`summary.timeline_truncated`). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: correlationId in: path required: true schema: type: string maxLength: 128 - name: excludeAutomation in: query required: false schema: type: string description: | Comma-separated automation slugs to leave out of the timeline. Defaults to `_stream-event` (one execution per streamed chunk). Send `__none__` to keep every step. - name: x-draft-mode in: header required: false schema: type: string enum: ['true'] description: Resolve the agent as its editor does (draft configuration). responses: '200': description: Assembled trace. content: application/json: schema: $ref: '#/components/schemas/AgentTrace' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden - `agent-factory:traces:read` is required. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found, or no trace for this correlationId on this agent. content: application/json: schema: $ref: '#/components/schemas/Error' '502': description: The event store could not be read (`SEARCH_FAILED`). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/traces/{correlationId}/events/{eventId}: get: tags: [Traces] operationId: getAgentTraceEvent summary: Inputs and outputs of one trace step description: | Returns the inputs and outputs of one step of a trace, fetched on demand. Same permission as the trace (`agent-factory:traces:read`). The event must belong both to the given correlation and to an execution of the given agent. Known secret keys are stripped from `input` and `output`; the raw event is never served (open it in the Builder activity view, under workspace access control). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: correlationId in: path required: true schema: type: string maxLength: 128 - name: eventId in: path required: true schema: type: string maxLength: 128 - name: x-draft-mode in: header required: false schema: type: string enum: ['true'] description: Resolve the agent as its editor does (draft configuration). responses: '200': description: Step detail. content: application/json: schema: $ref: '#/components/schemas/AgentTraceEvent' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden - `agent-factory:traces:read` is required. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent or event not found for this trace. content: application/json: schema: $ref: '#/components/schemas/Error' '502': description: The event store could not be read (`SEARCH_FAILED`). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/messages/send: post: tags: [Messages] operationId: sendMessage summary: Send a message to an agent (A2A, non-streaming) description: | A2A-compliant message send. The body follows the A2A flat `MessageSendParams` shape - a `message` envelope with `message_id`, `role`, `parts[]`, and an optional `contextId`. Parts are discriminated by field presence: `TextPart` (`text`), `FilePart` (`url` or `raw`), `DataPart` (`data`). An always-on rate-limit floor (200/h per user) applies, plus any agent-configured limit. The HITL approval flow is supported and will park the task in `input-required` until resolved through `/v1/agents/{agentId}/tasks/{taskId}/resolve`. Send the `x-draft-mode: true` header to bypass `published_config` resolution and exercise live (draft) configuration - owners and agent-factory writers only. **Idempotency (opt-in).** Set `message.metadata.clientMessageId` to a stable per-user key and the send becomes replay-safe: the first call runs normally, and any later call with the same key returns that first answer verbatim with `task.replayed: true`, without running the agent and without opening a second conversation. A replay arriving while the first run is still in flight answers `409 MESSAGE_IN_PROGRESS` and names the conversation it is writing to. The body of a replay is not compared with the first one: a different message under the same key still gets the first answer. Replays count against the rate limits. The body's `message_id` plays no part in this. **Not supported on `messages/stream`**: a streamed send is always executed. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: x-draft-mode in: header required: false schema: type: boolean description: | When true, the call exercises the agent's live (draft) config instead of `published_config`. Reserved for owners/writers. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/MessageSendInput' example: message: message_id: msg-test-2 role: user parts: - text: What is 2+2? Reply with just the number. responses: '200': description: Completed task with the agent's reply. content: application/json: schema: $ref: '#/components/schemas/MessageSendResponse' '400': description: | Validation error - missing `agent_id`, or a `message.metadata.clientMessageId` that is not a 1-128 character string of `[A-Za-z0-9._:-]` (`VALIDATION_ERROR`). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden, including an agent with no published version called by someone who is neither an editor nor an explicit grantee. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '409': description: | Either `TASK_IN_PROGRESS` - a previous task in this conversation is still held by an external hook - or `MESSAGE_IN_PROGRESS`, when a send carrying the same `message.metadata.clientMessageId` is still running. `MESSAGE_IN_PROGRESS` carries `details.contextId` (the conversation the first run is writing to), `details.clientMessageId` and `details.retryAfter` (seconds). Retry the same key rather than sending a new message: once the first run finishes, the retry replays its answer. content: application/json: schema: $ref: '#/components/schemas/Error' '429': description: Rate limit exceeded (200/h floor or agent-configured). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/messages/stream: post: tags: [Messages] operationId: streamMessage summary: Stream an agent reply via SSE (A2A) description: | A2A-compliant streaming send. The request body uses the same `MessageSendParams` shape as `messages/send`. The response is delivered as Server-Sent Events (`text/event-stream`). Each frame is a `data: ` line; the server emits no native SSE `event:` field. Lifecycle frames use `{"event":"","data":{...}}`. The lifecycle sequence starts with `task.status`, emits zero or more `task.output.delta` events, and reaches its terminal state with `task.output.completed`. Clients must inspect `data.status.state` on that event: `completed`, `failed`, or `input-required`. Between frames, the server sends `: keepalive` SSE comment lines to keep the connection open. Ignore every line starting with `:`, as `EventSource` does. Frames without an `event` property are transport frames. Discard only the literal `{"keepAlive": true}` frame, the keep-alive older servers send instead of the comment line. The server closes the stream with a summary frame shaped as `{"error":...,"task":{"status":{"state":...}}}`. Inspect that frame: an early authorization failure is delivered there, with its code in `error.error` and HTTP 200 already committed. Never treat HTTP 200 alone as success. The `x-draft-mode: true` header bypasses `published_config` resolution. The same HITL approval flow as `messages/send` applies - a streaming task may park in `input-required` until resolved. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: x-draft-mode in: header required: false schema: type: boolean description: | When true, the stream exercises the agent's live (draft) config instead of `published_config`. Owners/writers only. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/MessageSendInput' responses: '200': description: | Server-Sent Events stream of A2A task lifecycle events. `task.output.completed` is the terminal lifecycle event. Its `data.status.state` reports whether the task completed, failed, or requires user input. A transport summary frame follows; inspect its `error` and `task.status.state` fields before closing the stream. content: text/event-stream: schema: type: string description: | Stream of `data: ` lines. Lifecycle frames use `{"event":"","data":{...}}`; the server does not emit native SSE `event:` fields. Ignore `: keepalive` comment lines, and discard the literal `{"keepAlive": true}` frame sent by older servers. The final summary frame has no `event`; inspect `error.error` for an early authorization failure and `task.status.state` for the final task state. '400': description: Validation error. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden, including an agent with no published version called by someone who is neither an editor nor an explicit grantee. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '429': description: Rate limit exceeded. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/tasks: get: tags: [Tasks] operationId: listTasks summary: List tasks for an agent description: | List the caller's tasks on this agent, with optional `context_id` and `status` filters. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: context_id in: query required: false schema: type: string maxLength: 64 description: Filter to one conversation. - name: status in: query required: false schema: type: string enum: [working, completed, canceled, failed, input-required] maxLength: 32 - name: limit in: query required: false schema: type: string description: Page size (default 20). - name: page in: query required: false schema: type: string responses: '200': description: Page of tasks. content: application/json: schema: $ref: '#/components/schemas/TaskListResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/tasks/{taskId}: get: tags: [Tasks] operationId: getTask summary: Get a single task by ID parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: taskId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Task record. content: application/json: schema: $ref: '#/components/schemas/Task' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Task not found. content: application/json: schema: $ref: '#/components/schemas/Error' patch: tags: [Tasks] operationId: updateTaskFromHook summary: Update a task from a hook callback description: | Callback used by `async` and `stream` hook targets (the `callback.patch_url` they receive) to update the task they were invoked for. Authenticated with the callback token from `callback.token`, sent in `X-Hook-Token` (or `Authorization: Bearer cbt_...`). User credentials are not used on this method. When `status` is set, a `task.status` event is emitted to the task's subscribers. security: - HookCallbackTokenAuth: [] parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: taskId in: path required: true schema: type: string maxLength: 128 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TaskHookUpdateInput' example: status: state: completed responses: '200': description: Task updated. content: application/json: schema: type: object properties: ok: type: boolean example: true taskId: type: string status: type: object additionalProperties: true '401': description: Missing, invalid or expired callback token. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Task not found. content: application/json: schema: $ref: '#/components/schemas/Error' '409': description: Callback replayed or bound to another hook invocation. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/tasks/{taskId}/events: post: tags: [Tasks] operationId: pushTaskEvent summary: Push an event into a task from a hook callback description: | Callback used by `async` and `stream` hook targets (the `callback.url` they receive) to forward incremental updates to the client that started the task. The event is broadcast to the task's SSE/WebSocket subscribers; `task.status` and `task.output.completed` are persisted, `task.output.delta` is not. Authenticated with the callback token from `callback.token`, sent in `X-Hook-Token` (or `Authorization: Bearer cbt_...`). security: - HookCallbackTokenAuth: [] parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: taskId in: path required: true schema: type: string maxLength: 128 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TaskHookEventInput' example: event: task.output.delta data: delta: Partial answer responses: '200': description: Event accepted. content: application/json: schema: type: object properties: ok: type: boolean example: true taskId: type: string event: type: string seq: type: integer description: Sequence number of this callback event for the hook invocation. '400': description: '`event` missing or not one of the accepted events.' content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Missing, invalid or expired callback token. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Task not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only POST is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' '409': description: Callback replayed or bound to another hook invocation. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/tasks/{taskId}/cancel: post: tags: [Tasks] operationId: cancelTask summary: Cancel a running task (A2A) description: | Sets the task `status.state` to `canceled` and stamps a `_completed_at`. Tasks already in `completed` or `canceled` return a 4xx. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: taskId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Task canceled. content: application/json: schema: $ref: '#/components/schemas/TaskCancelResult' '400': description: Task is already terminal (`completed` or `canceled`). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Task not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/tasks/{taskId}/resolve: post: tags: [Tasks] operationId: resolveTask summary: Resolve a pending HITL approval (external approver) description: | External approval endpoint for tasks parked in `input-required`. The caller is the approver - distinct from the chatting user - and is authorized via the task's `pending_approval.approvers` list. On `approved: true`, the agent loop resumes; on `approved: false`, the task is failed with the supplied reason. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: taskId in: path required: true schema: type: string maxLength: 128 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TaskResolveInput' responses: '200': description: Resolved task summary. content: application/json: schema: $ref: '#/components/schemas/TaskResolveResponse' '400': description: Validation error (`approved` missing or non-boolean). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Caller is not an authorized approver for this task. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Task not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only POST is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' '500': description: Resolved successfully but the resumed action failed mid-execution. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/tasks/{taskId}/subscribe: get: tags: [Tasks] operationId: getTaskSnapshot summary: Get a task snapshot (A2A subscribe - non-streaming) description: | Returns the current task state plus history. Stateless: closes the response immediately. For real-time updates on non-terminal tasks, clients subscribe to the native event-bus SSE channel for `task.output.completed` lifecycle events. The `terminal` flag indicates whether further updates are still possible. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: taskId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Task snapshot. content: application/json: schema: $ref: '#/components/schemas/TaskSnapshot' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Task not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/artifacts: get: tags: [Artifacts] operationId: listArtifacts summary: List artifacts owned by the caller description: | List artifacts the authenticated user owns, optionally filtered by `agent_id`, `conversation_id`, and `artifact_type`. parameters: - name: agent_id in: query required: false schema: type: string maxLength: 64 - name: conversation_id in: query required: false schema: type: string maxLength: 64 - name: artifact_type in: query required: false schema: type: string maxLength: 64 - name: limit in: query required: false schema: type: string description: Page size (default 50). - name: page in: query required: false schema: type: string responses: '200': description: Page of artifacts. content: application/json: schema: $ref: '#/components/schemas/ArtifactListResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only GET is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/artifacts/{artifactId}: get: tags: [Artifacts] operationId: getArtifact summary: Get an artifact (with current version content) parameters: - name: artifactId in: path required: true schema: type: string maxLength: 128 - name: version in: query required: false schema: type: string description: Historical version number to read. Omit for the current version (unknown version returns 404 `ARTIFACT_VERSION_NOT_FOUND`). - name: versions in: query required: false schema: type: string description: When present (e.g. `1`), the response includes `versions`, the version history metadata (up to 200, newest first, no content). responses: '200': description: Artifact record + resolved version content. content: application/json: schema: $ref: '#/components/schemas/ArtifactDetail' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden - only the owner (or platform admin) can read. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Artifact not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' patch: tags: [Artifacts] operationId: updateArtifact summary: Update artifact content or restore a version description: | Two mutation modes, both creating a new current version: `restore_version` re-commits a historical version's content (it wins when both are sent), otherwise `content` replaces the whole document. `base_version` opts into optimistic concurrency control on the `content` mode. parameters: - name: artifactId in: path required: true schema: type: string maxLength: 128 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ArtifactPatchInput' example: content: Updated greeting message change_summary: Updated greeting message responses: '200': description: New version persisted. content: application/json: schema: type: object additionalProperties: true description: | Helper-defined update result - includes the new `current_version` and `total_versions`. '400': description: Validation error - neither `content` nor `restore_version` provided. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden - only the owner can mutate. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Artifact not found. content: application/json: schema: $ref: '#/components/schemas/Error' '409': description: Optimistic concurrency conflict (`base_version` mismatch). content: application/json: schema: $ref: '#/components/schemas/Error' delete: tags: [Artifacts] operationId: deleteArtifact summary: Delete an artifact and all of its versions parameters: - name: artifactId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Artifact deleted. content: application/json: schema: $ref: '#/components/schemas/ArtifactDeleteResult' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden - only the owner can delete. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Artifact not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/conversations/{contextId}/share: post: tags: [Shares] operationId: createConversationShare summary: Create a share snapshot of a conversation or single message description: | Creates an immutable snapshot of a conversation (or a single message when `message_id` is provided) plus any artifacts it references. Returns both a UI URL and a public-facing API URL. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: contextId in: path required: true schema: type: string maxLength: 64 requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/ConversationShareInput' example: {} responses: '200': description: Share created. content: application/json: schema: $ref: '#/components/schemas/ConversationShareResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Conversation or referenced `message_id` not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/artifacts/{artifactId}/shares: post: tags: [Shares] operationId: createArtifactShare summary: Create (or refresh) a share for an artifact description: | Returns the existing share for `(artifact_id, user_id)` if one exists, with the snapshot refreshed from the artifact's current version. Otherwise creates a new share. parameters: - name: artifactId in: path required: true schema: type: string maxLength: 128 requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/ArtifactShareInput' responses: '200': description: Share created or refreshed. content: application/json: schema: $ref: '#/components/schemas/ArtifactShareResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Artifact not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/shares: get: tags: [Shares] operationId: listShares summary: List shares created by the caller parameters: - name: type in: query required: false schema: type: string enum: [conversation, message, artifact] maxLength: 32 - name: agent_id in: query required: false schema: type: string maxLength: 64 - name: limit in: query required: false schema: type: string description: Page size (default 20). - name: page in: query required: false schema: type: string responses: '200': description: Page of shares. content: application/json: schema: $ref: '#/components/schemas/ShareListResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only GET is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/shares/{shareId}: get: tags: [Shares] operationId: getShare summary: Get a share owned by the caller parameters: - name: shareId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Share record (owner view). content: application/json: schema: $ref: '#/components/schemas/Share' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Share not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' delete: tags: [Shares] operationId: deleteShare summary: Delete a share owned by the caller parameters: - name: shareId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Share deleted. content: application/json: schema: $ref: '#/components/schemas/DeletedResult' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Share not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/shared/{shareId}: get: tags: [Shares] operationId: getSharedConversation summary: Public-facing share viewer (auth-required) description: | Returns the share snapshot. Despite the `/shared/` prefix this endpoint still requires authentication - both end-user JWTs (`Authorization: Bearer`) and `iak_*` instance keys (`x-prismeai-api-key`) work, but anonymous callers are rejected. The response sets `is_mine: true` when the caller owns the share. parameters: - name: shareId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Share view (snapshot + ownership flag). content: application/json: schema: $ref: '#/components/schemas/ShareView' '401': description: Anonymous access - authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Share not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/a2a: get: tags: [A2A] operationId: legacyA2aTaskSnapshot summary: Legacy A2A gateway - task snapshot dispatch (GET) description: | Backward-compatible legacy gateway. `GET /v1/a2a?taskId=xxx` looks up the task's `_agent_id` and forwards to the per-agent endpoint `GET /v1/agents/{agentId}/a2a?taskId=xxx`. New clients should call the per-agent path directly. parameters: - name: taskId in: query required: true schema: type: string maxLength: 128 responses: '200': description: Task snapshot (forwarded from the per-agent endpoint). content: application/json: schema: $ref: '#/components/schemas/TaskSnapshot' '404': description: Task not found (rendered as a JSON-RPC error envelope). content: application/json: schema: $ref: '#/components/schemas/JsonRpcErrorEnvelope' post: tags: [A2A] operationId: legacyAgentToAgentCall summary: Legacy A2A gateway - JSON-RPC 2.0 dispatch (POST) description: | Backward-compatible legacy JSON-RPC 2.0 gateway. The body MUST include `params.id` (the target agent ID); the gateway forwards the call to `POST /v1/agents/{agentId}/a2a`. Returns the forwarded JSON-RPC response or a JSON-RPC error envelope. Recognised methods on the underlying per-agent endpoint: `message/send`, `message/stream`, `tasks/get`, `tasks/cancel`, `tasks/sendSubscribe`, `agent/getCard`, `agent/getExtendedCard`. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LegacyJsonRpcRequest' responses: '200': description: | JSON-RPC 2.0 response. `result` is the forwarded result envelope; alternatively `error` carries a JSON-RPC error object when the dispatch failed. content: application/json: schema: $ref: '#/components/schemas/JsonRpcResponse' '400': description: Invalid JSON-RPC envelope (returned as a JSON-RPC error response). content: application/json: schema: $ref: '#/components/schemas/JsonRpcErrorEnvelope' /v1/agents/{agentId}/a2a: get: tags: [A2A] operationId: agentTaskSnapshotA2a summary: A2A task snapshot (per-agent, GET) description: | Per-agent A2A gateway snapshot endpoint. `GET ?taskId=xxx` validates the task belongs to this agent then forwards to `getTaskSnapshot`. Returns a JSON-RPC error envelope when the task does not belong to the agent. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: taskId in: query required: true schema: type: string maxLength: 128 responses: '200': description: Task snapshot. content: application/json: schema: $ref: '#/components/schemas/TaskSnapshot' '404': description: Task not found for this agent (JSON-RPC error envelope). content: application/json: schema: $ref: '#/components/schemas/JsonRpcErrorEnvelope' post: tags: [A2A] operationId: agentToAgentCall summary: A2A JSON-RPC 2.0 dispatch (per-agent) description: | Per-agent JSON-RPC 2.0 entry point. The agent ID is taken from the path - `params.id` is ignored. Recognised methods include `message/send`, `message/stream`, `tasks/get`, `tasks/cancel`, `tasks/sendSubscribe`, `agent/getCard`, `agent/getExtendedCard`. For first-class consumers the dedicated REST endpoints (`/messages/send`, `/messages/stream`, `/tasks/{taskId}`, etc.) are preferred - this endpoint exists for A2A interoperability. Note: `tasks/sendSubscribe` directly streams Server-Sent Events without a JSON-RPC wrapper - it does not produce the `application/json` body documented here. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/JsonRpcRequest' responses: '200': description: | JSON-RPC 2.0 response. Carries `result` on success or `error` on failure. content: application/json: schema: $ref: '#/components/schemas/JsonRpcResponse' '400': description: Invalid JSON-RPC envelope. content: application/json: schema: $ref: '#/components/schemas/JsonRpcErrorEnvelope' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/.well-known/agent.json: get: tags: [A2A] operationId: getAgentCard summary: A2A discovery card (.well-known/agent.json) description: | A2A 0.3 discovery card. Owners (and same-org callers) see the live card; outside callers receive the `published_config` view. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: A2A AgentCard payload. content: application/json: schema: $ref: '#/components/schemas/AgentCard' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/extendedAgentCard: get: tags: [A2A] operationId: getExtendedAgentCard summary: A2A extended card (full agent config) description: | Same shape as the public `.well-known/agent.json` plus the agent's `tools`, `guardrails`, `sub_agents`, `model`, and `temperature`. Auth-gated for callers with read access. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Extended A2A AgentCard. content: application/json: schema: $ref: '#/components/schemas/ExtendedAgentCard' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/tools: get: tags: [Tools] operationId: listAgentTools summary: List the tools attached to an agent parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Tool list. content: application/json: schema: $ref: '#/components/schemas/ToolListResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' post: tags: [Tools] operationId: addAgentTool summary: Attach a tool to an agent description: | Adds a tool to the agent's `tools[]`. `type` MUST be one of `file_search`, `mcp`, or `function`. The tool name must match `^[a-zA-Z0-9_-]+$` (OpenAI tool-name constraint). When the agent is published, `has_draft_changes` is set to `true`. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ToolAddInput' example: type: file_search name: test_file_search description: Test file search tool vector_store_id: vs_test_123 catalog_id: template-file-search responses: '200': description: Tool added. content: application/json: schema: $ref: '#/components/schemas/Tool' '400': description: Validation error (invalid type, bad tool name, missing fields). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' '409': description: A tool with the same name already exists on this agent. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/tools/{toolId}: get: tags: [Tools] operationId: getAgentTool summary: Get a single tool from an agent parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: toolId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Tool record. content: application/json: schema: $ref: '#/components/schemas/Tool' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Tool not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' delete: tags: [Tools] operationId: removeAgentTool summary: Remove a tool from an agent description: | Removes the tool from `tools[]`. When the agent is published, `has_draft_changes` is set to `true`. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: toolId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Tool removed. content: application/json: schema: $ref: '#/components/schemas/DeletedResult' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Tool not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/tools/{toolId}/capabilities: get: tags: [Tools] operationId: getAgentToolCapabilities summary: List the tools an attached MCP server exposes description: | Runs the server's `tools/list` and returns each advertised tool with the `canonical_name` the model calls it by (the name a `tool_permissions` rule must target to reach that tool), plus its `inputSchema` and `annotations` exactly as published. `canonical_name` is computed by the runtime's own naming helper: consume it, never derive it. Always `200` once the entry is resolved. `status` says whether the list could be fetched (`ok`), whether the caller has to connect to an OAuth-gated server first (`auth_required`, empty `items`), or whether the server did not answer (`unavailable`, empty `items`, `error`). Only `mcp` entries have capabilities: any other type is a `400`. The list is served from the same per-server cache the runtime uses, with the same rule: never cached for auth-bearing catalog entries. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: toolId in: path required: true schema: type: string maxLength: 128 responses: '200': description: Server tools, or the reason they could not be listed. content: application/json: schema: $ref: '#/components/schemas/ToolCapabilities' '400': description: The entry is not an MCP server. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Tool not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/retention: get: tags: [Retention] operationId: getAgentRetention summary: Get an agent's retention policy description: | Returns the raw agent-level retention policy (or null if none) plus the resolved `effective` values (agent -> org -> platform defaults). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: Policy + effective values. content: application/json: schema: $ref: '#/components/schemas/AgentRetentionResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' put: tags: [Retention] operationId: updateAgentRetention summary: Upsert an agent retention policy description: | Upserts the agent-level retention policy. Each field is validated against the org limit; admins (platform admin or agent-factory admin) may set `admin_override: true` to exceed the org limits. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AgentRetentionInput' responses: '200': description: Upserted policy + effective values. content: application/json: schema: $ref: '#/components/schemas/AgentRetentionResponse' '400': description: Validation error or value exceeds org limit (and not admin-overridden). content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' delete: tags: [Retention] operationId: deleteAgentRetention summary: Delete the agent-level retention policy (revert to org/defaults) parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 responses: '200': description: 'Deletion result. `deleted: false` when no agent-level policy existed.' content: application/json: schema: $ref: '#/components/schemas/RetentionDeleteResult' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/orgs/{orgSlug}/agents: get: tags: [Agents] operationId: listOrgAgents summary: List all agents of an organization (admin) description: | Org-wide agent listing for administrators (agent-factory admin or platform admin), whatever the owner or visibility. The caller must belong to `orgSlug`. Rows expose the published snapshot when one exists and never carry `published_config`. Sorted descending. parameters: - name: orgSlug in: path required: true schema: type: string maxLength: 64 - name: status in: query required: false schema: type: string maxLength: 32 - name: search in: query required: false schema: type: string maxLength: 200 description: Case-insensitive match on name or description. - name: last_message_after in: query required: false schema: type: string maxLength: 40 description: ISO date - only agents with a message at or after this date. - name: last_message_before in: query required: false schema: type: string maxLength: 40 description: ISO date - agents with no message since this date (never-used agents included). - name: min_messages in: query required: false schema: type: string description: Minimum `messages_count`. - name: created_before in: query required: false schema: type: string maxLength: 40 description: ISO date - only agents created before this date. - name: sort in: query required: false schema: type: string enum: [created, last_message, messages] description: Sort field, always descending (default `created`). - name: limit in: query required: false schema: type: string description: Page size (max 100, default 20). - name: page in: query required: false schema: type: string description: 1-indexed page number. responses: '200': description: Page of the org's agents. content: application/json: schema: $ref: '#/components/schemas/AgentListResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden - not a member of this org, or not an agent-factory / platform admin. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed (only GET is accepted). content: application/json: schema: $ref: '#/components/schemas/Error' /v1/orgs/{orgSlug}/retention: get: tags: [Retention] operationId: getOrgRetention summary: Get the org-level retention policy description: | Org-scoped retention policy. Admin-only (platform admin or agent-factory admin). Returns the raw policy document plus the resolved `effective` values (org override -> platform defaults). parameters: - name: orgSlug in: path required: true schema: type: string maxLength: 64 responses: '200': description: Org retention policy + effective values. content: application/json: schema: $ref: '#/components/schemas/OrgRetentionResponse' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Platform or agent-factory admin access required. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' put: tags: [Retention] operationId: updateOrgRetention summary: Upsert the org-level retention policy parameters: - name: orgSlug in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/OrgRetentionInput' responses: '200': description: Upserted policy. content: application/json: schema: $ref: '#/components/schemas/OrgRetentionResponse' '400': description: Validation error. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Platform or agent-factory admin access required. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Resource not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/agents/{agentId}/evaluations: get: tags: [Evaluations] operationId: listEvaluations summary: List or fetch an evaluation description: | Without `eval_id`, returns the page of evaluations owned by the caller for this agent. With `eval_id`, returns that single evaluation (404 if not found). parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 - name: eval_id in: query required: false schema: type: string maxLength: 128 description: When set, returns a single evaluation by ID. - name: limit in: query required: false schema: type: string description: Page size (default 20). - name: page in: query required: false schema: type: string responses: '200': description: Evaluation list or single evaluation. content: application/json: schema: oneOf: - type: object properties: items: type: array items: type: object additionalProperties: true - type: object additionalProperties: true description: Single evaluation record (when `eval_id` is set). '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Evaluation not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' post: tags: [Evaluations] operationId: runEvaluation summary: Start a new evaluation run description: | Kicks off an evaluation against a stored input file. Persists a `tasks` record with `_type: evaluation` and emits `evaluation.started` for the worker pool to pick up. parameters: - name: agentId in: path required: true schema: type: string maxLength: 64 requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/EvaluationRunInput' responses: '200': description: Evaluation accepted (status `running`). content: application/json: schema: $ref: '#/components/schemas/EvaluationRunResponse' '400': description: Validation error. content: application/json: schema: $ref: '#/components/schemas/Error' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Forbidden. content: application/json: schema: $ref: '#/components/schemas/Error' '404': description: Agent or input file not found. content: application/json: schema: $ref: '#/components/schemas/Error' '405': description: Method not allowed. content: application/json: schema: $ref: '#/components/schemas/Error' /v1/admin/user-deletion: post: tags: [Admin] operationId: adminDeleteUserData summary: Delete a user's data (GDPR erasure) description: | Erases a user's data across the platform: anonymizes their conversations, transfers ownership of their agents to the calling admin, deletes their shares, ratings, access requests, access bindings, tasks and artifacts, then asks the Tools Memories, Knowledges and AI Insights workspaces to delete their data. Each step is best effort: failures are reported in `errors` and do not stop the run. Requires a platform administrator session (`platformRole` `superadmin` or `root`); other callers get `403`. Rate limited to 10 calls per hour per admin. With `dry_run: true`, nothing is deleted and the counts preview what would be affected (cross-workspace counts stay at `0`). security: - BearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AdminUserRequest' example: user_id: user-123 responses: '200': description: Deletion (or dry-run preview) report. content: application/json: schema: $ref: '#/components/schemas/AdminUserDeletionResult' '400': description: Missing or invalid `user_id`. content: application/json: schema: $ref: '#/components/schemas/AdminError' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/AdminError' '403': description: The caller is not a platform administrator. content: application/json: schema: $ref: '#/components/schemas/AdminError' example: error: Platform admin access required code: FORBIDDEN status: 403 '405': description: Method not allowed (only POST is accepted). content: application/json: schema: $ref: '#/components/schemas/AdminError' '429': description: Rate limit exceeded (10 per hour per admin). content: application/json: schema: $ref: '#/components/schemas/AdminError' /v1/admin/user-export: post: tags: [Admin] operationId: adminExportUserData summary: Export a user's data (GDPR access) description: | Collects a user's data across the platform: conversations, shares, ratings, access requests, access bindings, archived tasks and owned agents, plus their memories (Tools Memories), files and knowledge bases (Knowledges) and insights (AI Insights). Each source is best effort: failures are reported in `errors`. Allowed for a platform administrator (`platformRole` `superadmin` or `root`) on any user, and for any authenticated user on their own `user_id`; other callers get `403`. Rate limited to 10 calls per hour per caller. security: - BearerAuth: [] requestBody: required: true content: application/json: schema: type: object additionalProperties: false required: [user_id] properties: user_id: type: string maxLength: 128 description: Identifier of the user whose data is exported. example: user_id: user-123 responses: '200': description: Consolidated export. content: application/json: schema: $ref: '#/components/schemas/AdminUserExportResult' '400': description: Missing or invalid `user_id`. content: application/json: schema: $ref: '#/components/schemas/AdminError' '401': description: Authentication required. content: application/json: schema: $ref: '#/components/schemas/AdminError' '403': description: The caller is neither a platform administrator nor the exported user. content: application/json: schema: $ref: '#/components/schemas/AdminError' '405': description: Method not allowed (only POST is accepted). content: application/json: schema: $ref: '#/components/schemas/AdminError' '429': description: Rate limit exceeded (10 per hour per caller). content: application/json: schema: $ref: '#/components/schemas/AdminError' /v1/push/devices: post: tags: [Push] operationId: registerPushDevice summary: Register the signed-in user's mobile device for push notifications description: | Stores the device's APNs or FCM token and its notification key (RFC 8291), sealed at rest. Registering again with the same `device_id` updates it. A former registration of the same token, whichever the account, is replaced. The app draws a `device_id` at sign-in and forgets it at sign-out; on `409` it draws a new one and retries. Org API keys are refused. security: - BearerAuth: [] requestBody: required: true content: application/json: schema: type: object additionalProperties: false required: [device_id, platform, token, p256dh, auth] properties: device_id: type: string pattern: '^[A-Za-z0-9_-]{16,64}$' platform: type: string enum: [ios, android] token: type: string description: APNs or FCM token. p256dh: type: string description: Uncompressed P-256 public key, base64url. auth: type: string description: 16-byte secret, base64url. environment: type: string enum: [production, development] description: APNs environment. Required on iOS, refused on Android. topic: type: string description: APNs topic (the app bundle id). iOS only. responses: '204': description: Device registered. '400': description: Invalid registration. `error` names the field (`InvalidToken`, `InvalidKey`, ...). content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Not a user credential. content: application/json: schema: $ref: '#/components/schemas/Error' '409': description: This `device_id` belongs to another account (`error` is `DeviceIdTaken`). content: application/json: schema: $ref: '#/components/schemas/Error' '503': description: Push notifications are not configured on this instance. content: application/json: schema: $ref: '#/components/schemas/Error' delete: tags: [Push] operationId: forgetPushDevice summary: Forget one of the signed-in user's devices description: Called at sign-out. Only the owner of the device can forget it. security: - BearerAuth: [] parameters: - name: device_id in: query required: true schema: type: string responses: '204': description: Device forgotten, or it was not registered for this user. '400': description: '`device_id` is missing.' content: application/json: schema: $ref: '#/components/schemas/Error' '403': description: Not a user credential. content: application/json: schema: $ref: '#/components/schemas/Error' components: securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: JWT description: | User-bound credential carrying an identity: either a session JWT or a user access token (`at:*`) generated from the user settings UI. Send as `Authorization: Bearer `. Org API keys (`iak_*`) are **not** accepted here - they carry no user identity. Use the `x-prismeai-api-key` header instead (see `OrgApiKeyAuth`). OrgApiKeyAuth: type: apiKey in: header name: x-prismeai-api-key description: | Organization API key (`iak_{orgSlug}_{uuid}`). Unlike `Authorization: Bearer`, this credential is **not** tied to a user identity - it is bound to the org and its effective access is defined by the scopes / permission rules attached to it (it can be restricted to a single project, or kept broader). For Agent Factory, these keys can be generated directly from the Agent Factory UI (in addition to the AI Governance settings). Send as `x-prismeai-api-key: iak_...`. HookCallbackTokenAuth: type: apiKey in: header name: X-Hook-Token description: | Short-lived callback token (`cbt_...`) minted for one hook invocation and delivered to the hook target in `callback.token`. `Authorization: Bearer cbt_...` is also accepted. schemas: # ---------------------------------------------------------------- # Common envelopes # ---------------------------------------------------------------- Error: type: object required: [error, message] properties: error: type: string description: Stable PascalCase or SNAKE_CASE error code (e.g. AgentNotFound, VALIDATION_ERROR, FORBIDDEN, METHOD_NOT_ALLOWED). message: type: string description: Human-readable error message. details: type: object description: Optional structured context for the error. additionalProperties: true AdminError: type: object description: | Error body of the Admin routes. Authentication failures return `error` + `message`; permission, validation, method and rate-limit failures return `error` (message text) + `code` + `status`. required: [error] properties: error: type: string description: Error code (authentication failures) or human-readable message. message: type: string description: Human-readable message (authentication failures). code: type: string description: Stable error code (FORBIDDEN, VALIDATION_ERROR, METHOD_NOT_ALLOWED). status: type: integer description: HTTP status, repeated in the body. AdminUserRequest: type: object additionalProperties: false required: [user_id] properties: user_id: type: string maxLength: 128 description: Identifier of the user whose data is erased. dry_run: type: boolean default: false description: When `true`, only count what would be affected; nothing is deleted. AdminStepError: type: object properties: step: type: string description: Step that failed (e.g. conversations, shares, storage, ai_insights). error: type: string description: Error message of the failed step. AdminUserDeletionResult: type: object properties: dry_run: type: boolean user_id: type: string conversations_anonymized: type: integer agents_transferred: type: integer shares_deleted: type: integer ratings_deleted: type: integer access_requests_deleted: type: integer agent_bindings_deleted: type: integer tasks_archive_deleted: type: integer memories_deleted: type: integer storage_files_deleted: type: integer storage_vector_stores_deleted: type: integer insights_deleted: type: integer errors: type: array items: $ref: '#/components/schemas/AdminStepError' example: dry_run: false user_id: user-123 conversations_anonymized: 12 agents_transferred: 1 shares_deleted: 2 ratings_deleted: 3 access_requests_deleted: 0 agent_bindings_deleted: 4 tasks_archive_deleted: 5 memories_deleted: 6 storage_files_deleted: 2 storage_vector_stores_deleted: 1 insights_deleted: 7 errors: [] AdminUserExportResult: type: object properties: exported_at: type: string format: date-time user_id: type: string data: type: object description: Raw records per source, as stored by each workspace. properties: conversations: { type: array, items: { type: object, additionalProperties: true } } shares: { type: array, items: { type: object, additionalProperties: true } } ratings: { type: array, items: { type: object, additionalProperties: true } } access_requests: { type: array, items: { type: object, additionalProperties: true } } agent_bindings: { type: array, items: { type: object, additionalProperties: true } } tasks_archive: { type: array, items: { type: object, additionalProperties: true } } agents: { type: array, items: { type: object, additionalProperties: true } } memories: { type: array, items: { type: object, additionalProperties: true } } files: { type: array, items: { type: object, additionalProperties: true } } vector_stores: { type: array, items: { type: object, additionalProperties: true } } insights: { type: array, items: { type: object, additionalProperties: true } } gdpr_requests: { type: array, items: { type: object, additionalProperties: true } } counts: type: object description: Number of records per source. additionalProperties: type: integer errors: type: array items: $ref: '#/components/schemas/AdminStepError' example: exported_at: '2026-01-15T10:00:00.000Z' user_id: user-123 data: conversations: [] shares: [] ratings: [] access_requests: [] agent_bindings: [] tasks_archive: [] agents: [] memories: [] files: [] vector_stores: [] insights: [] gdpr_requests: [] counts: conversations: 0 shares: 0 ratings: 0 access_requests: 0 agent_bindings: 0 tasks_archive: 0 agents: 0 memories: 0 files: 0 vector_stores: 0 insights: 0 gdpr_requests: 0 errors: [] DeletedResult: type: object description: Generic delete acknowledgement. properties: deleted: type: boolean example: true # ---------------------------------------------------------------- # Agents # ---------------------------------------------------------------- SubAgentRef: type: object description: Sub-agent delegation entry on an agent. properties: agent_id: type: string name: type: string description: type: string Approver: type: object description: | Designated reviewer for a `tool_permissions` rule. When at least one approver is set, the platform emits a `task.approval.required` event and the approval is resolved through `POST /v1/agents/{agent_id}/tasks/{task_id}/resolve` by anyone matching the entry. Validation rejects unknown `type` values or `user`/`group` entries missing an `id`; it does NOT verify that the referenced principal exists. properties: type: type: string enum: [owner, user, group] id: type: string description: Required for `user` and `group`. Ignored for `owner`. required: [type] ToolPermissionRule: type: object description: | Per-tool override on the default policy. Targets a function tool by name, or an MCP server by its parent name (the rule then cascades to every child tool the server exposes at runtime; a child-name rule wins over a parent rule on conflict). properties: tool: type: string policy: type: string enum: [auto, always_ask, ask_external, ask_first] conditions: type: object description: | Optional `jsonmatch` pattern compared against the tool call's arguments. The rule's policy only fires when the pattern matches. A matching conditional rule beats a rule without `conditions` on the same tool, whatever their order in the array; when no conditional rule matches, the call falls through to the tool's rule without `conditions`, then to a legacy rule on the bare tool name, then to the server's rule, then to `default`. additionalProperties: true approvers: type: array items: $ref: '#/components/schemas/Approver' required: [tool, policy] ToolPermissions: type: object description: | Human-in-the-Loop configuration. Sets a default policy plus optional per-tool overrides. Policies: - `auto` - run immediately (default). - `always_ask` - halt every call on approval. - `ask_external` - halt only on MCP tool calls. - `ask_first` - halt the first time a tool runs in a session, then auto-approve that tool for the rest of the session. The approval is cached per tool (the namespaced `__` name for an MCP child) whatever level the rule is written at: under an MCP server rule, approving one child does not approve its siblings. When the matched rule carries `conditions`, the approval is also scoped to those conditions (e.g. `records` with `action: delete` is approved apart from `records` itself). properties: default: type: string enum: [auto, always_ask, ask_external, ask_first] default: auto tools: type: array items: $ref: '#/components/schemas/ToolPermissionRule' ToolActivationRule: type: object description: | Per-tool override on the default activation. Targets a function tool by name, or an MCP server by its parent name (activation cascades to every child tool the server exposes at runtime). properties: tool: type: string activation: type: string enum: [auto, user_first] required: [tool, activation] ToolActivation: type: object description: | Controls whether the model can use a given tool on a given turn. `user_first` tools are replaced by a same-named, schema-less stub with a "disabled" description on each turn, unless the user explicitly summons the tool from the chat input via `metadata.tool_choice`. Eligible tool types: `function` and `mcp`. `file_search`, `skill`, `guardrail`, and `system` types are exempt and always behave as `auto`. properties: default: type: string enum: [auto, user_first] default: auto tools: type: array items: $ref: '#/components/schemas/ToolActivationRule' Agent: type: object description: | Agent record (full view). Owners see this complete record including `published_config`. Non-owners with binding receive the same shape with `published_config` stripped server-side. Restricted-agent rows additionally carry `access_status` (`granted` or `none`) when seen in list/discovery views. additionalProperties: true properties: id: type: string name: type: string description: type: string instructions: type: string model: type: string fallback_models: type: array items: type: string temperature: type: number icon_url: type: string skills: type: array items: type: object additionalProperties: true attachments: type: object readOnly: true description: | Where to upload an attachment before referencing it in `message.parts[].url`: `POST {url}` in multipart, then put the returned file `url` in the part. This is the storage workspace, the one the web chat uploads to; clients should read it here rather than hardcode a workspace. properties: upload: type: object properties: workspaceId: type: string description: | Workspace reference usable as-is in a `/workspaces/{workspaceId}` path. Currently the slug form `slug:storage`, not a raw id. url: type: string format: uri method: type: string enum: [POST] tools: type: array items: $ref: '#/components/schemas/Tool' tool_permissions: $ref: '#/components/schemas/ToolPermissions' tool_activation: $ref: '#/components/schemas/ToolActivation' guardrails: type: object additionalProperties: true sub_agents: type: array items: $ref: '#/components/schemas/SubAgentRef' starters: type: array items: type: object additionalProperties: true allowed_models: type: array items: type: string max_tokens: type: integer max_turns: type: integer token_budget: type: integer tool_call_budget: type: integer effective_defaults: type: object description: | Editor view only (x-draft-mode, caller with edit rights). The values the runtime applies when an advanced field is left empty: profile limits first, then the workspace defaults (max_turns and tool_call_budget have no profile default: the workspace default applies, 50 and 100 respectively); max_tokens is the model's declared response limit, or null when the provider drops max_tokens (its own default applies). temperature_ignored is true when the model's provider drops the temperature parameter. properties: temperature: type: number temperature_ignored: type: boolean max_tokens: type: integer nullable: true max_turns: type: integer token_budget: type: integer tool_call_budget: type: integer canvas_enabled: type: boolean visibility: type: string enum: [public, private, restricted] category: type: string tags: type: array items: type: string status: type: string enum: [draft, published] profile: type: string enum: [simple, workflow, agent_light, agent_full, orchestrator] owner_id: type: string orgSlug: type: string subscription_id: type: string serviceAccountId: type: string published_config: type: object additionalProperties: true description: Snapshot of runtime fields at last publish (owners only). published_at: type: string format: date-time has_draft_changes: type: boolean rating: type: number ratings_count: type: integer messages_count: type: integer conversations_count: type: integer access_status: type: string enum: [granted, none] description: Only present on restricted-agent rows in list/discovery views. role: type: string enum: [owner, admin, editor, reader, null] nullable: true description: | The CALLER's effective rights on this agent, computed at read time. It has the same shape as `role` on knowledge bases. Returned by `GET /v1/agents/{agent_id}` and by the list endpoint. - `owner` - owns the agent. - `admin` - platform admin, agent-factory admin in the agent's org, or a share carrying the owner/admin role. Implies publish rights. - `editor` - may write but NOT publish. A surface rendering a *publish* button must check for `admin`, not merely "not reader". - `reader` - a decision was taken and it grants no write. - `null` - UNDETERMINED, **not** a refusal: for a caller who is neither owner nor admin, the write decision is only taken when the request asks for it - `x-draft-mode` on the detail endpoint, `x-draft-mode` or `?action=write` on the list. A consumer read (chat, embed, A2A, MCP) pays for no probe and gets null. Render no access screen on null - re-ask with the header, or show the consumer view. Reading an agent is much wider than editing it (a published+public agent is readable org-wide), which is why Agent Creator gates its UI on this rather than on the global `agent-factory:agents:write` scope. Informational - write endpoints still authorize on their own. access_reason: type: string description: >- Which access path granted the read: `owner`, `admin`, `public`, `published`, `trusted-source:`, `binding:[:]`, `wildcard-scope`, `scope` or `permission`. Diagnostic companion to `role`, and internal authorization topology - so it rides with the editor surface only: `GET /v1/agents/{agent_id}` returns it when the request carries `x-draft-mode`, and never on a consumer read or in the list. The `binding:` prefix carries a second job: it is what lets an agent with no published version be served to someone it was explicitly shared with - never published or withdrawn alike, since withdrawing empties the catalogue and not the shares. A public consumer (`public`), an admin (`admin`) and an RBAC scope (`wildcard-scope`, `scope`) do not match it and keep the refusal. is_owner: type: boolean description: >- Whether the caller owns this agent. Redundant with `role` = `owner`, kept for surfaces that only need that one bit. createdAt: type: string format: date-time updatedAt: type: string format: date-time AgentCreateInput: type: object required: [instructions] properties: name: type: string maxLength: 256 description: description: Plain string, or an object of per-locale strings. oneOf: - type: string maxLength: 4096 - type: object additionalProperties: type: string maxLength: 4096 instructions: type: string maxLength: 100000 description: System prompt / agent instructions. model: type: string maxLength: 128 fallback_models: type: array items: type: string temperature: type: number profile: type: string maxLength: 64 enum: [simple, workflow, agent_light, agent_full, orchestrator] skills: type: array items: type: object additionalProperties: true sub_agents: type: array description: Sub-agent delegations (max 20). items: $ref: '#/components/schemas/SubAgentRef' starters: type: array description: Conversation starter prompts (max 10). items: type: object additionalProperties: true max_turns: type: integer minimum: 1 nullable: true description: Persisted only when provided; otherwise the workspace default applies (max_turns has no profile default). 0 and negative values are rejected. token_budget: type: integer description: Overrides the profile default when provided. tool_call_budget: type: integer minimum: 0 nullable: true description: Persisted only when provided and positive; otherwise the workspace default applies (tool_call_budget has no profile default). 0 means the default, like null or omission. Negative values are rejected. tools: type: array items: $ref: '#/components/schemas/Tool' tool_activation: $ref: '#/components/schemas/ToolActivation' AgentUpdateInput: type: object description: Partial agent update payload. Any subset of the writable Agent fields. properties: name: type: string maxLength: 256 description: description: Plain string, or an object of per-locale strings. oneOf: - type: string maxLength: 4096 - type: object additionalProperties: type: string maxLength: 4096 instructions: type: string maxLength: 100000 model: type: string maxLength: 128 fallback_models: type: array items: type: string temperature: type: number nullable: true description: Send null to reset to the default temperature. tools: type: array items: $ref: '#/components/schemas/Tool' icon_url: type: string nullable: true description: Send null or an empty string to remove the icon. skills: type: array items: type: object additionalProperties: true guardrails: type: object additionalProperties: true sub_agents: type: array items: type: object additionalProperties: true tool_permissions: $ref: '#/components/schemas/ToolPermissions' tool_activation: $ref: '#/components/schemas/ToolActivation' allowed_models: type: array items: type: string max_tokens: type: integer nullable: true description: Send null to remove the per-agent limit (the LLM Gateway limit applies). max_turns: type: integer minimum: 1 nullable: true description: Send null to reset to the workspace default (max_turns has no profile default). 0 and negative values are rejected. token_budget: type: integer nullable: true description: Send null to reset to the profile or platform default. tool_call_budget: type: integer minimum: 0 nullable: true description: Send null or 0 to reset to the workspace default (tool_call_budget has no profile default). Negative values are rejected. canvas_enabled: type: boolean visibility: type: string enum: [public, private, restricted] maxLength: 32 category: type: string maxLength: 128 tags: type: array nullable: true description: Send null or an empty array to remove all tags. items: type: string starters: type: array items: type: object additionalProperties: true status: type: string enum: [draft, published] maxLength: 32 profile: type: string enum: [simple, workflow, agent_light, agent_full, orchestrator] maxLength: 64 AgentCreateResponse: type: object description: Slim record returned on agent create / import. properties: id: type: string name: type: string status: type: string enum: [draft] serviceAccountId: type: string createdAt: type: string format: date-time AgentImportInput: type: object required: [agents_md] properties: agents_md: type: string maxLength: 200000 description: Full AGENTS.md document (front matter + markdown). target_agent_id: type: string maxLength: 128 description: | Optional - when set, patches the matching agent instead of creating a new one. Frontmatter `id:` is ignored; only this field triggers the patch path. AgentImportResponse: allOf: - $ref: '#/components/schemas/AgentCreateResponse' - type: object properties: imported: type: boolean example: true action: type: string enum: [created, updated] description: | Indicates whether the call created a new agent or patched an existing one (based on `target_agent_id`). AgentUnpublishResponse: type: object properties: status: type: string example: draft visibility: type: string example: private unpublished_at: type: string format: date-time ConversationUsageTotals: type: object properties: messages: type: integer description: Turns that carried usage (one per assistant turn with an LLM call). tokens_input: type: integer tokens_output: type: integer tokens_total: type: integer cost: type: number carbon: type: number description: Global warming potential of the turns (from `usage.carbon.gwp.value`). ConversationUsage: type: object properties: context_id: type: string agent_id: type: string title: type: string totals: $ref: '#/components/schemas/ConversationUsageTotals' by_model: type: array items: allOf: - $ref: '#/components/schemas/ConversationUsageTotals' - type: object properties: model: type: string meta: type: object properties: source: type: string example: tasks messages_count: type: integer generated_at: type: string format: date-time ConnectorAccountList: type: object properties: object: type: string example: list items: type: array items: type: object properties: knowledge_base_id: type: string capability_id: type: string capability_name: type: string connected: type: boolean connect_url: type: string disconnect_url: type: string usage: type: string description: Scope of the connection (bound to this agent). AgentTrace: type: object properties: correlationId: type: string agent_id: type: string summary: type: object properties: eventCount: type: integer errorCount: type: integer toolCallCount: type: integer retrievalCount: type: integer model: type: string startTime: type: string format: date-time endTime: type: string format: date-time details_expired: type: boolean timeline_truncated: type: boolean workspaceId: type: string usage: type: object properties: input_tokens: type: integer output_tokens: type: integer total_tokens: type: integer cost: type: number duration_ms: type: integer completions: type: integer retrieval: type: array items: type: object properties: query: type: string tool_name: type: string knowledge_base_id: type: string status: type: string returned: type: integer total_found: type: integer duplicates_filtered: type: integer passages: type: array items: type: object additionalProperties: true timestamp: type: string format: date-time tool_calls: type: array items: type: object properties: type: type: string tool_call_id: type: string tool_name: type: string display_name: type: string status: type: string error: nullable: true timestamp: type: string format: date-time timeline: type: array description: Projected steps (never raw payloads), sorted by emission time. items: type: object additionalProperties: true properties: id: type: string description: Event id, to pass to the step-detail endpoint. workspaceId: type: string timestamp: type: string format: date-time startedAt: type: string format: date-time type: type: string automation: type: string appInstance: type: string errors: type: array items: type: object properties: id: type: string automation: type: string appInstance: type: string trigger: type: object additionalProperties: true error: nullable: true message: type: string details: nullable: true timestamp: type: string format: date-time AgentTraceEvent: type: object properties: id: type: string type: type: string timestamp: type: string format: date-time automation: type: string appInstance: type: string workspaceId: type: string duration: type: number trigger: type: object additionalProperties: true expired: type: boolean description: True when the 14-day cleanup already removed this step's inputs and outputs. input: nullable: true description: Step inputs, known secret keys removed. output: nullable: true description: Step outputs, known secret keys removed. source: type: object properties: correlationId: type: string automationSlug: type: string appInstanceFullSlug: type: string appInstanceDepth: type: integer workspaceId: type: string userId: type: string sessionId: type: string serviceTopic: type: string TaskHookEventInput: type: object required: [event] properties: event: type: string enum: [task.status, task.output.delta, task.output.completed] data: type: object additionalProperties: true description: A2A-shaped payload of the event. TaskHookUpdateInput: type: object properties: status: type: object additionalProperties: true description: A2A task status (`state`, optional `timestamp`, defaulted to now). artifacts: type: array items: type: object additionalProperties: true output: type: object additionalProperties: true AgentListResponse: type: object description: Page of agents (with `published_config` stripped on list rows). properties: items: type: array items: $ref: '#/components/schemas/Agent' total: type: integer page: type: integer limit: type: integer DiscoveryCategory: type: object properties: value: type: string count: type: integer DiscoveryResponse: type: object description: Featured agents + categories for the discovery surface. properties: featured: type: array items: $ref: '#/components/schemas/Agent' categories: type: array items: $ref: '#/components/schemas/DiscoveryCategory' # ---------------------------------------------------------------- # Publishing # ---------------------------------------------------------------- AgentPublishInput: type: object properties: visibility: type: string enum: [public, restricted] maxLength: 32 description: Defaults to `public`. category: type: string maxLength: 128 tags: type: array items: type: string AgentPublishResponse: type: object properties: status: type: string enum: [published] visibility: type: string enum: [public, restricted] published_at: type: string format: date-time AgentDiscardDraftResponse: type: object properties: discarded: type: boolean example: true agent_id: type: string # ---------------------------------------------------------------- # Ratings # ---------------------------------------------------------------- RatingInput: type: object required: [rating] properties: rating: type: integer minimum: 1 maximum: 5 RatingResult: type: object properties: rating: type: number description: New average rating (rounded to 1 decimal). ratings_count: type: integer description: Total number of ratings. # ---------------------------------------------------------------- # Profiles # ---------------------------------------------------------------- Profile: type: object description: Agent profile preset. properties: id: type: string enum: [simple, workflow, agent_light, agent_full, orchestrator] description: type: string level: type: string features: type: object additionalProperties: true limits: type: object description: 'Per-message limits the profile sets by default — `token_budget`, plus `cost_budget_usd` and `max_delegation_depth` on the higher profiles. `max_turns` and the tool call budget are not profile limits (no `tool_calls` key): they are workspace-wide defaults an agent can override.' additionalProperties: true use_cases: type: array items: type: string ProfileListResponse: type: object properties: items: type: array items: $ref: '#/components/schemas/Profile' # ---------------------------------------------------------------- # Tools # ---------------------------------------------------------------- Tool: type: object description: | Tool entry attached to an agent. Discriminated by `type` - `file_search` (requires `vector_store_id`), `mcp` (uses `server`, `headers`, `scope`), or `function` (uses `url`, `parameters`, `headers`). additionalProperties: true properties: id: type: string type: type: string enum: [file_search, mcp, function] name: type: string pattern: '^[a-zA-Z0-9_-]+$' display_name: type: string description: type: string catalog_id: type: string auth: type: object additionalProperties: true icon_url: type: string vector_store_id: type: string description: Required for `file_search`. server: type: string description: MCP server URL (for `mcp`). headers: type: object additionalProperties: true scope: type: string url: type: string description: Required for `function`. parameters: type: object additionalProperties: true description: JSON Schema describing the function tool's parameters. ToolAddInput: type: object required: [type] properties: type: type: string enum: [file_search, mcp, function] maxLength: 64 name: type: string maxLength: 128 pattern: '^[a-zA-Z0-9_-]+$' display_name: type: string maxLength: 256 description: type: string maxLength: 4096 catalog_id: type: string maxLength: 128 auth: type: object additionalProperties: true icon_url: type: string maxLength: 2048 vector_store_id: type: string maxLength: 128 description: Required for `file_search`. server: type: string maxLength: 2048 description: MCP server URL (for `mcp`). headers: type: object additionalProperties: true scope: type: string maxLength: 256 url: type: string maxLength: 2048 description: Required for `function`. parameters: type: object additionalProperties: true description: JSON Schema describing the function tool's parameters. ToolListResponse: type: object properties: items: type: array items: $ref: '#/components/schemas/Tool' ServerTool: type: object description: | One tool advertised by an MCP server (`tools/list`), with the name the runtime exposes it under. required: [name, canonical_name] properties: name: type: string description: Tool name exactly as the server advertises it (what `tools/call` receives). canonical_name: type: string pattern: '^[a-zA-Z0-9_-]{1,64}$' description: | `__` name the model calls the tool by, and the value a `tool_permissions.tools[].tool` rule must carry to target this tool. Both segments sanitised to `[A-Za-z0-9_-]`, the pair trimmed to 64 characters. Computed by the runtime; never derive it. description: type: string inputSchema: type: object additionalProperties: true description: | JSON Schema of the tool's arguments, as published. A `properties.action.enum` is the Prisme schema convention for several operations behind one tool; a rule may target one of them with `conditions: {action: ""}`. annotations: type: object nullable: true additionalProperties: true description: | MCP tool annotations as published (`readOnlyHint`, `destructiveHint`, …), `null` when the server publishes none. Forwarded raw; nothing is derived from them. ToolCapabilities: type: object description: | Tools an MCP server attached to an agent exposes, as returned by `GET /v1/agents/{agentId}/tools/{toolId}/capabilities`. required: [status, items] properties: status: type: string enum: [ok, auth_required, unavailable] description: | `ok`: `items` is the server's list. `auth_required`: OAuth-gated server the caller is not connected to; `items` is empty. `unavailable`: the handshake or `tools/list` failed; `items` is empty and `error` carries the message. items: type: array items: $ref: '#/components/schemas/ServerTool' error: type: string description: Transport or JSON-RPC error message when `status` is `unavailable`. # ---------------------------------------------------------------- # Conversations # ---------------------------------------------------------------- Conversation: type: object description: Conversation envelope (one row per A2A `contextId`). properties: contextId: type: string agent_id: type: string title: type: string is_archived: type: boolean is_starred: type: boolean messages_count: type: integer last_message_at: type: string createdAt: type: string format: date-time ConversationCreateInput: type: object properties: title: type: string maxLength: 512 description: Optional title. If omitted, the client localizes a default title. ConversationUpdateInput: type: object properties: title: type: string maxLength: 512 is_archived: type: boolean is_starred: type: boolean ConversationListResponse: type: object properties: items: type: array items: $ref: '#/components/schemas/Conversation' ConversationDetailResponse: type: object properties: conversation: $ref: '#/components/schemas/Conversation' messages: type: array description: Task-message records (A2A history entries). items: type: object additionalProperties: true ConversationsBulkDeleteResult: type: object properties: deleted: type: boolean example: true count: type: integer description: Number of conversations deleted. # ---------------------------------------------------------------- # Messages / A2A # ---------------------------------------------------------------- MessagePart: type: object description: | A2A message part. Discriminated by field presence: `TextPart` (`text`), `FilePart` (`url`/`raw`, `mediaType`, `filename`), `DataPart` (`data`, `mediaType`). additionalProperties: true Message: type: object description: A2A v0.3 flat message envelope. properties: message_id: type: string maxLength: 256 description: | Client-chosen message identifier, echoed for correlation only. It is **not** used to deduplicate: the server mints its own `msg_*` ids for the stored history. To make a send idempotent, use `metadata.clientMessageId`. role: type: string enum: [user, agent] contextId: type: string maxLength: 64 description: | Conversation the message belongs to. Omit it to start a new conversation, then send the `contextId` returned by the first reply with every following message. Each message opens a new task in the conversation, and the agent receives the earlier turns of that conversation. taskId: type: string description: | Only to answer a task waiting for the user (`input-required`), for example a tool-call approval sent as a `DataPart` `{"approved": true, "toolCallId": "..."}` together with `contextId`. A message without `taskId` opens a new task. metadata: type: object additionalProperties: true description: | Message-level metadata. Recognised keys below; any other key is accepted and ignored. properties: clientMessageId: type: string minLength: 1 maxLength: 128 pattern: '^[A-Za-z0-9._:-]{1,128}$' description: | Opt-in idempotency key, scoped to (caller, agent). The client picks it and keeps it **stable across retries of the same logical message**, typically a local id minted before the first attempt. Replaying a send with the same key returns the first answer verbatim (with `task.replayed: true`) instead of running the agent again, so a client killed before it could read the response can retry without opening a second conversation. A replay that arrives while the first run is still in flight gets `409 MESSAGE_IN_PROGRESS`. The key alone identifies the message: the body of a replay is **not compared** with the first one. A replay carrying a different text, other parts or another `contextId` still gets the first answer, silently. A client that changes the message must mint a new key, and reuse a key only to retry the exact same send. A replay still counts against the rate limits like any other call (it is checked before the key is looked up), and one that is over the limit gets `429`, not the stored answer. Honoured only for a caller authenticated as a user. An org API key with no user behind it resolves to a single shared identity, so the key would be shared by every caller of that key: it is ignored there and the message is sent normally (the format check below still applies). Keys are kept for 7 days by default (`config.idempotency.receipt_retention_days`); after that the same key is treated as new. An invalid value is rejected with `400 VALIDATION_ERROR`: omit the field to keep the previous (non-idempotent) behaviour. Not supported on `messages/stream`. locale: type: string description: | BCP-47 code of the user's interface language (`fr`, `fr-FR`, `pt-BR`), used as the default response language only when the message itself does not make the language clear. Also accepted per part; the message level wins. Falls back to the `Accept-Language` header; an unrecognised code is ignored. parts: type: array items: $ref: '#/components/schemas/MessagePart' MessageSendInput: type: object required: [message] properties: message: $ref: '#/components/schemas/Message' ToolCallSummary: type: object properties: name: type: string arguments: type: object additionalProperties: true status: type: string MessageSendResponse: type: object properties: error: type: object nullable: true additionalProperties: true task: type: object properties: id: type: string contextId: type: string description: | Always present, including when the request omitted it: this is the identifier of the conversation that was created. Send it back on the next message to continue that conversation. status: $ref: '#/components/schemas/TaskStatus' replayed: type: boolean description: | Present and `true` only when this body was replayed from an earlier send carrying the same `message.metadata.clientMessageId`. The agent was not run again. Absent on a first execution. output: type: object properties: messages: type: array items: $ref: '#/components/schemas/Message' usage: type: object additionalProperties: true tool_calls: type: array items: $ref: '#/components/schemas/ToolCallSummary' # ---------------------------------------------------------------- # Tasks # ---------------------------------------------------------------- TaskState: type: string description: A2A task state. enum: [working, completed, canceled, failed, input-required] TaskStatus: type: object properties: state: $ref: '#/components/schemas/TaskState' timestamp: type: string message: type: object additionalProperties: true Task: type: object description: A2A task record. properties: id: type: string contextId: type: string status: $ref: '#/components/schemas/TaskStatus' history: type: array items: type: object additionalProperties: true artifacts: type: array items: type: object additionalProperties: true metadata: type: object additionalProperties: true createdAt: type: string format: date-time TaskListResponse: type: object properties: items: type: array items: $ref: '#/components/schemas/Task' TaskCancelResult: type: object properties: id: type: string status: type: string example: canceled TaskResolveInput: type: object required: [approved] properties: approved: type: boolean description: Approve or reject the pending tool call. reason: type: string maxLength: 2048 description: Optional rationale, surfaced in audit trail. TaskResolveResponse: type: object properties: task_id: type: string status: type: object additionalProperties: true resolution: type: string enum: [approved, rejected] resolved_by: type: string TaskSnapshot: allOf: - $ref: '#/components/schemas/Task' - type: object properties: terminal: type: boolean description: True when state is `completed`, `canceled`, or `failed`. # ---------------------------------------------------------------- # Artifacts # ---------------------------------------------------------------- ArtifactDetail: type: object description: Artifact record with the resolved current-version content. properties: id: type: string title: type: string artifact_type: type: string mime_type: type: string language: type: string filename: type: string current_version: type: integer total_versions: type: integer version: type: integer description: Version whose `content` is returned. content: type: string versions: type: array description: Only with `?versions=1`. items: type: object properties: version: type: integer createdAt: type: string format: date-time changeSummary: type: string createdByType: type: string bytes: type: integer conversation_id: type: string agent_id: type: string user_id: type: string created_at: type: string format: date-time updated_at: type: string format: date-time ArtifactListResponse: type: object description: Paginated list of artifacts (no `total` returned by this endpoint). properties: artifacts: type: array items: type: object additionalProperties: true description: Artifact record (see `ArtifactDetail`). page: type: integer limit: type: integer ArtifactPatchInput: type: object description: | Send `content` (full replace) or `restore_version` (fork a historical version into a new current version). properties: content: type: string description: Full replacement content (creates a new version). restore_version: type: number description: Historical version number to re-commit as the new current version. change_summary: type: string maxLength: 512 base_version: type: integer description: Expected current version for optimistic concurrency. ArtifactDeleteResult: type: object properties: deleted: type: boolean example: true artifact_id: type: string # ---------------------------------------------------------------- # Shares # ---------------------------------------------------------------- ConversationShareInput: type: object properties: message_id: type: string maxLength: 128 description: | Optional - when set, share is scoped to this single message (`type: "message"` instead of `"conversation"`). ConversationShareResponse: type: object properties: id: type: string type: type: string enum: [conversation, message] url: type: string description: UI URL on the caller's origin (`/share/{share_id}`). apiUrl: type: string description: Public API URL pointing at `/v1/shared/{shareId}`. created_at: type: string format: date-time ArtifactShareInput: type: object properties: access_level: type: string enum: [view] maxLength: 32 description: Default `view`. ArtifactShareResponse: type: object properties: id: type: string type: type: string enum: [artifact] artifact_id: type: string url: type: string apiUrl: type: string access_level: type: string ShareListItem: type: object description: Share row as returned by the owner's list endpoint. properties: id: type: string type: type: string enum: [conversation, message, artifact] context_id: type: string message_id: type: string artifact_id: type: string agent_id: type: string title: type: string agent_name: type: string artifact_type: type: string url: type: string description: Workspace-relative public viewer URL. created_at: type: string format: date-time ShareListResponse: type: object properties: items: type: array items: $ref: '#/components/schemas/ShareListItem' Share: type: object description: Share record (owner view). properties: id: type: string type: type: string enum: [conversation, message, artifact] context_id: type: string message_id: type: string agent_id: type: string url: type: string created_at: type: string format: date-time snapshot: type: object additionalProperties: true description: | The frozen snapshot - for `conversation`/`message` shares this includes `messages`, `artifacts`, `agent_name`, `agent_icon_url`. For `artifact` shares it carries `content`, `artifact_type`, `mime_type`, `version`, `access_level`. ShareView: type: object description: Public-facing view returned by `/v1/shared/{shareId}`. properties: id: type: string type: type: string enum: [conversation, message, artifact] created_at: type: string format: date-time snapshot: type: object additionalProperties: true is_mine: type: boolean # ---------------------------------------------------------------- # Access bindings & requests # ---------------------------------------------------------------- AccessBinding: type: object description: Access binding granting a principal a role on an agent. properties: agent_id: type: string principal_type: type: string enum: [user, group, org] principal_id: type: string email: type: string orgSlug: type: string granted_by: type: string role_slug: type: string AccessBindingListResponse: type: object properties: items: type: array items: $ref: '#/components/schemas/AccessBinding' total: type: integer page: type: integer limit: type: integer AccessShareInput: type: object required: [principal_type, principal_id] properties: principal_type: type: string enum: [user, group, org] maxLength: 32 principal_id: type: string maxLength: 128 description: User id (or email for user type, resolved server-side), group id, or org slug. For `org`, the target may be the agent's own org, another org (sharer must be a member), or the literal `*` for all authenticated users belonging to at least one org - both beyond-own-org forms require `agent-factory:sharing:cross-org`. role_slug: type: string maxLength: 64 description: Role to grant, `admin` or `user` (`owner` is refused). Defaults to `admin` for same-org shares, `user` for any org target beyond the agent's own org. AccessShareResponse: type: object properties: created: type: boolean example: true binding: $ref: '#/components/schemas/AccessBinding' AccessRequest: type: object description: Pending or resolved access request for a restricted agent. additionalProperties: true properties: _id: type: string agent_id: type: string requester_id: type: string requester_email: type: string orgSlug: type: string status: type: string enum: [pending, approved, rejected] message: type: string resolved_by: type: string rejection_reason: type: string AccessRequestInput: type: object properties: message: type: string maxLength: 1024 description: Optional rationale for the access request. AccessRequestListResponse: type: object properties: items: type: array items: $ref: '#/components/schemas/AccessRequest' total: type: integer page: type: integer limit: type: integer AccessRequestResolveInput: type: object required: [action] properties: action: type: string enum: [approve, reject] maxLength: 16 rejection_reason: type: string maxLength: 1024 AccessRequestResolveResponse: type: object properties: _id: type: string agent_id: type: string requester_id: type: string requester_email: type: string status: type: string enum: [approved, rejected] resolved_by: type: string rejection_reason: type: string # ---------------------------------------------------------------- # API keys # ---------------------------------------------------------------- AgentApiKeyCreateInput: type: object required: [name, slug, permissions] properties: name: type: string maxLength: 128 slug: type: string maxLength: 96 permissions: type: array minItems: 1 items: type: string maxLength: 96 description: Permissions (will be prefixed with `agent-factory:` server-side). expiresAt: type: string description: ISO timestamp. AgentApiKeyRotateInput: type: object properties: expiresAt: type: string description: New expiration ISO timestamp (optional). # ---------------------------------------------------------------- # Activity feed # ---------------------------------------------------------------- ActivityItem: type: object properties: id: type: string type: type: string group: type: string timestamp: type: string format: date-time correlationId: type: string userId: type: string agent_id: type: string data: type: object additionalProperties: true description: Sanitized event payload (sensitive fields stripped). ActivityListResponse: type: object properties: items: type: array items: $ref: '#/components/schemas/ActivityItem' total: type: integer page: type: integer limit: type: integer # ---------------------------------------------------------------- # Analytics # ---------------------------------------------------------------- AnalyticsPeriod: type: object properties: type: type: string start: type: string end: type: string granularity: type: string AnalyticsSeriesPoint: type: object properties: date: type: string users: type: integer conversations: type: integer messages: type: integer rating: type: number cost: type: number status: type: string enum: [incomplete, complete] AnalyticsMeta: type: object properties: generated_at: type: string data_points: type: integer includes_current_interval: type: boolean summary_cached: type: boolean data_computed_at: type: string next_refresh_at: type: string AgentAnalytics: type: object description: Analytics payload (series + summary) for a single agent. properties: agent_id: type: string agent_name: type: string period: $ref: '#/components/schemas/AnalyticsPeriod' summary: type: object additionalProperties: true description: Aggregated KPIs (users, engagement, quality, performance, cost, models, tools). series: type: array items: $ref: '#/components/schemas/AnalyticsSeriesPoint' meta: $ref: '#/components/schemas/AnalyticsMeta' RefreshMetricsInput: type: object properties: period_start: type: string description: ISO timestamp - start of the refresh window. period_end: type: string description: ISO timestamp - end of the refresh window (exclusive). granularity: type: string enum: [5m, hourly, daily] description: Aggregation granularity. Default `hourly`. RefreshMetricsResult: type: object properties: status: type: string example: refreshed agent_id: type: string granularity: type: string enum: [5m, hourly, daily] period_start: type: string period_end: type: string entries_written: type: integer error: type: string description: Set if a partial failure occurred during aggregation. # ---------------------------------------------------------------- # Retention # ---------------------------------------------------------------- RetentionEffective: type: object description: Resolved retention values (agent -> org -> platform defaults). properties: conversations_retention_days: type: integer nullable: true documents_retention_days: type: integer nullable: true tasks_retention_days: type: integer nullable: true artifacts_retention_days: type: integer nullable: true AgentRetentionInput: type: object properties: conversations_retention_days: type: integer nullable: true documents_retention_days: type: integer nullable: true tasks_retention_days: type: integer nullable: true artifacts_retention_days: type: integer nullable: true admin_override: type: boolean description: Admins only - opt out of org-limit enforcement. OrgRetentionInput: type: object properties: conversations_retention_days: type: integer nullable: true documents_retention_days: type: integer nullable: true tasks_retention_days: type: integer nullable: true artifacts_retention_days: type: integer nullable: true AgentRetentionResponse: type: object properties: policy: type: object nullable: true additionalProperties: true description: | Raw `retention_policies` document for this agent (`scope: "agent"`). Null when no override is set. effective: $ref: '#/components/schemas/RetentionEffective' OrgRetentionResponse: type: object properties: policy: type: object nullable: true additionalProperties: true effective: $ref: '#/components/schemas/RetentionEffective' RetentionDeleteResult: type: object properties: deleted: type: boolean # ---------------------------------------------------------------- # Evaluations # ---------------------------------------------------------------- EvaluationRunInput: type: object required: [file_id] properties: file_id: type: string maxLength: 128 description: Storage `file_id` containing the evaluation inputs. name: type: string maxLength: 256 criteria: type: string maxLength: 4096 description: Free-text grading criteria. judge_model: type: string maxLength: 128 description: LLM-as-judge model. Default `gpt-4o`. EvaluationRunResponse: type: object properties: id: type: string status: type: string example: running name: type: string createdAt: type: string format: date-time # ---------------------------------------------------------------- # A2A - JSON-RPC envelopes & cards # ---------------------------------------------------------------- JsonRpcError: type: object properties: code: type: integer message: type: string data: type: object additionalProperties: true JsonRpcResponse: type: object description: A2A JSON-RPC 2.0 response. properties: jsonrpc: type: string enum: ['2.0'] id: type: string nullable: true description: Echoes the request id (string or null per JSON-RPC 2.0). result: type: object additionalProperties: true error: $ref: '#/components/schemas/JsonRpcError' JsonRpcErrorEnvelope: type: object description: | Bare JSON-RPC error envelope returned without a successful `result` (e.g. when the legacy gateway cannot resolve the target agent). properties: jsonrpc: type: string enum: ['2.0'] error: type: object properties: code: type: integer example: -32000 message: type: string id: type: string nullable: true description: Echoes the request id (string or null per JSON-RPC 2.0). JsonRpcRequest: type: object description: Per-agent A2A JSON-RPC 2.0 request. required: [jsonrpc, method] properties: jsonrpc: type: string enum: ['2.0'] method: type: string maxLength: 64 params: type: object additionalProperties: true id: type: string maxLength: 128 LegacyJsonRpcRequest: type: object description: | Legacy `/v1/a2a` JSON-RPC request. `params.id` MUST be present - it identifies the target agent for gateway dispatch. required: [jsonrpc, method, params] properties: jsonrpc: type: string enum: ['2.0'] method: type: string maxLength: 64 description: A2A method name (e.g. `message/send`, `tasks/get`). params: type: object required: [id] properties: id: type: string maxLength: 128 description: Target agent ID - required by the legacy gateway. additionalProperties: true id: type: string maxLength: 128 description: JSON-RPC request id - echoed back in the response. AgentCardInterface: type: object properties: url: type: string protocolBinding: type: string AgentCardCapabilities: type: object properties: streaming: type: boolean pushNotifications: type: boolean stateTransitionHistory: type: boolean AgentCard: type: object description: A2A 0.3 discovery card. additionalProperties: true properties: protocolVersions: type: array items: type: string name: type: string description: type: string version: type: string supportedInterfaces: type: array items: $ref: '#/components/schemas/AgentCardInterface' capabilities: $ref: '#/components/schemas/AgentCardCapabilities' securitySchemes: type: object additionalProperties: true security: type: array items: type: object additionalProperties: true defaultInputModes: type: array items: type: string defaultOutputModes: type: array items: type: string skills: type: array items: type: object additionalProperties: true iconUrl: type: string ExtendedAgentCard: type: object description: | Extended A2A AgentCard. Public AgentCard fields + `tools`, `guardrails`, `sub_agents`, `model`, `temperature`. additionalProperties: true