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

# Publish a procedure version

> Compiles a procedure’s source and stores it as the next immutable version of the procedure its source names, creating the procedure on its first publish. A new procedure belongs to the caller, and only its owner can run it until access is granted, unless `access` is `organization`.

The new version goes live (runs that name `live` start it) when it keeps the live version’s inputs and result, or when it is the first; otherwise `live.outcome` is `held_interface_mismatch` and setProcedureLiveVersion moves it. Source that does not compile is refused with 422 `invalid_procedure`, whose `details` give each error’s line, column and message. Creating a procedure needs `procedures:create`; publishing a later version needs build access to it.

Idempotency-Key is required: a retry with the same key and request answers with the version that request published (`outcome: already_published`, 200); the same key with a different request is refused with 409 `idempotency_conflict`. Use a new key for corrected source.



## OpenAPI

````yaml /openapi.json post /procedures/procedures
openapi: 3.0.3
info:
  title: Effective API
  version: 2.0.0
  description: The public Effective REST API. Authenticate using an Effective API key.
servers:
  - url: https://api.effectiveai.app/api/v2
    description: Production
security:
  - bearerAuth: []
paths:
  /procedures/procedures:
    post:
      tags:
        - Procedures
      summary: Publish a procedure version
      description: >-
        Compiles a procedure’s source and stores it as the next immutable
        version of the procedure its source names, creating the procedure on its
        first publish. A new procedure belongs to the caller, and only its owner
        can run it until access is granted, unless `access` is `organization`.


        The new version goes live (runs that name `live` start it) when it keeps
        the live version’s inputs and result, or when it is the first; otherwise
        `live.outcome` is `held_interface_mismatch` and setProcedureLiveVersion
        moves it. Source that does not compile is refused with 422
        `invalid_procedure`, whose `details` give each error’s line, column and
        message. Creating a procedure needs `procedures:create`; publishing a
        later version needs build access to it.


        Idempotency-Key is required: a retry with the same key and request
        answers with the version that request published (`outcome:
        already_published`, 200); the same key with a different request is
        refused with 409 `idempotency_conflict`. Use a new key for corrected
        source.
      operationId: publishProcedure
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 128
            pattern: ^[A-Za-z0-9\-_.:]+$
            description: >-
              Client-chosen key for safe retries: 1-128 letters, digits, -, _, .
              or :. Use a new random UUID for each intended operation and the
              same key when retrying it. Do not put customer data or credentials
              in the key.
          required: true
          description: >-
            Client-chosen key for safe retries: 1-128 letters, digits, -, _, .
            or :. Use a new random UUID for each intended operation and the same
            key when retrying it. Do not put customer data or credentials in the
            key.
          name: Idempotency-Key
          in: header
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProcedurePublishRequest'
      responses:
        '200':
          description: 'A retry: the version this request published before.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublishedProcedure'
        '201':
          description: The version published.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublishedProcedure'
        '400':
          description: Invalid body or Idempotency-Key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '403':
          description: The caller may not create procedures, or may not publish this one.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '404':
          description: A procedure the source calls was not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '409':
          description: >-
            idempotency_conflict, or version_conflict: the latest version is not
            expectedLatestVersion.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '413':
          description: Request body is too large.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '422':
          description: >-
            invalid_procedure: the source did not compile; details name each
            error. procedure_upgrade_needed: a procedure it calls must be
            republished first.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '503':
          description: Procedures are temporarily unavailable. Retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
      security:
        - bearerAuth: []
