{
  "openapi": "3.1.0",
  "info": {
    "title": "Commando HQ Business Exchange",
    "version": "1.3.0",
    "description": "Search without authentication. For each new quote request generate 32 cryptographically random bytes, encode as unpadded base64url or hex, and use it as a bearer key. Retain the key privately. A successful request returns sub, statusUrl, version, and an ES256 compact JWS. Poll statusUrl with the same key. Get explicit buyer approval of the returned price and time before accepting the offered version. During a booking retry, use acceptedVersion. A booked receipt reflects booking status when retrieved. Verify the JWS with the public JWK from the same trusted Commando HQ origin at /businesses/{iss}/key, pin alg ES256, and match iss and sub to your expected business and request. Signatures attest to Commando records. Credentials in a passport are published by its owner. For a scheduled visit, use its own appointment.version to request another time or confirm cancellation. Settlement reports invoiced amounts, recorded net collections and refunds. Delivered requires completed work, a completed visit, and positive settled receipts with no open dispute. Each business includes a public directoryUrl, bookingMode and bookingUrl. For external bookingMode, direct the customer to bookingUrl to confirm in the business’s own scheduler. For native bookingMode, request only an available time for the selected service, then confirm the offer. Times are ISO instants with the appointment time zone supplied separately. Search findNetworkBusinesses to discover listed businesses across production workspaces. Follow the returned profile and booking links to the business’s home workspace."
  },
  "servers": [
    {
      "url": "/api/exchange/v1"
    }
  ],
  "paths": {
    "/businesses": {
      "get": {
        "operationId": "findBusinesses",
        "summary": "Search owner-published businesses",
        "parameters": [
          {
            "name": "service",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "region",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "businesses": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BusinessProfile"
                      }
                    },
                    "next": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/businesses/{id}": {
      "get": {
        "operationId": "getPassport",
        "summary": "Read the public service catalog and terms",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessProfile"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/businesses/{id}/key": {
      "get": {
        "operationId": "getVerificationKey",
        "summary": "Read the passport’s ES256 public JWK",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicKey"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/businesses/{id}/requests": {
      "post": {
        "operationId": "requestQuote",
        "summary": "Send a consented quote request; retry the same body with the same private key",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "privateRequestKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "customer",
                  "email",
                  "brief",
                  "service",
                  "consent"
                ],
                "properties": {
                  "customer": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "brief": {
                    "type": "string",
                    "maxLength": 900
                  },
                  "service": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "consent": {
                    "const": true
                  },
                  "remember": {
                    "type": "boolean"
                  },
                  "preferredStart": {
                    "type": "string",
                    "format": "date-time",
                    "description": "An offered UTC start from getAvailability. If omitted, an authorized rule may offer its first available time."
                  },
                  "requestOnly": {
                    "type": "boolean",
                    "description": "Request a proposal without selecting an automatic appointment."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/requests/{id}": {
      "get": {
        "operationId": "getReceipt",
        "summary": "Read current offer, availability, appointment, and signed receipt",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "privateRequestKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/requests/{id}/accept": {
      "post": {
        "operationId": "acceptRequest",
        "summary": "Accept this version of the quote and book the proposed Commando HQ appointment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "privateRequestKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "version",
                  "confirm"
                ],
                "properties": {
                  "version": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "confirm": {
                    "const": true
                  },
                  "maxAmountCents": {
                    "type": "integer",
                    "description": "Optional hard ceiling authorized by the buyer in USD cents.",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/requests/{id}/cancel": {
      "post": {
        "operationId": "cancelRequest",
        "summary": "Withdraw a pending request or explicitly cancel a confirmed scheduled visit",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "privateRequestKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "version": {
                        "type": "integer",
                        "minimum": 1
                      }
                    },
                    "required": [
                      "version"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "appointmentVersion": {
                        "type": "integer",
                        "minimum": 1
                      },
                      "confirm": {
                        "const": true
                      },
                      "note": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      }
                    },
                    "required": [
                      "appointmentVersion",
                      "confirm"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/requests/{id}/forget": {
      "post": {
        "operationId": "forgetRequest",
        "summary": "Withdraw permission to use service history for future planning",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "privateRequestKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/businesses/{id}/availability": {
      "get": {
        "operationId": "getAvailability",
        "summary": "Check currently open owner-authorized service times and fixed prices",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Availability"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/requests/{id}/counter": {
      "post": {
        "operationId": "counterOffer",
        "summary": "Ask the business to revise a quote within a stated price ceiling",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "privateRequestKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "version",
                  "note",
                  "maxAmountCents"
                ],
                "properties": {
                  "version": {
                    "type": "integer"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 350
                  },
                  "maxAmountCents": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/requests/{id}/reschedule": {
      "post": {
        "operationId": "requestNewAppointmentTime",
        "summary": "Ask the business for a different time for a scheduled appointment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "security": [
          {
            "privateRequestKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "appointmentVersion": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "note": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                },
                "required": [
                  "appointmentVersion",
                  "note"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Missing request key"
          },
          "404": {
            "description": "Unavailable resource"
          },
          "409": {
            "description": "State changed, refresh before retrying"
          },
          "429": {
            "description": "Request limit reached"
          }
        }
      }
    },
    "/businesses.json": {
      "servers": [
        {
          "url": "/directory"
        }
      ],
      "get": {
        "operationId": "findNetworkBusinesses",
        "summary": "Search public directory listings across Commando HQ workspaces",
        "parameters": [
          {
            "name": "service",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "region",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public listings with profileHref and bookHref, an optional nextPage cursor, and any unavailable workspace links. Resolve relative links against the requesting origin."
          },
          "400": {
            "description": "Invalid search or cursor"
          },
          "503": {
            "description": "All directory sources are unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "privateRequestKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "A new private, client-generated 256-bit request key."
      }
    },
    "schemas": {
      "Offer": {
        "type": "object",
        "properties": {
          "amountCents": {
            "type": "integer",
            "minimum": 0
          },
          "currency": {
            "const": "USD"
          },
          "description": {
            "type": "string"
          },
          "authority": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "startsAt": {
            "type": "string",
            "format": "date-time"
          },
          "minutes": {
            "type": "integer"
          },
          "zone": {
            "type": "string"
          }
        },
        "required": [
          "amountCents",
          "currency",
          "description",
          "authority",
          "expiresAt",
          "startsAt",
          "minutes"
        ]
      },
      "Appointment": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "changeRequested": {
            "type": "boolean"
          },
          "startsAt": {
            "type": "string",
            "format": "date-time"
          },
          "endsAt": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "zone": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "status",
          "version",
          "changeRequested",
          "startsAt",
          "endsAt"
        ]
      },
      "Settlement": {
        "type": "object",
        "properties": {
          "currency": {
            "const": "USD"
          },
          "invoiceStatus": {
            "type": "string"
          },
          "invoicedCents": {
            "type": "integer",
            "minimum": 0
          },
          "collectedCents": {
            "type": "integer",
            "minimum": 0
          },
          "refundedCents": {
            "type": "integer",
            "minimum": 0
          },
          "balanceCents": {
            "type": "integer",
            "minimum": 0
          },
          "delivered": {
            "type": "boolean"
          }
        },
        "required": [
          "currency",
          "invoiceStatus",
          "invoicedCents",
          "collectedCents",
          "refundedCents",
          "balanceCents",
          "delivered"
        ]
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "iss": {
            "type": "string",
            "format": "uuid"
          },
          "sub": {
            "type": "string",
            "format": "uuid"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "type": "string"
          },
          "statusUrl": {
            "type": "string"
          },
          "receipt": {
            "type": "string",
            "description": "ES256 compact JWS including offer, current appointment, recorded settlement and history."
          },
          "offer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Offer"
              },
              {
                "type": "null"
              }
            ]
          },
          "appointment": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Appointment"
              },
              {
                "type": "null"
              }
            ]
          },
          "settlement": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Settlement"
              },
              {
                "type": "null"
              }
            ]
          },
          "history": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string"
                },
                "actor": {
                  "type": "string"
                },
                "at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "status",
                "actor",
                "at"
              ]
            }
          },
          "available": {
            "type": "boolean"
          },
          "acceptedVersion": {
            "type": "integer",
            "minimum": 1
          },
          "remember": {
            "type": "boolean"
          }
        },
        "required": [
          "iss",
          "sub",
          "version",
          "status",
          "statusUrl",
          "receipt",
          "offer",
          "appointment",
          "settlement",
          "history",
          "remember"
        ]
      },
      "Availability": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "format": "uuid"
          },
          "asOf": {
            "type": "string",
            "format": "date-time"
          },
          "slots": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "service": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "startsAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "endsAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "amountCents": {
                  "type": "integer",
                  "minimum": 0
                },
                "currency": {
                  "const": "USD"
                },
                "zone": {
                  "type": "string"
                }
              },
              "required": [
                "service",
                "description",
                "startsAt",
                "endsAt",
                "amountCents",
                "currency"
              ]
            }
          },
          "bookingMode": {
            "enum": [
              "native",
              "external"
            ]
          },
          "bookingUrl": {
            "type": "string"
          }
        },
        "required": [
          "businessId",
          "asOf",
          "slots"
        ]
      },
      "PublicKey": {
        "type": "object",
        "properties": {
          "alg": {
            "const": "ES256"
          },
          "kty": {
            "const": "EC"
          },
          "crv": {
            "const": "P-256"
          },
          "x": {
            "type": "string"
          },
          "y": {
            "type": "string"
          },
          "kid": {
            "type": "string"
          }
        },
        "required": [
          "alg",
          "kty",
          "crv",
          "x",
          "y",
          "kid"
        ]
      },
      "BusinessProfile": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "pricing": {
            "type": "string"
          },
          "terms": {
            "type": "string"
          },
          "credentialEvidence": {
            "type": "string"
          },
          "website": {
            "type": "string"
          },
          "publicPhone": {
            "type": "string"
          },
          "directoryUrl": {
            "type": "string"
          },
          "bookingUrl": {
            "type": "string"
          },
          "services": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bookingMode": {
            "enum": [
              "native",
              "external"
            ]
          },
          "directoryListings": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          }
        }
      }
    }
  }
}
