> ## 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.

# Start a procedure run

> Starts a run of a published procedure version with its inputs: `live` by default, or a version number. The run proceeds on its own; read it with getProcedureRun until its status is final, and answer the tasks it creates for people.

The inputs are checked against the version’s input schemas (getProcedureVersion) before the run starts; a mismatch is refused with 422 `invalid_run_inputs`, whose `details` say what to fix. Needs `procedures:run` on the procedure. Model and compute use is billed as the run consumes it; the call itself is not charged.

To try source before publishing it, send `source` (with `sourceName`, `fragments` and `documents`, as publishProcedure takes them) instead of `procedureId`. That starts a draft: the source is compiled and run against your real connections, but no version is stored; the run has `draft: true` and no `version`, and is private unless `visibility` says otherwise. A draft needs the right to publish the procedure its source names (build access, or `procedures:create` for a new one); scoped API keys cannot start drafts. Source that does not compile is refused with 422 `invalid_procedure`, whose `details` give each error as publishProcedure does. A draft cannot declare secrets. Triggers never start drafts, and nothing a draft stores can be published: to keep it, publish the source.

Idempotency-Key is required: a retry with the same key and request answers with the run that request started (`outcome: already_started`, 200); the same key with a different request is refused with 409 `idempotency_conflict`.



## OpenAPI

````yaml /openapi.json post /procedures/runs
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/runs:
    post:
      tags:
        - Procedure runs
      summary: Start a procedure run
      description: >-
        Starts a run of a published procedure version with its inputs: `live` by
        default, or a version number. The run proceeds on its own; read it with
        getProcedureRun until its status is final, and answer the tasks it
        creates for people.


        The inputs are checked against the version’s input schemas
        (getProcedureVersion) before the run starts; a mismatch is refused with
        422 `invalid_run_inputs`, whose `details` say what to fix. Needs
        `procedures:run` on the procedure. Model and compute use is billed as
        the run consumes it; the call itself is not charged.


        To try source before publishing it, send `source` (with `sourceName`,
        `fragments` and `documents`, as publishProcedure takes them) instead of
        `procedureId`. That starts a draft: the source is compiled and run
        against your real connections, but no version is stored; the run has
        `draft: true` and no `version`, and is private unless `visibility` says
        otherwise. A draft needs the right to publish the procedure its source
        names (build access, or `procedures:create` for a new one); scoped API
        keys cannot start drafts. Source that does not compile is refused with
        422 `invalid_procedure`, whose `details` give each error as
        publishProcedure does. A draft cannot declare secrets. Triggers never
        start drafts, and nothing a draft stores can be published: to keep it,
        publish the source.


        Idempotency-Key is required: a retry with the same key and request
        answers with the run that request started (`outcome: already_started`,
        200); the same key with a different request is refused with 409
        `idempotency_conflict`.
      operationId: startProcedureRun
      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/ProcedureRunStartRequest'
      responses:
        '200':
          description: 'A retry: the run this request started before.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StartedProcedureRun'
        '201':
          description: The run started.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StartedProcedureRun'
        '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 run this procedure, or may not publish the
            procedure a draft names.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '404':
          description: No such procedure or version, or the caller cannot see it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '409':
          description: idempotency_conflict, or the procedure cannot start now.
          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_run_inputs: the inputs do not match the version; details say
            what to fix. invalid_procedure: a draft’s source did not compile;
            details name each error. procedure_upgrade_needed: republish the
            version first.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '503':
          description: Procedure runs are temporarily unavailable. Retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
      security:
        - bearerAuth: []
