info:
  description: API for managing counterparty risk and intelligence
  title: PostRFP FSM API
  version: 1.8.1
servers:
- url: https://re.postrfp.com/fsm/api
- url: http://localhost:9000/fsm/api
paths:
  /entities:
    get:
      description: "Get a list of all available FSM entity types.\n\nPermissions:
        MANAGE_ORGANISATION"
      parameters: []
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EntityTypeList'
      operationId: get_entities
  /transition:
    post:
      description: "Execute a transition on an FSM entity.\n\nThis is a generic endpoint
        that can be used for any FSM entity type,\nreplacing entity-specific endpoints
        like put_project_publish.\n\nPermission checking is delegated to the guard
        function associated with\nthe transition, which has access to entity context
        and user information\nto perform appropriate authorization checks.\n\nPermissions:
        Delegated to guard function"
      parameters: []
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransitionResult'
      operationId: post_transition
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TransitionRequest'
  /workflow:
    post:
      description: "Create a new FSM workflow.\n\nThe workflow ID should not be set
        - it will be ignored if provided.\n\nPermissions: MANAGE_ORGANISATION"
      parameters: []
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IdSchema'
      operationId: post_workflow
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkflowSchema'
  /workflow/{workflow_id}:
    delete:
      description: "Delete an FSM workflow.\n\nPermissions: MANAGE_ORGANISATION"
      parameters:
      - in: path
        required: true
        name: workflow_id
        schema:
          type: integer
      responses:
        '200':
          description: Successful Response
      operationId: delete_workflow
    get:
      description: "Get a specific FSM workflow by ID.\n\nPermissions: MANAGE_ORGANISATION"
      parameters:
      - in: path
        required: true
        name: workflow_id
        schema:
          type: integer
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowSchema'
      operationId: get_workflow
    put:
      description: "Update an existing FSM workflow.\n\nPermissions: MANAGE_ORGANISATION"
      parameters:
      - in: path
        required: true
        name: workflow_id
        schema:
          type: integer
      responses:
        '200':
          description: Successful Response
      operationId: put_workflow
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkflowSchema'
  /workflow/{workflow_id}/entity/{entity_id}/transitions:
    get:
      description: "List transitions that can be performed by the current user at
        the current status\nfor the given workflow\n\nPermissions: MANAGE_ORGANISATION"
      parameters:
      - in: path
        required: true
        name: workflow_id
        schema:
          type: integer
      - in: path
        required: true
        name: entity_id
        schema:
          type: integer
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/TransitionSchema'
      operationId: get_workflow_entity_transitions
  /workflow/{workflow_id}/statuses:
    get:
      description: "Get all states for an FSM workflow.\n\nPermissions: MANAGE_ORGANISATION"
      parameters:
      - in: path
        required: true
        name: workflow_id
        schema:
          type: integer
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/StatusSchema'
      operationId: get_workflow_statuses
  /workflow/{workflow_id}/transitions:
    get:
      description: "Get all transitions for an FSM workflow.\n\nPermissions: MANAGE_ORGANISATION"
      parameters:
      - in: path
        required: true
        name: workflow_id
        schema:
          type: integer
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/TransitionSchema'
      operationId: get_workflow_transitions
  /workflows:
    get:
      description: "Get a list of FSM workflows, optionally filtered by entity type
        and organisation.\n\nPermissions: MANAGE_ORGANISATION"
      parameters:
      - in: query
        required: false
        name: entity
        schema:
          type: string
      - in: query
        required: false
        name: page_size
        description: The number of records to return in a single page,  maximum 
          200, minimum 1
        schema:
          type: integer
          default: 20
      - in: query
        required: false
        name: page
        description: Page number of records to show, beginning from 1
        schema:
          type: integer
          default: 1
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowList'
      operationId: get_workflows
