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

# Publish an SA form draft

> Creates the SA form from the full form in the body and removes the draft.



## OpenAPI

````yaml api-reference/doc-tool/ipd-api/protocol-openapi.json post /protocol/workflow/sa-forms/drafts/{id}/publish
openapi: 3.1.0
info:
  title: Eka Protocol API
  version: '1.0'
  description: >-
    Hospital workflows for IPD: rules, the tasks they create, and the forms
    filled on an admission.
servers:
  - description: Production
    url: https://api.eka.care
  - description: Stage/Sandbox
    url: https://api.dev.eka.care
security: []
tags:
  - name: Tasks
    description: >-
      Workflow tasks at a hospital. Rules create them; users claim, release,
      complete and cancel them here. Task documents are also readable live from
      Firestore (`protocol/{bid}/tasks`) through `@orbi/protocol-sdk`; every
      change goes through this API.
  - name: Forms
    description: >-
      Forms filled on an entity (today: an admission, the IPD Forms tab) and
      what happened to each.
  - name: Rules
    description: >-
      Hospital workflow rules: events → conditions → tasks. Each save is a new
      version, compiled to a workflow.
  - name: Catalog
    description: The events and fields rules are written against.
  - name: Events
    description: 'Fire an event for a scope: every active rule on it starts a run.'
  - name: SA forms
    description: >-
      The hospital's SA forms (its own and the system ones), with versions and
      archiving.
  - name: SA form drafts
    description: SA forms saved before they are ready. Not offered in IPD until published.
  - name: AI drafts
    description: Draft an SA form from a prompt or a file with AI.
paths:
  /protocol/workflow/sa-forms/drafts/{id}/publish:
    post:
      tags:
        - SA form drafts
      summary: Publish an SA form draft
      description: >-
        Creates the SA form from the full form in the body and removes the
        draft.
      operationId: postSaFormsDraftsIdPublish
      parameters:
        - name: auth
          in: header
          required: true
          description: >-
            The access token. The gateway verifies it and passes the user and
            the business on.
          schema:
            type: string
        - name: id
          in: path
          required: true
          schema:
            type: string
            pattern: ^sad_[a-z0-9]+_[a-f0-9]+$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 120
                description:
                  type: string
                  maxLength: 1000
                questions:
                  type: array
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                        pattern: ^[a-zA-Z][a-zA-Z0-9_]{0,59}$
                      kind:
                        type: string
                        enum:
                          - heading
                          - page_break
                          - short_text
                          - long_text
                          - number
                          - yes_no
                          - single
                          - dropdown
                          - multi
                          - grid
                          - date
                          - symptom
                          - diagnosis
                          - medication
                          - lab
                          - injection
                          - pmh
                      label:
                        type: string
                        maxLength: 500
                        default: ''
                      required:
                        type: boolean
                        default: false
                      options:
                        type: array
                        items:
                          type: string
                          minLength: 1
                          maxLength: 200
                        maxItems: 50
                        default: []
                      scores:
                        anyOf:
                          - type: array
                            items:
                              anyOf:
                                - type: number
                                  minimum: -1000
                                  maximum: 1000
                                - type: 'null'
                            maxItems: 50
                          - type: 'null'
                      show_when:
                        anyOf:
                          - type: object
                            properties:
                              question:
                                type: string
                                minLength: 1
                                maxLength: 60
                              op:
                                type: string
                                enum:
                                  - is
                                  - is_not
                                  - gt
                                  - lt
                                  - has
                                  - has_not
                              value:
                                type: string
                                minLength: 1
                                maxLength: 200
                            required:
                              - question
                              - op
                              - value
                            additionalProperties: false
                          - type: 'null'
                    required:
                      - key
                      - kind
                    additionalProperties: false
                  minItems: 1
                score:
                  anyOf:
                    - type: object
                      properties:
                        name:
                          type: string
                          minLength: 1
                          maxLength: 60
                      required:
                        - name
                      additionalProperties: false
                    - type: 'null'
              required:
                - name
                - questions
              additionalProperties: false
      responses:
        '201':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    const: success
                  data:
                    $ref: '#/components/schemas/SaForm'
                required:
                  - status
                  - data
        '401':
          description: No signed-in user, or no business on the session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Not in a state for this.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: The request failed validation; `details` names each invalid path.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    SaForm:
      type: object
      properties:
        _id:
          type: string
        bid:
          anyOf:
            - type: string
            - type: 'null'
        source:
          $ref: '#/components/schemas/SaFormSource'
        name:
          type: string
        description:
          type: string
        score:
          anyOf:
            - $ref: '#/components/schemas/SaScore'
            - type: 'null'
        workflow_id:
          type: number
        workflow_name:
          type: string
        questions:
          type: array
          items:
            $ref: '#/components/schemas/SaQuestion'
        version:
          type: number
        active:
          type: boolean
        created_by:
          $ref: '#/components/schemas/Actor'
        updated_by:
          $ref: '#/components/schemas/Actor'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - _id
        - bid
        - source
        - name
        - description
        - workflow_id
        - workflow_name
        - questions
        - active
        - created_by
        - updated_by
        - created_at
        - updated_at
    Error:
      type: object
      properties:
        status:
          type: string
          const: error
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  path:
                    type: string
                  message:
                    type: string
                required:
                  - path
                  - message
          required:
            - code
            - message
      required:
        - status
        - error
    SaFormSource:
      type: string
      enum:
        - SYSTEM
        - USER
    SaScore:
      type: object
      properties:
        name:
          type: string
      required:
        - name
    SaQuestion:
      type: object
      properties:
        key:
          type: string
        kind:
          type: string
          enum:
            - number
            - date
            - heading
            - page_break
            - short_text
            - long_text
            - yes_no
            - single
            - dropdown
            - multi
            - grid
            - symptom
            - diagnosis
            - medication
            - lab
            - injection
            - pmh
        label:
          type: string
        required:
          type: boolean
        options:
          type: array
          items:
            type: string
        show_when:
          anyOf:
            - $ref: '#/components/schemas/SaCondition'
            - type: 'null'
        scores:
          anyOf:
            - type: array
              items:
                anyOf:
                  - type: number
                  - type: 'null'
            - type: 'null'
        rev:
          type: number
      required:
        - key
        - kind
        - label
        - required
        - options
    Actor:
      type: object
      properties:
        oid:
          type: string
        name:
          type: string
        ps:
          type: string
          enum:
            - D
            - S
            - AD
            - SYSTEM
        s:
          type: string
      required:
        - oid
        - name
        - ps
        - s
    SaCondition:
      type: object
      properties:
        question:
          type: string
        op:
          type: string
          enum:
            - is
            - is_not
            - gt
            - lt
            - has
            - has_not
        value:
          type: string
      required:
        - question
        - op
        - value

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.