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

# Run a flow up to a step on a real record, in a sandbox

> Runs the steps up to `until` as the editor's Run button does, on the given account: nothing is saved and nothing is sent. Returns each step's output and what would have been sent (long text and lists cut). A full test can take up to two minutes, longer than many clients wait: test step by step with `until` first.



## OpenAPI

````yaml /api/statisfy-api.openapi.json post /v1/automations/flows/{flow_id}/test
openapi: 3.1.0
info:
  description: >-
    The agent-first Statisfy API. Authenticate with an API key (`Authorization:
    Bearer stfy_live_…`), then call `GET /v1/meta/capabilities` to discover
    every operation and its schemas.
  title: Statisfy API
  version: 1.0.0
servers:
  - url: https://api.statisfy.com
    description: Production
security: []
paths:
  /v1/automations/flows/{flow_id}/test:
    post:
      tags:
        - automations
      summary: Run a flow up to a step on a real record, in a sandbox
      description: >-
        Runs the steps up to `until` as the editor's Run button does, on the
        given account: nothing is saved and nothing is sent. Returns each step's
        output and what would have been sent (long text and lists cut). A full
        test can take up to two minutes, longer than many clients wait: test
        step by step with `until` first.
      operationId: automations_test_flow
      parameters:
        - in: path
          name: flow_id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                record:
                  $ref: '#/components/schemas/FlowTestRecord'
                  description: >-
                    The record the trigger runs on (its id); leave it out for a
                    schedule, which runs for no record
                simulate:
                  additionalProperties: true
                  description: >-
                    Answers for waiting steps, by step id, so the steps after
                    them run: an approval true (approved as prepared) or the
                    edited data; a sleep any value; an email reply the reply
                    text, or false for no reply. A waiting step with no answer
                    ends its branch and shows in `waits`.
                  title: Simulate
                  type: object
                until:
                  anyOf:
                    - type: string
                    - type: 'null'
                  default: null
                  description: The last step to run; none runs every step
                  title: Until
              type: object
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlowTestResult'
          description: Successful Response
      security:
        - HTTPBearer: []
components:
  schemas:
    FlowTestRecord:
      description: >-
        The record a test runs on, as the dispatcher would hand it to the
        trigger: the id that matches it.
      properties:
        account_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Account Id
        activity_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Activity Id
        calendar_event_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Calendar Event Id
        contact_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Contact Id
        opportunity_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Opportunity Id
        project_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Project Id
        task_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Task Id
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: User Id
      title: FlowTestRecord
      type: object
    FlowTestResult:
      properties:
        flow_id:
          title: Flow Id
          type: string
        held_events:
          description: >-
            Events the steps raised (a task created) that a test does not
            publish
          items:
            additionalProperties: true
            type: object
          title: Held Events
          type: array
        not_taken:
          description: >-
            Steps on a branch a condition did not take for this record: they did
            not run, and need not
          items:
            type: string
          title: Not Taken
          type: array
        order:
          items:
            type: string
          title: Order
          type: array
        passed:
          description: >-
            Every step ran without an error, apart from steps on a branch not
            taken, and nothing in `warnings` fails the test (a full test marks
            the version tested)
          title: Passed
          type: boolean
        skipped:
          description: Outside calls a test does not make
          items:
            type: string
          title: Skipped
          type: array
        steps:
          additionalProperties:
            $ref: '#/components/schemas/FlowTestStep'
          title: Steps
          type: object
        trigger_matches:
          anyOf:
            - type: boolean
            - type: 'null'
          description: >-
            Whether the record is in the trigger's audience now. false: the
            hourly job would not start the flow for it, so no step ran; pick a
            record that matches. null: the trigger has no audience to check
          title: Trigger Matches
        until:
          anyOf:
            - type: string
            - type: 'null'
          title: Until
        version:
          title: Version
          type: integer
        waits:
          description: >-
            Steps that would wait (an approval, a sleep, an email reply): what
            for, and whether `simulate` answered
          items:
            additionalProperties: true
            type: object
          title: Waits
          type: array
        warnings:
          description: >-
            What the steps' own results don't show: a condition that found no
            such field, an approval no one would be asked for (fails the test),
            a step that waited on rows another run holds (fails the test)
          items:
            type: string
          title: Warnings
          type: array
        would_send:
          description: What the steps would have sent; none was sent
          items:
            additionalProperties: true
            type: object
          title: Would Send
          type: array
        would_write:
          description: >-
            Rows the steps wrote inside the test (a task, a comment, a field
            value): table, insert/update/delete and the values; all were undone
            when the test ended
          items:
            additionalProperties: true
            type: object
          title: Would Write
          type: array
      required:
        - flow_id
        - version
        - until
        - order
        - steps
        - would_send
        - skipped
        - passed
      title: FlowTestResult
      type: object
    FlowTestStep:
      properties:
        branch:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            For a step that branches (a condition, an email reply wait): the
            branch it took. `output` is what it passed down that branch (null
            when nothing follows it)
          title: Branch
        cached:
          title: Cached
          type: boolean
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        note:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            What the test did instead of the real thing: a write undone, a send
            held back
          title: Note
        output:
          title: Output
        step:
          title: Step
          type: string
        valid:
          title: Valid
          type: boolean
      required:
        - step
        - valid
        - cached
      title: FlowTestStep
      type: object
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http
      description: >-
        An API key, sent as `Authorization: Bearer stfy_live_…`. See
        [Authentication](/rest-api/authentication) for how to get one and which
        scopes it needs.

````

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