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

# Run a workflow

> Run a published workflow with a spending session or x402 payment. An unpublished workflow requires its owner’s session.

Read the [streaming guide](https://docs.man0.space/developer/streaming.md) for event handling and resume behavior.


## OpenAPI

````yaml openapi.json POST /api/workflows/{id}/run
openapi: 3.0.3
info:
  title: Man0 API
  version: 1.0.0
  description: Man0 workflows, catalog, accounts and NEAR Intents.
servers:
  - url: https://api.man0.space
security: []
tags:
  - name: System
  - name: Accounts
  - name: Authentication
  - name: Catalog
  - name: Vibe and media
  - name: Workflows
  - name: Drafts
  - name: Execution
  - name: Analytics
  - name: NEAR accounts
  - name: Intents
paths:
  /api/workflows/{id}/run:
    post:
      tags:
        - Execution
      summary: Run a workflow
      description: >-
        Run a published workflow with a spending session or x402 payment. An
        unpublished workflow requires its owner’s session.
      operationId: workflow_run
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: x-session-user-address
          in: header
          required: false
          schema:
            type: string
          description: >-
            Spending wallet subject or authenticated canonical account address;
            the API verifies that identity.
        - name: x-network-id
          in: header
          required: false
          schema:
            type: string
          description: Settlement network in CAIP-2 format, such as near:mainnet.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunInput'
      responses:
        '200':
          description: Stream of newline-delimited JSON events.
          content:
            application/x-ndjson:
              schema:
                $ref: '#/components/schemas/RunStreamEvent'
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication required or expired.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Payment authorization required. Decode the PAYMENT-REQUIRED header.
          headers:
            PAYMENT-REQUIRED:
              schema:
                type: string
        '403':
          description: Permission or current consent required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Resource or policy changed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: >-
            Request body exceeds the size limit. Upload attachments accept at
            most 20 MB of decoded file bytes.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Request rate exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Service unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - spendingSession: []
        - x402Payment: []
components:
  schemas:
    RunInput:
      type: object
      properties:
        input:
          type: string
          maxLength: 32000
        attachments:
          maxItems: 8
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - image
                  - audio
                  - video
                  - pdf
                  - file
                  - text
                  - json
              url:
                type: string
                maxLength: 2048
                format: uri
              mimeType:
                type: string
                maxLength: 160
              name:
                type: string
                maxLength: 240
              size:
                type: integer
                minimum: 0
                maximum: 9007199254740991
              cid:
                type: string
                maxLength: 160
              text:
                type: string
                maxLength: 64000
            required:
              - type
              - url
        dry:
          type: boolean
        threadId:
          type: string
          minLength: 1
          maxLength: 200
        coordinator:
          nullable: true
          type: object
          properties:
            id:
              type: string
              minLength: 1
              maxLength: 160
            userAddress:
              default: ''
              type: string
              maxLength: 160
            agentId:
              default: 0
              type: integer
              minimum: 0
              maximum: 9007199254740991
            walletAddress:
              type: string
              minLength: 2
              maxLength: 160
            name:
              type: string
              minLength: 1
              maxLength: 120
            image:
              default: ''
              type: string
              maxLength: 2048
            personality:
              default: ''
              type: string
              maxLength: 8000
            model:
              type: string
              minLength: 1
              maxLength: 256
            cid:
              default: ''
              type: string
              maxLength: 256
            txHash:
              default: ''
              type: string
              maxLength: 256
            contractId:
              default: ''
              type: string
              maxLength: 160
            network:
              type: string
              minLength: 2
              maxLength: 80
            created:
              type: string
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
          required:
            - id
            - walletAddress
            - name
            - model
            - network
        connectorDecisions:
          maxItems: 16
          type: array
          items:
            type: object
            properties:
              runId:
                type: string
                minLength: 1
                maxLength: 200
              requestId:
                type: string
                minLength: 1
                maxLength: 200
              decision:
                type: string
                enum:
                  - connected
                  - discarded
            required:
              - runId
              - requestId
              - decision
    RunStreamEvent:
      anyOf:
        - type: object
          properties:
            type:
              type: string
              enum:
                - thread:init
            threadId:
              type: string
            runId:
              type: string
          required:
            - type
            - threadId
            - runId
        - type: object
          properties:
            type:
              type: string
              enum:
                - step:start
            stepId:
              type: string
            label:
              type: string
            kind:
              type: string
          required:
            - type
            - stepId
            - label
            - kind
        - type: object
          properties:
            type:
              type: string
              enum:
                - step:done
            stepId:
              type: string
            label:
              type: string
            kind:
              type: string
            output:
              type: string
          required:
            - type
            - stepId
            - label
            - kind
            - output
        - type: object
          properties:
            type:
              type: string
              enum:
                - sse:activity
            id:
              type: string
            ts:
              type: number
            stepId:
              nullable: true
              type: string
            kind:
              type: string
            status:
              type: string
              enum:
                - running
                - completed
                - pending
                - failed
            title:
              type: string
            summary:
              type: string
          required:
            - type
            - id
            - ts
            - stepId
            - kind
            - status
            - title
        - type: object
          properties:
            type:
              type: string
              enum:
                - sse:delta
            stepId:
              nullable: true
              type: string
            delta:
              type: string
          required:
            - type
            - stepId
            - delta
        - type: object
          properties:
            type:
              type: string
              enum:
                - sse:bill
            composeBillWei:
              type: string
            bills:
              type: array
              items:
                $ref: '#/components/schemas/WorkflowBillItem'
          required:
            - type
            - composeBillWei
            - bills
        - type: object
          properties:
            type:
              type: string
              enum:
                - connector:pause
            missing:
              type: array
              items:
                $ref: '#/components/schemas/MissingConnectorRequirement'
          required:
            - type
            - missing
        - type: object
          properties:
            type:
              type: string
              enum:
                - input:pause
            missingInputs:
              type: array
              items:
                $ref: '#/components/schemas/MissingInputRequirement'
          required:
            - type
            - missingInputs
        - type: object
          properties:
            type:
              type: string
              enum:
                - ping
            ts:
              type: number
          required:
            - type
            - ts
        - type: object
          properties:
            type:
              type: string
              enum:
                - result
            execution:
              $ref: '#/components/schemas/Execution'
          required:
            - type
            - execution
        - type: object
          properties:
            type:
              type: string
              enum:
                - error
            statusCode:
              type: number
            code:
              type: string
            threadId:
              type: string
            missing:
              type: array
              items:
                $ref: '#/components/schemas/MissingConnectorRequirement'
            missingInputs:
              type: array
              items:
                $ref: '#/components/schemas/MissingInputRequirement'
            error:
              type: string
          required:
            - type
            - error
    Error:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
        threadId:
          type: string
        missing:
          type: array
          items:
            $ref: '#/components/schemas/MissingConnectorRequirement'
        missingInputs:
          type: array
          items:
            $ref: '#/components/schemas/MissingInputRequirement'
      required:
        - error
    WorkflowBillItem:
      type: object
      properties:
        category:
          type: string
          enum:
            - coordinator
            - model
            - connector
            - agent
        kind:
          type: string
        name:
          type: string
        subject:
          type: string
        stepId:
          type: string
        receiptId:
          type: string
        txHash:
          type: string
        amountWei:
          type: string
      required:
        - category
        - kind
        - name
        - amountWei
    MissingConnectorRequirement:
      type: object
      properties:
        entryId:
          type: string
        slug:
          type: string
        name:
          type: string
        type:
          type: string
          enum:
            - account
            - gated
        userAddress:
          type: string
        missingVars:
          type: array
          items:
            type: object
            properties:
              varName:
                type: string
              description:
                type: string
              obtainUrl:
                type: string
            required:
              - varName
        reason:
          type: string
        agentWallet:
          type: string
        runId:
          type: string
        threadId:
          type: string
        requestId:
          type: string
      required:
        - entryId
        - slug
        - name
        - type
        - reason
    MissingInputRequirement:
      type: object
      properties:
        stepId:
          type: string
        stepLabel:
          type: string
        modelId:
          type: string
        modelName:
          type: string
        acceptedInputs:
          type: array
          items:
            type: string
        questions:
          type: array
          items:
            type: string
        reason:
          type: string
        agentWallet:
          type: string
        runId:
          type: string
        threadId:
          type: string
        proposalId:
          type: string
      required:
        - stepId
        - stepLabel
        - acceptedInputs
        - reason
    Execution:
      type: object
      properties:
        ok:
          type: boolean
        workflowId:
          type: string
        threadId:
          type: string
        chainWorkflowId:
          type: number
          nullable: true
        name:
          type: string
        creatorUserAddress:
          type: string
        userAddress:
          type: string
        network:
          type: string
        dry:
          type: boolean
        composeBillWei:
          type: string
        creatorFeePercent:
          type: number
        creatorFeeWei:
          type: string
        platformFeePercent:
          type: number
        platformFeeWei:
          type: string
        serviceFeeWei:
          type: string
        totalChargedWei:
          type: string
        txHash:
          nullable: true
          type: string
        paymentIntentId:
          nullable: true
          type: string
        proofCid:
          nullable: true
          type: string
        proofUrl:
          nullable: true
          type: string
        output:
          type: string
        steps:
          type: array
          items:
            $ref: '#/components/schemas/Trace'
        bills:
          type: array
          items:
            $ref: '#/components/schemas/WorkflowBillItem'
      required:
        - ok
        - workflowId
        - chainWorkflowId
        - name
        - creatorUserAddress
        - userAddress
        - network
        - composeBillWei
        - creatorFeePercent
        - creatorFeeWei
        - platformFeePercent
        - platformFeeWei
        - serviceFeeWei
        - totalChargedWei
        - txHash
        - paymentIntentId
        - output
        - steps
    Trace:
      type: object
      properties:
        id:
          type: string
        label:
          type: string
        kind:
          type: string
        entryId:
          nullable: true
          type: string
        billWei:
          type: string
        output:
          type: string
      required:
        - id
        - label
        - kind
        - entryId
        - billWei
        - output
  securitySchemes:
    spendingSession:
      type: apiKey
      in: header
      name: x-compose-key
      description: >-
        Compose spending-session token. Also accepted as an Authorization Bearer
        token.
    x402Payment:
      type: apiKey
      in: header
      name: PAYMENT-SIGNATURE
      description: Base64-encoded x402 v2 payment payload.

````

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