# Generated public contract; edit the source and localization catalog.
openapi: 3.1.0
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
info:
  title: OrbitSpace Artifacts API
  version: 1.0.0
  description: Public v1 application contract for artifacts. Protocol lifecycle and capability availability are documented in the integration guides.
servers:
  - url: https://api.orbitspace.dev
security:
  - bearerAuth: []
paths:
  /api/v1/artifacts:
    get:
      tags:
        - ArtifactService
      operationId: ArtifactService_ListArtifacts
      parameters:
        - name: task_id
          in: query
          schema:
            type: string
          description: Identifier of the durable Task; do not substitute an execution Run ID.
        - name: run_id
          in: query
          schema:
            type: string
          description: Identifier of an execution Run associated with a Task.
        - name: page_size
          in: query
          schema:
            type: integer
            format: int32
          description: Requested page size, subject to the endpoint limits.
        - name: page_token
          in: query
          schema:
            type: string
          description: Opaque pagination token returned by the previous page. Do not construct or modify it.
        - name: status
          in: query
          schema:
            type: string
          description: Status.
        - name: status_group
          in: query
          schema:
            type: string
          description: Status group used to filter current or historical records. See the endpoint contract for accepted values.
        - name: query
          in: query
          schema:
            type: string
          description: Query.
      responses:
        "200":
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ListArtifactsResponse"
        default:
          description: RFC 9457 Problem Details.
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
      summary: List artifacts
      description: List artifacts. Use the declared pagination parameters to continue through results.
    post:
      tags:
        - ArtifactService
      operationId: ArtifactService_CreateArtifact
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateArtifactRequest"
        required: true
        description: Request body for create artifact.
      responses:
        "200":
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Artifact"
        default:
          description: RFC 9457 Problem Details.
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
      summary: Create artifact
      description: Create artifact. Supply the fields defined in the request schema.
  /api/v1/artifacts/{id}:
    get:
      tags:
        - ArtifactService
      operationId: ArtifactService_GetArtifact
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Identifier of the resource addressed by this schema or URL.
      responses:
        "200":
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Artifact"
        default:
          description: RFC 9457 Problem Details.
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
      summary: Get artifact
      description: Get artifact.
  /api/v1/artifacts/{id}/download:
    get:
      tags:
        - ArtifactService
      operationId: ArtifactService_GetArtifactDownload
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Identifier of the resource addressed by this schema or URL.
        - name: ttl
          in: query
          schema:
            pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$
            type: string
            description: Represents a a duration between -315,576,000,000s and 315,576,000,000s (around 10000 years). Precision is in nanoseconds. 1 nanosecond is represented as 0.000000001s
          description: Ttl.
      responses:
        "200":
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ArtifactDownload"
        default:
          description: RFC 9457 Problem Details.
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
      summary: Get artifact download
      description: Request a temporary download grant for an accessible artifact. Store the artifact ID as the durable reference and request a fresh URL when the grant expires.
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  schemas:
    Artifact:
      type: object
      properties:
        id:
          type: string
          description: Identifier of the resource addressed by this schema or URL.
        tenant_id:
          type: string
          description: Tenant identifier used with the authenticated access context. Supplying an ID does not grant access.
        task_id:
          type: string
          description: Identifier of the durable Task; do not substitute an execution Run ID.
        run_id:
          type: string
          description: Identifier of an execution Run associated with a Task.
        tool_call_id:
          type: string
          description: Tool call id.
        kind:
          type: string
          description: Kind.
        name:
          type: string
          description: Name.
        content_type:
          type: string
          description: Content type.
        checksum_sha256:
          type: string
          description: Checksum sha256.
        size_bytes:
          type: string
          description: Size bytes.
        status:
          enum:
            - ARTIFACT_STATUS_UNSPECIFIED
            - ARTIFACT_STATUS_PENDING
            - ARTIFACT_STATUS_READY
            - ARTIFACT_STATUS_FAILED
            - ARTIFACT_STATUS_DELETING
          type: string
          format: enum
          description: Status.
          x-enum-descriptions:
            ARTIFACT_STATUS_UNSPECIFIED: unspecified
            ARTIFACT_STATUS_PENDING: pending
            ARTIFACT_STATUS_READY: ready
            ARTIFACT_STATUS_FAILED: failed
            ARTIFACT_STATUS_DELETING: deleting
        retention_until:
          type: string
          format: date-time
          description: Retention until as an RFC 3339 timestamp.
        ready_at:
          type: string
          format: date-time
          description: Ready at as an RFC 3339 timestamp.
        created_at:
          type: string
          format: date-time
          description: Created at as an RFC 3339 timestamp.
        updated_at:
          type: string
          format: date-time
          description: Updated at as an RFC 3339 timestamp.
        policy_scope_id:
          type: string
          description: Policy scope id.
      description: Artifact representation.
    ArtifactDownload:
      type: object
      properties:
        url:
          type: string
          description: Resource URL.
        expires_at:
          type: string
          format: date-time
          description: Expires at as an RFC 3339 timestamp.
        checksum_sha256:
          type: string
          description: Checksum sha256.
        size_bytes:
          type: string
          description: Size bytes.
        content_type:
          type: string
          description: Content type.
      description: Artifact download representation.
    CreateArtifactRequest:
      type: object
      properties:
        artifact_id:
          type: string
          description: Artifact id.
        task_id:
          type: string
          description: Identifier of the durable Task; do not substitute an execution Run ID.
        run_id:
          type: string
          description: Identifier of an execution Run associated with a Task.
        tool_call_id:
          type: string
          description: Tool call id.
        kind:
          type: string
          description: Kind.
        name:
          type: string
          description: Name.
        content_type:
          type: string
          description: Content type.
        content:
          type: string
          format: bytes
          description: Content encoded as Base64.
        checksum_sha256:
          type: string
          description: Checksum sha256.
        retention_until:
          type: string
          format: date-time
          description: Retention until as an RFC 3339 timestamp.
        idempotency_key:
          type: string
          description: Idempotency key for this operation. Reuse it only when retrying the same submission with the same payload.
        policy_scope_id:
          type: string
          description: |-
            Project policy scope used for an application input staged before a Task
             exists. It is optional when task_id is supplied and must then match it.
      description: Create artifact request.
    ListArtifactsResponse:
      type: object
      properties:
        artifacts:
          type: array
          items:
            $ref: "#/components/schemas/Artifact"
          description: Artifacts list.
        next_page_token:
          type: string
          description: Pagination token for the next page. An empty value indicates there is no next page.
        total_count:
          type: string
          description: Total count.
      description: List artifacts response.
    ProblemDetails:
      type: object
      description: RFC 9457 Problem Details with OrbitSpace correlation extensions.
      required:
        - type
        - title
        - status
        - detail
        - request_id
      properties:
        type:
          type: string
          format: uri
          description: Type.
        title:
          type: string
          description: Title.
        status:
          type: integer
          minimum: 400
          maximum: 599
          description: Status.
        detail:
          type: string
          description: Detail.
        instance:
          type: string
          format: uri-reference
          description: Instance.
        code:
          type: string
          pattern: ^[A-Z][A-Z0-9_]*$
          description: Code.
        request_id:
          type: string
          format: uuid
          description: Request id.
tags:
  - name: ArtifactService
    x-displayName: Artifacts
    description: Artifacts operations.
