> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usehasp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Publish the current draft version

> POST /v1/agents/{agent_id}/draft/publish

Enforces ADR-QVWZEY invariant 8: both input_schema and output_schema must be
present on the draft before publishing.

Returns the now-published version.



## OpenAPI

````yaml /openapi/v1.json post /agents/{agentId}/draft/publish
openapi: 3.1.0
info:
  title: HASP AI API
  version: '2026-07-12'
  description: >-
    The HASP Public AI API is the regulated-AI substrate for healthcare and
    other

    regulated industries — identity, policy, audit, compliance, and PHI handling

    for AI inference, exposed via two surfaces:


    - **Native (`/v1/ai/*`)**: HASP-native chat with full event taxonomy, run
    lifecycle,
      and PHI metadata.
    - **Anthropic-compat (`/v1/messages`)**: Drop-in replacement for
    `@anthropic-ai/sdk` —
      change only `baseURL`. All Gateway compliance checks (BAA, credits, PHI policy) apply.

    All requests require an API key (`Authorization: Bearer
    hasp_api_live_<key>`). See

    [Authentication](https://docs.usehasp.com/ai-api/authentication) for key
    management.
servers:
  - url: https://api.usehasp.com/v1
    description: Production
security:
  - http: []
paths:
  /agents/{agentId}/draft/publish:
    post:
      tags:
        - AgentVersions
      summary: Publish the current draft version
      description: >-
        POST /v1/agents/{agent_id}/draft/publish


        Enforces ADR-QVWZEY invariant 8: both input_schema and output_schema
        must be

        present on the draft before publishing.


        Returns the now-published version.
      operationId: v1.agents.draft.publish
      parameters:
        - name: agentId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Published version.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      version:
                        type: object
                        properties:
                          id:
                            type: string
                          agent_id:
                            type: string
                          version:
                            type: integer
                          is_draft:
                            type: boolean
                          is_deprecated:
                            type: boolean
                          is_retired:
                            type: boolean
                          persona:
                            type:
                              - string
                              - 'null'
                          model:
                            type:
                              - string
                              - 'null'
                          tool_allowlist:
                            type:
                              - array
                              - 'null'
                            items:
                              type: string
                          default_scope_grants:
                            type: array
                            items:
                              type: object
                              additionalProperties: {}
                          input_schema:
                            type:
                              - object
                              - 'null'
                            additionalProperties: {}
                          output_schema:
                            type:
                              - object
                              - 'null'
                            additionalProperties: {}
                          behavior_constraints:
                            type:
                              - object
                              - 'null'
                            additionalProperties: {}
                          invocation_limits:
                            type:
                              - object
                              - 'null'
                            additionalProperties: {}
                          schema_hash:
                            type:
                              - string
                              - 'null'
                          visibility:
                            type: string
                          released_at:
                            type:
                              - string
                              - 'null'
                          released_by:
                            type:
                              - string
                              - 'null'
                          deprecated_at:
                            type:
                              - string
                              - 'null'
                          retired_at:
                            type:
                              - string
                              - 'null'
                          created_at:
                            type: string
                          updated_at:
                            type: string
                        required:
                          - id
                          - agent_id
                          - version
                          - is_draft
                          - is_deprecated
                          - is_retired
                          - persona
                          - model
                          - tool_allowlist
                          - default_scope_grants
                          - input_schema
                          - output_schema
                          - behavior_constraints
                          - invocation_limits
                          - schema_hash
                          - visibility
                          - released_at
                          - released_by
                          - deprecated_at
                          - retired_at
                          - created_at
                          - updated_at
                    required:
                      - version
                required:
                  - success
                  - data
        '401':
          description: Bearer token is missing, malformed, or revoked.
          content:
            application/json:
              schema:
                type: object
                example:
                  success: false
                  error:
                    type: authentication
                    code: INVALID_API_KEY
                    message: Bearer token is missing, malformed, or revoked.
                    param: null
                    details: null
                    retryable: false
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
                  meta:
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
        '403':
          description: >-
            The caller is authenticated but lacks the scope or capability this
            route requires.
          content:
            application/json:
              schema:
                type: object
                example:
                  success: false
                  error:
                    type: permission
                    code: MISSING_SCOPE
                    message: >-
                      The caller is authenticated but lacks the scope or
                      capability this route requires.
                    param: null
                    details: null
                    retryable: false
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
                  meta:
                    request_id: 01JQREQ7XZQK5N6PZ1VVXHYB8T
        '422':
          description: ''
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      success:
                        type: boolean
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            const: IO_SCHEMA_REQUIRED
                          type:
                            type: string
                            const: unprocessable
                          message:
                            type: string
                            const: >-
                              Both input_schema and output_schema must be set on
                              the draft before publishing (ADR-QVWZEY invariant
                              8).
                          retryable:
                            type: boolean
                        required:
                          - code
                          - type
                          - message
                          - retryable
                    required:
                      - success
                      - error
                  - type: object
                    properties:
                      success:
                        type: boolean
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            const: NO_PUBLISHABLE_DRAFT
                          type:
                            type: string
                            const: unprocessable
                          message:
                            type: string
                            const: >-
                              This agent has no current draft version to
                              publish.
                          retryable:
                            type: boolean
                        required:
                          - code
                          - type
                          - message
                          - retryable
                    required:
                      - success
                      - error
                  - type: object
                    properties:
                      success:
                        type: boolean
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            const: DELEGATING_USER_REQUIRED
                          type:
                            type: string
                            const: unprocessable
                          message:
                            type: string
                            const: >-
                              This operation must be performed on behalf of a
                              specific user. Use a personal API key.
                          retryable:
                            type: boolean
                        required:
                          - code
                          - type
                          - message
                          - retryable
                    required:
                      - success
                      - error
components:
  securitySchemes:
    http:
      type: http
      scheme: bearer

````