# AUTO-GENERATED tier-A mirror spec — do not edit.
# Source: openapi/runtime/activity.yaml (runtime 0.124.0)
#  + policy: openapi/mirror-policies/activity.json
# Regenerate: node scripts/generate-mirror-specs.mjs
openapi: 3.0.3
info:
  title: naturali.ai — Activity API
  version: 1.0.0
  description: >-
    Activity: what a project's agents actually did, newest first — one entry per executed action,
    resolved approval, raised exception and fired schedule, each with a one-line summary and the
    structured detail behind it. A fully runtime-backed module — this spec is generated verbatim
    from the runtime's own, re-rooted under /v1/projects/{project_id}. The project in the path is
    authorized by naturali and enforced upstream by the project's scoped credential.


    This module mirrors the upstream runtime verbatim (tier A): paths are the runtime's own
    re-rooted under /v1/projects/{project_id}, and every field, method, status code and error shape
    passes through unchanged. Errors raised by the runtime arrive in its envelope; errors raised by
    naturali itself (authentication, project resolution, an unreachable runtime) use naturali's.
  contact:
    name: naturali.ai
    url: https://naturali.ai
servers:
  - url: "{baseUrl}"
    description: Host of your naturali.ai deployment; every path carries the /v1 prefix.
    variables:
      baseUrl:
        description: Base host URL.
        default: https://api.naturali.ai
tags:
  - name: Activity
    description: Read the autonomous-execution activity feed
security:
  - bearerAuth: []
  - oauth2:
      - mcp:access
paths:
  /v1/projects/{project_id}/activity:
    get:
      tags:
        - Activity
      summary: List activity feed entries
      description: Returns activity entries for a project, newest first, filterable by kind, severity,
        agent, generation and orchestration run — every filter composable with the rest. Pass the
        previous page's `next_cursor` as `cursor` to fetch the next one; a `null` `next_cursor`
        means there is no more data.
      operationId: listActivity
      parameters:
        - name: kind
          in: query
          description: Filter by activity kind
          schema:
            type: string
            enum:
              - action_executed
              - approval_created
              - approval_resolved
              - exception_created
              - schedule_fired
              - share_cap_exceeded
              - share_resumed
              - share_revoked
              - share_suspended
              - tool_resolution_failed
              - usage_quantity_invalid
        - name: severity
          in: query
          description: Filter by severity
          schema:
            type: string
            enum:
              - info
              - warning
              - critical
        - name: agent_id
          in: query
          description: Filter to entries produced by one agent. Composable with every other filter — entries
            carry one agent, one generation and one run, so naming two narrows to the rows where
            both hold.
          schema:
            type: string
            example: agent_V1StGXR8Z5jdHi6B
        - name: generation_id
          in: query
          description: "Filter to entries produced during one agent generation. This is what turns
            `tool_resolution_failed` from alertable into usable: the warning for a suspect turn is
            one query rather than a scan of the project's feed."
          schema:
            type: string
            example: gen_V1StGXR8Z5jdHi6B
        - name: orchestration_run_id
          in: query
          description: Filter to entries produced during one orchestration run.
          schema:
            type: string
            example: orch_run_V1StGXR8Z5jdHi
        - $ref: "#/components/parameters/Limit"
        - $ref: "#/components/parameters/Cursor"
      responses:
        "200":
          description: Page of activity entries
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/Page"
                  - properties:
                      data:
                        type: array
                        items:
                          $ref: "#/components/schemas/ActivityEntry"
        "400":
          description: Malformed cursor, or one sent with other filters
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          $ref: "#/components/responses/ProjectNotFound"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    parameters:
      - $ref: "#/components/parameters/ProjectId"
  /v1/projects/{project_id}/activity/export:
    get:
      tags:
        - Activity
      summary: Export the activity feed as NDJSON
      description: "Streams a project's activity entries as newline-delimited JSON — one entry object per
        line, **oldest first**, where the feed itself reads newest first: a feed answers what just
        happened, and a file is read start to end. The export is per-project: `project_id` names it,
        or a project-bound credential implies its own. Filters behave exactly as they do on the list
        endpoint."
      operationId: exportActivity
      x-mcp-exclude: true
      parameters:
        - name: kind
          in: query
          description: Only entries of this kind
          schema:
            type: string
            enum:
              - action_executed
              - approval_created
              - approval_resolved
              - exception_created
              - schedule_fired
              - share_cap_exceeded
              - share_resumed
              - share_revoked
              - share_suspended
              - tool_resolution_failed
              - usage_quantity_invalid
        - name: severity
          in: query
          description: Only entries of this severity
          schema:
            type: string
            enum:
              - info
              - warning
              - critical
        - name: agent_id
          in: query
          description: Only entries an agent produced
          schema:
            type: string
            example: agent_V1StGXR8Z5jdHi6B
        - name: generation_id
          in: query
          description: Only entries a generation produced
          schema:
            type: string
            example: gen_V1StGXR8Z5jdHi6B
        - name: orchestration_run_id
          in: query
          description: Only entries an orchestration run produced
          schema:
            type: string
            example: orch_run_V1StGXR8Z5jdHi6B
      responses:
        "200":
          description: A newline-delimited stream of activity entries. Each line is a JSON object with the
            same fields as `ActivityEntry`.
          content:
            application/x-ndjson:
              schema:
                type: string
        "400":
          description: "`project_id` is missing and the credential names no project"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          $ref: "#/components/responses/ProjectNotFound"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalError"
    parameters:
      - $ref: "#/components/parameters/ProjectId"