components:
  schemas:
    ProcedureRunStartRequest:
      type: object
      properties:
        procedureId:
          type: string
          maxLength: 256
          pattern: ^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$
          description: >-
            The published procedure to run. Send `procedureId` or `source` (a
            draft), not both.
        version:
          anyOf:
            - type: integer
              minimum: 0
              exclusiveMinimum: true
              maximum: 9007199254740991
              description: Immutable positive procedure version
            - type: string
              enum:
                - live
          description: >-
            A published version, or `live` (the default). Only with
            `procedureId`.
        source:
          type: string
          minLength: 1
          maxLength: 1048576
          description: >-
            Starts a draft: this root document, compiled and run without
            publishing it. As publishProcedure takes it. Send `procedureId` or
            `source`, not both.
        sourceName:
          type: string
          minLength: 1
          maxLength: 512
          description: >-
            The root document’s file name, such as `intake.procedure.yaml`.
            Required with `source`.
        fragments:
          type: object
          additionalProperties:
            type: string
            maxLength: 1048576
          description: Fragment documents the draft’s root includes, by path. At most 128.
        documents:
          type: object
          additionalProperties:
            type: string
            maxLength: 1048576
          description: Other documents the draft’s source reads, by path. At most 128.
        inputs:
          type: object
          additionalProperties:
            nullable: true
          description: >-
            Input values by name, as getProcedureVersion describes them. An
            omitted input takes its default.
        connections:
          type: object
          additionalProperties:
            type: string
            format: uuid
          description: Connection id for each connection slot the version declares.
        projectId:
          type: string
          format: uuid
          description: The project the run belongs to.
        visibility:
          type: string
          enum:
            - collaborative
            - private
          description: >-
            `private` runs are visible only to the person who started them.
            Defaults to the procedure’s setting, and to `private` for a draft.
      additionalProperties: false
    StartedProcedureRun:
      type: object
      properties:
        outcome:
          type: string
          enum:
            - started
            - already_started
          description: >-
            `already_started` when this Idempotency-Key and request started a
            run before: that run.
        run:
          $ref: '#/components/schemas/ProcedureRunSummary'
      required:
        - outcome
        - run
    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
    ProcedureRunSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Tenant-scoped logical procedure run identifier
        procedureId:
          type: string
          maxLength: 256
          pattern: ^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$
          description: Stable procedure identifier
        version:
          type: integer
          nullable: true
          minimum: 0
          exclusiveMinimum: true
          maximum: 9007199254740991
          description: The published version the run runs. Null for a draft.
        draft:
          type: boolean
          description: >-
            True for a draft: a run of unpublished source, started with
            `source`. Nothing a draft stores can be published; to keep the
            procedure, publish its source.
        title:
          type: string
        status:
          type: string
          x-extensible-enum:
            - starting
            - running
            - completed
            - failed
            - cancelled
            - terminated
            - timed_out
            - unavailable
          description: >-
            `unavailable` when the run’s state could not be read. completed,
            failed, cancelled, terminated and timed_out are final. New statuses
            may be added; treat an unknown one as not final.
        visibility:
          type: string
          enum:
            - collaborative
            - private
        projectId:
          type: string
          nullable: true
        cause:
          $ref: '#/components/schemas/ProcedureRunStartCause'
        startedBy:
          type: object
          nullable: true
          properties:
            userId:
              type: string
            name:
              type: string
              nullable: true
          required:
            - userId
            - name
          description: The person the run acts for, when one did.
        createdAt:
          type: string
          format: date-time
        finishedAt:
          type: string
          nullable: true
          format: date-time
        webUrl:
          type: string
          format: uri
          description: The run’s page in Effective.
      required:
        - id
        - procedureId
        - version
        - draft
        - title
        - status
        - visibility
        - projectId
        - cause
        - startedBy
        - createdAt
        - finishedAt
        - webUrl
    V2Error:
      type: object
      properties:
        error:
          type: string
          minLength: 1
          description: Human-readable explanation of the failure.
      required:
        - error
    ProcedureRunStartCause:
      type: object
      properties:
        kind:
          type: string
          x-extensible-enum:
            - direct
            - trigger
            - procedure
            - other
          description: What started the run. New kinds may be added.
        triggerId:
          type: string
          nullable: true
          description: The trigger, for `trigger`.
        parentRunId:
          type: string
          nullable: true
          format: uuid
          description: The run that started it, for `procedure`.
      required:
        - kind
        - triggerId
        - parentRunId
  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.