components:
  schemas:
    ProcedurePublishRequest:
      type: object
      properties:
        source:
          type: string
          minLength: 1
          maxLength: 1048576
          description: 'The procedure’s root document: its YAML or Markdown source.'
        sourceName:
          type: string
          minLength: 1
          maxLength: 512
          description: The root document’s file name, such as `intake.procedure.yaml`.
        fragments:
          type: object
          additionalProperties:
            type: string
            maxLength: 1048576
          description: Fragment documents the root includes, by path. At most 128.
        documents:
          type: object
          additionalProperties:
            type: string
            maxLength: 1048576
          description: Other documents the source reads, by path. At most 128.
        tests:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
                minLength: 1
                maxLength: 2048
              source:
                type: string
                minLength: 1
                maxLength: 1048576
            required:
              - path
              - source
            additionalProperties: false
          minItems: 1
          maxItems: 256
          description: Authoring tests kept beside the version. They do not run on publish.
        expectedLatestVersion:
          type: integer
          nullable: true
          minimum: 0
          exclusiveMinimum: true
          maximum: 9007199254740991
          description: >-
            Optional precondition. `null` requires that the procedure does not
            exist yet; a number requires that it is the latest version.
            Otherwise the publish is refused with `version_conflict`.
        access:
          type: string
          enum:
            - organization
          description: >-
            Who may run a new procedure. `organization` lets every member run
            it; omitted, only its owner can until access is granted. Ignored
            when the procedure already exists.
      required:
        - source
        - sourceName
      additionalProperties: false
    PublishedProcedure:
      type: object
      properties:
        procedureId:
          type: string
          maxLength: 256
          pattern: ^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$
          description: Stable procedure identifier
        version:
          type: integer
          minimum: 0
          exclusiveMinimum: true
          maximum: 9007199254740991
          description: Immutable positive procedure version
        outcome:
          type: string
          enum:
            - published
            - already_published
          description: >-
            `already_published` when this Idempotency-Key and request were
            accepted before: the version that request published.
        created:
          type: boolean
          description: True when this publish created the procedure.
        live:
          type: object
          nullable: true
          properties:
            outcome:
              type: string
              enum:
                - promoted
                - unchanged
                - held_interface_mismatch
              description: >-
                `promoted`: this version is now live. `unchanged`: the live
                version stayed. `held_interface_mismatch`: its inputs or result
                differ from the live version’s, so it is not live; set it with
                setProcedureLiveVersion.
            version:
              type: integer
              nullable: true
              minimum: 0
              exclusiveMinimum: true
              maximum: 9007199254740991
              description: The live version now.
          required:
            - outcome
            - version
          description: What the publish did to the live version. Null on a retry.
        diagnostics:
          type: array
          items:
            $ref: '#/components/schemas/ProcedureCompilerDiagnostic'
          description: Compiler warnings.
      required:
        - procedureId
        - version
        - outcome
        - created
        - live
        - diagnostics
    V2CodedError:
      allOf:
        - $ref: '#/components/schemas/V2Error'
        - type: object
          properties:
            code:
              type: string
              minLength: 1
              description: Stable error code. Clients must tolerate unknown future codes.
            details:
              type: array
              items:
                type: object
                properties:
                  location:
                    type: string
                    enum:
                      - path
                      - query
                      - header
                      - body
                  path:
                    type: array
                    items:
                      type: string
                      maxLength: 64
                    maxItems: 12
                  code:
                    type: string
                    enum:
                      - required
                      - invalid_type
                      - invalid_value
                      - unknown_field
                  message:
                    type: string
                    minLength: 1
                    maxLength: 200
                required:
                  - location
                  - path
                  - code
                  - message
              minItems: 1
              maxItems: 20
              description: Bounded safe validation issues; may omit some invalid fields.
            requestId:
              type: string
              minLength: 1
              maxLength: 128
              description: >-
                Existing server correlation for this HTTP attempt, when
                available.
            dataset:
              type: string
              enum:
                - naic
                - osha
              description: Dataset needed for dataset_not_enabled.
            businessCode:
              type: string
              description: The rater’s own refusal code, for business_rejection.
            violations:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                    description: Authored or built-in constraint code
                  message:
                    type: string
                    description: Authored message for the failed constraint
                  path:
                    type: string
                    description: Input path of the offending value; empty for the request
                  value:
                    nullable: true
                    description: Offending input value, size-bounded by the runtime
                  constraint:
                    type: string
                    description: The constraint the value failed, as text
                  cite:
                    type: string
                    nullable: true
                    description: >-
                      Filing citation of the constraint, when the source cites
                      one
                required:
                  - code
                  - message
                  - path
                  - value
                  - constraint
                  - cite
                additionalProperties: false
              maxItems: 256
              description: >-
                Each input constraint the submission failed, for invalid_inputs
                and business_rejection.
            violationsTruncated:
              type: boolean
              description: >-
                True when the rater reported more violations than violations
                holds.
            executionId:
              type: string
              description: >-
                The recorded execution of a failed rating, for rater rating
                failures.
            accessUrl:
              type: string
              nullable: true
              format: uri
              description: Not currently returned.
          required:
            - code
    ProcedureCompilerDiagnostic:
      type: object
      properties:
        code:
          type: string
        severity:
          type: string
          enum:
            - error
            - warning
        message:
          type: string
        line:
          type: integer
          minimum: 0
          exclusiveMinimum: true
        column:
          type: integer
          minimum: 0
          exclusiveMinimum: true
      required:
        - code
        - severity
        - message
        - line
        - column
    V2Error:
      type: object
      properties:
        error:
          type: string
          minLength: 1
          description: Human-readable explanation of the failure.
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Effective API key. Send Authorization: Bearer sk-eai-...'

````

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