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

# Test a draft

> Test a supplied workflow graph with a spending session. Read newline-delimited JSON activity and results.

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


## OpenAPI

````yaml openapi.json POST /api/draft/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/draft/run:
    post:
      tags:
        - Execution
      summary: Test a draft
      description: >-
        Test a supplied workflow graph with a spending session. Read
        newline-delimited JSON activity and results.
      operationId: draft_run
      parameters:
        - 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: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DraftRunInput'
      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:
        - man0Auth: []
          spendingSession: []
components:
  schemas:
    DraftRunInput:
      type: object
      properties:
        flow:
          type: object
          properties:
            id:
              type: string
              format: uuid
              pattern: >-
                ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
            name:
              type: string
              minLength: 1
              maxLength: 200
            brief:
              type: string
              maxLength: 32000
            banner:
              nullable: true
              type: string
              maxLength: 524288
            tasks:
              maxItems: 3
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 64
            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
            nodes:
              maxItems: 500
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    minLength: 1
                    maxLength: 100
                  type:
                    type: string
                    enum:
                      - step
                  position:
                    type: object
                    properties:
                      x:
                        type: number
                      'y':
                        type: number
                    required:
                      - x
                      - 'y'
                  data:
                    type: object
                    properties:
                      label:
                        type: string
                        minLength: 1
                        maxLength: 200
                      kind:
                        type: string
                        enum:
                          - model
                          - connector
                          - agent
                      entry:
                        type: object
                        properties:
                          id:
                            type: string
                            minLength: 1
                            maxLength: 512
                          name:
                            type: string
                            minLength: 1
                            maxLength: 200
                          description:
                            type: string
                            maxLength: 10000
                          kind:
                            type: string
                            enum:
                              - model
                              - connector
                              - agent
                          groups:
                            maxItems: 16
                            type: array
                            items:
                              type: string
                              minLength: 1
                              maxLength: 80
                          subgroups:
                            maxItems: 24
                            type: array
                            items:
                              type: string
                              minLength: 1
                              maxLength: 120
                          modality:
                            type: string
                            minLength: 1
                            maxLength: 80
                          family:
                            type: string
                            minLength: 1
                            maxLength: 80
                          isFrontier:
                            type: boolean
                          isLatest:
                            type: boolean
                          logo:
                            type: string
                            maxLength: 1024
                            format: uri
                          input:
                            maxItems: 32
                            type: array
                            items:
                              type: string
                              minLength: 1
                              maxLength: 80
                          output:
                            maxItems: 32
                            type: array
                            items:
                              type: string
                              minLength: 1
                              maxLength: 80
                          type:
                            anyOf:
                              - type: string
                                minLength: 1
                                maxLength: 120
                              - maxItems: 32
                                type: array
                                items:
                                  type: string
                                  minLength: 1
                                  maxLength: 120
                          operations:
                            maxItems: 64
                            type: array
                            items:
                              type: object
                              properties:
                                modality:
                                  type: string
                                  minLength: 1
                                  maxLength: 80
                                operation:
                                  type: string
                                  minLength: 1
                                  maxLength: 120
                                sourceTypes:
                                  maxItems: 32
                                  type: array
                                  items:
                                    type: string
                                    maxLength: 120
                                input:
                                  maxItems: 32
                                  type: array
                                  items:
                                    type: string
                                    maxLength: 80
                                output:
                                  maxItems: 32
                                  type: array
                                  items:
                                    type: string
                                    maxLength: 80
                                pricingUnits:
                                  maxItems: 32
                                  type: array
                                  items:
                                    type: string
                                    maxLength: 80
                                streamable:
                                  type: boolean
                              required:
                                - modality
                                - operation
                                - sourceTypes
                                - input
                                - output
                                - pricingUnits
                                - streamable
                              additionalProperties: {}
                        required:
                          - id
                          - name
                          - description
                          - kind
                      note:
                        type: string
                        maxLength: 16000
                    required:
                      - label
                      - kind
                      - note
                required:
                  - id
                  - type
                  - position
                  - data
            edges:
              maxItems: 2000
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    minLength: 1
                    maxLength: 200
                  source:
                    type: string
                  target:
                    type: string
                  sourceHandle:
                    nullable: true
                    type: string
                  targetHandle:
                    nullable: true
                    type: string
                  type:
                    type: string
                    enum:
                      - wire
                required:
                  - id
                  - source
                  - target
            modified:
              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
            - name
            - nodes
            - edges
            - modified
        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
      required:
        - flow
    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:
    man0Auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Man0 authentication token returned by sign-in.
    spendingSession:
      type: apiKey
      in: header
      name: x-compose-key
      description: >-
        Compose spending-session token. Also accepted as an Authorization Bearer
        token.

````

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