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

# Publish the draft policy version

> Make the draft the active version. The whole draft goes live, including any edits made in the dashboard, not only values set through the API. The previously active version is archived, and author_email becomes the publisher's email. Refused when a check reads data that no workflow path produces before its section's policy node.




## OpenAPI

````yaml https://app.herondata.io/swagger post /api/policy_version/publish
openapi: 3.0.0
info:
  contact:
    email: support@herondata.io
    name: Support
  title: Heron Data API
  version: '2021-07-19'
servers:
  - description: Production
    url: https://app.herondata.io
security:
  - ApiKeyAuth:
      - key_XXX
externalDocs:
  description: Read Tutorial
  url: https://docs.herondata.io/
paths:
  /api/policy_version/publish:
    post:
      tags:
        - Policy Versions
      summary: Publish the draft policy version
      description: >
        Make the draft the active version. The whole draft goes live, including
        any edits made in the dashboard, not only values set through the API.
        The previously active version is archived, and author_email becomes the
        publisher's email. Refused when a check reads data that no workflow path
        produces before its section's policy node.
      parameters:
        - description: Account to act on. Honoured only for admins.
          in: query
          name: user_id
          required: false
          schema:
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  issues:
                    description: Warnings that did not stop the publish
                    items:
                      $ref: '#/components/schemas/PublishIssueSchema'
                    type: array
                  policy_version:
                    $ref: '#/components/schemas/PolicyVersionSchema'
                type: object
          description: OK
        '404':
          description: No draft policy version
        '422':
          content:
            application/json:
              schema:
                properties:
                  description:
                    type: string
                  errors:
                    items:
                      $ref: '#/components/schemas/PublishIssueSchema'
                    type: array
                type: object
          description: >
            A concurrent change won the race, or the draft has issues that block
            publishing, listed in `errors`.
      security:
        - ApiKeyAuth: []