components:
  schemas:
    ActivityEntry:
      type: object
      properties:
        id:
          type: string
          example: acte_V1StGXR8Z5jdHi6B
        project_id:
          x-naturali-ref: projects
          type: string
        kind:
          type: string
          enum:
            - action_executed
            - approval_created
            - approval_resolved
            - exception_created
            - schedule_fired
            - share_cap_exceeded
            - share_resumed
            - share_revoked
            - share_suspended
            - tool_resolution_failed
            - usage_quantity_invalid
          description: How the entry was produced. `tool_resolution_failed` means a tool binding contributed
            no tool to the turn — its source could not be reached or refused the listing, or the
            listing was read and left nothing to attach — so the turn ran without it. The generation
            itself completes, carrying no error, so this is the only signal that it answered with
            fewer tools than it was configured to have. `share_suspended`, `share_resumed` and
            `share_revoked` land in a consumer project when the publisher of a share it accepted
            suspends, resumes or revokes it; `ref_id` is the share and `detail` names the resource
            and the publisher project. `share_cap_exceeded` lands in the consumer project when a
            call through a share it accepted is refused by the share's `cap`.
            `usage_quantity_invalid` lands in the project a tool call is metered in when a resource
            price row's `quantity` reads no finite number >= 0; `ref_id` is the tool.
        severity:
          type: string
          enum:
            - info
            - warning
            - critical
        summary:
          type: string
          description: One-line, human-readable description
        detail:
          type: object
          nullable: true
          description: Kind-specific structured context (tool, args digest, node id, guardrail policy version)
        orchestration_run_id:
          type: string
          nullable: true
          description: Originating orchestration run, if any
        agent_id:
          type: string
          nullable: true
          description: Associated agent, if any
        generation_id:
          type: string
          nullable: true
          description: The agent generation the entry was produced during, if any. Filter on it with the
            `generation_id` query parameter to read everything one turn did.
        ref_id:
          type: string
          nullable: true
          description: Producer-specific reference (the approval, exception, or trigger firing id the entry
            came from, or the executed tool's id)
        created_at:
          type: string
          format: date-time
    Page:
      type: object
      description: One page of a list. Rows inserted or removed between two calls neither repeat nor skip
        a row on the next page.
      required:
        - data
        - next_cursor
      properties:
        data:
          type: array
          description: This page's items, in the list's order.
          items: {}
        next_cursor:
          type: string
          nullable: true
          description: Pass as `cursor` to fetch the next page; `null` on the last page.
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          description: Structured error. Every error response uses this shape, so `code` can be read without
            first checking the type of `error`.
          required:
            - code
            - message
            - hint
          properties:
            code:
              type: string
              pattern: ^[A-Z][A-Z0-9_]*$
              description: Machine-readable error code, UPPER_SNAKE whether naturali or the runtime raises it.
              example: FORBIDDEN
            message:
              type: string
              description: Human-readable explanation.
              example: Your role in this project does not carry this action.
            hint:
              type: string
              description: What to do about it, naming the routes of this API to call. For people and agents; it
                may change, so branch on `code`.
              example: Use a credential whose scope includes this action, or ask a project `admin` or `owner` to
                act; the caller's role or key excludes it.
            meta:
              type: object
              additionalProperties: true
              description: Structured context, such as the `resource` and `limit` of a `PLAN_LIMIT_REACHED`.
  parameters:
    ProjectId:
      name: project_id
      in: path
      required: true
      description: Project public ID (proj_ prefix).
      schema:
        type: string
        example: proj_V1StGXR8Z5jdHi6B
    Limit:
      name: limit
      in: query
      required: false
      description: Results per page, 1 to 100 (default 50). Above 100 it is clamped; below 1 or not an
        integer it is `400`.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 50
    Cursor:
      name: cursor
      in: query
      required: false
      description: The previous page's `next_cursor`; omit it for the first page. A cursor this list did
        not issue is `400`.
      schema:
        type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A naturali API key (nat_sk_…) or a session JWT.
    oauth2:
      type: oauth2
      description: "A connected app's OAuth access token, issued by this API's authorization server
        (discovery: /.well-known/oauth-authorization-server). Its one scope carries every operation,
        confined to the projects the user chose when approving the app."
      flows:
        authorizationCode:
          authorizationUrl: https://api.naturali.ai/authorize
          tokenUrl: https://api.naturali.ai/token
          refreshUrl: https://api.naturali.ai/token
          scopes:
            mcp:access: Every operation this API serves, on the projects the grant covers.
  responses:
    TooManyRequests:
      description: "`QUOTA_EXCEEDED` — a `requests` quota on the calling API key or its project is spent
        for the window; `Retry-After` says when it reopens"
      headers:
        Retry-After:
          description: Seconds until the quota window admits a request again
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    InternalError:
      description: Unexpected server error — `INTERNAL_ERROR`, with the raw message never forwarded
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
    ProjectNotFound:
      description: The project does not exist or the caller is not a member of it (`RESOURCE_NOT_FOUND`).
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
