{
  "openapi": "3.1.0",
  "info": {
    "title": "NoodleFinity local partner integration",
    "version": "1.2.0",
    "description": "Implemented sandbox partner interfaces for cash financing, order finance and payment evidence. Capabilities are scoped to the authenticated service client."
  },
  "servers": [
    {
      "url": "/integration/v1"
    }
  ],
  "security": [
    {
      "serviceToken": []
    }
  ],
  "paths": {
    "/token": {
      "post": {
        "summary": "Exchange service credentials",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "token_type": {
                      "const": "Bearer"
                    },
                    "client_id": {
                      "type": "string"
                    },
                    "expires_in": {
                      "const": 900
                    }
                  },
                  "required": [
                    "access_token",
                    "token_type",
                    "client_id",
                    "expires_in"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Invalid request, credentials, authority, reference, stage or evidence version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "serviceClient": []
          }
        ],
        "operationId": "issueToken"
      }
    },
    "/applications": {
      "get": {
        "summary": "List visible cases in the organization's work queue",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "applications": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Application"
                      }
                    }
                  },
                  "required": [
                    "applications"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Invalid request, credentials, authority, reference, stage or evidence version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "listApplications"
      }
    },
    "/applications/{case_id}": {
      "get": {
        "summary": "Read the permitted application fields",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                }
              }
            }
          },
          "default": {
            "description": "Invalid request, credentials, authority, reference, stage or evidence version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "case_id",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "operationId": "getApplication"
      }
    },
    "/applications/{case_id}/state": {
      "get": {
        "summary": "Read available commands, reviews and case receipts",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/State"
                }
              }
            }
          },
          "default": {
            "description": "Invalid request, credentials, authority, reference, stage or evidence version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "case_id",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "operationId": "getApplicationState"
      }
    },
    "/applications/{case_id}/commands/{action}": {
      "post": {
        "summary": "Submit an authorized case command",
        "responses": {
          "202": {
            "description": "Accepted command; poll state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommandReceipt"
                }
              }
            }
          },
          "default": {
            "description": "Invalid request, credentials, authority, reference, stage or evidence version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "description": "Copy the confirmation from the current state when present. Replay the same key and body after an uncertain reply.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Command"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "case_id",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "action",
            "in": "path",
            "schema": {
              "enum": [
                "attest",
                "notify",
                "forward",
                "offer",
                "approve",
                "decline",
                "funding",
                "payout",
                "funded",
                "post",
                "return",
                "correct"
              ]
            },
            "required": true
          }
        ],
        "operationId": "command"
      }
    },
    "/applications/{case_id}/events": {
      "get": {
        "summary": "Read this recipient\u2019s reference-only event feed",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Notice"
                      }
                    },
                    "next_cursor": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "events",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Invalid request, credentials, authority, reference, stage or evidence version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "case_id",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "required": false
          }
        ],
        "operationId": "applicationEvents"
      }
    },
    "/transfers": {
      "get": {
        "summary": "Read this payment source\u2019s assigned external transfer instructions",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transfers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Transfer"
                      }
                    }
                  },
                  "required": [
                    "transfers"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Invalid request, credentials, authority, reference, stage or evidence version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "listTransfers"
      }
    },
    "/transfers/{case_id}": {
      "get": {
        "summary": "Read this payment source\u2019s assigned external transfer instructions",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transfers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Transfer"
                      }
                    }
                  },
                  "required": [
                    "transfers"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Invalid request, credentials, authority, reference, stage or evidence version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "case_id",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "operationId": "getTransfers"
      }
    },
    "/callbacks/{issuer}": {
      "post": {
        "summary": "Submit independently signed transfer evidence",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EvidenceReceipt"
                }
              }
            }
          },
          "default": {
            "description": "Invalid request, credentials, authority, reference, stage or evidence version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "description": "HMAC-SHA256 hex over POST, one space, the absolute path, newline, UNIX milliseconds, newline, and the exact UTF-8 JSON bytes. Five-minute window. Event ID and body remain stable across retries. A correction uses a new event ID and the current source_version.",
        "security": [
          {
            "evidenceSignature": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Callback"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "issuer",
            "in": "path",
            "schema": {
              "enum": [
                "payout",
                "collections",
                "bank"
              ]
            },
            "required": true
          },
          {
            "name": "X-Finity-Timestamp",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "operationId": "submitEvidence"
      }
    },
    "/merchant-launches": {
      "post": {
        "summary": "Open financing for a merchant who signed in with their network",
        "description": "Merchant-network backend only. Identify the authorized signer and shop. Transmit the returned one-use code to the Hub iframe in its URL fragment.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "subject",
                  "reference",
                  "business",
                  "signer",
                  "capacity"
                ],
                "properties": {
                  "subject": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 120
                  },
                  "reference": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 80
                  },
                  "business": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 160
                  },
                  "signer": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 100
                  },
                  "capacity": {
                    "enum": [
                      "proprietor",
                      "company"
                    ]
                  },
                  "intent_ref": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Single-use code for this network",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "expires_in"
                  ],
                  "properties": {
                    "code": {
                      "type": "string",
                      "pattern": "^[a-f0-9]{64}$"
                    },
                    "expires_in": {
                      "const": 90
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Only merchant networks may issue launches"
          },
          "422": {
            "description": "Invalid shop details"
          }
        },
        "operationId": "createMerchantLaunch"
      }
    },
    "/financing-intents": {
      "post": {
        "summary": "Create or recover a financing intent",
        "responses": {
          "201": {
            "description": "Create or recover a financing intent",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PurchaseOrder"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "intent_ref": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "entry": {
                          "type": "string",
                          "minLength": 1
                        },
                        "expires_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "intent_ref",
                        "entry",
                        "expires_at"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FinancingIntent"
              }
            }
          }
        },
        "description": "Machine-side call. Use working_capital for restrictions, resume or offer with an assigned case_ref, and invoice with invoice_ref. Priced amounts use integer minor units.",
        "operationId": "createFinancingIntent"
      }
    },
    "/purchases": {
      "get": {
        "summary": "List assigned orders",
        "responses": {
          "200": {
            "description": "List assigned orders",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PurchaseOrder"
                      }
                    }
                  },
                  "required": [
                    "orders"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "operationId": "listPurchases"
      }
    },
    "/purchases/{intent_ref}": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "summary": "Read the current authorized order",
        "responses": {
          "200": {
            "description": "Read the current authorized order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseOrder"
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "operationId": "getPurchase"
      }
    },
    "/purchases/{intent_ref}/request": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Order request",
        "responses": {
          "200": {
            "description": "Order request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseOrder"
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idempotency_key": {
                    "type": "string",
                    "minLength": 1
                  },
                  "question": {
                    "type": "string",
                    "enum": [
                      "Please confirm the delivery location for this order.",
                      "When can the shop take delivery?",
                      "What date is on the supplier quote?",
                      "What is the supplier bill number?"
                    ]
                  }
                },
                "required": [
                  "idempotency_key",
                  "question"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "operationId": "requestPurchaseInformation"
      }
    },
    "/purchases/{intent_ref}/approve": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Order approve",
        "responses": {
          "200": {
            "description": "Order approve",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseOrder"
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idempotency_key": {
                    "type": "string",
                    "minLength": 1
                  },
                  "question_ref": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "answer_ref": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "application_ref": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "idempotency_key",
                  "application_ref",
                  "question_ref",
                  "answer_ref"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "operationId": "approvePurchase",
        "description": "Only the program\u2019s lender of record can approve the current application and answer references."
      }
    },
    "/purchases/{intent_ref}/fulfil": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Order fulfil",
        "responses": {
          "200": {
            "description": "Order fulfil",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseOrder"
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idempotency_key": {
                    "type": "string",
                    "minLength": 1
                  },
                  "amount_minor": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "idempotency_key",
                  "amount_minor"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "operationId": "fulfilPurchase"
      }
    },
    "/purchases/{intent_ref}/return": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Order return",
        "responses": {
          "200": {
            "description": "Order return",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseOrder"
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idempotency_key": {
                    "type": "string",
                    "minLength": 1
                  },
                  "amount_minor": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "idempotency_key",
                  "amount_minor"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "operationId": "returnPurchase"
      }
    },
    "/purchases/{intent_ref}/cancel": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Order cancel",
        "responses": {
          "200": {
            "description": "Order cancel",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseOrder"
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idempotency_key": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "idempotency_key"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "operationId": "cancelPurchase"
      }
    },
    "/purchases/{intent_ref}/revise": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Order revise",
        "responses": {
          "200": {
            "description": "Order revise",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseOrder"
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idempotency_key": {
                    "type": "string",
                    "minLength": 1
                  },
                  "revision": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10
                  },
                  "sku": {
                    "type": "string",
                    "enum": [
                      "stock",
                      "equipment"
                    ]
                  }
                },
                "required": [
                  "idempotency_key",
                  "revision"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "operationId": "revisePurchase"
      }
    },
    "/purchases/{intent_ref}/evidence": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Order evidence",
        "responses": {
          "200": {
            "description": "Order evidence",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "question_ref": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "question_ref"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "operationId": "getPurchaseEvidence"
      }
    },
    "/purchases/{intent_ref}/events": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "in": "query",
          "name": "after",
          "schema": {
            "type": "integer",
            "minimum": 0
          }
        }
      ],
      "get": {
        "summary": "Catch up on assigned purchase webhooks",
        "responses": {
          "200": {
            "description": "Catch up on assigned purchase webhooks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PurchaseNotice"
                      }
                    },
                    "next_cursor": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "events",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "operationId": "purchaseEvents"
      }
    },
    "/applications/{case_id}/questions": {
      "parameters": [
        {
          "name": "case_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "summary": "List underwriting rounds",
        "responses": {
          "200": {
            "description": "List underwriting rounds",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "questions": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  },
                  "required": [
                    "questions"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "operationId": "listQuestions"
      }
    },
    "/applications/{case_id}/questions/{action}": {
      "parameters": [
        {
          "name": "case_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "action",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "enum": [
              "request",
              "accept_answer",
              "waive",
              "evidence"
            ]
          }
        }
      ],
      "post": {
        "summary": "Manage or read the current underwriting response",
        "responses": {
          "200": {
            "description": "Manage or read the current underwriting response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "403": {
            "description": "Actor has no authority"
          },
          "404": {
            "description": "Resource unavailable"
          },
          "409": {
            "description": "Stale revision, prior commitment or conflicting retry"
          },
          "422": {
            "description": "Invalid input"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "revision": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "supplier_bill",
                      "bill_date",
                      "delivery_days"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "verify_stock",
                      "unclear_date",
                      "delivery_timing"
                    ]
                  }
                },
                "required": [
                  "key",
                  "revision"
                ]
              }
            }
          }
        },
        "operationId": "actOnQuestion"
      }
    },
    "/capabilities": {
      "get": {
        "summary": "Discover entries and lending programs assigned to this client",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Capabilities"
                }
              }
            }
          }
        },
        "operationId": "capabilities"
      }
    },
    "/purchases/{intent_ref}/deliveries": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "after",
          "in": "query",
          "required": false,
          "schema": {
            "type": "integer",
            "minimum": 0
          }
        }
      ],
      "get": {
        "summary": "Read this recipient\u2019s delivery state in version order",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deliveries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PurchaseDelivery"
                      }
                    },
                    "next_cursor": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "deliveries",
                    "next_cursor"
                  ]
                }
              }
            }
          }
        },
        "operationId": "purchaseDeliveries"
      }
    },
    "/purchases/{intent_ref}/deliveries/{delivery_id}/redeliver": {
      "parameters": [
        {
          "name": "intent_ref",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "delivery_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Redeliver an acknowledged notice with the same event identity",
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "generation": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "id",
                    "generation"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Delivery already pending"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idempotency_key": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_.:-]{1,120}$"
                  }
                },
                "required": [
                  "idempotency_key"
                ]
              }
            }
          }
        },
        "operationId": "redeliverPurchase"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "serviceToken": {
        "type": "http",
        "scheme": "bearer"
      },
      "serviceClient": {
        "type": "http",
        "scheme": "basic"
      },
      "evidenceSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Finity-Signature"
      }
    },
    "schemas": {
      "Application": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "stage": {
            "type": "string"
          },
          "channel": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "treatment": {
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "purpose": {
            "type": "string"
          },
          "requested_minor": {
            "type": "integer"
          },
          "approved_minor": {
            "type": "integer"
          },
          "outstanding": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "stage",
          "channel",
          "name",
          "treatment"
        ]
      },
      "State": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "stage": {
            "type": "string"
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "action": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "review": {
                  "type": "object"
                },
                "confirmation": {
                  "type": "string"
                }
              },
              "required": [
                "action",
                "label"
              ]
            }
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        },
        "required": [
          "id",
          "stage",
          "actions",
          "events"
        ]
      },
      "Command": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "confirmation": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "properties": {
              "reference": {
                "type": "string"
              },
              "from": {
                "type": "string",
                "format": "date"
              },
              "to": {
                "type": "string",
                "format": "date"
              },
              "sales": {
                "type": "integer"
              },
              "amount": {
                "type": "integer"
              },
              "route": {
                "enum": [
                  "manual",
                  "simulated"
                ]
              },
              "ledger_reference": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              }
            },
            "required": []
          }
        },
        "required": [
          "key"
        ]
      },
      "CommandReceipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "status"
        ]
      },
      "Notice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "enum": [
              "application.ready",
              "receipt.changed",
              "transfer.ready"
            ]
          },
          "environment": {
            "const": "sandbox"
          },
          "case_ref": {
            "type": "string",
            "format": "uuid"
          },
          "receipt_ref": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "type",
          "environment",
          "case_ref",
          "version",
          "occurred_at"
        ]
      },
      "Transfer": {
        "type": "object",
        "properties": {
          "case_ref": {
            "type": "string",
            "format": "uuid"
          },
          "instruction": {
            "type": "string",
            "format": "uuid"
          },
          "direction": {
            "enum": [
              "payout",
              "pay",
              "return"
            ]
          },
          "currency": {
            "const": "PKR"
          },
          "amount_minor": {
            "type": "integer"
          },
          "merchant_ref": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "source_version": {
            "type": "integer"
          },
          "source_receipt": {
            "type": "string"
          },
          "source_account": {
            "type": "object",
            "properties": {
              "owner": {
                "enum": [
                  "merchant",
                  "lender"
                ]
              },
              "reference": {
                "type": "string"
              },
              "network": {
                "type": "string"
              },
              "lender": {
                "type": "string"
              }
            },
            "required": [
              "owner",
              "reference"
            ]
          },
          "destination_account": {
            "type": "object",
            "properties": {
              "owner": {
                "enum": [
                  "merchant",
                  "lender"
                ]
              },
              "reference": {
                "type": "string"
              },
              "network": {
                "type": "string"
              },
              "lender": {
                "type": "string"
              }
            },
            "required": [
              "owner",
              "reference"
            ]
          },
          "instruction_status": {
            "type": "string"
          },
          "responsibility": {
            "enum": [
              "execute_once_and_report",
              "report_bank_entry"
            ]
          },
          "original_collection": {
            "type": "string",
            "format": "uuid"
          },
          "original_receipt": {
            "type": "string"
          }
        },
        "required": [
          "case_ref",
          "instruction",
          "direction",
          "currency",
          "amount_minor",
          "merchant_ref",
          "status",
          "source_version",
          "source_account",
          "destination_account",
          "instruction_status",
          "responsibility"
        ]
      },
      "Evidence": {
        "type": "object",
        "properties": {
          "merchant_ref": {
            "type": "string"
          },
          "statement_ref": {
            "type": "string"
          },
          "transfer_ref": {
            "type": "string"
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d{1,7}(\\.\\d{1,2})?$"
          },
          "value_date": {
            "type": "string",
            "format": "date"
          }
        },
        "required": [
          "merchant_ref",
          "statement_ref",
          "transfer_ref",
          "amount",
          "value_date"
        ]
      },
      "Callback": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "const": "transfer.evidence"
          },
          "case_ref": {
            "type": "string",
            "format": "uuid"
          },
          "instruction": {
            "type": "string",
            "format": "uuid"
          },
          "expected_version": {
            "type": "integer"
          },
          "evidence": {
            "$ref": "#/components/schemas/Evidence"
          }
        },
        "required": [
          "id",
          "type",
          "case_ref",
          "instruction",
          "expected_version",
          "evidence"
        ]
      },
      "EvidenceReceipt": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer"
          },
          "status": {
            "enum": [
              "awaiting_evidence",
              "mismatch",
              "matched"
            ]
          }
        },
        "required": [
          "event_id",
          "version",
          "status"
        ]
      },
      "FinancingIntent": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "shop_ref": {
                "type": "string",
                "minLength": 1
              },
              "idempotency_key": {
                "type": "string",
                "minLength": 1
              },
              "entry": {
                "type": "string",
                "enum": [
                  "discovery",
                  "working_capital",
                  "offer",
                  "resume"
                ]
              },
              "case_ref": {
                "type": "string",
                "format": "uuid"
              },
              "currency": {
                "type": "string",
                "enum": [
                  "PKR"
                ]
              },
              "product_ref": {
                "type": "string",
                "enum": [
                  "working-capital-v1"
                ]
              },
              "finance_amount": {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "open",
                      "fixed",
                      "suggested",
                      "maximum"
                    ]
                  },
                  "minor": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "mode"
                ]
              }
            },
            "required": [
              "shop_ref",
              "idempotency_key",
              "entry"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "shop_ref": {
                "type": "string",
                "minLength": 1
              },
              "idempotency_key": {
                "type": "string",
                "minLength": 1
              },
              "entry": {
                "type": "string",
                "enum": [
                  "order_checkout",
                  "facility_draw",
                  "invoice",
                  "assisted"
                ]
              },
              "order_ref": {
                "type": "string",
                "minLength": 1
              },
              "sku": {
                "type": "string",
                "enum": [
                  "stock",
                  "equipment"
                ]
              },
              "quantity": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10
              },
              "manual_review": {
                "type": "boolean"
              },
              "invoice_ref": {
                "type": "string",
                "minLength": 1
              },
              "revision": {
                "type": "integer",
                "minimum": 1
              },
              "program_ref": {
                "type": "string",
                "enum": [
                  "panel-stock-v1",
                  "trazmo-stock-v1"
                ]
              }
            },
            "required": [
              "shop_ref",
              "idempotency_key",
              "entry",
              "order_ref"
            ],
            "additionalProperties": false
          }
        ]
      },
      "PurchaseOrder": {
        "type": "object",
        "properties": {
          "intent_ref": {
            "type": "string",
            "format": "uuid"
          },
          "order_ref": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "quoted",
              "needs_information",
              "in_review",
              "approved",
              "confirmed",
              "settlement_pending",
              "partially_fulfilled",
              "fulfilled",
              "return_pending",
              "refunded",
              "paid",
              "paid_now",
              "cancelled"
            ]
          },
          "terms_ref": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string",
            "enum": [
              "PKR"
            ]
          },
          "revision": {
            "type": "integer",
            "minimum": 0
          },
          "total_minor": {
            "type": "integer",
            "minimum": 0
          },
          "deposit_minor": {
            "type": "integer",
            "minimum": 0
          },
          "finance_minor": {
            "type": "integer",
            "minimum": 0
          },
          "settled_minor": {
            "type": "integer",
            "minimum": 0
          },
          "balance_minor": {
            "type": "integer",
            "minimum": 0
          },
          "available_limit_minor": {
            "type": "integer",
            "minimum": 0
          },
          "followups": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "receipts": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "program_ref": {
            "type": "string",
            "enum": [
              "panel-stock-v1",
              "trazmo-stock-v1"
            ]
          },
          "lender": {
            "type": "string"
          },
          "decision_party": {
            "type": "string",
            "enum": [
              "lender",
              "trazmo"
            ]
          },
          "relay": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "intent_ref",
          "order_ref",
          "status",
          "total_minor",
          "balance_minor"
        ]
      },
      "PurchaseNotice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "enum": [
              "purchase.changed"
            ]
          },
          "environment": {
            "type": "string",
            "enum": [
              "sandbox"
            ]
          },
          "intent_ref": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "type",
          "environment",
          "intent_ref",
          "version",
          "occurred_at"
        ]
      },
      "Program": {
        "type": "object",
        "properties": {
          "program_ref": {
            "type": "string",
            "enum": [
              "panel-stock-v1",
              "trazmo-stock-v1"
            ]
          },
          "lender": {
            "type": "string"
          },
          "decision_party": {
            "type": "string"
          },
          "relay": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "program_ref",
          "lender",
          "decision_party",
          "relay"
        ]
      },
      "Capabilities": {
        "type": "object",
        "properties": {
          "client": {
            "type": "string"
          },
          "environment": {
            "const": "sandbox"
          },
          "contract": {
            "type": "string"
          },
          "entries": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "purchase_programs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Program"
            }
          },
          "transfer_source": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "client",
          "environment",
          "contract",
          "entries",
          "purchase_programs",
          "transfer_source"
        ]
      },
      "PurchaseDelivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer",
            "minimum": 0
          },
          "generation": {
            "type": "integer",
            "minimum": 0
          },
          "attempts": {
            "type": "integer",
            "minimum": 0
          },
          "delivered": {
            "type": "boolean"
          },
          "acknowledged_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "version",
          "generation",
          "attempts",
          "delivered",
          "acknowledged_at"
        ]
      }
    }
  },
  "webhooks": {
    "notice": {
      "post": {
        "summary": "Hub to configured receiver; signature headers cover the configured path and raw payload.",
        "security": [],
        "parameters": [
          {
            "name": "X-Notice-Sent",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "name": "X-Notice-Signature",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Notice"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Receiver persisted and deduplicated the event; echoes original ID",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}