openapi: 3.1.1
components:
  schemas:
    EntityTypeList:
      description: Schema for a list of FSM entity types.
      properties:
        data:
          items:
            $ref: '#/components/schemas/EntityTypeSchema'
          title: Data
          type: array
      required:
      - data
      title: EntityTypeList
      type: object
    EntityTypeSchema:
      description: Schema for FSM entity types.
      properties:
        name:
          description: Entity class name
          title: Name
          type: string
        table_name:
          description: SQLAlchemy table name
          title: Table Name
          type: string
        context_schema:
          additionalProperties: true
          description: JSON schema for context validation
          title: Context Schema
          type: object
      required:
      - name
      - table_name
      - context_schema
      title: EntityTypeSchema
      type: object
    IdSchema:
      description: Schema for returning an ID.
      properties:
        id:
          description: Unique identifier
          title: Id
          type: integer
      required:
      - id
      title: IdSchema
      type: object
    Pagination:
      description: Schema for pagination information.
      properties:
        current_page:
          title: Current Page
          type: integer
        page_size:
          title: Page Size
          type: integer
        total_count:
          title: Total Count
          type: integer
        total_pages:
          title: Total Pages
          type: integer
        has_next:
          title: Has Next
          type: boolean
        current_page_count:
          default: 0
          description: Number of records in the current page
          title: Current Page Count
          type: integer
      required:
      - current_page
      - page_size
      - total_count
      - total_pages
      - has_next
      title: Pagination
      type: object
    StatusSchema:
      description: Schema for state data compatible with  editor.
      properties:
        id:
          anyOf:
          - type: integer
          - type: 'null'
          default:
          title: Id
        name:
          description: Human-readable name of the state
          maxLength: 64
          title: Name
          type: string
        code:
          description: System identifier for the state
          maxLength: 64
          title: Code
          type: string
        colour:
          anyOf:
          - maxLength: 7
            pattern: ^#[0-9A-Fa-f]{6}$
            type: string
          - type: 'null'
          default:
          description: Hex color code (#RRGGBB)
          examples:
          - '#1E90FF'
          title: Colour
        status_actions:
          default: []
          items:
            type: string
          title: Status Actions
          type: array
        description:
          anyOf:
          - maxLength: 512
            type: string
          - type: 'null'
          default:
          title: Description
      required:
      - name
      - code
      title: StatusSchema
      type: object
    TransitionRequest:
      properties:
        entity_id:
          title: Entity Id
          type: integer
        entity_type:
          enum:
          - Project
          - Issue
          title: Entity Type
          type: string
        transition_name:
          title: Transition Name
          type: string
      required:
      - entity_id
      - entity_type
      - transition_name
      title: TransitionRequest
      type: object
    TransitionResult:
      description: Result returned from running an Entity transition
      properties:
        transition_permitted:
          title: Transition Permitted
          type: boolean
        message:
          anyOf:
          - type: string
          - type: 'null'
          default:
          description: Message returned from the Angst server
          title: Message
        job_ref:
          anyOf:
          - type: string
          - type: 'null'
          default:
          description: Job ID of any HTTP calls invoked on the Angst server
          title: Job Ref
      required:
      - transition_permitted
      title: TransitionResult
      type: object
    TransitionSchema:
      description: Schema for transition data compatible with  editor.
      properties:
        id:
          anyOf:
          - type: integer
          - type: 'null'
          default:
          title: Id
        name:
          maxLength: 64
          title: Name
          type: string
        source_status:
          $ref: '#/components/schemas/StatusSchema'
        target_status:
          $ref: '#/components/schemas/StatusSchema'
        guard_policy:
          anyOf:
          - type: string
          - type: 'null'
          default:
          description: CEL expression for guard condition
          title: Guard Policy
      required:
      - name
      - source_status
      - target_status
      title: TransitionSchema
      type: object
    WorkflowList:
      description: Schema for a list of transitions.
      properties:
        data:
          items:
            $ref: '#/components/schemas/WorkflowSummary'
          title: Data
          type: array
        pagination:
          $ref: '#/components/schemas/Pagination'
      required:
      - data
      - pagination
      title: WorkflowList
      type: object
    WorkflowSchema:
      description: Schema for  definition compatible with  editor.
      properties:
        id:
          anyOf:
          - type: integer
          - type: 'null'
          default:
          description: ID of the FSM definition
          title: Id
        title:
          maxLength: 128
          title: Title
          type: string
        description:
          anyOf:
          - maxLength: 1024
            type: string
          - type: 'null'
          default:
          title: Description
        entity_type:
          maxLength: 64
          title: Entity Type
          type: string
        initial_status_code:
          anyOf:
          - maxLength: 64
            type: string
          - type: 'null'
          default: Not Set
          description: Code of the initial state
          title: Initial Status Code
        current_state:
          anyOf:
          - type: string
          - type: 'null'
          default:
          description: Current state code (if applicable)
          title: Current State
        context_spec:
          anyOf:
          - type: string
          - type: 'null'
          default:
          description: JSON schema for context validation
          title: Context Spec
        version:
          default: 1
          title: Version
          type: integer
        is_active:
          default: true
          title: Is Active
          type: boolean
        organisation_id:
          description: 'ID of the organisation that owns this '
          title: Organisation Id
          type: string
        statuses:
          items:
            $ref: '#/components/schemas/StatusSchema'
          minItems: 1
          title: Statuses
          type: array
        transitions:
          default: []
          items:
            $ref: '#/components/schemas/TransitionSchema'
          title: Transitions
          type: array
      required:
      - title
      - entity_type
      - organisation_id
      title: WorkflowSchema
      type: object
    WorkflowSummary:
      description: Schema for a summary of a workflow definition.
      properties:
        id:
          description: ID of the FSM definition
          title: Id
          type: integer
        title:
          maxLength: 128
          title: Title
          type: string
        entity_type:
          maxLength: 64
          title: Entity Type
          type: string
        version:
          default: 1
          title: Version
          type: integer
        is_active:
          default: true
          title: Is Active
          type: boolean
      required:
      - id
      - title
      - entity_type
      title: WorkflowSummary
      type: object