components:
  schemas:
    PublishIssueSchema:
      properties:
        attribute_label:
          description: The variable the check reads
          nullable: true
          type: string
        available_after:
          description: >-
            Customer-facing name of the step after which every deal has the
            variable
          nullable: true
          type: string
        blocks_publish:
          description: Publishing is refused while this is true; saving never is
          type: boolean
        check_name:
          description: The top-level check, even when a condition in it reads the variable
          nullable: true
          type: string
        code:
          enum:
            - data_on_no_path
            - data_not_in_workflow
            - data_on_some_paths_only
            - data_unverified
            - policy_node_left_without_sections
        message:
          type: string
        path:
          description: >-
            The check that reads the variable, as a save error would point at
            it, down to a condition inside a group; empty for a workflow node
          items: {}
          type: array
        policy_node_id:
          description: Workflow node left with no sections
          nullable: true
          type: string
        section_heron_id:
          nullable: true
          type: string
        section_name:
          nullable: true
          type: string
      required:
        - blocks_publish
        - code
        - message
        - path
      type: object
    PolicyVersionSchema:
      properties:
        author_email:
          description: >-
            Email of whoever last acted on this version: the drafter while it is
            a draft, the publisher once published
          readOnly: true
          type: string
        backtest_status:
          allOf:
            - $ref: '#/components/schemas/PolicyVersionBacktestStatus'
          readOnly: true
        change_description:
          description: What changed in this version
          nullable: true
          readOnly: true
          type: string
        created:
          format: date-time
          readOnly: true
          type: string
        last_edited_at:
          format: date-time
          nullable: true
          readOnly: true
          type: string
        policy_definition:
          allOf:
            - $ref: '#/components/schemas/PolicyDefinition'
          readOnly: true
        published_at:
          format: date-time
          nullable: true
          readOnly: true
          type: string
        status:
          enum:
            - draft
            - active
            - archived
          readOnly: true
        version:
          description: Version number, unique per account
          readOnly: true
          type: integer
      type: object
    PolicyVersionBacktestStatus:
      properties:
        backtest_heron_id:
          nullable: true
          readOnly: true
          type: string
        deal_count:
          description: Deals the backtest covered
          nullable: true
          readOnly: true
          type: integer
        finished_at:
          format: date-time
          nullable: true
          readOnly: true
          type: string
        flipped_deal_count:
          description: Deals whose outcome changed, null unless the run completed
          nullable: true
          readOnly: true
          type: integer
        run_status:
          description: >-
            Status of this version's latest backtest, null if it has never been
            backtested
          enum:
            - pending
            - running
            - complete
            - failed
            - null
          nullable: true
          readOnly: true
        stale:
          description: >-
            The version was edited after that backtest was asked for, so re-run
            before publishing
          readOnly: true
          type: boolean
      type: object
    PolicyDefinition:
      properties:
        policy_sections:
          items:
            $ref: '#/components/schemas/PolicyVersionSection'
          type: array
      required:
        - policy_sections
      type: object
    PolicyVersionSection:
      properties:
        branches:
          description: >-
            Ordered routes through the section; the section's own checks run on
            every route
          items:
            $ref: '#/components/schemas/PolicyBranch'
          type: array
        checks:
          items:
            $ref: '#/components/schemas/Check'
          type: array
        default_branch:
          allOf:
            - $ref: '#/components/schemas/DefaultPolicyBranch'
          description: Runs when no branch's condition passes
          nullable: true
        display_order:
          nullable: true
          type: integer
        heron_id:
          nullable: true
          type: string
        name:
          type: string
        use_case:
          enum:
            - background_check
            - cashflow
      required:
        - name
      type: object
    PolicyBranch:
      properties:
        checks:
          items:
            $ref: '#/components/schemas/Check'
          type: array
        condition:
          allOf:
            - $ref: '#/components/schemas/Check'
          description: >-
            Selects this branch when it passes. Branches are tried in order and
            the first match runs; a condition that fails or is missing data does
            not match.
        heron_id:
          description: Stable across renames; omit for a new branch and one is minted
          nullable: true
          type: string
        name:
          type: string
      required:
        - condition
        - name
      type: object
    Check:
      properties:
        attribute_description:
          description: >-
            What the attribute measures. Present only for accounts on policy
            versions
          nullable: true
          type: string
        attribute_display_name:
          description: >-
            The attribute's human-readable name. Present only for accounts on
            policy versions
          nullable: true
          type: string
        attribute_label:
          nullable: true
          type: string
        attribute_unit:
          description: >-
            The unit of `attribute_label`, for formatting the attribute's value
            and the check's threshold. Null for a check without an attribute or
            an attribute with no declared unit
          enum:
            - currency
            - percentage
            - count
            - ratio
            - days
            - text
            - null
          nullable: true
        attribute_value_set:
          description: >-
            The vocabulary `attribute_label` draws from, so the editor can offer
            a dropdown. Keys into the /policy_value_sets response. Null for free
            text
          enum:
            - us_state
            - naics_industry
            - restricted_industries
            - null
          nullable: true
        boolean_check:
          allOf:
            - $ref: '#/components/schemas/BooleanCheck'
          nullable: true
        composite_check:
          allOf:
            - $ref: '#/components/schemas/CompositeCheck'
          nullable: true
        date_check:
          allOf:
            - $ref: '#/components/schemas/DateCheck'
          nullable: true
        date_delta_to_now_check:
          allOf:
            - $ref: '#/components/schemas/DateDeltaToNowCheck'
          nullable: true
        enhanced_sql_check:
          allOf:
            - $ref: '#/components/schemas/EnhancedSQLCheck'
          nullable: true
        group:
          nullable: true
          type: string
        heron_id:
          description: >-
            Stable across edits; omit for a new check and one is minted. Policy
            versions only
          nullable: true
          type: string
        identity:
          description: Stable kind:key identity used to match stored check evaluations
          nullable: true
          readOnly: true
          type: string
        name:
          nullable: true
          type: string
        numeric_check:
          allOf:
            - $ref: '#/components/schemas/NumericCheck'
          nullable: true
        parameters:
          additionalProperties:
            type: string
          nullable: true
          type: object
        sql_check:
          allOf:
            - $ref: '#/components/schemas/SQLCheck'
          nullable: true
        string_check:
          allOf:
            - $ref: '#/components/schemas/StringCheck'
          nullable: true
      type: object
    DefaultPolicyBranch:
      properties:
        checks:
          items:
            $ref: '#/components/schemas/Check'
          type: array
        condition:
          description: >-
            Not allowed: the default runs when no branch matches. Accepted only
            to report that at its path
          nullable: true
          writeOnly: true
        decline_code:
          description: Optional code sent with a failed or review_required result
          nullable: true
          type: string
        decline_description:
          description: Required when result is failed or review_required
          nullable: true
          type: string
        heron_id:
          nullable: true
          type: string
        name:
          default: Default
          type: string
        result:
          description: >-
            What happens to deals no branch matches when the default has no
            checks; required then
          enum:
            - passed
            - failed
            - review_required
            - null
          nullable: true
      type: object
    BooleanCheck:
      properties:
        auto_decline:
          default: false
          type: boolean
        decline_code:
          description: >-
            The CRM's identifier for this decline reason, e.g. a LendSaas reason
            id. Left unset, the CRM sync falls back to this check's
            decline_description.
          nullable: true
          type: string
        decline_description:
          nullable: true
          type: string
        email_template_name:
          nullable: true
          type: string
        ignore_metric_availability:
          default: false
          type: boolean
        is_mandatory:
          default: false
          type: boolean
        on_failure:
          default: fail
          enum:
            - fail
            - review_required
        pass_description:
          nullable: true
          type: string
        transaction_scope:
          allOf:
            - $ref: '#/components/schemas/TransactionScope'
          nullable: true
        value:
          type: boolean
      type: object
    CompositeCheck:
      properties:
        auto_decline:
          default: false
          type: boolean
        checks:
          items:
            $ref: '#/components/schemas/Check'
          type: array
        decline_code:
          description: >-
            The CRM's identifier for this decline reason, e.g. a LendSaas reason
            id. Left unset, the CRM sync falls back to this check's
            decline_description.
          nullable: true
          type: string
        decline_description:
          nullable: true
          type: string
        email_template_name:
          nullable: true
          type: string
        ignore_metric_availability:
          default: false
          type: boolean
        is_mandatory:
          default: false
          type: boolean
        on_failure:
          default: fail
          enum:
            - fail
            - review_required
        pass_description:
          nullable: true
          type: string
        transaction_scope:
          allOf:
            - $ref: '#/components/schemas/TransactionScope'
          nullable: true
        type:
          enum:
            - AND
            - OR
      type: object
    DateCheck:
      properties:
        auto_decline:
          default: false
          type: boolean
        decline_code:
          description: >-
            The CRM's identifier for this decline reason, e.g. a LendSaas reason
            id. Left unset, the CRM sync falls back to this check's
            decline_description.
          nullable: true
          type: string
        decline_description:
          nullable: true
          type: string
        email_template_name:
          nullable: true
          type: string
        ignore_metric_availability:
          default: false
          type: boolean
        is_mandatory:
          default: false
          type: boolean
        on_failure:
          default: fail
          enum:
            - fail
            - review_required
        pass_description:
          nullable: true
          type: string
        transaction_scope:
          allOf:
            - $ref: '#/components/schemas/TransactionScope'
          nullable: true
        type:
          enum:
            - equal
            - not_equal
            - before
            - before_or_on
            - after
            - after_or_on
        value:
          format: date
          type: string
      type: object
    DateDeltaToNowCheck:
      properties:
        auto_decline:
          default: false
          type: boolean
        decline_code:
          description: >-
            The CRM's identifier for this decline reason, e.g. a LendSaas reason
            id. Left unset, the CRM sync falls back to this check's
            decline_description.
          nullable: true
          type: string
        decline_description:
          nullable: true
          type: string
        email_template_name:
          nullable: true
          type: string
        ignore_metric_availability:
          default: false
          type: boolean
        is_mandatory:
          default: false
          type: boolean
        on_failure:
          default: fail
          enum:
            - fail
            - review_required
        pass_description:
          nullable: true
          type: string
        pass_if_value_missing:
          default: false
          type: boolean
        transaction_scope:
          allOf:
            - $ref: '#/components/schemas/TransactionScope'
          nullable: true
        type:
          enum:
            - greater_than
            - greater_than_or_equal
            - less_than
            - less_than_or_equal
        value:
          additionalProperties: {}
          nullable: true
          type: object
      type: object
    EnhancedSQLCheck:
      properties:
        auto_decline:
          default: false
          type: boolean
        check_type:
          enum:
            - equal
            - not_equal
            - greater_than
            - greater_than_or_equal
            - less_than
            - less_than_or_equal
            - before
            - before_or_on
            - after
            - after_or_on
            - is_in
            - is_not_in
        column_name:
          type: string
        comparison_value: {}
        data_type:
          enum:
            - numeric
            - date
            - string
        decline_code:
          description: >-
            The CRM's identifier for this decline reason, e.g. a LendSaas reason
            id. Left unset, the CRM sync falls back to this check's
            decline_description.
          nullable: true
          type: string
        decline_description:
          nullable: true
          type: string
        email_template_name:
          nullable: true
          type: string
        ignore_metric_availability:
          default: false
          type: boolean
        is_mandatory:
          default: false
          type: boolean
        on_failure:
          default: fail
          enum:
            - fail
            - review_required
        pass_description:
          nullable: true
          type: string
        query_name:
          type: string
        transaction_scope:
          allOf:
            - $ref: '#/components/schemas/TransactionScope'
          nullable: true
      required:
        - check_type
        - column_name
        - comparison_value
        - data_type
        - query_name
      type: object
    NumericCheck:
      properties:
        auto_decline:
          default: false
          type: boolean
        decline_code:
          description: >-
            The CRM's identifier for this decline reason, e.g. a LendSaas reason
            id. Left unset, the CRM sync falls back to this check's
            decline_description.
          nullable: true
          type: string
        decline_description:
          nullable: true
          type: string
        email_template_name:
          nullable: true
          type: string
        ignore_metric_availability:
          default: false
          type: boolean
        is_mandatory:
          default: false
          type: boolean
        on_failure:
          default: fail
          enum:
            - fail
            - review_required
        pass_description:
          nullable: true
          type: string
        transaction_scope:
          allOf:
            - $ref: '#/components/schemas/TransactionScope'
          nullable: true
        type:
          enum:
            - equal
            - not_equal
            - greater_than
            - greater_than_or_equal
            - less_than
            - less_than_or_equal
        value:
          type: string
      type: object
    SQLCheck:
      properties:
        auto_decline:
          default: false
          type: boolean
        column_name:
          type: string
        decline_code:
          description: >-
            The CRM's identifier for this decline reason, e.g. a LendSaas reason
            id. Left unset, the CRM sync falls back to this check's
            decline_description.
          nullable: true
          type: string
        decline_description:
          nullable: true
          type: string
        email_template_name:
          nullable: true
          type: string
        ignore_metric_availability:
          default: false
          type: boolean
        is_mandatory:
          default: false
          type: boolean
        on_failure:
          default: fail
          enum:
            - fail
            - review_required
        pass_description:
          nullable: true
          type: string
        query_name:
          type: string
        transaction_scope:
          allOf:
            - $ref: '#/components/schemas/TransactionScope'
          nullable: true
      required:
        - column_name
        - query_name
      type: object
    StringCheck:
      properties:
        auto_decline:
          default: false
          type: boolean
        decline_code:
          description: >-
            The CRM's identifier for this decline reason, e.g. a LendSaas reason
            id. Left unset, the CRM sync falls back to this check's
            decline_description.
          nullable: true
          type: string
        decline_description:
          nullable: true
          type: string
        email_template_name:
          nullable: true
          type: string
        ignore_metric_availability:
          default: false
          type: boolean
        is_mandatory:
          default: false
          type: boolean
        match_count:
          nullable: true
          type: integer
        on_failure:
          default: fail
          enum:
            - fail
            - review_required
        pass_description:
          nullable: true
          type: string
        transaction_scope:
          allOf:
            - $ref: '#/components/schemas/TransactionScope'
          nullable: true
        type:
          enum:
            - equal
            - not_equal
            - starts_with
            - starts_with_any_of
            - does_not_start_with_any_of
            - contains
            - does_not_start_with
            - does_not_contain
            - is_in
            - is_not_in
            - has_none_of
            - has_any_of
            - has_only
            - has_fewer_than_n_matches
            - has_more_than_n_matches
        value:
          type: string
      type: object
    TransactionScope:
      properties:
        file_classes:
          items:
            type: string
          nullable: true
          type: array
        min_reconciliation_status:
          enum:
            - failed
            - not_possible
            - reconciled
            - null
          nullable: true
          type: string
      type: object
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: x-api-key
      type: apiKey

````

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