{
  "openapi": "3.1.0",
  "info": {
    "title": "Net Amount API",
    "version": "1.8.0",
    "description": "Net Amount exposes 69 REST operations across 47 paths to look up current US general sales tax rates, calculate sourcing- and taxability-aware penny-accurate sales tax (single and batch up to 25 orders with effective-dated B2B/B2C rules, reduced rates, dollar thresholds, partial taxable percentages, local overrides, discounts, Retail Delivery Fees, customer-defined products, custom tax rules, multi-entity scope, customer exemption certificates, and atomic transaction commit persistence), manage exemption certificates with PDF/PNG/JPEG document storage (up to 3 MiB) and single-use buyer upload links, bulk import transactions, exemptions, and custom products from JSON or CSV, connect Stripe and Shopify via signed webhooks and manual JSON sync, configure HMAC-SHA256 signed outbound webhooks and review/acknowledge proactive compliance alerts, inspect and export immutable workspace audit logs (JSON or CSV), review metadata-only API request logs and latency/error usage analytics, manage committed transactions (list, inspect, void, full/partial refund, JSON/CSV filing reports), persistent filing periods and statutory filing calendars, legal entity hierarchies and state registrations, custom products, and custom tax rules, search named jurisdictions, check state and local taxability, evaluate and monitor US state economic nexus, and inspect account plan and monthly usage.\n\n## Get started\n1. [Create an API key](/dashboard/keys) and copy it when shown.\n2. Send `Authorization: Bearer YOUR_API_KEY` on every request.\n3. Read `taxRate` (decimal: `0.075` means **7.5%**) and `status` before using a result.\n\nKeep API keys on your server. Never put them in public code or URLs.\n\n## AI agents & Remote MCP\nConnect MCP-compatible agents to `POST https://netamount.com/mcp` (Streamable HTTP, JSON-RPC 2.0, 69 tools) with `Authorization: Bearer YOUR_API_KEY`, or read `/llms.txt` for an agent-ready summary.\n\n## Request limits\nSend JSON inputs in the request body on POST, PATCH, and PUT endpoints and documented query filters only on `GET /nexus/thresholds`, `GET /nexus/monitor`, `GET /exemptions`, `GET /transactions`, `GET /transactions/report`, `GET /filings`, `GET /filings/calendar`, `GET /entities`, `GET /products`, `GET /rules`, `GET /integrations/connections`, `GET /webhooks/{webhookId}/deliveries`, `GET /alerts`, `GET /audit-logs`, `GET /logs/requests`, and `GET /logs/summary`; do not add unexpected query parameters or extra fields. Throughput and active key limits scale by plan across REST API, Remote MCP, and the dashboard (Starter: 300 req/min, burst 30, unlimited keys; Growth: 600+ req/min, unlimited keys; unsubscribed or usage-credits Hobby: 30 req/min, burst 10, 1 key). On HTTP 429, wait for the `Retry-After` delay.\n\n## Results\nA completed lookup or calculation returns HTTP 200. Read `status`: `taxRate` and `calculation` are null whenever a usable total cannot be confirmed. Missing rates never mean zero. These endpoints return current general Sales rates, database-backed effective-dated state and local taxability rules, customer exemption certificate enforcement and document attachments, committed transaction ledger workflows, bulk CSV/JSON imports, Stripe and Shopify commerce connectors, signed outbound webhooks and proactive compliance alerts, immutable workspace audit logs, metadata-only API request logs and usage analytics, persistent filing periods and statutory due-date calendars, multi-entity hierarchies and state registrations, custom products and tax rules, and statutory remote-seller economic nexus references.\n\n## Monthly Plans & Usage\nNet Amount defaults to flat per-region pricing (`region_flat`): Starter ($100/region/mo for 1–9 active tax regions, self-serve, $0 implementation or setup fees, up to 50,000 monthly transactions with no per-transaction or revenue-based fees) and Growth (10+ regions or 50,000+ monthly transactions, custom sales contract). Deployments can also switch to `usage_credits` mode (Hobby $0/mo with 500-request hard cap, Pro $20/mo with $20 monthly credit and $0.004/req pay-as-you-go, Enterprise custom from $0.002/req). Starter and Growth (or Pro and Enterprise in `usage_credits` mode) unlock batch calculations, multi-state economic nexus evaluation and live monitoring, rich effective-dated state and local taxability rules, customer exemption certificates with document uploads and buyer upload links, bulk CSV/JSON imports, Stripe and Shopify commerce connectors, signed outbound webhooks and proactive compliance alerts, immutable workspace audit logs (`GET /audit-logs`), committed transaction ledger workflows and JSON/CSV filing reports, persistent filing periods and statutory calendars, multi-entity management, custom products, and custom tax rules. Each matched `/rate/lookup`, `/tax/calculate`, `/tax/calculate/batch` item, `/jurisdictions/search`, or `/taxability/check` response, and each completed `/nexus/evaluate` call, counts as 1 billable request. Explicit zero rates count as matched lookups. `GET /account/balance`, `GET /nexus/thresholds`, `GET /nexus/monitor`, `GET /taxability/items`, `/exemptions` CRUD, import, document, and upload-link endpoints, `/transactions` ledger, import, and `/transactions/report` endpoints, `/filings` and `/filings/calendar` endpoints, `/entities` hierarchy and registration endpoints, `/products` CRUD and import endpoints, `/rules` and `/rules/test` endpoints, `/integrations/connections` endpoints, `/webhooks` and `/alerts` endpoints, `GET /audit-logs`, `GET /logs/requests`, `GET /logs/summary`, empty/unknown results, incomplete or ambiguous results, and failed requests are always free. See [Pricing](/pricing) or manage your plan at [/dashboard/billing](/dashboard/billing)."
  },
  "servers": [
    {
      "url": "https://api.netamount.com",
      "description": "Net Amount production REST API"
    }
  ],
  "security": [
    {
      "ApiKey": []
    }
  ],
  "tags": [
    {
      "name": "Rates",
      "description": "Look up combined sales tax rates for exact locations."
    },
    {
      "name": "Tax Calculation",
      "description": "Compute exact penny-rounded sales tax and jurisdiction splits."
    },
    {
      "name": "Jurisdictions",
      "description": "Search named states, counties, cities, and special districts."
    },
    {
      "name": "Economic Nexus",
      "description": "Inspect US state remote-seller economic nexus thresholds and evaluate exposure."
    },
    {
      "name": "Taxability",
      "description": "List and check rich state and local taxability rules (reduced rates, dollar thresholds, taxable percentages, local overrides)."
    },
    {
      "name": "Exemptions",
      "description": "Create, list, inspect, and revoke customer sales tax exemption certificates."
    },
    {
      "name": "Transactions",
      "description": "List, inspect, void, and refund committed tax transactions in the audit ledger."
    },
    {
      "name": "Filings",
      "description": "Persistent sales tax return periods, statutory due-date calendar, period locks on filed returns, and linked amendments."
    },
    {
      "name": "Account",
      "description": "Inspect account usage and billing capacity."
    },
    {
      "name": "Entities",
      "description": "Manage multi-entity legal hierarchies, EINs, tax reporting modes, default ship-from origins, and state sales tax registrations."
    },
    {
      "name": "Products",
      "description": "Define custom product codes mapped to platform taxability categories and default treatments."
    },
    {
      "name": "Custom Rules",
      "description": "Create, manage, and dry-run custom taxability, reduced-rate, rate-adjustment, threshold, and max-tax cap rules."
    },
    {
      "name": "Integrations",
      "description": "Manage first-party Stripe and Shopify commerce connectors, secret rotation, and batch event sync."
    },
    {
      "name": "Webhooks",
      "description": "Configure HMAC-SHA256 signed outbound HTTPS webhook endpoints, inspect delivery history, and send test deliveries."
    },
    {
      "name": "Alerts",
      "description": "List and acknowledge proactive nexus, filing, exemption, and usage quota compliance alerts."
    },
    {
      "name": "Audit Logs",
      "description": "Inspect and export immutable workspace audit logs with cursor pagination and RFC 4180 CSV export."
    },
    {
      "name": "Request Logs",
      "description": "Inspect metadata-only API request logs and aggregated latency, error, endpoint, and API key usage analytics."
    }
  ],
  "paths": {
    "/rate/lookup": {
      "post": {
        "tags": [
          "Rates"
        ],
        "operationId": "lookupRate",
        "summary": "Look up a tax rate",
        "description": "Send a full street address or numeric latitude and longitude. Address lookup requires one precise rooftop match and includes Google Maps attribution. Coordinate lookup omits geocoding. The coordinates use WGS 84 decimal degrees.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/RateLookupCoordinatesRequest"
                  },
                  {
                    "$ref": "#/components/schemas/RateLookupAddressRequest"
                  }
                ]
              },
              "examples": {
                "address": {
                  "summary": "Jacksonville City Hall",
                  "value": {
                    "address": "117 W Duval St, Jacksonville, FL 32202, USA"
                  }
                },
                "coordinates": {
                  "summary": "Jacksonville coordinates",
                  "value": {
                    "latitude": 30.3297,
                    "longitude": -81.6586
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lookup completed. Check status and taxRate before use. A missing or ambiguous result also returns HTTP 200. Examples illustrate the response format; current data can change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LookupResponse"
                },
                "examples": {
                  "coordinates": {
                    "summary": "Coordinate lookup — 7.5%",
                    "value": {
                      "coordinates": {
                        "latitude": 30.3297,
                        "longitude": -81.6586
                      },
                      "status": "matched",
                      "hasMissingRates": false,
                      "taxRate": 0.075,
                      "jurisdictions": [
                        {
                          "name": "Florida",
                          "stateName": "Florida",
                          "relation": "inside",
                          "rates": [
                            {
                              "name": "Florida",
                              "jurisdictionType": "state",
                              "taxType": "Sales",
                              "rate": 0.06,
                              "effectiveDate": "2017-01-01",
                              "endDate": "2029-12-31"
                            }
                          ]
                        },
                        {
                          "name": "Duval",
                          "stateName": "Florida",
                          "relation": "inside",
                          "rates": [
                            {
                              "name": "Duval",
                              "jurisdictionType": "county",
                              "taxType": "Sales",
                              "rate": 0.015,
                              "effectiveDate": "2021-01-01",
                              "endDate": "2029-12-31"
                            }
                          ]
                        }
                      ]
                    }
                  },
                  "address": {
                    "summary": "Address lookup — 7.5%",
                    "value": {
                      "coordinates": {
                        "latitude": 30.3297,
                        "longitude": -81.6586
                      },
                      "status": "matched",
                      "hasMissingRates": false,
                      "taxRate": 0.075,
                      "jurisdictions": [
                        {
                          "name": "Florida",
                          "stateName": "Florida",
                          "relation": "inside",
                          "rates": [
                            {
                              "name": "Florida",
                              "jurisdictionType": "state",
                              "taxType": "Sales",
                              "rate": 0.06,
                              "effectiveDate": "2017-01-01",
                              "endDate": "2029-12-31"
                            }
                          ]
                        },
                        {
                          "name": "Duval",
                          "stateName": "Florida",
                          "relation": "inside",
                          "rates": [
                            {
                              "name": "Duval",
                              "jurisdictionType": "county",
                              "taxType": "Sales",
                              "rate": 0.015,
                              "effectiveDate": "2021-01-01",
                              "endDate": "2029-12-31"
                            }
                          ]
                        }
                      ],
                      "geocoding": {
                        "provider": "Google Maps",
                        "formattedAddress": "117 W Duval St, Jacksonville, FL 32202, USA",
                        "precision": "ROOFTOP",
                        "attribution": "Google Maps"
                      }
                    }
                  },
                  "noMatch": {
                    "summary": "No matching jurisdiction",
                    "value": {
                      "coordinates": {
                        "latitude": 0,
                        "longitude": 0
                      },
                      "status": "no_match",
                      "hasMissingRates": false,
                      "taxRate": null,
                      "jurisdictions": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, inputs, or query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Provide either latitude and longitude, or an address."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "402": {
            "description": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests (or the Hobby 500-request monthly cap was reached in usage-credits mode). Subscribe or upgrade on the billing page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "quota_exceeded",
                    "message": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests. Subscribe at https://netamount.com/dashboard/billing."
                  }
                }
              }
            }
          },
          "403": {
            "description": "A session request came from a different origin. API key requests do not use session authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Session requests must come from this site."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST for rate lookup."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 4096 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 4096 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "422": {
            "description": "Address not found, ambiguous, or insufficiently precise. Supply a full street address or verified coordinates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "address_imprecise",
                    "message": "A precise street address match is required. Check the address or provide verified coordinates."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The lookup service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "The lookup service could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Authentication, geocoding, or lookup is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "lookup_unavailable",
                    "message": "The lookup is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/tax/calculate": {
      "post": {
        "tags": [
          "Tax Calculation"
        ],
        "operationId": "calculateSalesTax",
        "summary": "Calculate sales tax",
        "description": "Look up the current general Sales tax rate for a single street address/coordinates or a shipFrom/shipTo pair (with automatic intrastate origin vs. destination and interstate destination sourcing), optionally resolve rich state and local taxability rules (reduced rates, dollar thresholds, taxable percentages, local overrides) via lineItems[].itemKey and shippingType, apply customer exemption certificates via customerId or exemptionCertificateId, and optionally commit the matched calculation to the immutable transaction ledger via commit: true (taxability resolution, exemptions, and transaction commits require the Starter plan or higher). Computes penny-accurate subtotal, tax amount, grand total, per-line-item totals, and per-jurisdiction breakdown. Supports tax-exclusive (add tax) and tax-inclusive (extract tax) modes. Counts as 1 billable request when status is matched. `externalId` is unique per `(owner, entityId)` scope (unscoped workspace commits with no `entityId` form their own namespace, and voided rows retain their `externalId`) and stays reserved after the transaction is voided; send a unique `externalId` with `commit: true` so a retry cannot book the sale twice. Maximum body size is 16,384 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaxCalculateRequest"
              },
              "examples": {
                "singleAmount": {
                  "summary": "Single USD amount (exclusive)",
                  "value": {
                    "latitude": 30.3297,
                    "longitude": -81.6586,
                    "amount": 100
                  }
                },
                "lineItems": {
                  "summary": "Line items with exempt item and taxable shipping",
                  "value": {
                    "address": "117 W Duval St, Jacksonville, FL 32202, USA",
                    "lineItems": [
                      {
                        "id": "widget",
                        "amount": 19.99,
                        "quantity": 2,
                        "taxable": true
                      },
                      {
                        "id": "exempt_item",
                        "amount": 10,
                        "taxable": false
                      }
                    ],
                    "shipping": 5,
                    "shippingTaxable": true,
                    "mode": "exclusive",
                    "rounding": "half_up"
                  }
                },
                "committedWithExemption": {
                  "summary": "Committed calculation with customerId, itemKey, and externalId",
                  "value": {
                    "latitude": 30.3297,
                    "longitude": -81.6586,
                    "lineItems": [
                      {
                        "id": "sku_1",
                        "amount": 120,
                        "quantity": 1,
                        "itemKey": "general_tangible_goods"
                      }
                    ],
                    "customerId": "cust_acme_01",
                    "commit": true,
                    "externalId": "order_2026_1001",
                    "transactionDate": "2026-10-06",
                    "metadata": {
                      "channel": "checkout"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation completed. Check status and calculation before use; non-matched responses return calculation: null and are always free.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxCalculateResponse"
                },
                "examples": {
                  "singleAmount": {
                    "summary": "$100.00 in Jacksonville, FL (7.5%)",
                    "value": {
                      "coordinates": {
                        "latitude": 30.3297,
                        "longitude": -81.6586
                      },
                      "status": "matched",
                      "hasMissingRates": false,
                      "taxRate": 0.075,
                      "jurisdictions": [
                        {
                          "name": "Florida",
                          "stateName": "Florida",
                          "relation": "inside",
                          "rates": [
                            {
                              "name": "Florida",
                              "jurisdictionType": "state",
                              "taxType": "Sales",
                              "rate": 0.06,
                              "effectiveDate": "2017-01-01",
                              "endDate": "2029-12-31"
                            }
                          ]
                        },
                        {
                          "name": "Duval",
                          "stateName": "Florida",
                          "relation": "inside",
                          "rates": [
                            {
                              "name": "Duval",
                              "jurisdictionType": "county",
                              "taxType": "Sales",
                              "rate": 0.015,
                              "effectiveDate": "2021-01-01",
                              "endDate": "2029-12-31"
                            }
                          ]
                        }
                      ],
                      "calculation": {
                        "currency": "USD",
                        "mode": "exclusive",
                        "rounding": "half_up",
                        "subtotal": 100,
                        "taxableAmount": 100,
                        "exemptAmount": 0,
                        "shippingAmount": 0,
                        "taxAmount": 7.5,
                        "total": 107.5,
                        "lineItems": [
                          {
                            "id": "item_1",
                            "quantity": 1,
                            "unitAmount": 100,
                            "subtotal": 100,
                            "taxable": true,
                            "taxAmount": 7.5,
                            "total": 107.5
                          }
                        ],
                        "breakdown": [
                          {
                            "jurisdictionName": "Florida",
                            "rateName": "Florida",
                            "jurisdictionType": "state",
                            "rate": 0.06,
                            "taxAmount": 6
                          },
                          {
                            "jurisdictionName": "Duval",
                            "rateName": "Duval",
                            "jurisdictionType": "county",
                            "rate": 0.015,
                            "taxAmount": 1.5
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, inputs, or query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Provide either amount or lineItems, but not both."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "402": {
            "description": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests (or the Hobby 500-request monthly cap was reached in usage-credits mode). Subscribe or upgrade on the billing page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "quota_exceeded",
                    "message": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests. Subscribe at https://netamount.com/dashboard/billing."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Database-resolved taxability, exemption certificates, and transaction commits requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Database-resolved taxability, exemption certificates, and transaction commits requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Transaction persistence and audit ledger require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Explicitly specified `exemptionCertificateId` or entity reference (`entityId`, `entityCode`, `ein`) was not found (`exemption_not_found`, `entity_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "exemption_not_found",
                    "message": "Exemption certificate was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST for tax calculation."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate externalId within the same (owner, entityId) scope (duplicate_transaction), ambiguous EIN (entity_ambiguous), or commit dated inside a locked filed return period (filing_period_locked) (non-billable).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "duplicateTransaction": {
                    "summary": "Duplicate externalId",
                    "value": {
                      "error": {
                        "code": "duplicate_transaction",
                        "message": "A transaction with externalId order_2026_1001 already exists."
                      }
                    }
                  },
                  "filingPeriodLocked": {
                    "summary": "Transaction date falls in a locked filed return period",
                    "value": {
                      "error": {
                        "code": "filing_period_locked",
                        "message": "Filing period 2026-10-01 to 2026-10-31 for FL is locked (flg_1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d). Amend the filed return before modifying transactions in this period."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 16,384 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 16384 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "422": {
            "description": "Address not found, ambiguous, or insufficiently precise (`address_not_found`, `address_ambiguous`, `address_imprecise`), an unknown `productCode` was supplied (`product_not_found`), a requested `itemKey` or `shippingType` has no configured rule (`taxability_unknown`), an explicitly specified `exemptionCertificateId` is revoked, expired, or does not cover the matched state/customer (`exemption_invalid`), or `commit: true` was requested when no calculation can be produced (`commit_not_possible`, non-billable).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "addressImprecise": {
                    "summary": "Address lacks rooftop precision",
                    "value": {
                      "error": {
                        "code": "address_imprecise",
                        "message": "A precise street address match is required. Check the address or provide verified coordinates."
                      }
                    }
                  },
                  "taxabilityUnknown": {
                    "summary": "No stored taxability rule for itemKey",
                    "value": {
                      "error": {
                        "code": "taxability_unknown",
                        "message": "No taxability rule found in Florida (FL) for: custom_item. Supply explicit taxable booleans or add the rule."
                      }
                    }
                  },
                  "exemptionInvalid": {
                    "summary": "Explicit exemption certificate is revoked, expired, or inapplicable",
                    "value": {
                      "error": {
                        "code": "exemption_invalid",
                        "message": "Exemption certificate is not active for state FL on 2026-10-06."
                      }
                    }
                  },
                  "commitNotPossible": {
                    "summary": "commit requested but no calculation is possible",
                    "value": {
                      "error": {
                        "code": "commit_not_possible",
                        "message": "The transaction cannot be committed because no tax calculation could be produced for this location."
                      }
                    }
                  },
                  "productNotFound": {
                    "summary": "Unknown custom productCode supplied on a line item",
                    "value": {
                      "error": {
                        "code": "product_not_found",
                        "message": "Custom product code 'unknown_sku' was not found for this workspace."
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The calculation service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "The calculation service could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Geocoding or calculation is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "lookup_unavailable",
                    "message": "The calculation service is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/tax/calculate/batch": {
      "post": {
        "tags": [
          "Tax Calculation"
        ],
        "operationId": "calculateSalesTaxBatch",
        "summary": "Calculate sales tax in batch",
        "description": "Calculate penny-rounded US general Sales tax for up to 25 orders in a single request with automatic location deduplication so identical coordinates or street addresses are geocoded and spatially resolved once per batch. Each item supports all `/tax/calculate` options—including `shipFrom`/`shipTo` sourcing, itemized `lineItems`, retailer and manufacturer discounts (`discountAmount`, `discountType`), Colorado and Minnesota Retail Delivery Fees (`includeRetailDeliveryFees`, `retailDeliveryFeeExempt`), B2B/B2C effective-dated taxability rules, custom products and rules, exemption certificates, and atomic ledger commits—plus an optional `batchItemId` echoed in the matching result item. Requires the Starter plan or higher. Each matched item counts as 1 billable request; failed or non-matched items are not billed. Maximum body size is 262,144 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaxCalculateBatchRequest"
              },
              "examples": {
                "multiOrder": {
                  "summary": "Two orders sharing a location (deduplicated)",
                  "value": {
                    "items": [
                      {
                        "batchItemId": "order_1001",
                        "latitude": 30.3297,
                        "longitude": -81.6586,
                        "amount": 100
                      },
                      {
                        "batchItemId": "order_1002",
                        "latitude": 30.3297,
                        "longitude": -81.6586,
                        "lineItems": [
                          {
                            "id": "widget",
                            "amount": 50,
                            "quantity": 2,
                            "taxable": true
                          }
                        ],
                        "shipping": 10,
                        "shippingTaxable": false
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch calculation completed. Inspect top-level `count`, `succeeded`, and `failed` counters and each item's `status` (`ok` with `response`, or `error` with `error`) and `httpStatus`. Per-item failures—including monthly quota exhaustion (`httpStatus: 402`, `error.code: \"quota_exceeded\"`), validation errors, geocoding failures, and commit conflicts—are reported per item inside `results[]` rather than failing the top-level batch.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxCalculateBatchResponse"
                },
                "examples": {
                  "multiOrder": {
                    "summary": "Two matched orders in Jacksonville, FL (7.5%) with location deduplication",
                    "value": {
                      "count": 2,
                      "succeeded": 2,
                      "failed": 0,
                      "results": [
                        {
                          "index": 0,
                          "batchItemId": "order_1001",
                          "status": "ok",
                          "httpStatus": 200,
                          "response": {
                            "coordinates": {
                              "latitude": 30.3297,
                              "longitude": -81.6586
                            },
                            "status": "matched",
                            "hasMissingRates": false,
                            "taxRate": 0.075,
                            "jurisdictions": [
                              {
                                "name": "Florida",
                                "stateName": "Florida",
                                "relation": "inside",
                                "rates": [
                                  {
                                    "name": "Florida",
                                    "jurisdictionType": "state",
                                    "taxType": "Sales",
                                    "rate": 0.06,
                                    "effectiveDate": "2017-01-01",
                                    "endDate": "2029-12-31"
                                  }
                                ]
                              },
                              {
                                "name": "Duval",
                                "stateName": "Florida",
                                "relation": "inside",
                                "rates": [
                                  {
                                    "name": "Duval",
                                    "jurisdictionType": "county",
                                    "taxType": "Sales",
                                    "rate": 0.015,
                                    "effectiveDate": "2021-01-01",
                                    "endDate": "2029-12-31"
                                  }
                                ]
                              }
                            ],
                            "calculation": {
                              "currency": "USD",
                              "mode": "exclusive",
                              "rounding": "half_up",
                              "subtotal": 100,
                              "taxableAmount": 100,
                              "exemptAmount": 0,
                              "shippingAmount": 0,
                              "taxAmount": 7.5,
                              "total": 107.5,
                              "lineItems": [
                                {
                                  "id": "item_1",
                                  "quantity": 1,
                                  "unitAmount": 100,
                                  "subtotal": 100,
                                  "taxable": true,
                                  "taxAmount": 7.5,
                                  "total": 107.5
                                }
                              ],
                              "breakdown": [
                                {
                                  "jurisdictionName": "Florida",
                                  "rateName": "Florida",
                                  "jurisdictionType": "state",
                                  "rate": 0.06,
                                  "taxAmount": 6
                                },
                                {
                                  "jurisdictionName": "Duval",
                                  "rateName": "Duval",
                                  "jurisdictionType": "county",
                                  "rate": 0.015,
                                  "taxAmount": 1.5
                                }
                              ]
                            }
                          }
                        },
                        {
                          "index": 1,
                          "batchItemId": "order_1002",
                          "status": "ok",
                          "httpStatus": 200,
                          "response": {
                            "coordinates": {
                              "latitude": 30.3297,
                              "longitude": -81.6586
                            },
                            "status": "matched",
                            "hasMissingRates": false,
                            "taxRate": 0.075,
                            "jurisdictions": [
                              {
                                "name": "Florida",
                                "stateName": "Florida",
                                "relation": "inside",
                                "rates": [
                                  {
                                    "name": "Florida",
                                    "jurisdictionType": "state",
                                    "taxType": "Sales",
                                    "rate": 0.06,
                                    "effectiveDate": "2017-01-01",
                                    "endDate": "2029-12-31"
                                  }
                                ]
                              },
                              {
                                "name": "Duval",
                                "stateName": "Florida",
                                "relation": "inside",
                                "rates": [
                                  {
                                    "name": "Duval",
                                    "jurisdictionType": "county",
                                    "taxType": "Sales",
                                    "rate": 0.015,
                                    "effectiveDate": "2021-01-01",
                                    "endDate": "2029-12-31"
                                  }
                                ]
                              }
                            ],
                            "calculation": {
                              "currency": "USD",
                              "mode": "exclusive",
                              "rounding": "half_up",
                              "subtotal": 100,
                              "taxableAmount": 100,
                              "exemptAmount": 10,
                              "shippingAmount": 10,
                              "taxAmount": 7.5,
                              "total": 117.5,
                              "lineItems": [
                                {
                                  "id": "widget",
                                  "quantity": 2,
                                  "unitAmount": 50,
                                  "subtotal": 100,
                                  "taxable": true,
                                  "taxAmount": 7.5,
                                  "total": 107.5
                                }
                              ],
                              "breakdown": [
                                {
                                  "jurisdictionName": "Florida",
                                  "rateName": "Florida",
                                  "jurisdictionType": "state",
                                  "rate": 0.06,
                                  "taxAmount": 6
                                },
                                {
                                  "jurisdictionName": "Duval",
                                  "rateName": "Duval",
                                  "jurisdictionType": "county",
                                  "rate": 0.015,
                                  "taxAmount": 1.5
                                }
                              ]
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, batch envelope, or query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "items must be a non-empty array of 1 to 25 calculation requests."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Batch tax calculation requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Batch tax calculation requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Batch tax calculation requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST with a JSON body for batch tax calculation."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 262,144 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 262144 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The batch calculation service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "The batch calculation service could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Geocoding or batch calculation is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "lookup_unavailable",
                    "message": "The batch calculation service is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/jurisdictions/search": {
      "post": {
        "tags": [
          "Jurisdictions"
        ],
        "operationId": "searchJurisdictions",
        "summary": "Search named jurisdictions",
        "description": "Search named US states, counties, cities, and special districts to inspect individual current Sales tax rates when no street address is available. Returns individual place rates rather than stacked address totals. Counts as 1 billable request when at least one jurisdiction matches; empty results are always free. Maximum body size is 1,024 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JurisdictionSearchRequest"
              },
              "examples": {
                "countySearch": {
                  "summary": "Search Duval in Florida",
                  "value": {
                    "query": "Duval",
                    "state": "FL",
                    "limit": 5
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Search completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JurisdictionSearchResponse"
                },
                "examples": {
                  "duval": {
                    "summary": "Duval County, Florida",
                    "value": {
                      "query": "Duval",
                      "stateName": "Florida",
                      "asOf": "2026-10-06",
                      "results": [
                        {
                          "name": "Duval",
                          "stateName": "Florida",
                          "countyNames": [
                            "Duval"
                          ],
                          "jurisdictionTypes": [
                            "county"
                          ],
                          "rates": [
                            {
                              "name": "Duval",
                              "jurisdictionType": "county",
                              "taxType": "Sales",
                              "rate": 0.015,
                              "effectiveDate": "2021-01-01",
                              "endDate": "2029-12-31"
                            }
                          ]
                        }
                      ],
                      "note": "Jurisdiction search returns individual named place rates, not stacked location totals. Use /rate/lookup or /tax/calculate with a street address or coordinates for combined sales or use tax rates."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or search parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "query must be a string of 1 to 100 characters without control characters."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "402": {
            "description": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests (or the Hobby 500-request monthly cap was reached in usage-credits mode). Subscribe or upgrade on the billing page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "quota_exceeded",
                    "message": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests. Subscribe at https://netamount.com/dashboard/billing."
                  }
                }
              }
            }
          },
          "403": {
            "description": "A session request came from a different origin. API key requests do not use session authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Session requests must come from this site."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST for jurisdiction search."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 1,024 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 1024 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Jurisdiction search could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Jurisdiction search could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Jurisdiction search is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "lookup_unavailable",
                    "message": "Jurisdiction search is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/account/balance": {
      "get": {
        "tags": [
          "Account"
        ],
        "operationId": "getAccountBalance",
        "summary": "Get account plan and monthly usage",
        "description": "Return active pricing model, active plan details, active region count (in per-region mode), included monthly request capacity, current UTC monthly usage, and estimated overages. Authenticated and rate-limited; always free.",
        "responses": {
          "200": {
            "description": "Current plan details and monthly usage.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountBalanceResponse"
                },
                "examples": {
                  "customer": {
                    "summary": "Active Starter plan (region_flat default)",
                    "value": {
                      "billingEnabled": true,
                      "exempt": false,
                      "pricingModel": "region_flat",
                      "plan": {
                        "pricingModel": "region_flat",
                        "id": "starter",
                        "name": "Starter",
                        "billingCycle": "monthly",
                        "subscriptionStatus": "active",
                        "monthlyPriceDollars": 300,
                        "pricePerRegionDollars": 100,
                        "activeRegions": 3,
                        "minRegions": 1,
                        "maxRegions": 9,
                        "includedCreditDollars": null,
                        "hardCap": false,
                        "includedRequests": 50000,
                        "overagePerRequestDollars": null,
                        "rateLimitPerMinute": 300,
                        "burst": 30,
                        "maxActiveKeys": null,
                        "entitled": true,
                        "features": {
                          "nexusEvaluate": true,
                          "taxability": true,
                          "exemptions": true,
                          "transactions": true
                        }
                      },
                      "usageMonth": "2026-11",
                      "usedThisMonth": 120,
                      "reservedInFlight": 0,
                      "includedRemaining": 49880,
                      "usedCreditDollars": null,
                      "creditRemainingDollars": null,
                      "overageThisMonth": 0,
                      "estimatedOverageDollars": 0,
                      "currentPeriodEnd": 1796083200000
                    }
                  },
                  "usageCreditsHobby": {
                    "summary": "Hobby plan (usage_credits mode)",
                    "value": {
                      "billingEnabled": true,
                      "exempt": false,
                      "pricingModel": "usage_credits",
                      "plan": {
                        "pricingModel": "usage_credits",
                        "id": "hobby",
                        "name": "Hobby",
                        "billingCycle": null,
                        "subscriptionStatus": null,
                        "monthlyPriceDollars": 0,
                        "pricePerRegionDollars": null,
                        "activeRegions": null,
                        "minRegions": null,
                        "maxRegions": null,
                        "includedCreditDollars": 0,
                        "hardCap": true,
                        "includedRequests": 500,
                        "overagePerRequestDollars": null,
                        "rateLimitPerMinute": 30,
                        "burst": 10,
                        "maxActiveKeys": 1,
                        "entitled": true,
                        "features": {
                          "nexusEvaluate": false,
                          "taxability": false,
                          "exemptions": false,
                          "transactions": false
                        }
                      },
                      "usageMonth": "2026-11",
                      "usedThisMonth": 5,
                      "reservedInFlight": 0,
                      "includedRemaining": 495,
                      "usedCreditDollars": null,
                      "creditRemainingDollars": null,
                      "overageThisMonth": 0,
                      "estimatedOverageDollars": 0,
                      "currentPeriodEnd": null
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Query parameters are not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_request",
                    "message": "Query parameters are not supported."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "A session request came from a cross-site or different origin. API key requests do not use session authentication.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Session requests must come from this site."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET for account balance."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Account balance could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Account balance could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Account balance is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "billing_unavailable",
                    "message": "Account balance is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/nexus/thresholds": {
      "get": {
        "tags": [
          "Economic Nexus"
        ],
        "operationId": "getEconomicNexusThresholds",
        "summary": "Get US economic nexus thresholds",
        "description": "Return statutory remote-seller economic nexus thresholds (sales threshold, transaction threshold, logic test, and measurement period) across all 50 US states, DC, and Puerto Rico, or filter to one state with `?state=`. Authenticated and rate-limited; always free.",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "Optional US state name or two-letter code (e.g., TX, Florida, DC, PR).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Statutory economic nexus threshold reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NexusThresholdsResponse"
                },
                "examples": {
                  "texas": {
                    "summary": "Texas economic nexus threshold",
                    "value": {
                      "count": 1,
                      "thresholds": [
                        {
                          "stateCode": "TX",
                          "stateName": "Texas",
                          "hasStateSalesTax": true,
                          "hasEconomicNexus": true,
                          "scope": "statewide",
                          "salesThresholdDollars": 500000,
                          "transactionThreshold": null,
                          "logic": "sales_only",
                          "measurementPeriod": "Preceding 12 calendar months",
                          "note": "Total Texas revenue from tangible personal property and services."
                        }
                      ],
                      "disclaimer": "Economic nexus thresholds are general remote-seller statutory references. Physical presence, affiliate/click-through nexus, marketplace facilitator exclusions, and includable exempt-sale definitions vary by state."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid state or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "state must be a US state name or two-letter code (50 states, DC, or PR)."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "A session request came from a cross-site or different origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Session requests must come from this site."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET for economic nexus thresholds."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Economic nexus reference could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Economic nexus reference could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Economic nexus reference is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "lookup_unavailable",
                    "message": "Economic nexus reference is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/nexus/evaluate": {
      "post": {
        "tags": [
          "Economic Nexus"
        ],
        "operationId": "evaluateEconomicNexus",
        "summary": "Evaluate multi-state economic nexus exposure",
        "description": "Evaluate 1 to 52 unique US state, DC, or Puerto Rico sales totals and optional transaction counts against statutory remote-seller economic nexus thresholds. Requires the Starter plan or higher. Counts as 1 billable request per completed evaluation. Maximum body size is 16,384 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NexusEvaluateRequest"
              },
              "examples": {
                "multiState": {
                  "summary": "Evaluate Texas and Florida sales",
                  "value": {
                    "states": [
                      {
                        "state": "TX",
                        "sales": 420000,
                        "transactions": 950
                      },
                      {
                        "state": "FL",
                        "sales": 125000
                      }
                    ],
                    "approachingPercent": 80
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Economic nexus evaluation completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NexusEvaluateResponse"
                },
                "examples": {
                  "multiState": {
                    "summary": "Texas approaching, Florida exceeded",
                    "value": {
                      "asOf": "2026-10-06",
                      "approachingPercent": 80,
                      "summary": {
                        "totalEvaluated": 2,
                        "exceededCount": 1,
                        "approachingCount": 1,
                        "belowThresholdCount": 0,
                        "noNexusRuleCount": 0,
                        "needsTransactionCount": 0
                      },
                      "results": [
                        {
                          "stateCode": "TX",
                          "stateName": "Texas",
                          "status": "approaching",
                          "triggeredBy": null,
                          "sales": 420000,
                          "transactions": 950,
                          "salesPercentOfThreshold": 84,
                          "transactionsPercentOfThreshold": null,
                          "threshold": {
                            "stateCode": "TX",
                            "stateName": "Texas",
                            "hasStateSalesTax": true,
                            "hasEconomicNexus": true,
                            "scope": "statewide",
                            "salesThresholdDollars": 500000,
                            "transactionThreshold": null,
                            "logic": "sales_only",
                            "measurementPeriod": "Preceding 12 calendar months",
                            "note": "Total Texas revenue from tangible personal property and services."
                          },
                          "note": "Total Texas revenue from tangible personal property and services."
                        },
                        {
                          "stateCode": "FL",
                          "stateName": "Florida",
                          "status": "exceeded",
                          "triggeredBy": "sales",
                          "sales": 125000,
                          "transactions": null,
                          "salesPercentOfThreshold": 125,
                          "transactionsPercentOfThreshold": null,
                          "threshold": {
                            "stateCode": "FL",
                            "stateName": "Florida",
                            "hasStateSalesTax": true,
                            "hasEconomicNexus": true,
                            "scope": "statewide",
                            "salesThresholdDollars": 100000,
                            "transactionThreshold": null,
                            "logic": "sales_only",
                            "measurementPeriod": "Previous calendar year",
                            "note": "Measured on taxable remote sales."
                          },
                          "note": "Measured on taxable remote sales."
                        }
                      ],
                      "disclaimer": "Economic nexus thresholds are general remote-seller statutory references. Physical presence, affiliate/click-through nexus, marketplace facilitator exclusions, and includable exempt-sale definitions vary by state."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, state list, or query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "states must contain between 1 and 52 state entries."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "402": {
            "description": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests (or the Hobby 500-request monthly cap was reached in usage-credits mode). Subscribe or upgrade on the billing page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "quota_exceeded",
                    "message": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests. Subscribe at https://netamount.com/dashboard/billing."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Multi-state economic nexus evaluation requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Economic nexus evaluation requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Multi-state economic nexus evaluation requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST for economic nexus evaluation."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 16,384 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 16384 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Economic nexus evaluation could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Economic nexus evaluation could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Economic nexus evaluation is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "lookup_unavailable",
                    "message": "Economic nexus evaluation is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/nexus/monitor": {
      "get": {
        "tags": [
          "Economic Nexus"
        ],
        "operationId": "monitorEconomicNexus",
        "summary": "Monitor live economic nexus exposure from committed transactions",
        "description": "Automatically aggregate committed sales and refunds in your transaction ledger by state and evaluate live exposure against US statutory economic nexus thresholds, sorted by urgency (`exceeded` and `approaching` states first). Scans up to 25,000 committed transactions in the selected period (`truncated: true` if capped). Requires the Starter plan or higher. Always free (0 billable requests). When omitted, an API key with `defaultEntityId` (or a single `allowedEntityIds` entry) automatically scopes results to that entity; unrestricted keys without `defaultEntityId` read the full account.",
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "required": false,
            "description": "Lookback period preset (default rolling_12_months). Supply from and to when custom.",
            "schema": {
              "type": "string",
              "enum": [
                "rolling_12_months",
                "current_calendar_year",
                "previous_calendar_year",
                "custom"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Inclusive custom start date (YYYY-MM-DD). Must be paired with to.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Inclusive custom end date (YYYY-MM-DD). Must be paired with from.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "approachingPercent",
            "in": "query",
            "required": false,
            "description": "Threshold percentage at which a state is flagged as approaching (integer 1-99, default 80).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 99
            }
          },
          {
            "name": "salesBasis",
            "in": "query",
            "required": false,
            "description": "Evaluate net gross sales (default) or net taxable sales against each state threshold.",
            "schema": {
              "type": "string",
              "enum": [
                "gross",
                "taxable"
              ]
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "Optional US state name or two-letter code filter (50 states, DC, or PR).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Optional legal entity ID (ent_...) to scope results.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          },
          {
            "name": "entityCode",
            "in": "query",
            "required": false,
            "description": "Optional legal entity code slug to scope results.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "ein",
            "in": "query",
            "required": false,
            "description": "Optional US EIN (XX-XXXXXXX or 9 digits) to scope results.",
            "schema": {
              "type": "string",
              "minLength": 9,
              "maxLength": 12
            }
          },
          {
            "name": "includeChildren",
            "in": "query",
            "required": false,
            "description": "When true, include all descendant entities instead of only consolidated-with-parent children (default false).",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Live state-by-state economic nexus evaluation computed from committed ledger transactions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NexusMonitorResponse"
                },
                "examples": {
                  "rollingWindow": {
                    "summary": "Rolling 12-month live nexus monitor",
                    "value": {
                      "asOf": "2026-10-06",
                      "period": {
                        "preset": "rolling_12_months",
                        "from": "2025-10-07",
                        "to": "2026-10-06"
                      },
                      "salesBasis": "gross",
                      "approachingPercent": 80,
                      "stateFilter": null,
                      "truncated": false,
                      "transactionCount": 185,
                      "unassignedTransactionCount": 0,
                      "summary": {
                        "totalEvaluated": 1,
                        "exceededCount": 1,
                        "approachingCount": 0,
                        "belowThresholdCount": 0,
                        "noNexusRuleCount": 0,
                        "needsTransactionCount": 0
                      },
                      "results": [
                        {
                          "stateCode": "FL",
                          "stateName": "Florida",
                          "status": "exceeded",
                          "triggeredBy": "sales",
                          "sales": 112500,
                          "transactions": 185,
                          "salesPercentOfThreshold": 112.5,
                          "transactionsPercentOfThreshold": null,
                          "threshold": {
                            "stateCode": "FL",
                            "stateName": "Florida",
                            "hasStateSalesTax": true,
                            "hasEconomicNexus": true,
                            "scope": "statewide",
                            "salesThresholdDollars": 100000,
                            "transactionThreshold": null,
                            "logic": "sales_only",
                            "measurementPeriod": "Previous calendar year",
                            "note": "Measured on taxable remote sales."
                          },
                          "note": "Measured on taxable remote sales.",
                          "saleCount": 185,
                          "refundCount": 0,
                          "grossSales": 112500,
                          "refundedSales": 0,
                          "netSales": 112500,
                          "taxableSales": 112500,
                          "exemptSales": 0,
                          "netTax": 8437.5
                        }
                      ],
                      "disclaimer": "Economic nexus thresholds are general remote-seller statutory references. Physical presence, affiliate/click-through nexus, marketplace facilitator exclusions, and includable exempt-sale definitions vary by state."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "from must be a valid YYYY-MM-DD calendar date."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Transaction persistence and audit ledger requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Transaction persistence and audit ledger requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Transaction persistence and audit ledger require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Referenced entity (`entityId`, `entityCode`, or `ein`) was not found (`entity_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found for this account."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET for live economic nexus monitoring."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            }
          },
          "409": {
            "description": "Multiple entities matched the requested `ein` or `entityCode` (`entity_ambiguous`). Pass `entityId` instead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_ambiguous",
                    "message": "Multiple entities match this EIN. Specify entityId instead."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Transaction ledger could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Live economic nexus monitor could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Transaction ledger is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Live economic nexus monitor is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/taxability/items": {
      "get": {
        "tags": [
          "Taxability"
        ],
        "operationId": "listTaxabilityItems",
        "summary": "List available taxability items",
        "description": "List all high-level taxability itemKey slugs and labels stored in Net Amount (such as `shipping_separately_stated`, `saas`, `groceries`, `clothing`). Initial seeded rules cover the 50 US states plus DC (51 jurisdictions); additional jurisdictions and custom itemKeys can be upserted anytime. Authenticated and rate-limited; always free.",
        "responses": {
          "200": {
            "description": "Available taxability items.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxabilityItemsResponse"
                },
                "examples": {
                  "items": {
                    "summary": "High-level taxability items",
                    "value": {
                      "count": 2,
                      "items": [
                        {
                          "itemKey": "saas",
                          "label": "Software as a Service (SaaS)",
                          "stateCount": 51
                        },
                        {
                          "itemKey": "shipping_separately_stated",
                          "label": "Shipping (separately stated)",
                          "stateCount": 51
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Query parameters are not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_request",
                    "message": "Query parameters are not supported."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "A session request came from a cross-site or different origin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Session requests must come from this site."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET for taxability items."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Taxability items could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Taxability items could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Taxability items are temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "lookup_unavailable",
                    "message": "Taxability items are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/taxability/check": {
      "post": {
        "tags": [
          "Taxability"
        ],
        "operationId": "checkTaxability",
        "summary": "Check state and local taxability rules",
        "description": "Check whether 1 to 50 unique high-level `itemKey` categories (such as `shipping_separately_stated`, `saas`, `groceries`, `clothing`) are `taxable`, `exempt`, or `reduced_rate` in a given US state, including reduced-rate scopes, per-item dollar thresholds, partial taxable percentages, and optional local jurisdiction overrides (`jurisdiction` + optional `jurisdictionType`). Requires the Starter plan or higher. Counts as 1 billable request when at least one item matches a stored rule; all-unknown responses are always free. Maximum body size is 4,096 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaxabilityCheckRequest"
              },
              "examples": {
                "florida": {
                  "summary": "Check shipping and SaaS in Florida",
                  "value": {
                    "state": "FL",
                    "items": [
                      "shipping_separately_stated",
                      "saas"
                    ]
                  }
                },
                "chicagoSaas": {
                  "summary": "Check Chicago, IL SaaS with local override",
                  "value": {
                    "state": "IL",
                    "items": [
                      "saas"
                    ],
                    "jurisdiction": "Chicago",
                    "jurisdictionType": "city"
                  }
                },
                "californiaSaas2027": {
                  "summary": "Effective-dated 2027 CA SaaS check (SB 122)",
                  "value": {
                    "state": "CA",
                    "asOf": "2027-01-01",
                    "items": [
                      "saas"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Taxability lookup completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxabilityCheckResponse"
                },
                "examples": {
                  "florida": {
                    "summary": "Florida rules",
                    "value": {
                      "stateCode": "FL",
                      "stateName": "Florida",
                      "asOf": "2026-10-06",
                      "results": [
                        {
                          "itemKey": "shipping_separately_stated",
                          "label": "Shipping (separately stated)",
                          "treatment": "exempt",
                          "reducedRate": null,
                          "reducedRateScope": null,
                          "thresholdDollars": null,
                          "thresholdMode": null,
                          "taxablePercent": null,
                          "effectiveDate": null,
                          "endDate": null,
                          "localOverride": null,
                          "note": "Exempt when separately stated and optional to the buyer."
                        },
                        {
                          "itemKey": "saas",
                          "label": "Software as a Service (SaaS)",
                          "treatment": "exempt",
                          "reducedRate": null,
                          "reducedRateScope": null,
                          "thresholdDollars": null,
                          "thresholdMode": null,
                          "taxablePercent": null,
                          "effectiveDate": null,
                          "endDate": null,
                          "localOverride": null,
                          "note": null
                        }
                      ]
                    }
                  },
                  "chicagoSaas": {
                    "summary": "Chicago, IL SaaS local override (15% Personal Property Lease Transaction Tax)",
                    "value": {
                      "stateCode": "IL",
                      "stateName": "Illinois",
                      "asOf": "2026-10-06",
                      "jurisdiction": "Chicago",
                      "jurisdictionType": "city",
                      "results": [
                        {
                          "itemKey": "saas",
                          "label": "Software as a Service (SaaS)",
                          "treatment": "exempt",
                          "reducedRate": null,
                          "reducedRateScope": null,
                          "thresholdDollars": null,
                          "thresholdMode": null,
                          "taxablePercent": null,
                          "effectiveDate": null,
                          "endDate": null,
                          "localOverride": {
                            "jurisdictionType": "city",
                            "jurisdictionName": "Chicago",
                            "treatment": "reduced_rate",
                            "reducedRate": 0.15,
                            "reducedRateScope": "jurisdiction_only",
                            "thresholdDollars": null,
                            "thresholdMode": null,
                            "taxablePercent": null,
                            "effectiveDate": "2026-01-01",
                            "endDate": null,
                            "note": "Chicago levies a 15% Personal Property Lease Transaction Tax (eff. Jan 1, 2026) on nonpossessory computer leases including SaaS."
                          },
                          "note": "Exempt from Illinois state sales tax (86 Ill. Adm. Code 130.1935); Chicago levies a 15% Personal Property Lease Transaction Tax (eff. Jan 1, 2026) on cloud software."
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, state, or itemKey list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "state must be a US state name or two-letter code."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "402": {
            "description": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests (or the Hobby 500-request monthly cap was reached in usage-credits mode). Subscribe or upgrade on the billing page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "quota_exceeded",
                    "message": "An active Starter ($100/region/mo) or Growth plan is required to make billable API requests. Subscribe at https://netamount.com/dashboard/billing."
                  }
                }
              }
            }
          },
          "403": {
            "description": "State product and shipping taxability checks require the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Taxability checks require Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "State product and shipping taxability requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST for taxability lookup."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 4,096 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 4096 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Taxability lookup could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Taxability lookup could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Taxability lookup is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "lookup_unavailable",
                    "message": "Taxability lookup is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/exemptions": {
      "get": {
        "tags": [
          "Exemptions"
        ],
        "operationId": "listExemptionCertificates",
        "summary": "List customer exemption certificates",
        "description": "List customer sales tax exemption certificates stored for the authenticated account, optionally filtered by `customerId`, `state`, `status`, and `limit` (1–100). Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "customerId",
            "in": "query",
            "required": false,
            "description": "Filter by exact customerId (1–128 characters).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "Filter to certificates covering a US state name or 2-letter code (e.g., FL or Florida).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by certificate status.",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "revoked"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum certificates to return (default 50, max 100).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Optional legal entity ID (ent_...) to scope results.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching exemption certificates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExemptionsListResponse"
                },
                "examples": {
                  "activeList": {
                    "summary": "Active certificates for a customer",
                    "value": {
                      "count": 1,
                      "certificates": [
                        {
                          "certificateId": "exc_0123456789abcdef0123456789abcdef",
                          "customerId": "cust_acme_01",
                          "customerName": "Acme Wholesale LLC",
                          "exemptionReason": "resale",
                          "certificateNumber": "FL-RESALE-88421",
                          "states": [
                            "FL",
                            "GA"
                          ],
                          "status": "active",
                          "effectiveDate": "2026-01-01",
                          "expirationDate": "2028-12-31",
                          "itemKeys": null,
                          "notes": "Blanket resale certificate on file.",
                          "createdAt": 1767225600000,
                          "updatedAt": 1767225600000,
                          "revokedAt": null
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "status must be active or revoked."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Customer exemption certificates requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Customer exemption certificates requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Customer exemption certificates require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET or POST for exemption certificates."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Exemption certificates could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption certificates could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Exemption certificates are temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption certificates are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Exemptions"
        ],
        "operationId": "createExemptionCertificate",
        "summary": "Create a customer exemption certificate",
        "description": "Create a blanket or item-scoped customer sales tax exemption certificate covering 1 to 52 US states/DC/PR. Accounts may hold up to 1,000 certificates. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 8,192 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateExemptionCertificateRequest"
              },
              "examples": {
                "resaleBlanket": {
                  "summary": "Blanket resale certificate",
                  "value": {
                    "customerId": "cust_acme_01",
                    "customerName": "Acme Wholesale LLC",
                    "exemptionReason": "resale",
                    "certificateNumber": "FL-RESALE-88421",
                    "states": [
                      "FL",
                      "GA"
                    ],
                    "effectiveDate": "2026-01-01",
                    "expirationDate": "2028-12-31",
                    "notes": "Blanket resale certificate on file."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Exemption certificate created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExemptionCertificateResponse"
                },
                "examples": {
                  "created": {
                    "summary": "Created certificate",
                    "value": {
                      "certificate": {
                        "certificateId": "exc_0123456789abcdef0123456789abcdef",
                        "customerId": "cust_acme_01",
                        "customerName": "Acme Wholesale LLC",
                        "exemptionReason": "resale",
                        "certificateNumber": "FL-RESALE-88421",
                        "states": [
                          "FL",
                          "GA"
                        ],
                        "status": "active",
                        "effectiveDate": "2026-01-01",
                        "expirationDate": "2028-12-31",
                        "itemKeys": null,
                        "notes": "Blanket resale certificate on file.",
                        "createdAt": 1767225600000,
                        "updatedAt": 1767225600000,
                        "revokedAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or certificate fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "effectiveDate must be a valid YYYY-MM-DD calendar date."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Customer exemption certificates requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Customer exemption certificates requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Customer exemption certificates require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET or POST for exemption certificates."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            }
          },
          "409": {
            "description": "Per-account certificate limit (1,000) reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "exemption_limit_reached",
                    "message": "Exemption certificate limit reached (1000 certificates per account)."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Exemption certificates could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption certificates could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Exemption certificates are temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption certificates are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/exemptions/import": {
      "post": {
        "tags": [
          "Exemptions"
        ],
        "operationId": "importExemptionCertificates",
        "summary": "Bulk import exemption certificates",
        "description": "Bulk import up to 100 customer exemption certificates from JSON rows or RFC 4180 CSV with duplicate detection, entity scoping, and optional dry-run validation. Maximum request body size is 262,144 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExemptionsImportRequest"
              },
              "examples": {
                "jsonRows": {
                  "summary": "Import exemption certificates from JSON rows",
                  "value": {
                    "format": "json",
                    "dryRun": true,
                    "rows": [
                      {
                        "customerId": "cust_acme_01",
                        "customerName": "Acme Wholesale LLC",
                        "exemptionReason": "resale",
                        "certificateNumber": "FL-RESALE-2026-001",
                        "states": [
                          "FL"
                        ],
                        "effectiveDate": "2026-01-01"
                      }
                    ]
                  }
                },
                "csvUpload": {
                  "summary": "Import exemption certificates from CSV",
                  "value": {
                    "format": "csv",
                    "dryRun": true,
                    "csv": "customerId,customerName,exemptionReason,certificateNumber,states,effectiveDate\ncust_acme_01,Acme Wholesale LLC,resale,FL-RESALE-2026-001,FL,2026-01-01"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Exemption import completed (or validated when dryRun is true).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExemptionsImportResponse"
                },
                "example": {
                  "dryRun": true,
                  "totalRows": 1,
                  "imported": 0,
                  "valid": 1,
                  "skippedDuplicates": 0,
                  "failed": 0,
                  "results": [
                    {
                      "row": 1,
                      "status": "valid",
                      "customerId": "cust_acme_01",
                      "certificateNumber": "FL-RESALE-2026-001"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or missing body",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Exemption imports requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Exemption imports requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Exemption imports requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Specified entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST to import exemption certificates."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Multiple entities matched the provided EIN.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_ambiguous",
                    "message": "Multiple entities share this EIN. Specify entityId or entityCode."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 262,144 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 262144 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption import could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption import is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/exemptions/{certificateId}": {
      "parameters": [
        {
          "name": "certificateId",
          "in": "path",
          "required": true,
          "description": "Exemption certificate identifier (e.g., exc_...).",
          "schema": {
            "type": "string",
            "pattern": "^exc_[a-f0-9]{16,64}$"
          }
        }
      ],
      "get": {
        "tags": [
          "Exemptions"
        ],
        "operationId": "getExemptionCertificate",
        "summary": "Get an exemption certificate",
        "description": "Retrieve one customer exemption certificate by `certificateId` for the authenticated account. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Exemption certificate details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExemptionCertificateResponse"
                },
                "examples": {
                  "certificate": {
                    "summary": "Active exemption certificate",
                    "value": {
                      "certificate": {
                        "certificateId": "exc_0123456789abcdef0123456789abcdef",
                        "customerId": "cust_acme_01",
                        "customerName": "Acme Wholesale LLC",
                        "exemptionReason": "resale",
                        "certificateNumber": "FL-RESALE-88421",
                        "states": [
                          "FL",
                          "GA"
                        ],
                        "status": "active",
                        "effectiveDate": "2026-01-01",
                        "expirationDate": "2028-12-31",
                        "itemKeys": null,
                        "notes": "Blanket resale certificate on file.",
                        "createdAt": 1767225600000,
                        "updatedAt": 1767225600000,
                        "revokedAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid certificateId or unexpected query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Invalid certificateId."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Customer exemption certificates requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Customer exemption certificates requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Customer exemption certificates require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Exemption certificate not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "exemption_not_found",
                    "message": "Exemption certificate was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET or DELETE for an exemption certificate."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, DELETE"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Exemption certificates could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption certificates could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Exemption certificates are temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption certificates are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Exemptions"
        ],
        "operationId": "revokeExemptionCertificate",
        "summary": "Revoke an exemption certificate",
        "description": "Soft-revoke a customer exemption certificate by `certificateId` (idempotent if already revoked). Revoked certificates remain visible for audit purposes but will not exempt future calculations. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Exemption certificate revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExemptionCertificateResponse"
                },
                "examples": {
                  "revoked": {
                    "summary": "Revoked certificate",
                    "value": {
                      "certificate": {
                        "certificateId": "exc_0123456789abcdef0123456789abcdef",
                        "customerId": "cust_acme_01",
                        "customerName": "Acme Wholesale LLC",
                        "exemptionReason": "resale",
                        "certificateNumber": "FL-RESALE-88421",
                        "states": [
                          "FL",
                          "GA"
                        ],
                        "status": "revoked",
                        "effectiveDate": "2026-01-01",
                        "expirationDate": "2028-12-31",
                        "itemKeys": null,
                        "notes": "Blanket resale certificate on file.",
                        "createdAt": 1767225600000,
                        "updatedAt": 1768003200000,
                        "revokedAt": 1768003200000
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid certificateId or unexpected query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Invalid certificateId."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Customer exemption certificates requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Customer exemption certificates requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Customer exemption certificates require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Exemption certificate not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "exemption_not_found",
                    "message": "Exemption certificate was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET or DELETE for an exemption certificate."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, DELETE"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Exemption certificates could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption certificates could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Exemption certificates are temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption certificates are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/exemptions/{certificateId}/document": {
      "get": {
        "tags": [
          "Exemptions"
        ],
        "operationId": "getExemptionDocument",
        "summary": "Get exemption certificate document",
        "description": "Retrieve metadata and authenticated base64-encoded file contents (`contentBase64`) for the PDF, PNG, or JPEG supporting document attached to an exemption certificate. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "certificateId",
            "in": "path",
            "required": true,
            "description": "Exemption certificate identifier (exc_...).",
            "schema": {
              "type": "string",
              "pattern": "^exc_[a-f0-9]{16,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Attached exemption document metadata and base64-encoded file contents.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExemptionDocumentGetResponse"
                },
                "example": {
                  "certificateId": "exc_0123456789abcdef0123456789abcdef",
                  "document": {
                    "filename": "acme-fl-resale-2026.pdf",
                    "contentType": "application/pdf",
                    "sizeBytes": 9,
                    "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
                    "uploadedAt": 1775001600000,
                    "contentBase64": "JVBERi0xLjQK"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid path parameter or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Invalid parameter value."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Query parameters are not supported on this endpoint."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Exemption documents requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Exemption documents requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Exemption documents requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Exemption certificate or attached document was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "exemptionNotFound": {
                    "summary": "Exemption certificate not found",
                    "value": {
                      "error": {
                        "code": "exemption_not_found",
                        "message": "Exemption certificate was not found."
                      }
                    }
                  },
                  "documentNotFound": {
                    "summary": "No document attached",
                    "value": {
                      "error": {
                        "code": "document_not_found",
                        "message": "No document is attached to this exemption certificate."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, POST, DELETE.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, POST, DELETE"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to fetch, POST to upload, or DELETE to remove a document."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption documents could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption documents are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Exemptions"
        ],
        "operationId": "uploadExemptionDocument",
        "summary": "Upload exemption certificate document",
        "description": "Upload or replace a PDF, PNG, or JPEG supporting document (up to 3 MiB decoded binary, validated against leading file magic bytes; JSON body max 4,400,000 bytes) for an active exemption certificate. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "certificateId",
            "in": "path",
            "required": true,
            "description": "Exemption certificate identifier (exc_...).",
            "schema": {
              "type": "string",
              "pattern": "^exc_[a-f0-9]{16,64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UploadExemptionDocumentRequest"
              },
              "examples": {
                "pdfUpload": {
                  "summary": "Upload PDF exemption certificate",
                  "value": {
                    "filename": "acme-fl-resale-2026.pdf",
                    "contentType": "application/pdf",
                    "contentBase64": "JVBERi0xLjQK"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Document uploaded and attached to the exemption certificate.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExemptionDocumentUploadResponse"
                },
                "example": {
                  "certificateId": "exc_0123456789abcdef0123456789abcdef",
                  "document": {
                    "filename": "acme-fl-resale-2026.pdf",
                    "contentType": "application/pdf",
                    "sizeBytes": 9,
                    "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
                    "uploadedAt": 1775001600000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or missing body",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Exemption documents requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Exemption documents requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Exemption documents requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Exemption certificate was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "exemption_not_found",
                    "message": "Exemption certificate was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, POST, DELETE.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, POST, DELETE"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to fetch, POST to upload, or DELETE to remove a document."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Exemption certificate is revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "exemption_revoked",
                    "message": "Cannot attach a document to a revoked exemption certificate."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 4,400,000 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 4400000 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption documents could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption documents are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Exemptions"
        ],
        "operationId": "deleteExemptionDocument",
        "summary": "Delete exemption certificate document",
        "description": "Delete the supporting document attached to an exemption certificate. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "certificateId",
            "in": "path",
            "required": true,
            "description": "Exemption certificate identifier (exc_...).",
            "schema": {
              "type": "string",
              "pattern": "^exc_[a-f0-9]{16,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Attached document deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExemptionDocumentDeleteResponse"
                },
                "example": {
                  "certificateId": "exc_0123456789abcdef0123456789abcdef",
                  "deleted": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid path parameter or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Invalid parameter value."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Query parameters are not supported on this endpoint."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Exemption documents requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Exemption documents requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Exemption documents requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Exemption certificate or attached document was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "exemptionNotFound": {
                    "summary": "Exemption certificate not found",
                    "value": {
                      "error": {
                        "code": "exemption_not_found",
                        "message": "Exemption certificate was not found."
                      }
                    }
                  },
                  "documentNotFound": {
                    "summary": "No document attached",
                    "value": {
                      "error": {
                        "code": "document_not_found",
                        "message": "No document is attached to this exemption certificate."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, POST, DELETE.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, POST, DELETE"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to fetch, POST to upload, or DELETE to remove a document."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Exemption certificate is revoked; documents attached to revoked certificates are retained for audit compliance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "exemption_revoked",
                    "message": "Cannot remove a document from a revoked exemption certificate."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption documents could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption documents are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/exemptions/{certificateId}/upload-link": {
      "post": {
        "tags": [
          "Exemptions"
        ],
        "operationId": "createExemptionUploadLink",
        "summary": "Create buyer self-service upload link",
        "description": "Generate a single-use, expiring self-service upload token and relative uploadPath so a buyer can upload their signed exemption document without an API key. Maximum request body size is 4,096 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "certificateId",
            "in": "path",
            "required": true,
            "description": "Exemption certificate identifier (exc_...).",
            "schema": {
              "type": "string",
              "pattern": "^exc_[a-f0-9]{16,64}$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateExemptionUploadLinkRequest"
              },
              "examples": {
                "defaultExpiry": {
                  "summary": "Create 7-day upload link (default)",
                  "value": {}
                },
                "customExpiry": {
                  "summary": "Create 72-hour upload link",
                  "value": {
                    "expiresInHours": 72
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Single-use buyer upload link created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateExemptionUploadLinkResponse"
                },
                "example": {
                  "certificateId": "exc_0123456789abcdef0123456789abcdef",
                  "uploadToken": "upl_abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG",
                  "uploadPath": "/exemptions/upload/upl_abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG",
                  "expiresAt": 1775606400000
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or missing body",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Exemption upload links requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Exemption upload links requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Exemption upload links requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Exemption certificate was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "exemption_not_found",
                    "message": "Exemption certificate was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST to create a buyer self-service upload link."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Exemption certificate is revoked or already has an attached document.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "exemptionRevoked": {
                    "summary": "Exemption certificate is revoked",
                    "value": {
                      "error": {
                        "code": "exemption_revoked",
                        "message": "Cannot create an upload link for a revoked exemption certificate."
                      }
                    }
                  },
                  "documentAlreadyExists": {
                    "summary": "Exemption certificate already has an attached document",
                    "value": {
                      "error": {
                        "code": "document_already_exists",
                        "message": "A document is already attached to this exemption certificate."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 4,096 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 4096 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption upload links could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Exemption upload links are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transactions": {
      "get": {
        "tags": [
          "Transactions"
        ],
        "operationId": "listTaxTransactions",
        "summary": "List committed tax transactions and ledger summary",
        "description": "List committed, voided, and refunded tax transactions for the authenticated account with cursor pagination (`hasMore`, `nextCursor`) and exact integer-cent reconciled ledger summary totals (`grossSales`, `taxableSales`, `exemptSales`, `taxCollected`, `taxRefunded`, `netTax`). Voided transactions are excluded from sales and tax totals and counted in `voidedCount`. On page 1 (without `cursor`), the summary scans up to 10,000 matching rows across paginated batches; when more rows match, `truncated` is `true`, and you can still paginate through the entire ledger with `cursor`. Requires the Starter plan or higher. Always free (0 billable requests). When omitted, an API key with `defaultEntityId` (or a single `allowedEntityIds` entry) automatically scopes results to that entity; unrestricted keys without `defaultEntityId` read the full account.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "committed",
                "voided"
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "sale",
                "refund"
              ]
            }
          },
          {
            "name": "customerId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "externalId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Inclusive start date (YYYY-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Inclusive end date (YYYY-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum transactions to return (default 50, max 100).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque nextCursor token returned by a previous page response.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Optional legal entity ID (ent_...) to scope results.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          },
          {
            "name": "entityCode",
            "in": "query",
            "required": false,
            "description": "Optional legal entity code slug to scope results.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "ein",
            "in": "query",
            "required": false,
            "description": "Optional US EIN (XX-XXXXXXX or 9 digits) to scope results.",
            "schema": {
              "type": "string",
              "minLength": 9,
              "maxLength": 12
            }
          },
          {
            "name": "includeChildren",
            "in": "query",
            "required": false,
            "description": "When true, include all descendant entities instead of only consolidated-with-parent children (default false).",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "taxType",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "sales",
                "sellers_use",
                "consumers_use"
              ]
            },
            "description": "Optional tax type filter: sales, sellers_use, or consumers_use."
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered transactions and ledger summary.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxTransactionsListResponse"
                },
                "examples": {
                  "ledger": {
                    "summary": "Committed sale transaction list",
                    "value": {
                      "count": 1,
                      "hasMore": false,
                      "nextCursor": null,
                      "truncated": false,
                      "summary": {
                        "saleCount": 1,
                        "refundCount": 0,
                        "voidedCount": 0,
                        "grossSales": 100,
                        "taxableSales": 100,
                        "exemptSales": 0,
                        "taxCollected": 7.5,
                        "taxRefunded": 0,
                        "netTax": 7.5
                      },
                      "transactions": [
                        {
                          "transactionId": "txn_0123456789abcdef0123456789abcdef",
                          "externalId": "order_2026_1001",
                          "type": "sale",
                          "status": "committed",
                          "parentTransactionId": null,
                          "transactionDate": "2026-10-06",
                          "customerId": "cust_acme_01",
                          "exemptionCertificateId": null,
                          "exemptionReason": null,
                          "stateCode": "FL",
                          "stateName": "Florida",
                          "currency": "USD",
                          "mode": "exclusive",
                          "rounding": "half_up",
                          "taxRate": 0.075,
                          "subtotal": 100,
                          "taxableAmount": 100,
                          "exemptAmount": 0,
                          "shippingAmount": 0,
                          "taxAmount": 7.5,
                          "total": 107.5,
                          "committedAt": 1767225600000,
                          "voidedAt": null,
                          "voidReason": null,
                          "metadata": {
                            "channel": "checkout"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "from must be a valid YYYY-MM-DD calendar date."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Transaction persistence and audit ledger requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Transaction persistence and audit ledger requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Transaction persistence and audit ledger require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Referenced entity (`entityId`, `entityCode`, or `ein`) was not found (`entity_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found for this account."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to list transactions."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            }
          },
          "409": {
            "description": "Multiple entities matched the requested `ein` or `entityCode` (`entity_ambiguous`). Pass `entityId` instead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_ambiguous",
                    "message": "Multiple entities match this EIN. Specify entityId instead."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Transaction ledger could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction ledger could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Transaction ledger is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction ledger is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transactions/import": {
      "post": {
        "tags": [
          "Transactions"
        ],
        "operationId": "importTransactions",
        "summary": "Bulk import tax transactions",
        "description": "Bulk import up to 200 historical or external sales and refund transactions from JSON rows or RFC 4180 CSV (supporting generic, stripe, and shopify column presets) with exact-cent validation, duplicate externalId deduplication, filing-period lock enforcement, and optional dry-run validation. Maximum request body size is 524,288 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransactionsImportRequest"
              },
              "examples": {
                "jsonRows": {
                  "summary": "Import sales transactions from JSON rows",
                  "value": {
                    "format": "json",
                    "dryRun": true,
                    "rows": [
                      {
                        "externalId": "ord_2026_001",
                        "transactionDate": "2026-04-15",
                        "state": "FL",
                        "subtotal": 100,
                        "taxAmount": 7.5,
                        "customerId": "cust_acme_01"
                      }
                    ]
                  }
                },
                "csvGeneric": {
                  "summary": "Import transactions from generic CSV",
                  "value": {
                    "format": "csv",
                    "preset": "generic",
                    "dryRun": true,
                    "csv": "externalId,transactionDate,state,subtotal,taxAmount\nord_2026_001,2026-04-15,FL,100.00,7.50"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transaction import completed (or validated when dryRun is true).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionsImportResponse"
                },
                "example": {
                  "dryRun": true,
                  "totalRows": 1,
                  "imported": 0,
                  "valid": 1,
                  "skippedDuplicates": 0,
                  "failed": 0,
                  "results": [
                    {
                      "row": 1,
                      "status": "valid",
                      "externalId": "ord_2026_001"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or missing body",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Transaction imports requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Transaction imports requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Transaction imports requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Specified entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST to import transactions."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Multiple entities matched the provided EIN.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_ambiguous",
                    "message": "Multiple entities share this EIN. Specify entityId or entityCode."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 524,288 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 524288 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction import could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction import is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transactions/report": {
      "get": {
        "tags": [
          "Transactions"
        ],
        "operationId": "getTaxFilingReport",
        "summary": "Generate a state and local sales tax filing report (JSON or CSV)",
        "description": "Aggregate committed sales and refunds within an inclusive `from` to `to` date range into penny-reconciled totals grouped by state and taxing jurisdiction (state, county, city, and special district). Voided transactions are excluded. Supports structured JSON (default) and RFC 4180 CSV export (`format=csv`). Scans up to 25,000 committed transactions (`truncated: true` if capped). Requires the Starter plan or higher. Always free (0 billable requests). CSV responses include entity columns (entity_id, entity_legal_name, entity_ein) and a `truncated` boolean column, and set the `X-Truncated: true` response header when the scan ceiling was reached. When omitted, an API key with `defaultEntityId` (or a single `allowedEntityIds` entry) automatically scopes results to that entity; unrestricted keys without `defaultEntityId` read the full account.",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "Inclusive start transactionDate (YYYY-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "Inclusive end transactionDate (YYYY-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "Optional US state code or name filter.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "Output format: json (default) or csv.",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "csv"
              ]
            }
          },
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Optional legal entity ID (ent_...) to scope results.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          },
          {
            "name": "entityCode",
            "in": "query",
            "required": false,
            "description": "Optional legal entity code slug to scope results.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "ein",
            "in": "query",
            "required": false,
            "description": "Optional US EIN (XX-XXXXXXX or 9 digits) to scope results.",
            "schema": {
              "type": "string",
              "minLength": 9,
              "maxLength": 12
            }
          },
          {
            "name": "includeChildren",
            "in": "query",
            "required": false,
            "description": "When true, include all descendant entities instead of only consolidated-with-parent children (default false).",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "taxType",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "sales",
                "sellers_use",
                "consumers_use"
              ]
            },
            "description": "Optional tax type filter: sales, sellers_use, or consumers_use."
          }
        ],
        "responses": {
          "200": {
            "description": "Penny-reconciled sales tax filing report in JSON or CSV format.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxFilingReportResponse"
                },
                "examples": {
                  "quarterlyReport": {
                    "summary": "Florida state and county filing report",
                    "value": {
                      "period": {
                        "from": "2026-10-01",
                        "to": "2026-12-31"
                      },
                      "stateFilter": "FL",
                      "generatedAt": "2026-10-06T12:00:00.000Z",
                      "truncated": false,
                      "transactionCount": 1,
                      "totals": {
                        "saleCount": 1,
                        "refundCount": 0,
                        "grossSales": 100,
                        "refundedSales": 0,
                        "netSales": 100,
                        "taxableSales": 100,
                        "exemptSales": 0,
                        "shippingAmount": 0,
                        "taxCollected": 7.5,
                        "taxRefunded": 0,
                        "netTax": 7.5
                      },
                      "states": [
                        {
                          "stateCode": "FL",
                          "stateName": "Florida",
                          "saleCount": 1,
                          "refundCount": 0,
                          "grossSales": 100,
                          "refundedSales": 0,
                          "netSales": 100,
                          "taxableSales": 100,
                          "exemptSales": 0,
                          "shippingAmount": 0,
                          "taxCollected": 7.5,
                          "taxRefunded": 0,
                          "netTax": 7.5,
                          "jurisdictions": [
                            {
                              "jurisdictionName": "Florida",
                              "rateName": "Florida",
                              "jurisdictionType": "state",
                              "rate": 0.06,
                              "saleCount": 1,
                              "refundCount": 0,
                              "taxCollected": 6,
                              "taxRefunded": 0,
                              "netTax": 6
                            },
                            {
                              "jurisdictionName": "Duval",
                              "rateName": "Duval",
                              "jurisdictionType": "county",
                              "rate": 0.015,
                              "saleCount": 1,
                              "refundCount": 0,
                              "taxCollected": 1.5,
                              "taxRefunded": 0,
                              "netTax": 1.5
                            }
                          ]
                        }
                      ]
                    }
                  }
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string",
                  "description": "RFC 4180 CSV with columns including period_from, period_to, entity_id, entity_legal_name, entity_ein, state_code, state_name, jurisdiction_name, rate_name, jurisdiction_type, rate, sale_count, refund_count, tax_collected, tax_refunded, net_tax, and truncated (`true` or `false`)."
                }
              }
            },
            "headers": {
              "X-Truncated": {
                "description": "Present with value `true` on CSV responses when more rows matched than the scan ceiling, matching the `truncated` column.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "from must be a valid YYYY-MM-DD calendar date."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Transaction persistence and audit ledger requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Transaction persistence and audit ledger requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Transaction persistence and audit ledger require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Referenced entity (`entityId`, `entityCode`, or `ein`) was not found (`entity_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found for this account."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to generate a tax filing report."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            }
          },
          "409": {
            "description": "Multiple entities matched the requested `ein` or `entityCode` (`entity_ambiguous`). Pass `entityId` instead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_ambiguous",
                    "message": "Multiple entities match this EIN. Specify entityId instead."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Transaction ledger could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Tax filing report could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Transaction ledger is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Tax filing report is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{transactionId}": {
      "parameters": [
        {
          "name": "transactionId",
          "in": "path",
          "required": true,
          "description": "Transaction identifier (e.g., txn_...).",
          "schema": {
            "type": "string",
            "pattern": "^txn_[a-f0-9]{16,64}$"
          }
        }
      ],
      "get": {
        "tags": [
          "Transactions"
        ],
        "operationId": "getTaxTransaction",
        "summary": "Get a committed tax transaction",
        "description": "Retrieve one tax transaction by `transactionId`, including its immutable calculation snapshot (line items, jurisdiction breakdown, applied sourcing/exemption) and all linked child refunds. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Transaction audit detail and linked refunds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxTransactionGetResponse"
                },
                "examples": {
                  "detail": {
                    "summary": "Committed sale transaction detail",
                    "value": {
                      "transaction": {
                        "transactionId": "txn_0123456789abcdef0123456789abcdef",
                        "externalId": "order_2026_1001",
                        "type": "sale",
                        "status": "committed",
                        "parentTransactionId": null,
                        "transactionDate": "2026-10-06",
                        "customerId": "cust_acme_01",
                        "exemptionCertificateId": null,
                        "exemptionReason": null,
                        "stateCode": "FL",
                        "stateName": "Florida",
                        "currency": "USD",
                        "mode": "exclusive",
                        "rounding": "half_up",
                        "taxRate": 0.075,
                        "subtotal": 100,
                        "taxableAmount": 100,
                        "exemptAmount": 0,
                        "shippingAmount": 0,
                        "taxAmount": 7.5,
                        "total": 107.5,
                        "committedAt": 1767225600000,
                        "voidedAt": null,
                        "voidReason": null,
                        "metadata": {
                          "channel": "checkout"
                        },
                        "snapshot": {
                          "coordinates": {
                            "latitude": 30.3297,
                            "longitude": -81.6586
                          },
                          "jurisdictions": [],
                          "calculation": {
                            "currency": "USD",
                            "mode": "exclusive",
                            "rounding": "half_up",
                            "subtotal": 100,
                            "taxableAmount": 100,
                            "exemptAmount": 0,
                            "shippingAmount": 0,
                            "taxAmount": 7.5,
                            "total": 107.5,
                            "lineItems": [
                              {
                                "id": "item_1",
                                "quantity": 1,
                                "unitAmount": 100,
                                "subtotal": 100,
                                "taxable": true,
                                "taxAmount": 7.5,
                                "total": 107.5
                              }
                            ],
                            "breakdown": [
                              {
                                "jurisdictionName": "Florida",
                                "rateName": "Florida",
                                "jurisdictionType": "state",
                                "rate": 0.06,
                                "taxAmount": 6
                              },
                              {
                                "jurisdictionName": "Duval",
                                "rateName": "Duval",
                                "jurisdictionType": "county",
                                "rate": 0.015,
                                "taxAmount": 1.5
                              }
                            ]
                          }
                        }
                      },
                      "refunds": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid transactionId or unexpected query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Invalid transactionId."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Transaction persistence and audit ledger requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Transaction persistence and audit ledger requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Transaction persistence and audit ledger require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Transaction not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "transaction_not_found",
                    "message": "Transaction was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to retrieve a transaction."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Transaction ledger could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction ledger could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Transaction ledger is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction ledger is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{transactionId}/void": {
      "parameters": [
        {
          "name": "transactionId",
          "in": "path",
          "required": true,
          "description": "Committed transaction identifier (e.g., txn_...) to void.",
          "schema": {
            "type": "string",
            "pattern": "^txn_[a-f0-9]{16,64}$"
          }
        }
      ],
      "post": {
        "tags": [
          "Transactions"
        ],
        "operationId": "voidTaxTransaction",
        "summary": "Void a committed tax transaction",
        "description": "Mark a committed transaction as `voided`, excluding it from sales and tax ledger totals. Rejects already-voided transactions (`transaction_already_voided`) and sales that have active committed child refunds (`transaction_has_refunds`). Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 4,096 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VoidTransactionRequest"
              },
              "examples": {
                "withReason": {
                  "summary": "Void with reason",
                  "value": {
                    "reason": "Order cancelled prior to fulfillment"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transaction voided.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxTransactionVoidResponse"
                },
                "examples": {
                  "voided": {
                    "summary": "Voided transaction",
                    "value": {
                      "transaction": {
                        "transactionId": "txn_0123456789abcdef0123456789abcdef",
                        "externalId": "order_2026_1001",
                        "type": "sale",
                        "status": "voided",
                        "parentTransactionId": null,
                        "transactionDate": "2026-10-06",
                        "customerId": "cust_acme_01",
                        "exemptionCertificateId": null,
                        "exemptionReason": null,
                        "stateCode": "FL",
                        "stateName": "Florida",
                        "currency": "USD",
                        "mode": "exclusive",
                        "rounding": "half_up",
                        "taxRate": 0.075,
                        "subtotal": 100,
                        "taxableAmount": 100,
                        "exemptAmount": 0,
                        "shippingAmount": 0,
                        "taxAmount": 7.5,
                        "total": 107.5,
                        "committedAt": 1767225600000,
                        "voidedAt": 1767312000000,
                        "voidReason": "Order cancelled prior to fulfillment",
                        "metadata": {
                          "channel": "checkout"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid transactionId or JSON body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "reason must be 1 to 500 characters."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Transaction persistence and audit ledger requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Transaction persistence and audit ledger requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Transaction persistence and audit ledger require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Transaction not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "transaction_not_found",
                    "message": "Transaction was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST to void a transaction."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            }
          },
          "409": {
            "description": "Transaction is already voided, has active child refunds, or falls in a locked filed return period.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "alreadyVoided": {
                    "summary": "Already voided",
                    "value": {
                      "error": {
                        "code": "transaction_already_voided",
                        "message": "Transaction is already voided."
                      }
                    }
                  },
                  "hasRefunds": {
                    "summary": "Has active child refunds",
                    "value": {
                      "error": {
                        "code": "transaction_has_refunds",
                        "message": "Cannot void a sale transaction that has active committed refunds."
                      }
                    }
                  },
                  "filingPeriodLocked": {
                    "summary": "Transaction date falls in a locked filed return period",
                    "value": {
                      "error": {
                        "code": "filing_period_locked",
                        "message": "Filing period 2026-10-01 to 2026-10-31 for FL is locked (flg_1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d). Amend the filed return before modifying transactions in this period."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 4,096 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 4096 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Transaction ledger could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction ledger could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Transaction ledger is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction ledger is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/transactions/{transactionId}/refund": {
      "parameters": [
        {
          "name": "transactionId",
          "in": "path",
          "required": true,
          "description": "Committed parent sale transaction identifier (e.g., txn_...).",
          "schema": {
            "type": "string",
            "pattern": "^txn_[a-f0-9]{16,64}$"
          }
        }
      ],
      "post": {
        "tags": [
          "Transactions"
        ],
        "operationId": "refundTaxTransaction",
        "summary": "Refund a committed sale transaction",
        "description": "Create a penny-exact full or partial refund transaction against a committed `sale` transaction. Omit both `lineItems` and `shipping` to refund 100% of remaining refundable amounts and pennies. Supply `lineItems` and/or `shipping` for a partial refund. Multiple partial refunds are tracked cumulatively and cannot exceed remaining refundable amounts (`refund_exceeds_remaining`). Each `lineItems` entry must specify exactly one of `quantity` or `amount` (at least 0.01). Send a unique `externalId` so a retry cannot create a second refund. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 16,384 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundTransactionRequest"
              },
              "examples": {
                "fullRefund": {
                  "summary": "Full remaining refund",
                  "value": {
                    "externalId": "refund_2026_1001",
                    "transactionDate": "2026-10-07",
                    "reason": "Customer returned order",
                    "metadata": {
                      "reason": "full_return"
                    }
                  }
                },
                "partialRefund": {
                  "summary": "Partial line-item refund",
                  "value": {
                    "reason": "Partial return",
                    "lineItems": [
                      {
                        "id": "item_1",
                        "amount": 50
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Refund transaction created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxTransactionRefundResponse"
                },
                "examples": {
                  "refunded": {
                    "summary": "Created refund transaction",
                    "value": {
                      "refund": {
                        "transactionId": "txn_fedcba9876543210fedcba9876543210",
                        "externalId": "refund_2026_1001",
                        "type": "refund",
                        "status": "committed",
                        "parentTransactionId": "txn_0123456789abcdef0123456789abcdef",
                        "transactionDate": "2026-10-07",
                        "customerId": "cust_acme_01",
                        "exemptionCertificateId": null,
                        "exemptionReason": null,
                        "stateCode": "FL",
                        "stateName": "Florida",
                        "currency": "USD",
                        "mode": "exclusive",
                        "rounding": "half_up",
                        "taxRate": 0.075,
                        "subtotal": -100,
                        "taxableAmount": -100,
                        "exemptAmount": 0,
                        "shippingAmount": 0,
                        "taxAmount": -7.5,
                        "total": -107.5,
                        "committedAt": 1767312000000,
                        "voidedAt": null,
                        "voidReason": null,
                        "metadata": {
                          "reason": "full_return"
                        },
                        "snapshot": {
                          "refundReason": "Customer returned order",
                          "isFullRefund": true,
                          "refundedLineItems": [
                            {
                              "id": "item_1",
                              "quantity": 1,
                              "subtotal": -100,
                              "taxableAmount": -100,
                              "exemptAmount": 0,
                              "taxAmount": -7.5,
                              "total": -107.5
                            }
                          ],
                          "refundedShipping": {
                            "subtotal": 0,
                            "taxableAmount": 0,
                            "exemptAmount": 0,
                            "taxAmount": 0,
                            "total": 0
                          },
                          "breakdown": [
                            {
                              "jurisdictionName": "Florida",
                              "rateName": "Florida",
                              "jurisdictionType": "state",
                              "rate": 0.06,
                              "taxAmount": -6
                            },
                            {
                              "jurisdictionName": "Duval",
                              "rateName": "Duval",
                              "jurisdictionType": "county",
                              "rate": 0.015,
                              "taxAmount": -1.5
                            }
                          ]
                        }
                      },
                      "parentTransaction": {
                        "transactionId": "txn_0123456789abcdef0123456789abcdef",
                        "externalId": "order_2026_1001",
                        "type": "sale",
                        "status": "committed",
                        "parentTransactionId": null,
                        "transactionDate": "2026-10-06",
                        "customerId": "cust_acme_01",
                        "exemptionCertificateId": null,
                        "exemptionReason": null,
                        "stateCode": "FL",
                        "stateName": "Florida",
                        "currency": "USD",
                        "mode": "exclusive",
                        "rounding": "half_up",
                        "taxRate": 0.075,
                        "subtotal": 100,
                        "taxableAmount": 100,
                        "exemptAmount": 0,
                        "shippingAmount": 0,
                        "taxAmount": 7.5,
                        "total": 107.5,
                        "committedAt": 1767225600000,
                        "voidedAt": null,
                        "voidReason": null,
                        "metadata": {
                          "channel": "checkout"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid transactionId or refund fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "lineItems[0].id does not exist on the parent transaction."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Transaction persistence and audit ledger requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or a session request came from a different origin (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Transaction persistence and audit ledger requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Transaction persistence and audit ledger require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Cross-origin session request",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Parent transaction not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "transaction_not_found",
                    "message": "Transaction was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST to refund a transaction."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate externalId (including voided transactions), invalid parent state, refund exceeds remaining refundable amount, refund limit reached, or refund date falls in a locked filed return period.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "duplicateTransaction": {
                    "summary": "Duplicate refund externalId",
                    "value": {
                      "error": {
                        "code": "duplicate_transaction",
                        "message": "A transaction with externalId refund_2026_1001 already exists."
                      }
                    }
                  },
                  "invalidState": {
                    "summary": "Parent transaction is voided or already a refund",
                    "value": {
                      "error": {
                        "code": "invalid_transaction_state",
                        "message": "Only committed sale transactions can be refunded."
                      }
                    }
                  },
                  "exceedsRemaining": {
                    "summary": "Refund exceeds remaining refundable amount",
                    "value": {
                      "error": {
                        "code": "refund_exceeds_remaining",
                        "message": "Requested refund exceeds the remaining refundable amount."
                      }
                    }
                  },
                  "refundLimitReached": {
                    "summary": "Too many refunds on one sale",
                    "value": {
                      "error": {
                        "code": "refund_limit_reached",
                        "message": "This transaction has reached the maximum number of refunds."
                      }
                    }
                  },
                  "filingPeriodLocked": {
                    "summary": "Transaction date falls in a locked filed return period",
                    "value": {
                      "error": {
                        "code": "filing_period_locked",
                        "message": "Filing period 2026-10-01 to 2026-10-31 for FL is locked (flg_1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d). Amend the filed return before modifying transactions in this period."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 16,384 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 16384 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "Transaction ledger could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction ledger could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Transaction ledger is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Transaction ledger is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/filings": {
      "get": {
        "operationId": "listFilings",
        "tags": [
          "Filings"
        ],
        "summary": "List sales tax filing periods",
        "description": "List persistent sales tax filing periods for the account, optionally filtered by entityId, state/stateCode, status, periodStart, periodEnd, and limit. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^ent_[a-f0-9]{16,64}$"
            },
            "description": "Filter by legal entity ID."
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "description": "Filter by US state name or two-letter code."
          },
          {
            "name": "stateCode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "description": "Alias for state."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "ready",
                "filed",
                "amended"
              ]
            },
            "description": "Filter by filing workflow status."
          },
          {
            "name": "periodStart",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "description": "Inclusive lower bound YYYY-MM-DD period start filter."
          },
          {
            "name": "periodEnd",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "description": "Inclusive upper bound YYYY-MM-DD period end filter."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            },
            "description": "Maximum number of filings to return (1 to 200)."
          }
        ],
        "responses": {
          "200": {
            "description": "Matching filing periods.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingsListResponse"
                },
                "example": {
                  "count": 1,
                  "filings": [
                    {
                      "filingId": "flg_8f7e6d5c4b3a29180716253443526170",
                      "entityId": "ent_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
                      "stateCode": "FL",
                      "stateName": "Florida",
                      "periodStart": "2026-11-01",
                      "periodEnd": "2026-11-30",
                      "filingFrequency": "monthly",
                      "dueDate": "2026-12-21",
                      "status": "draft",
                      "amendedFromFilingId": null,
                      "summary": {
                        "saleCount": 140,
                        "refundCount": 2,
                        "totalGrossSalesCents": 4825000,
                        "totalRefundedSalesCents": 100000,
                        "totalTaxableSalesCents": 4500000,
                        "totalExemptSalesCents": 325000,
                        "totalShippingCents": 0,
                        "totalTaxCollectedCents": 337500,
                        "totalTaxRefundedCents": 7500,
                        "netTaxDueCents": 330000,
                        "transactionCount": 142,
                        "truncated": false,
                        "jurisdictions": [
                          {
                            "jurisdictionName": "Florida",
                            "rateName": "Florida",
                            "jurisdictionType": "state",
                            "rate": 0.06,
                            "saleCount": 140,
                            "refundCount": 2,
                            "taxCollectedCents": 270000,
                            "taxRefundedCents": 6000,
                            "netTaxCents": 264000
                          },
                          {
                            "jurisdictionName": "Duval",
                            "rateName": "Duval",
                            "jurisdictionType": "county",
                            "rate": 0.015,
                            "saleCount": 140,
                            "refundCount": 2,
                            "taxCollectedCents": 67500,
                            "taxRefundedCents": 1500,
                            "netTaxCents": 66000
                          }
                        ],
                        "generatedAt": "2026-12-01T00:00:00.000Z"
                      },
                      "totalGrossSalesCents": 4825000,
                      "totalTaxableSalesCents": 4500000,
                      "totalExemptSalesCents": 325000,
                      "totalTaxCollectedCents": 337500,
                      "totalTaxRefundedCents": 7500,
                      "netTaxDueCents": 330000,
                      "deltaTaxDueCents": null,
                      "transactionCount": 142,
                      "truncated": false,
                      "confirmationNumber": null,
                      "notes": "November 2026 DR-15 preparation",
                      "metadata": null,
                      "lockedAt": null,
                      "filedAt": null,
                      "createdAt": 1796083200000,
                      "updatedAt": 1796083200000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown field, or malformed query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Invalid filing request input."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked Bearer API key.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Filing periods require the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by role or API key entity scope (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Filing periods require Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Filing periods require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, POST."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createFiling",
        "tags": [
          "Filings"
        ],
        "summary": "Create a draft filing period",
        "description": "Snapshot committed ledger transactions for an entity, state, and date range (max 366 days) into a new persistent draft filing period with an auto-computed statutory due date. Requires the Starter plan or higher. Always free (0 billable requests). Maximum request body size is 16,384 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateFilingRequest"
              },
              "examples": {
                "monthlyFlorida": {
                  "summary": "Create monthly Florida draft filing",
                  "value": {
                    "entityId": "ent_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
                    "state": "FL",
                    "periodStart": "2026-11-01",
                    "periodEnd": "2026-11-30",
                    "filingFrequency": "monthly",
                    "notes": "November 2026 DR-15 preparation"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Draft filing period created with snapshotted ledger totals.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingResponse"
                },
                "example": {
                  "filing": {
                    "filingId": "flg_8f7e6d5c4b3a29180716253443526170",
                    "entityId": "ent_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
                    "stateCode": "FL",
                    "stateName": "Florida",
                    "periodStart": "2026-11-01",
                    "periodEnd": "2026-11-30",
                    "filingFrequency": "monthly",
                    "dueDate": "2026-12-21",
                    "status": "draft",
                    "amendedFromFilingId": null,
                    "summary": {
                      "saleCount": 140,
                      "refundCount": 2,
                      "totalGrossSalesCents": 4825000,
                      "totalRefundedSalesCents": 100000,
                      "totalTaxableSalesCents": 4500000,
                      "totalExemptSalesCents": 325000,
                      "totalShippingCents": 0,
                      "totalTaxCollectedCents": 337500,
                      "totalTaxRefundedCents": 7500,
                      "netTaxDueCents": 330000,
                      "transactionCount": 142,
                      "truncated": false,
                      "jurisdictions": [
                        {
                          "jurisdictionName": "Florida",
                          "rateName": "Florida",
                          "jurisdictionType": "state",
                          "rate": 0.06,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 270000,
                          "taxRefundedCents": 6000,
                          "netTaxCents": 264000
                        },
                        {
                          "jurisdictionName": "Duval",
                          "rateName": "Duval",
                          "jurisdictionType": "county",
                          "rate": 0.015,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 67500,
                          "taxRefundedCents": 1500,
                          "netTaxCents": 66000
                        }
                      ],
                      "generatedAt": "2026-12-01T00:00:00.000Z"
                    },
                    "totalGrossSalesCents": 4825000,
                    "totalTaxableSalesCents": 4500000,
                    "totalExemptSalesCents": 325000,
                    "totalTaxCollectedCents": 337500,
                    "totalTaxRefundedCents": 7500,
                    "netTaxDueCents": 330000,
                    "deltaTaxDueCents": null,
                    "transactionCount": 142,
                    "truncated": false,
                    "confirmationNumber": null,
                    "notes": "November 2026 DR-15 preparation",
                    "metadata": null,
                    "lockedAt": null,
                    "filedAt": null,
                    "createdAt": 1796083200000,
                    "updatedAt": 1796083200000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown field, or malformed query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Invalid filing request input."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked Bearer API key.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Filing periods require the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by role or API key entity scope (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Filing periods require Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Filing periods require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Referenced entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, POST."
                  }
                }
              }
            }
          },
          "409": {
            "description": "An active non-amended filing already exists for this entity, state, and period.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "filing_already_exists",
                    "message": "A filing already exists for this entity, state, and period."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 16,384 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 16384 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/filings/calendar": {
      "get": {
        "operationId": "getFilingCalendar",
        "tags": [
          "Filings"
        ],
        "summary": "Get statutory filing calendar",
        "description": "Compute upcoming, open, overdue, and filed sales tax return periods from active entity state registrations and persisted filings. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^ent_[a-f0-9]{16,64}$"
            },
            "description": "Optional legal entity ID filter."
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "description": "Optional US state name or two-letter code filter."
          },
          {
            "name": "stateCode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "description": "Optional alias for state."
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "description": "Optional calendar window start date (YYYY-MM-DD)."
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "description": "Optional calendar window end date (YYYY-MM-DD, max 732 days after from)."
          },
          {
            "name": "asOf",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "description": "Optional reference date (YYYY-MM-DD, defaults to today UTC) used to compute isOverdue."
          }
        ],
        "responses": {
          "200": {
            "description": "Statutory filing calendar slots.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingCalendarResponse"
                },
                "example": {
                  "from": "2026-10-01",
                  "to": "2026-12-31",
                  "asOf": "2026-11-29",
                  "count": 1,
                  "items": [
                    {
                      "entityId": "ent_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
                      "stateCode": "FL",
                      "stateName": "Florida",
                      "filingFrequency": "monthly",
                      "periodStart": "2026-11-01",
                      "periodEnd": "2026-11-30",
                      "dueDate": "2026-12-21",
                      "status": "draft",
                      "filingId": "flg_8f7e6d5c4b3a29180716253443526170",
                      "isOverdue": false
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown field, or malformed query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Invalid filing request input."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked Bearer API key.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Filing periods require the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by role or API key entity scope (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Filing periods require Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Filing periods require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/filings/{filingId}": {
      "get": {
        "operationId": "getFiling",
        "tags": [
          "Filings"
        ],
        "summary": "Get a filing period",
        "description": "Retrieve a single persistent sales tax filing period with its stored ledger snapshot and jurisdiction breakdown. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "filingId",
            "in": "path",
            "required": true,
            "description": "Persistent filing identifier (flg_...).",
            "schema": {
              "type": "string",
              "pattern": "^flg_[a-f0-9]{16,32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Filing period detail.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingResponse"
                },
                "example": {
                  "filing": {
                    "filingId": "flg_8f7e6d5c4b3a29180716253443526170",
                    "entityId": "ent_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
                    "stateCode": "FL",
                    "stateName": "Florida",
                    "periodStart": "2026-11-01",
                    "periodEnd": "2026-11-30",
                    "filingFrequency": "monthly",
                    "dueDate": "2026-12-21",
                    "status": "draft",
                    "amendedFromFilingId": null,
                    "summary": {
                      "saleCount": 140,
                      "refundCount": 2,
                      "totalGrossSalesCents": 4825000,
                      "totalRefundedSalesCents": 100000,
                      "totalTaxableSalesCents": 4500000,
                      "totalExemptSalesCents": 325000,
                      "totalShippingCents": 0,
                      "totalTaxCollectedCents": 337500,
                      "totalTaxRefundedCents": 7500,
                      "netTaxDueCents": 330000,
                      "transactionCount": 142,
                      "truncated": false,
                      "jurisdictions": [
                        {
                          "jurisdictionName": "Florida",
                          "rateName": "Florida",
                          "jurisdictionType": "state",
                          "rate": 0.06,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 270000,
                          "taxRefundedCents": 6000,
                          "netTaxCents": 264000
                        },
                        {
                          "jurisdictionName": "Duval",
                          "rateName": "Duval",
                          "jurisdictionType": "county",
                          "rate": 0.015,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 67500,
                          "taxRefundedCents": 1500,
                          "netTaxCents": 66000
                        }
                      ],
                      "generatedAt": "2026-12-01T00:00:00.000Z"
                    },
                    "totalGrossSalesCents": 4825000,
                    "totalTaxableSalesCents": 4500000,
                    "totalExemptSalesCents": 325000,
                    "totalTaxCollectedCents": 337500,
                    "totalTaxRefundedCents": 7500,
                    "netTaxDueCents": 330000,
                    "deltaTaxDueCents": null,
                    "transactionCount": 142,
                    "truncated": false,
                    "confirmationNumber": null,
                    "notes": "November 2026 DR-15 preparation",
                    "metadata": null,
                    "lockedAt": null,
                    "filedAt": null,
                    "createdAt": 1796083200000,
                    "updatedAt": 1796083200000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown field, or malformed query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "filingId must be a valid filing identifier."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked Bearer API key.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Filing periods require the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by role or API key entity scope (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Filing periods require Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Filing periods require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Filing was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "filing_not_found",
                    "message": "Filing was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, PATCH.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateFiling",
        "tags": [
          "Filings"
        ],
        "summary": "Update or mark a filing period filed",
        "description": "Update a draft or ready filing period, optionally refresh its ledger snapshot, or transition status to filed (which records filedAt/lockedAt and locks the period against new commits or voids). Requires the Starter plan or higher. Always free (0 billable requests). Maximum request body size is 16,384 bytes.",
        "parameters": [
          {
            "name": "filingId",
            "in": "path",
            "required": true,
            "description": "Persistent filing identifier (flg_...).",
            "schema": {
              "type": "string",
              "pattern": "^flg_[a-f0-9]{16,32}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateFilingRequest"
              },
              "examples": {
                "markFiled": {
                  "summary": "Refresh snapshot and mark return filed",
                  "value": {
                    "status": "filed",
                    "confirmationNumber": "FL-DR15-20261218-4491",
                    "refreshSnapshot": true
                  }
                },
                "markReady": {
                  "summary": "Mark return ready for review",
                  "value": {
                    "status": "ready",
                    "notes": "Reconciled against ERP GL report"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated filing period.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilingResponse"
                },
                "example": {
                  "filing": {
                    "filingId": "flg_8f7e6d5c4b3a29180716253443526170",
                    "entityId": "ent_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
                    "stateCode": "FL",
                    "stateName": "Florida",
                    "periodStart": "2026-11-01",
                    "periodEnd": "2026-11-30",
                    "filingFrequency": "monthly",
                    "dueDate": "2026-12-21",
                    "status": "filed",
                    "amendedFromFilingId": null,
                    "summary": {
                      "saleCount": 140,
                      "refundCount": 2,
                      "totalGrossSalesCents": 4825000,
                      "totalRefundedSalesCents": 100000,
                      "totalTaxableSalesCents": 4500000,
                      "totalExemptSalesCents": 325000,
                      "totalShippingCents": 0,
                      "totalTaxCollectedCents": 337500,
                      "totalTaxRefundedCents": 7500,
                      "netTaxDueCents": 330000,
                      "transactionCount": 142,
                      "truncated": false,
                      "jurisdictions": [
                        {
                          "jurisdictionName": "Florida",
                          "rateName": "Florida",
                          "jurisdictionType": "state",
                          "rate": 0.06,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 270000,
                          "taxRefundedCents": 6000,
                          "netTaxCents": 264000
                        },
                        {
                          "jurisdictionName": "Duval",
                          "rateName": "Duval",
                          "jurisdictionType": "county",
                          "rate": 0.015,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 67500,
                          "taxRefundedCents": 1500,
                          "netTaxCents": 66000
                        }
                      ],
                      "generatedAt": "2026-12-01T00:00:00.000Z"
                    },
                    "totalGrossSalesCents": 4825000,
                    "totalTaxableSalesCents": 4500000,
                    "totalExemptSalesCents": 325000,
                    "totalTaxCollectedCents": 337500,
                    "totalTaxRefundedCents": 7500,
                    "netTaxDueCents": 330000,
                    "deltaTaxDueCents": null,
                    "transactionCount": 142,
                    "truncated": false,
                    "confirmationNumber": "FL-DR15-20261218-4491",
                    "notes": "November 2026 DR-15 preparation",
                    "metadata": null,
                    "lockedAt": 1797552000000,
                    "filedAt": 1797552000000,
                    "createdAt": 1796083200000,
                    "updatedAt": 1796083200000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown field, or malformed query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Invalid filing request input."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked Bearer API key.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Filing periods require the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by role or API key entity scope (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Filing periods require Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Filing periods require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Filing was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "filing_not_found",
                    "message": "Filing was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, PATCH.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Filing is already filed or amended (filing_locked), or status transition is invalid (invalid_filing_state).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "filingLocked": {
                    "summary": "Filing is locked",
                    "value": {
                      "error": {
                        "code": "filing_locked",
                        "message": "Filed or amended returns are locked and cannot be modified. Create an amendment instead."
                      }
                    }
                  },
                  "invalidFilingState": {
                    "summary": "Invalid status transition",
                    "value": {
                      "error": {
                        "code": "invalid_filing_state",
                        "message": "Requested filing status transition is not permitted."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 16,384 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 16384 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/filings/{filingId}/amend": {
      "post": {
        "operationId": "amendFiling",
        "tags": [
          "Filings"
        ],
        "summary": "Create a linked amendment for a filed return",
        "description": "Marks a filed return as amended and creates a new linked draft amendment with recalculated ledger totals and deltaTaxDueCents, unlocking the period for adjustments until the amendment is filed. Requires the Starter plan or higher. Always free (0 billable requests). Maximum request body size is 8,192 bytes.",
        "parameters": [
          {
            "name": "filingId",
            "in": "path",
            "required": true,
            "description": "Persistent filing identifier (flg_...).",
            "schema": {
              "type": "string",
              "pattern": "^flg_[a-f0-9]{16,32}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AmendFilingRequest"
              },
              "examples": {
                "amendWithNote": {
                  "summary": "Amend with explanation note",
                  "value": {
                    "notes": "Amended to include late marketplace credit adjustment"
                  }
                },
                "emptyBody": {
                  "summary": "Amend with empty object",
                  "value": {}
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Linked draft amendment created and original filing marked amended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AmendFilingResponse"
                },
                "example": {
                  "filing": {
                    "filingId": "flg_2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e",
                    "entityId": "ent_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
                    "stateCode": "FL",
                    "stateName": "Florida",
                    "periodStart": "2026-11-01",
                    "periodEnd": "2026-11-30",
                    "filingFrequency": "monthly",
                    "dueDate": "2026-12-21",
                    "status": "draft",
                    "amendedFromFilingId": "flg_8f7e6d5c4b3a29180716253443526170",
                    "summary": {
                      "saleCount": 140,
                      "refundCount": 2,
                      "totalGrossSalesCents": 4825000,
                      "totalRefundedSalesCents": 100000,
                      "totalTaxableSalesCents": 4500000,
                      "totalExemptSalesCents": 325000,
                      "totalShippingCents": 0,
                      "totalTaxCollectedCents": 337500,
                      "totalTaxRefundedCents": 7500,
                      "netTaxDueCents": 330000,
                      "transactionCount": 142,
                      "truncated": false,
                      "jurisdictions": [
                        {
                          "jurisdictionName": "Florida",
                          "rateName": "Florida",
                          "jurisdictionType": "state",
                          "rate": 0.06,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 270000,
                          "taxRefundedCents": 6000,
                          "netTaxCents": 264000
                        },
                        {
                          "jurisdictionName": "Duval",
                          "rateName": "Duval",
                          "jurisdictionType": "county",
                          "rate": 0.015,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 67500,
                          "taxRefundedCents": 1500,
                          "netTaxCents": 66000
                        }
                      ],
                      "generatedAt": "2026-12-01T00:00:00.000Z"
                    },
                    "totalGrossSalesCents": 4825000,
                    "totalTaxableSalesCents": 4500000,
                    "totalExemptSalesCents": 325000,
                    "totalTaxCollectedCents": 337500,
                    "totalTaxRefundedCents": 7500,
                    "netTaxDueCents": 330000,
                    "deltaTaxDueCents": 0,
                    "transactionCount": 142,
                    "truncated": false,
                    "confirmationNumber": null,
                    "notes": "November 2026 DR-15 preparation",
                    "metadata": null,
                    "lockedAt": null,
                    "filedAt": null,
                    "createdAt": 1796083200000,
                    "updatedAt": 1796083200000
                  },
                  "originalFiling": {
                    "filingId": "flg_8f7e6d5c4b3a29180716253443526170",
                    "entityId": "ent_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
                    "stateCode": "FL",
                    "stateName": "Florida",
                    "periodStart": "2026-11-01",
                    "periodEnd": "2026-11-30",
                    "filingFrequency": "monthly",
                    "dueDate": "2026-12-21",
                    "status": "amended",
                    "amendedFromFilingId": null,
                    "summary": {
                      "saleCount": 140,
                      "refundCount": 2,
                      "totalGrossSalesCents": 4825000,
                      "totalRefundedSalesCents": 100000,
                      "totalTaxableSalesCents": 4500000,
                      "totalExemptSalesCents": 325000,
                      "totalShippingCents": 0,
                      "totalTaxCollectedCents": 337500,
                      "totalTaxRefundedCents": 7500,
                      "netTaxDueCents": 330000,
                      "transactionCount": 142,
                      "truncated": false,
                      "jurisdictions": [
                        {
                          "jurisdictionName": "Florida",
                          "rateName": "Florida",
                          "jurisdictionType": "state",
                          "rate": 0.06,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 270000,
                          "taxRefundedCents": 6000,
                          "netTaxCents": 264000
                        },
                        {
                          "jurisdictionName": "Duval",
                          "rateName": "Duval",
                          "jurisdictionType": "county",
                          "rate": 0.015,
                          "saleCount": 140,
                          "refundCount": 2,
                          "taxCollectedCents": 67500,
                          "taxRefundedCents": 1500,
                          "netTaxCents": 66000
                        }
                      ],
                      "generatedAt": "2026-12-01T00:00:00.000Z"
                    },
                    "totalGrossSalesCents": 4825000,
                    "totalTaxableSalesCents": 4500000,
                    "totalExemptSalesCents": 325000,
                    "totalTaxCollectedCents": 337500,
                    "totalTaxRefundedCents": 7500,
                    "netTaxDueCents": 330000,
                    "deltaTaxDueCents": null,
                    "transactionCount": 142,
                    "truncated": false,
                    "confirmationNumber": null,
                    "notes": "November 2026 DR-15 preparation",
                    "metadata": null,
                    "lockedAt": 1797552000000,
                    "filedAt": 1797552000000,
                    "createdAt": 1796083200000,
                    "updatedAt": 1796083200000
                  },
                  "deltaTaxDueCents": 0
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown field, or malformed query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Invalid filing request input."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked Bearer API key.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Filing periods require the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by role or API key entity scope (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Filing periods require Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Filing periods require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Filing was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "filing_not_found",
                    "message": "Filing was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Source filing is not in filed status (invalid_filing_state) or cannot be amended (filing_locked).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidFilingState": {
                    "summary": "Source filing is not filed",
                    "value": {
                      "error": {
                        "code": "invalid_filing_state",
                        "message": "Only filed returns can be amended."
                      }
                    }
                  },
                  "filingLocked": {
                    "summary": "Filing cannot be amended",
                    "value": {
                      "error": {
                        "code": "filing_locked",
                        "message": "This filing has already been amended."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Filings are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/entities": {
      "get": {
        "tags": [
          "Entities"
        ],
        "operationId": "listEntities",
        "summary": "List legal entities",
        "description": "List legal entities and hierarchy metadata (depth, childCount, reportingParentEntityId, formatted EIN) stored for the authenticated account. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "archived"
              ]
            }
          },
          {
            "name": "parentEntityId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          },
          {
            "name": "ein",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 9,
              "maxLength": 12
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Entities retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntitiesListResponse"
                },
                "examples": {
                  "list": {
                    "summary": "Active entity list",
                    "value": {
                      "count": 1,
                      "entities": [
                        {
                          "entityId": "ent_0123456789abcdef0123456789abcdef",
                          "legalName": "Acme Cloud Holdings LLC",
                          "dbaName": "Acme Cloud",
                          "code": "acme-cloud",
                          "ein": "12-3456789",
                          "einLast4": "6789",
                          "structureType": "llc",
                          "parentEntityId": null,
                          "taxReportingMode": "separate_filer",
                          "isDefault": true,
                          "status": "active",
                          "defaultShipFrom": {
                            "address": "117 W Duval St, Jacksonville, FL 32202, USA",
                            "stateCode": "FL"
                          },
                          "metadata": {
                            "region": "us-east"
                          },
                          "depth": 0,
                          "childCount": 0,
                          "reportingParentEntityId": null,
                          "createdAt": 1760000000000,
                          "updatedAt": 1760000000000,
                          "archivedAt": null
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Multi-entity management requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, POST."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Entities"
        ],
        "operationId": "createEntity",
        "summary": "Create a legal entity",
        "description": "Create a legal entity with optional EIN, parent entity hierarchy (up to 5 levels), tax reporting mode, default flag, and default ship-from location. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 16,384 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEntityRequest"
              },
              "examples": {
                "parentLlc": {
                  "summary": "Primary operating LLC",
                  "value": {
                    "legalName": "Acme Cloud Holdings LLC",
                    "dbaName": "Acme Cloud",
                    "code": "acme-cloud",
                    "ein": "12-3456789",
                    "structureType": "llc",
                    "taxReportingMode": "separate_filer",
                    "isDefault": true,
                    "defaultShipFrom": {
                      "address": "117 W Duval St, Jacksonville, FL 32202, USA",
                      "stateCode": "FL"
                    },
                    "metadata": {
                      "region": "us-east"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Entity created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityResponse"
                },
                "examples": {
                  "created": {
                    "summary": "Created entity",
                    "value": {
                      "entity": {
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "legalName": "Acme Cloud Holdings LLC",
                        "dbaName": "Acme Cloud",
                        "code": "acme-cloud",
                        "ein": "12-3456789",
                        "einLast4": "6789",
                        "structureType": "llc",
                        "parentEntityId": null,
                        "taxReportingMode": "separate_filer",
                        "isDefault": true,
                        "status": "active",
                        "defaultShipFrom": {
                          "address": "117 W Duval St, Jacksonville, FL 32202, USA",
                          "stateCode": "FL"
                        },
                        "metadata": {
                          "region": "us-east"
                        },
                        "depth": 0,
                        "childCount": 0,
                        "reportingParentEntityId": null,
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "archivedAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Multi-entity management requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, POST."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate entity code or entity limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_conflict",
                    "message": "An active entity with this code already exists."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 16,384 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 16384 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/entities/{entityId}": {
      "parameters": [
        {
          "name": "entityId",
          "in": "path",
          "required": true,
          "description": "Legal entity identifier (ent_...).",
          "schema": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          }
        }
      ],
      "get": {
        "tags": [
          "Entities"
        ],
        "operationId": "getEntity",
        "summary": "Get a legal entity",
        "description": "Retrieve a legal entity along with its state registrations and direct child entities. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Entity details retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityDetailResponse"
                },
                "examples": {
                  "detail": {
                    "summary": "Entity with registrations",
                    "value": {
                      "entity": {
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "legalName": "Acme Cloud Holdings LLC",
                        "dbaName": "Acme Cloud",
                        "code": "acme-cloud",
                        "ein": "12-3456789",
                        "einLast4": "6789",
                        "structureType": "llc",
                        "parentEntityId": null,
                        "taxReportingMode": "separate_filer",
                        "isDefault": true,
                        "status": "active",
                        "defaultShipFrom": {
                          "address": "117 W Duval St, Jacksonville, FL 32202, USA",
                          "stateCode": "FL"
                        },
                        "metadata": {
                          "region": "us-east"
                        },
                        "depth": 0,
                        "childCount": 0,
                        "reportingParentEntityId": null,
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "archivedAt": null
                      },
                      "registrations": [
                        {
                          "entityId": "ent_0123456789abcdef0123456789abcdef",
                          "stateCode": "FL",
                          "stateName": "Florida",
                          "permitNumber": "FL-80-1234567890-1",
                          "filingFrequency": "monthly",
                          "effectiveDate": "2026-01-01",
                          "status": "active",
                          "notes": "Primary Florida sales tax certificate of registration.",
                          "createdAt": 1760000000000,
                          "updatedAt": 1760000000000,
                          "closedAt": null
                        }
                      ],
                      "children": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Multi-entity management requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, PATCH, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Entities"
        ],
        "operationId": "updateEntity",
        "summary": "Update a legal entity",
        "description": "Update a legal entity profile, EIN, parent hierarchy, reporting mode, default flag, default ship-from, status, or metadata. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 16,384 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEntityRequest"
              },
              "examples": {
                "updateDba": {
                  "summary": "Update DBA and default flag",
                  "value": {
                    "dbaName": "Acme Cloud Services",
                    "isDefault": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Entity updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityResponse"
                },
                "examples": {
                  "updated": {
                    "summary": "Updated entity",
                    "value": {
                      "entity": {
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "legalName": "Acme Cloud Holdings LLC",
                        "dbaName": "Acme Cloud",
                        "code": "acme-cloud",
                        "ein": "12-3456789",
                        "einLast4": "6789",
                        "structureType": "llc",
                        "parentEntityId": null,
                        "taxReportingMode": "separate_filer",
                        "isDefault": true,
                        "status": "active",
                        "defaultShipFrom": {
                          "address": "117 W Duval St, Jacksonville, FL 32202, USA",
                          "stateCode": "FL"
                        },
                        "metadata": {
                          "region": "us-east"
                        },
                        "depth": 0,
                        "childCount": 0,
                        "reportingParentEntityId": null,
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "archivedAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Multi-entity management requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, PATCH, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            }
          },
          "409": {
            "description": "Entity code conflict (`duplicate_entity_code`), cannot archive an entity with active child entities (`entity_has_active_children`), or cannot archive an entity referenced by an active API key (`entity_in_use`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_conflict",
                    "message": "Entity cannot be updated due to a conflict."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 16,384 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 16384 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Entities"
        ],
        "operationId": "archiveEntity",
        "summary": "Archive a legal entity",
        "description": "Soft-archive a legal entity that has no active child entities. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Entity archived.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityResponse"
                },
                "examples": {
                  "archived": {
                    "summary": "Archived entity",
                    "value": {
                      "entity": {
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "legalName": "Acme Cloud Holdings LLC",
                        "dbaName": "Acme Cloud",
                        "code": "acme-cloud",
                        "ein": "12-3456789",
                        "einLast4": "6789",
                        "structureType": "llc",
                        "parentEntityId": null,
                        "taxReportingMode": "separate_filer",
                        "isDefault": false,
                        "status": "archived",
                        "defaultShipFrom": {
                          "address": "117 W Duval St, Jacksonville, FL 32202, USA",
                          "stateCode": "FL"
                        },
                        "metadata": {
                          "region": "us-east"
                        },
                        "depth": 0,
                        "childCount": 0,
                        "reportingParentEntityId": null,
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "archivedAt": 1760000100000
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Multi-entity management requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, PATCH, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            }
          },
          "409": {
            "description": "Cannot archive an entity that still has active child entities (`entity_has_active_children`) or is referenced by an active API key (`entity_in_use`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_conflict",
                    "message": "Archive or reparent active child entities first."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entities could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/entities/{entityId}/registrations": {
      "parameters": [
        {
          "name": "entityId",
          "in": "path",
          "required": true,
          "description": "Legal entity identifier (ent_...).",
          "schema": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          }
        }
      ],
      "get": {
        "tags": [
          "Entities"
        ],
        "operationId": "listEntityRegistrations",
        "summary": "List entity state registrations",
        "description": "List US state sales tax registrations for a legal entity. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Registrations retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityRegistrationsListResponse"
                },
                "examples": {
                  "list": {
                    "summary": "Florida registration",
                    "value": {
                      "entityId": "ent_0123456789abcdef0123456789abcdef",
                      "count": 1,
                      "registrations": [
                        {
                          "entityId": "ent_0123456789abcdef0123456789abcdef",
                          "stateCode": "FL",
                          "stateName": "Florida",
                          "permitNumber": "FL-80-1234567890-1",
                          "filingFrequency": "monthly",
                          "effectiveDate": "2026-01-01",
                          "status": "active",
                          "notes": "Primary Florida sales tax certificate of registration.",
                          "createdAt": 1760000000000,
                          "updatedAt": 1760000000000,
                          "closedAt": null
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Multi-entity management requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entity registrations could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entity registrations could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/entities/{entityId}/registrations/{state}": {
      "parameters": [
        {
          "name": "entityId",
          "in": "path",
          "required": true,
          "description": "Legal entity identifier (ent_...).",
          "schema": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          }
        },
        {
          "name": "state",
          "in": "path",
          "required": true,
          "description": "US state name or two-letter code (e.g., FL, TX, New York).",
          "schema": {
            "type": "string",
            "minLength": 2,
            "maxLength": 64
          }
        }
      ],
      "put": {
        "tags": [
          "Entities"
        ],
        "operationId": "upsertEntityRegistration",
        "summary": "Upsert a state sales tax registration",
        "description": "Create or update a state sales tax registration permit, filing frequency, effective date, and status for a legal entity. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 8,192 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertEntityRegistrationRequest"
              },
              "examples": {
                "floridaPermit": {
                  "summary": "Florida monthly sales tax permit",
                  "value": {
                    "permitNumber": "FL-80-1234567890-1",
                    "filingFrequency": "monthly",
                    "effectiveDate": "2026-01-01",
                    "status": "active",
                    "notes": "Primary Florida sales tax certificate of registration."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Registration updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityRegistrationResponse"
                },
                "examples": {
                  "updated": {
                    "summary": "Updated registration",
                    "value": {
                      "registration": {
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "stateCode": "FL",
                        "stateName": "Florida",
                        "permitNumber": "FL-80-1234567890-1",
                        "filingFrequency": "monthly",
                        "effectiveDate": "2026-01-01",
                        "status": "active",
                        "notes": "Primary Florida sales tax certificate of registration.",
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "closedAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Registration created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityRegistrationResponse"
                },
                "examples": {
                  "created": {
                    "summary": "Created registration",
                    "value": {
                      "registration": {
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "stateCode": "FL",
                        "stateName": "Florida",
                        "permitNumber": "FL-80-1234567890-1",
                        "filingFrequency": "monthly",
                        "effectiveDate": "2026-01-01",
                        "status": "active",
                        "notes": "Primary Florida sales tax certificate of registration.",
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "closedAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Multi-entity management requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use PUT, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use PUT, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "PUT, DELETE"
                }
              }
            }
          },
          "409": {
            "description": "Registration conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "registration_conflict",
                    "message": "State registration could not be updated."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entity registrations could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entity registrations could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Entities"
        ],
        "operationId": "removeEntityRegistration",
        "summary": "Remove a state sales tax registration",
        "description": "Remove a state sales tax registration from a legal entity. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Registration removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityRegistrationResponse"
                },
                "examples": {
                  "removed": {
                    "summary": "Removed registration",
                    "value": {
                      "registration": {
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "stateCode": "FL",
                        "stateName": "Florida",
                        "permitNumber": "FL-80-1234567890-1",
                        "filingFrequency": "monthly",
                        "effectiveDate": "2026-01-01",
                        "status": "closed",
                        "notes": "Primary Florida sales tax certificate of registration.",
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "closedAt": 1760000200000
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Multi-entity management requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Multi-entity management requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Entity or state registration was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "registration_not_found",
                    "message": "State registration was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use PUT, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use PUT, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "PUT, DELETE"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entity registrations could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Entity registrations could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/products": {
      "get": {
        "tags": [
          "Products"
        ],
        "operationId": "listCustomProducts",
        "summary": "List custom products",
        "description": "List customer-defined products scoped to the workspace or a legal entity. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "archived"
              ]
            }
          },
          {
            "name": "baseItemKey",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Custom products retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductsListResponse"
                },
                "examples": {
                  "list": {
                    "summary": "Custom product list",
                    "value": {
                      "count": 1,
                      "products": [
                        {
                          "productId": "prd_0123456789abcdef0123456789abcdef",
                          "entityId": "ent_0123456789abcdef0123456789abcdef",
                          "productCode": "enterprise_saas_seat",
                          "name": "Enterprise SaaS Seat",
                          "description": "Annual per-seat cloud platform subscription.",
                          "baseItemKey": "saas",
                          "defaultTreatment": "taxable",
                          "status": "active",
                          "metadata": {
                            "lineOfBusiness": "cloud"
                          },
                          "createdAt": 1760000000000,
                          "updatedAt": 1760000000000,
                          "archivedAt": null
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom products requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom products requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom products requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, POST."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Products"
        ],
        "operationId": "createCustomProduct",
        "summary": "Create a custom product",
        "description": "Create a customer-defined product code mapped to an optional platform baseItemKey and default tax treatment. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 8,192 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomProductRequest"
              },
              "examples": {
                "saasSeat": {
                  "summary": "Enterprise SaaS SKU",
                  "value": {
                    "productCode": "enterprise_saas_seat",
                    "name": "Enterprise SaaS Seat",
                    "description": "Annual per-seat cloud platform subscription.",
                    "entityId": "ent_0123456789abcdef0123456789abcdef",
                    "baseItemKey": "saas",
                    "defaultTreatment": "taxable",
                    "metadata": {
                      "lineOfBusiness": "cloud"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Custom product created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomProductResponse"
                },
                "examples": {
                  "created": {
                    "summary": "Created custom product",
                    "value": {
                      "product": {
                        "productId": "prd_0123456789abcdef0123456789abcdef",
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "productCode": "enterprise_saas_seat",
                        "name": "Enterprise SaaS Seat",
                        "description": "Annual per-seat cloud platform subscription.",
                        "baseItemKey": "saas",
                        "defaultTreatment": "taxable",
                        "status": "active",
                        "metadata": {
                          "lineOfBusiness": "cloud"
                        },
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "archivedAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom products requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom products requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom products requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Specified entityId was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "The specified entityId was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, POST."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate productCode in scope or product limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "product_code_conflict",
                    "message": "A product with this productCode already exists in this scope."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/products/import": {
      "post": {
        "tags": [
          "Products"
        ],
        "operationId": "importCustomProducts",
        "summary": "Bulk import custom products",
        "description": "Bulk import or upsert up to 100 customer-defined products from JSON rows or RFC 4180 CSV with optional dry-run validation. Maximum request body size is 262,144 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductsImportRequest"
              },
              "examples": {
                "jsonRows": {
                  "summary": "Import custom products from JSON rows",
                  "value": {
                    "format": "json",
                    "dryRun": true,
                    "upsert": true,
                    "rows": [
                      {
                        "productCode": "cloud_seat_pro",
                        "name": "Cloud Seat Pro",
                        "baseItemKey": "saas",
                        "defaultTreatment": "taxable"
                      }
                    ]
                  }
                },
                "csvUpload": {
                  "summary": "Import custom products from CSV",
                  "value": {
                    "format": "csv",
                    "dryRun": true,
                    "csv": "productCode,name,baseItemKey,defaultTreatment\ncloud_seat_pro,Cloud Seat Pro,saas,taxable"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Product import completed (or validated when dryRun is true).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductsImportResponse"
                },
                "example": {
                  "dryRun": true,
                  "upsert": true,
                  "totalRows": 1,
                  "imported": 0,
                  "updated": 0,
                  "valid": 1,
                  "skippedDuplicates": 0,
                  "failed": 0,
                  "results": [
                    {
                      "row": 1,
                      "status": "valid",
                      "productCode": "cloud_seat_pro"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or missing body",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Product imports requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Product imports requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Product imports requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Specified entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST to import custom products."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Multiple entities matched the provided EIN.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_ambiguous",
                    "message": "Multiple entities share this EIN. Specify entityId or entityCode."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 262,144 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 262144 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Product import could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Product import is temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/products/{productId}": {
      "parameters": [
        {
          "name": "productId",
          "in": "path",
          "required": true,
          "description": "Custom product identifier (prd_...).",
          "schema": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          }
        }
      ],
      "get": {
        "tags": [
          "Products"
        ],
        "operationId": "getCustomProduct",
        "summary": "Get a custom product",
        "description": "Retrieve a customer-defined product by ID. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Custom product retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomProductResponse"
                },
                "examples": {
                  "detail": {
                    "summary": "Custom product",
                    "value": {
                      "product": {
                        "productId": "prd_0123456789abcdef0123456789abcdef",
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "productCode": "enterprise_saas_seat",
                        "name": "Enterprise SaaS Seat",
                        "description": "Annual per-seat cloud platform subscription.",
                        "baseItemKey": "saas",
                        "defaultTreatment": "taxable",
                        "status": "active",
                        "metadata": {
                          "lineOfBusiness": "cloud"
                        },
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "archivedAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom products requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom products requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom products requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Custom product was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "product_not_found",
                    "message": "Custom product was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, PATCH, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Products"
        ],
        "operationId": "updateCustomProduct",
        "summary": "Update a custom product",
        "description": "Update a customer-defined product name, description, baseItemKey, default treatment, status, or metadata. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 8,192 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomProductRequest"
              },
              "examples": {
                "updateName": {
                  "summary": "Update name and default treatment",
                  "value": {
                    "name": "Enterprise SaaS Seat (Annual)",
                    "defaultTreatment": "taxable"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Custom product updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomProductResponse"
                },
                "examples": {
                  "updated": {
                    "summary": "Updated custom product",
                    "value": {
                      "product": {
                        "productId": "prd_0123456789abcdef0123456789abcdef",
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "productCode": "enterprise_saas_seat",
                        "name": "Enterprise SaaS Seat",
                        "description": "Annual per-seat cloud platform subscription.",
                        "baseItemKey": "saas",
                        "defaultTreatment": "taxable",
                        "status": "active",
                        "metadata": {
                          "lineOfBusiness": "cloud"
                        },
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "archivedAt": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom products requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom products requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom products requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Custom product was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "product_not_found",
                    "message": "Custom product was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, PATCH, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate active productCode on reactivation or limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "product_code_conflict",
                    "message": "A product with this productCode already exists in this scope."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Products"
        ],
        "operationId": "archiveCustomProduct",
        "summary": "Archive a custom product",
        "description": "Soft-archive a customer-defined product by ID. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Custom product archived.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomProductResponse"
                },
                "examples": {
                  "archived": {
                    "summary": "Archived custom product",
                    "value": {
                      "product": {
                        "productId": "prd_0123456789abcdef0123456789abcdef",
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "productCode": "enterprise_saas_seat",
                        "name": "Enterprise SaaS Seat",
                        "description": "Annual per-seat cloud platform subscription.",
                        "baseItemKey": "saas",
                        "defaultTreatment": "taxable",
                        "status": "archived",
                        "metadata": {
                          "lineOfBusiness": "cloud"
                        },
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000,
                        "archivedAt": 1760000100000
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom products requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom products requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom products requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Custom product was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "product_not_found",
                    "message": "Custom product was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, PATCH, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom products could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rules": {
      "get": {
        "tags": [
          "Custom Rules"
        ],
        "operationId": "listCustomRules",
        "summary": "List custom tax rules",
        "description": "List custom taxability and rate override rules stored for the authenticated account. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          },
          {
            "name": "targetType",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "product",
                "item_key",
                "all"
              ]
            }
          },
          {
            "name": "targetKey",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "jurisdictionScope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all_us",
                "state",
                "county",
                "city",
                "district"
              ]
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 64
            }
          },
          {
            "name": "treatment",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "taxable",
                "exempt",
                "reduced_rate",
                "rate_adjustment"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "disabled"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Custom tax rules retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RulesListResponse"
                },
                "examples": {
                  "list": {
                    "summary": "Custom rule list",
                    "value": {
                      "count": 1,
                      "rules": [
                        {
                          "ruleId": "rul_0123456789abcdef0123456789abcdef",
                          "entityId": "ent_0123456789abcdef0123456789abcdef",
                          "targetType": "product",
                          "targetKey": "enterprise_saas_seat",
                          "jurisdictionScope": "state",
                          "stateCode": "TX",
                          "jurisdictionName": null,
                          "effectiveDate": "2026-01-01",
                          "endDate": null,
                          "buyerType": "b2b",
                          "customerTags": [
                            "enterprise"
                          ],
                          "minUnitAmountDollars": null,
                          "maxUnitAmountDollars": null,
                          "minLineSubtotalDollars": null,
                          "maxLineSubtotalDollars": null,
                          "sourcingType": null,
                          "treatment": "taxable",
                          "reducedRate": null,
                          "reducedRateScope": null,
                          "rateDelta": null,
                          "rateMultiplier": null,
                          "rateScope": null,
                          "thresholdDollars": null,
                          "thresholdMode": null,
                          "taxablePercent": 80,
                          "maxTaxPerUnitDollars": null,
                          "maxTaxPerLineDollars": null,
                          "priority": 50,
                          "status": "active",
                          "note": "Texas 80% taxable data-processing basis for enterprise SaaS seats.",
                          "createdAt": 1760000000000,
                          "updatedAt": 1760000000000
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom tax rules requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, POST."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Custom Rules"
        ],
        "operationId": "createCustomRule",
        "summary": "Create a custom tax rule",
        "description": "Create a custom taxability, reduced-rate, rate-adjustment, threshold, partial taxablePercent, or max-tax cap rule. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 8,192 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomRuleRequest"
              },
              "examples": {
                "texasSaasPartial": {
                  "summary": "Texas 80% taxable basis for B2B enterprise SaaS",
                  "value": {
                    "entityId": "ent_0123456789abcdef0123456789abcdef",
                    "targetType": "product",
                    "targetKey": "enterprise_saas_seat",
                    "jurisdictionScope": "state",
                    "state": "TX",
                    "effectiveDate": "2026-01-01",
                    "buyerType": "b2b",
                    "customerTags": [
                      "enterprise"
                    ],
                    "treatment": "taxable",
                    "taxablePercent": 80,
                    "priority": 50,
                    "note": "Texas 80% taxable data-processing basis for enterprise SaaS seats."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Custom tax rule created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomRuleResponse"
                },
                "examples": {
                  "created": {
                    "summary": "Created rule",
                    "value": {
                      "rule": {
                        "ruleId": "rul_0123456789abcdef0123456789abcdef",
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "targetType": "product",
                        "targetKey": "enterprise_saas_seat",
                        "jurisdictionScope": "state",
                        "stateCode": "TX",
                        "jurisdictionName": null,
                        "effectiveDate": "2026-01-01",
                        "endDate": null,
                        "buyerType": "b2b",
                        "customerTags": [
                          "enterprise"
                        ],
                        "minUnitAmountDollars": null,
                        "maxUnitAmountDollars": null,
                        "minLineSubtotalDollars": null,
                        "maxLineSubtotalDollars": null,
                        "sourcingType": null,
                        "treatment": "taxable",
                        "reducedRate": null,
                        "reducedRateScope": null,
                        "rateDelta": null,
                        "rateMultiplier": null,
                        "rateScope": null,
                        "thresholdDollars": null,
                        "thresholdMode": null,
                        "taxablePercent": 80,
                        "maxTaxPerUnitDollars": null,
                        "maxTaxPerLineDollars": null,
                        "priority": 50,
                        "status": "active",
                        "note": "Texas 80% taxable data-processing basis for enterprise SaaS seats.",
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom tax rules requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Specified entityId was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "The specified entityId was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, POST."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            }
          },
          "409": {
            "description": "Custom tax rule limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rule_limit_reached",
                    "message": "Custom tax rule limit reached (2000 rules per account)."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rules/{ruleId}": {
      "parameters": [
        {
          "name": "ruleId",
          "in": "path",
          "required": true,
          "description": "Custom tax rule identifier (rul_...).",
          "schema": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          }
        }
      ],
      "get": {
        "tags": [
          "Custom Rules"
        ],
        "operationId": "getCustomRule",
        "summary": "Get a custom tax rule",
        "description": "Retrieve a custom tax rule by ID. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Custom tax rule retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomRuleResponse"
                },
                "examples": {
                  "detail": {
                    "summary": "Custom rule",
                    "value": {
                      "rule": {
                        "ruleId": "rul_0123456789abcdef0123456789abcdef",
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "targetType": "product",
                        "targetKey": "enterprise_saas_seat",
                        "jurisdictionScope": "state",
                        "stateCode": "TX",
                        "jurisdictionName": null,
                        "effectiveDate": "2026-01-01",
                        "endDate": null,
                        "buyerType": "b2b",
                        "customerTags": [
                          "enterprise"
                        ],
                        "minUnitAmountDollars": null,
                        "maxUnitAmountDollars": null,
                        "minLineSubtotalDollars": null,
                        "maxLineSubtotalDollars": null,
                        "sourcingType": null,
                        "treatment": "taxable",
                        "reducedRate": null,
                        "reducedRateScope": null,
                        "rateDelta": null,
                        "rateMultiplier": null,
                        "rateScope": null,
                        "thresholdDollars": null,
                        "thresholdMode": null,
                        "taxablePercent": 80,
                        "maxTaxPerUnitDollars": null,
                        "maxTaxPerLineDollars": null,
                        "priority": 50,
                        "status": "active",
                        "note": "Texas 80% taxable data-processing basis for enterprise SaaS seats.",
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom tax rules requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Custom tax rule was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rule_not_found",
                    "message": "Custom tax rule was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, PATCH, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Custom Rules"
        ],
        "operationId": "updateCustomRule",
        "summary": "Update a custom tax rule",
        "description": "Update a custom tax rule scope, conditions, treatment, rate overrides, priority, or status. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 8,192 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomRuleRequest"
              },
              "examples": {
                "disableRule": {
                  "summary": "Disable rule and adjust priority",
                  "value": {
                    "status": "disabled",
                    "priority": 200
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Custom tax rule updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomRuleResponse"
                },
                "examples": {
                  "updated": {
                    "summary": "Updated rule",
                    "value": {
                      "rule": {
                        "ruleId": "rul_0123456789abcdef0123456789abcdef",
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "targetType": "product",
                        "targetKey": "enterprise_saas_seat",
                        "jurisdictionScope": "state",
                        "stateCode": "TX",
                        "jurisdictionName": null,
                        "effectiveDate": "2026-01-01",
                        "endDate": null,
                        "buyerType": "b2b",
                        "customerTags": [
                          "enterprise"
                        ],
                        "minUnitAmountDollars": null,
                        "maxUnitAmountDollars": null,
                        "minLineSubtotalDollars": null,
                        "maxLineSubtotalDollars": null,
                        "sourcingType": null,
                        "treatment": "taxable",
                        "reducedRate": null,
                        "reducedRateScope": null,
                        "rateDelta": null,
                        "rateMultiplier": null,
                        "rateScope": null,
                        "thresholdDollars": null,
                        "thresholdMode": null,
                        "taxablePercent": 80,
                        "maxTaxPerUnitDollars": null,
                        "maxTaxPerLineDollars": null,
                        "priority": 200,
                        "status": "disabled",
                        "note": "Texas 80% taxable data-processing basis for enterprise SaaS seats.",
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom tax rules requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Custom tax rule or entity was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rule_not_found",
                    "message": "Custom tax rule was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, PATCH, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            }
          },
          "409": {
            "description": "Custom tax rule limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rule_limit_reached",
                    "message": "Custom tax rule limit reached (2000 rules per account)."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Custom Rules"
        ],
        "operationId": "deleteCustomRule",
        "summary": "Delete a custom tax rule",
        "description": "Permanently delete a custom tax rule by ID. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "Custom tax rule deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteCustomRuleResponse"
                },
                "examples": {
                  "deleted": {
                    "summary": "Deleted rule",
                    "value": {
                      "deleted": true,
                      "ruleId": "rul_0123456789abcdef0123456789abcdef"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom tax rules requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Custom tax rule was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rule_not_found",
                    "message": "Custom tax rule was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use GET, PATCH, DELETE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET, PATCH, DELETE."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rules could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rules/test": {
      "post": {
        "tags": [
          "Custom Rules"
        ],
        "operationId": "testCustomRule",
        "summary": "Test custom tax rules (dry-run)",
        "description": "Dry-run custom tax rule matching and preview the winning rule, precedence trace, and estimated effective rate and tax. Requires the Starter plan or higher. Always free (0 billable requests). Maximum body size is 8,192 bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestCustomRuleRequest"
              },
              "examples": {
                "texasEnterpriseSaas": {
                  "summary": "Test B2B Texas SaaS rule",
                  "value": {
                    "state": "TX",
                    "entityId": "ent_0123456789abcdef0123456789abcdef",
                    "productCode": "enterprise_saas_seat",
                    "transactionDate": "2026-10-06",
                    "buyerType": "b2b",
                    "customerTags": [
                      "enterprise"
                    ],
                    "unitAmount": 100,
                    "quantity": 1,
                    "baseStateRate": 0.0625,
                    "baseLocalRate": 0.02
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rule test completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleTestResponse"
                },
                "examples": {
                  "matched": {
                    "summary": "Matched custom rule",
                    "value": {
                      "matched": true,
                      "rule": {
                        "ruleId": "rul_0123456789abcdef0123456789abcdef",
                        "entityId": "ent_0123456789abcdef0123456789abcdef",
                        "targetType": "product",
                        "targetKey": "enterprise_saas_seat",
                        "jurisdictionScope": "state",
                        "stateCode": "TX",
                        "jurisdictionName": null,
                        "effectiveDate": "2026-01-01",
                        "endDate": null,
                        "buyerType": "b2b",
                        "customerTags": [
                          "enterprise"
                        ],
                        "minUnitAmountDollars": null,
                        "maxUnitAmountDollars": null,
                        "minLineSubtotalDollars": null,
                        "maxLineSubtotalDollars": null,
                        "sourcingType": null,
                        "treatment": "taxable",
                        "reducedRate": null,
                        "reducedRateScope": null,
                        "rateDelta": null,
                        "rateMultiplier": null,
                        "rateScope": null,
                        "thresholdDollars": null,
                        "thresholdMode": null,
                        "taxablePercent": 80,
                        "maxTaxPerUnitDollars": null,
                        "maxTaxPerLineDollars": null,
                        "priority": 50,
                        "status": "active",
                        "note": "Texas 80% taxable data-processing basis for enterprise SaaS seats.",
                        "createdAt": 1760000000000,
                        "updatedAt": 1760000000000
                      },
                      "summary": "TX product enterprise_saas_seat (b2b, tags: enterprise): taxable (80% taxable)",
                      "matchedJurisdiction": null,
                      "entityScope": "exact",
                      "candidatesEvaluated": 3,
                      "matchedCount": 1,
                      "reason": "Matched exact entity state rule for product enterprise_saas_seat.",
                      "preview": {
                        "baseCombinedRate": 0.0825,
                        "effectiveCombinedRate": 0.066,
                        "effectiveStateRate": 0.05,
                        "effectiveLocalRate": 0.016,
                        "subtotalDollars": 100,
                        "taxableAmountDollars": 80,
                        "exemptAmountDollars": 20,
                        "estimatedTaxDollars": 6.6,
                        "taxCapped": false
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, path parameters, query parameters, or input fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "Request parameters or body fields are invalid."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid, or revoked API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication scheme required.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            }
          },
          "403": {
            "description": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode) (plan_upgrade_required), or the request is forbidden by API key entity scope or cross-origin session rules (forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Custom tax rules requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Custom tax rules requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by entity scope or cross-origin session",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Session requests must come from this site."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Specified entityId was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "The specified entityId was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method. Use POST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST."
                  }
                }
              }
            },
            "headers": {
              "Allow": {
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request limit reached. Wait for the Retry-After delay before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            }
          },
          "502": {
            "description": "The backend service could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rule testing could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "The service is temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Custom tax rule testing could not be reached. Try again."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/integrations/connections": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "operationId": "listCommerceConnections",
        "summary": "List commerce connections",
        "description": "List configured Stripe and Shopify commerce connections for the account. Never exposes webhook signing secrets. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "provider",
            "in": "query",
            "required": false,
            "description": "Filter by commerce provider (stripe or shopify).",
            "schema": {
              "type": "string",
              "enum": [
                "stripe",
                "shopify"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by connection status (active or paused).",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "paused"
              ]
            }
          },
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Filter by legal entity ID (ent_...).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of configured commerce connections.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionsListResponse"
                },
                "example": {
                  "count": 1,
                  "connections": [
                    {
                      "connectionId": "conn_0123456789abcdef01234567",
                      "entityId": "ent_0123456789abcdef0123456789abcdef",
                      "provider": "stripe",
                      "label": "Stripe US Production",
                      "status": "active",
                      "syncMode": "commit",
                      "webhookSecretLast4": "9f3a",
                      "ingestPath": "/api/integrations/webhook/conn_0123456789abcdef01234567",
                      "syncedCount": 42,
                      "lastSyncedAt": 1776211200000,
                      "createdAt": 1775001600000,
                      "updatedAt": 1776211200000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid path parameter or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Invalid parameter value."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Query parameters are not supported on this endpoint."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Commerce connections requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Commerce connections requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Commerce connections requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to list commerce connections or POST to create one."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Commerce connections could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Integrations are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Integrations"
        ],
        "operationId": "createCommerceConnection",
        "summary": "Create a commerce connection",
        "description": "Create a Stripe or Shopify commerce connector and return its ingestPath and webhookSigningSecret for HMAC-SHA256 webhook verification. Supply your Stripe (`whsec_...`) or Shopify signing secret in `webhookSecret`, or omit it to generate a random one-time secret. Maximum request body size is 8,192 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCommerceConnectionRequest"
              },
              "examples": {
                "stripeConnection": {
                  "summary": "Create a Stripe commerce connection",
                  "value": {
                    "provider": "stripe",
                    "label": "Stripe US Production",
                    "syncMode": "commit"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Commerce connection created with one-time webhookSigningSecret.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionResponse"
                },
                "example": {
                  "connection": {
                    "connectionId": "conn_0123456789abcdef01234567",
                    "entityId": null,
                    "provider": "stripe",
                    "label": "Stripe US Production",
                    "status": "active",
                    "syncMode": "commit",
                    "webhookSecretLast4": "9f3a",
                    "ingestPath": "/api/integrations/webhook/conn_0123456789abcdef01234567",
                    "syncedCount": 0,
                    "lastSyncedAt": null,
                    "createdAt": 1775001600000,
                    "updatedAt": 1775001600000
                  },
                  "webhookSigningSecret": "whsec_0123456789abcdef0123456789abcdef0123456789ab9f3a"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or missing body",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Commerce connections requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Commerce connections requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Commerce connections requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Specified entity was not found or is archived.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "entity_not_found",
                    "message": "Entity was not found or is archived."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to list commerce connections or POST to create one."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Account commerce connection limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "connection_limit_reached",
                    "message": "Commerce connection limit reached (25 connections per account)."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Commerce connections could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Integrations are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/integrations/connections/{connectionId}": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "operationId": "getCommerceConnection",
        "summary": "Get a commerce connection",
        "description": "Retrieve metadata, sync counts, and webhook ingestPath for a single commerce connection by ID. Never exposes webhook signing secrets. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "description": "Commerce connection identifier (conn_...).",
            "schema": {
              "type": "string",
              "pattern": "^conn_[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Commerce connection details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionResponse"
                },
                "example": {
                  "connection": {
                    "connectionId": "conn_0123456789abcdef01234567",
                    "entityId": null,
                    "provider": "stripe",
                    "label": "Stripe US Production",
                    "status": "active",
                    "syncMode": "commit",
                    "webhookSecretLast4": "9f3a",
                    "ingestPath": "/api/integrations/webhook/conn_0123456789abcdef01234567",
                    "syncedCount": 42,
                    "lastSyncedAt": 1776211200000,
                    "createdAt": 1775001600000,
                    "updatedAt": 1776211200000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid path parameter or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Invalid parameter value."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Query parameters are not supported on this endpoint."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Commerce connections requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Commerce connections requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Commerce connections requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Commerce connection was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "connection_not_found",
                    "message": "Commerce connection was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, PATCH, DELETE.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to inspect, PATCH to update, or DELETE to remove a connection."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Commerce connections could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Integrations are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Integrations"
        ],
        "operationId": "updateCommerceConnection",
        "summary": "Update a commerce connection",
        "description": "Update a commerce connection label, status (active or paused), syncMode (commit or dry_run), set a merchant-supplied provider webhookSecret, or rotate its generated webhookSigningSecret (returned once when rotateSecret is true). Maximum request body size is 8,192 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "description": "Commerce connection identifier (conn_...).",
            "schema": {
              "type": "string",
              "pattern": "^conn_[a-f0-9]{24}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCommerceConnectionRequest"
              },
              "examples": {
                "pauseAndRotate": {
                  "summary": "Update status and rotate webhook signing secret",
                  "value": {
                    "status": "paused",
                    "rotateSecret": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Commerce connection updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionResponse"
                },
                "example": {
                  "connection": {
                    "connectionId": "conn_0123456789abcdef01234567",
                    "entityId": null,
                    "provider": "stripe",
                    "label": "Stripe US Production",
                    "status": "paused",
                    "syncMode": "commit",
                    "webhookSecretLast4": "4c1e",
                    "ingestPath": "/api/integrations/webhook/conn_0123456789abcdef01234567",
                    "syncedCount": 42,
                    "lastSyncedAt": 1776211200000,
                    "createdAt": 1775001600000,
                    "updatedAt": 1776297600000
                  },
                  "webhookSigningSecret": "whsec_abcdef0123456789abcdef0123456789abcdef0123454c1e"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or missing body",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Commerce connections requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Commerce connections requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Commerce connections requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Commerce connection was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "connection_not_found",
                    "message": "Commerce connection was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, PATCH, DELETE.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to inspect, PATCH to update, or DELETE to remove a connection."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 8192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Commerce connections could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Integrations are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Integrations"
        ],
        "operationId": "deleteCommerceConnection",
        "summary": "Delete a commerce connection",
        "description": "Permanently delete a commerce connection and disable its webhook ingestion endpoint. Previously synced transactions remain in the ledger. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "description": "Commerce connection identifier (conn_...).",
            "schema": {
              "type": "string",
              "pattern": "^conn_[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Commerce connection deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionDeleteResponse"
                },
                "example": {
                  "deleted": true,
                  "connectionId": "conn_0123456789abcdef01234567"
                }
              }
            }
          },
          "400": {
            "description": "Invalid path parameter or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Invalid parameter value."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Query parameters are not supported on this endpoint."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Commerce connections requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Commerce connections requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Commerce connections requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Commerce connection was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "connection_not_found",
                    "message": "Commerce connection was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, PATCH, DELETE.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to inspect, PATCH to update, or DELETE to remove a connection."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Commerce connections could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Integrations are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/integrations/connections/{connectionId}/sync": {
      "post": {
        "tags": [
          "Integrations"
        ],
        "operationId": "syncCommerceConnection",
        "summary": "Sync commerce connection events",
        "description": "Batch-sync 1 to 100 Stripe or Shopify events into the tax transaction ledger with exact-cent parsing, idempotent externalId deduplication, filing-period lock checks, and optional dryRun preview. Maximum request body size is 524,288 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "description": "Commerce connection identifier (conn_...).",
            "schema": {
              "type": "string",
              "pattern": "^conn_[a-f0-9]{24}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SyncCommerceConnectionRequest"
              },
              "examples": {
                "stripeSync": {
                  "summary": "Dry-run sync of a Stripe paid invoice event",
                  "value": {
                    "dryRun": true,
                    "events": [
                      {
                        "type": "invoice.paid",
                        "data": {
                          "object": {
                            "id": "in_001",
                            "created": 1776211200,
                            "currency": "usd",
                            "subtotal": 10000,
                            "tax": 750,
                            "total": 10750,
                            "customer": "cus_acme_01",
                            "customer_address": {
                              "state": "FL",
                              "country": "US"
                            }
                          }
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Commerce events processed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionSyncResponse"
                },
                "example": {
                  "connectionId": "conn_0123456789abcdef01234567",
                  "provider": "stripe",
                  "syncMode": "commit",
                  "received": 1,
                  "committed": 0,
                  "dryRunCount": 1,
                  "duplicates": 0,
                  "locked": 0,
                  "skipped": 0,
                  "dryRun": true,
                  "results": [
                    {
                      "index": 0,
                      "externalId": "stripe:in_001",
                      "status": "dry_run",
                      "type": "sale",
                      "stateCode": "FL",
                      "transactionDate": "2026-04-15",
                      "subtotalCents": 10000,
                      "taxAmountCents": 750,
                      "totalCents": 10750
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or missing body",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Commerce connection sync requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Commerce connection sync requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Commerce connection sync requires the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This API key or workspace role is not authorized for the requested action."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Commerce connection was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "connection_not_found",
                    "message": "Commerce connection was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST with a JSON body to sync commerce events."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 524,288 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 524288 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Content-Type header is not application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Commerce connection sync could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Integrations are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhooks",
        "summary": "List webhook endpoints",
        "description": "List configured signed outbound HTTPS webhook endpoints for the workspace without exposing signing secrets. Requires the Starter plan or higher. Always free (0 billable requests).",
        "responses": {
          "200": {
            "description": "List of configured webhook endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhooksListResponse"
                },
                "example": {
                  "count": 1,
                  "webhooks": [
                    {
                      "webhookId": "whk_0123456789abcdef01234567",
                      "url": "https://hooks.example.com/netamount",
                      "description": "Production compliance alerts",
                      "events": [
                        "nexus.exceeded",
                        "filing.due_soon"
                      ],
                      "signingSecretLast4": "9f3a",
                      "status": "active",
                      "consecutiveFailures": 0,
                      "lastDeliveryAt": 1776211200000,
                      "lastSuccessAt": 1776211200000,
                      "createdAt": 1775001600000,
                      "updatedAt": 1776211200000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Query parameters are not supported on this endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_request",
                    "message": "Query parameters are not supported on this endpoint."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Outbound webhooks requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Outbound webhooks requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Outbound webhooks require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This credential is not authorized to manage workspace webhooks."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to list webhook endpoints or POST to create one."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "createWebhook",
        "summary": "Create a webhook endpoint",
        "description": "Create a signed outbound HTTPS webhook endpoint (up to 15 per workspace) and return its one-time HMAC-SHA256 signingSecret used to verify `X-NetAmount-Signature` (`t=<unix_sec>,v1=<hex_hmac_sha256>`) headers. All live and test deliveries send a canonical `WebhookEventEnvelope` (`#/components/schemas/WebhookEventEnvelope`) JSON body. Destination URLs must use public HTTPS on port 443 without credentials or private/loopback addresses; deliveries also verify DNS-resolved IPs against private/reserved ranges before connecting, use `redirect: \"manual\"` (3xx rejected), and enforce an 8-second timeout. Failed deliveries retry up to 5 attempts with exponential backoff, and endpoints auto-disable after 20 consecutive dead-lettered deliveries. Maximum request body size is 8,192 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              },
              "examples": {
                "complianceAlerts": {
                  "summary": "Subscribe to nexus and filing webhook events",
                  "value": {
                    "url": "https://hooks.example.com/netamount",
                    "events": [
                      "nexus.exceeded",
                      "filing.due_soon"
                    ],
                    "description": "Production compliance alerts"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook endpoint created with one-time signingSecret.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                },
                "example": {
                  "webhook": {
                    "webhookId": "whk_0123456789abcdef01234567",
                    "url": "https://hooks.example.com/netamount",
                    "description": "Production compliance alerts",
                    "events": [
                      "nexus.exceeded",
                      "filing.due_soon"
                    ],
                    "signingSecretLast4": "9f3a",
                    "status": "active",
                    "consecutiveFailures": 0,
                    "lastDeliveryAt": null,
                    "lastSuccessAt": null,
                    "createdAt": 1775001600000,
                    "updatedAt": 1776211200000
                  },
                  "signingSecret": "whsec_0123456789abcdef0123456789abcdef0123456789ab9f3a"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or invalid request",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Outbound webhooks requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Outbound webhooks requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Outbound webhooks require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This credential is not authorized to manage workspace webhooks."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to list webhook endpoints or POST to create one."
                  }
                }
              }
            }
          },
          "409": {
            "description": "Workspace webhook endpoint limit reached (15 endpoints).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "webhook_limit_reached",
                    "message": "Webhook endpoint limit reached (15 endpoints per workspace)."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds the maximum size limit of 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 8,192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Request Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{webhookId}": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getWebhook",
        "summary": "Get a webhook endpoint",
        "description": "Retrieve a single outbound webhook endpoint by ID without exposing its signing secret. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "Webhook endpoint identifier (whk_...).",
            "schema": {
              "type": "string",
              "pattern": "^whk_[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook endpoint details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                },
                "example": {
                  "webhook": {
                    "webhookId": "whk_0123456789abcdef01234567",
                    "url": "https://hooks.example.com/netamount",
                    "description": "Production compliance alerts",
                    "events": [
                      "nexus.exceeded",
                      "filing.due_soon"
                    ],
                    "signingSecretLast4": "9f3a",
                    "status": "active",
                    "consecutiveFailures": 0,
                    "lastDeliveryAt": 1776211200000,
                    "lastSuccessAt": 1776211200000,
                    "createdAt": 1775001600000,
                    "updatedAt": 1776211200000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid path parameter or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Invalid parameter value."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Query parameters are not supported on this endpoint."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Outbound webhooks requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Outbound webhooks requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Outbound webhooks require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This credential is not authorized to manage workspace webhooks."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Webhook endpoint was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "webhook_not_found",
                    "message": "Webhook endpoint was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, PATCH, DELETE.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to inspect, PATCH to update, or DELETE to remove a webhook endpoint."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "updateWebhook",
        "summary": "Update a webhook endpoint",
        "description": "Update an outbound webhook endpoint URL, subscribed events, description (pass null to clear), or status (setting status to `active` resets `consecutiveFailures` to 0), or set `rotateSecret: true` to generate and return a new one-time `signingSecret`. Maximum request body size is 8,192 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "Webhook endpoint identifier (whk_...).",
            "schema": {
              "type": "string",
              "pattern": "^whk_[a-f0-9]{24}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebhookRequest"
              },
              "examples": {
                "updateEventsAndStatus": {
                  "summary": "Update subscribed events and reactivate endpoint",
                  "value": {
                    "events": [
                      "nexus.approaching",
                      "nexus.exceeded",
                      "exemption.expiring_soon"
                    ],
                    "status": "active",
                    "description": "Updated compliance endpoint"
                  }
                },
                "rotateSecret": {
                  "summary": "Rotate the HMAC-SHA256 signing secret",
                  "value": {
                    "rotateSecret": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhook endpoint updated. Includes one-time signingSecret only when rotateSecret is true.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                },
                "example": {
                  "webhook": {
                    "webhookId": "whk_0123456789abcdef01234567",
                    "url": "https://hooks.example.com/netamount",
                    "description": "Production compliance alerts",
                    "events": [
                      "nexus.exceeded",
                      "filing.due_soon"
                    ],
                    "signingSecretLast4": "4c1e",
                    "status": "active",
                    "consecutiveFailures": 0,
                    "lastDeliveryAt": 1776211200000,
                    "lastSuccessAt": 1776211200000,
                    "createdAt": 1775001600000,
                    "updatedAt": 1776211200000
                  },
                  "signingSecret": "whsec_abcdef0123456789abcdef0123456789abcdef0123454c1e"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or invalid request",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Outbound webhooks requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Outbound webhooks requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Outbound webhooks require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This credential is not authorized to manage workspace webhooks."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Webhook endpoint was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "webhook_not_found",
                    "message": "Webhook endpoint was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, PATCH, DELETE.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to inspect, PATCH to update, or DELETE to remove a webhook endpoint."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds the maximum size limit of 8,192 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 8,192 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Request Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "deleteWebhook",
        "summary": "Delete a webhook endpoint",
        "description": "Permanently delete an outbound webhook endpoint by ID. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "Webhook endpoint identifier (whk_...).",
            "schema": {
              "type": "string",
              "pattern": "^whk_[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook endpoint deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeleteResponse"
                },
                "example": {
                  "deleted": true,
                  "webhookId": "whk_0123456789abcdef01234567"
                }
              }
            }
          },
          "400": {
            "description": "Invalid path parameter or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Invalid parameter value."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Query parameters are not supported on this endpoint."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Outbound webhooks requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Outbound webhooks requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Outbound webhooks require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This credential is not authorized to manage workspace webhooks."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Webhook endpoint was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "webhook_not_found",
                    "message": "Webhook endpoint was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET, PATCH, DELETE.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET, PATCH, DELETE"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to inspect, PATCH to update, or DELETE to remove a webhook endpoint."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{webhookId}/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "listWebhookDeliveries",
        "summary": "List webhook deliveries",
        "description": "List recent outbound webhook delivery attempts, HTTP statuses, retry schedules, and sanitized error messages for a webhook endpoint. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "Webhook endpoint identifier (whk_...).",
            "schema": {
              "type": "string",
              "pattern": "^whk_[a-f0-9]{24}$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter deliveries by delivery status.",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "succeeded",
                "retrying",
                "failed"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of deliveries to return (1-100, default 25).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recent webhook deliveries for the endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveriesListResponse"
                },
                "example": {
                  "webhookId": "whk_0123456789abcdef01234567",
                  "count": 1,
                  "deliveries": [
                    {
                      "deliveryId": "dlv_0123456789abcdef01234567",
                      "webhookId": "whk_0123456789abcdef01234567",
                      "eventId": "evt_0123456789abcdef01234567",
                      "eventType": "webhook.test",
                      "status": "succeeded",
                      "attemptCount": 1,
                      "maxAttempts": 1,
                      "nextAttemptAt": null,
                      "lastHttpStatus": 200,
                      "lastError": null,
                      "deliveredAt": 1776211200500,
                      "createdAt": 1776211200000,
                      "updatedAt": 1776211200500
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid path parameter or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Invalid parameter value."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Query parameters are not supported on this endpoint."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Outbound webhooks requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Outbound webhooks requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Outbound webhooks require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This credential is not authorized to manage workspace webhooks."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Webhook endpoint was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "webhook_not_found",
                    "message": "Webhook endpoint was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to list webhook delivery history."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhook deliveries could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{webhookId}/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "testWebhook",
        "summary": "Send a test webhook delivery",
        "description": "Send an immediate HMAC-SHA256 signed test delivery wrapped in the canonical `WebhookEventEnvelope` (`#/components/schemas/WebhookEventEnvelope`) to a webhook endpoint and return the recorded delivery attempt. Accepts an empty request body or an optional JSON object specifying `eventType` (default: `webhook.test`). Enforces the same SSRF protections as live deliveries (HTTPS port 443, DNS-resolved IP verification, `redirect: \"manual\"` rejecting 3xx responses, and 8-second timeout). Test deliveries do not increment `consecutiveFailures` or auto-disable the endpoint. Maximum request body size is 4,096 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "description": "Webhook endpoint identifier (whk_...).",
            "schema": {
              "type": "string",
              "pattern": "^whk_[a-f0-9]{24}$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestWebhookRequest"
              },
              "examples": {
                "defaultTest": {
                  "summary": "Send default webhook.test event",
                  "value": {}
                },
                "customEventType": {
                  "summary": "Send a synthetic nexus.approaching test event",
                  "value": {
                    "eventType": "nexus.approaching"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Test delivery attempt recorded and completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookTestResponse"
                },
                "example": {
                  "delivery": {
                    "deliveryId": "dlv_0123456789abcdef01234567",
                    "webhookId": "whk_0123456789abcdef01234567",
                    "eventId": "evt_0123456789abcdef01234567",
                    "eventType": "webhook.test",
                    "status": "succeeded",
                    "attemptCount": 1,
                    "maxAttempts": 1,
                    "nextAttemptAt": null,
                    "lastHttpStatus": 200,
                    "lastError": null,
                    "deliveredAt": 1776211200500,
                    "createdAt": 1776211200000,
                    "updatedAt": 1776211200500
                  }
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or invalid request",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Outbound webhooks requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Outbound webhooks requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Outbound webhooks require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This credential is not authorized to manage workspace webhooks."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Webhook endpoint was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "webhook_not_found",
                    "message": "Webhook endpoint was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST to send a test webhook delivery."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds the maximum size limit of 4,096 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 4,096 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Request Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhook test delivery could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Webhooks are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/alerts": {
      "get": {
        "tags": [
          "Alerts"
        ],
        "operationId": "listComplianceAlerts",
        "summary": "List compliance alerts",
        "description": "List proactive compliance alerts (economic nexus approaching/exceeded, filing due soon, expiring exemption certificates, and monthly quota warnings) with an `openCount` summary and optional filters. Entity-scoped nexus, filing, and exemption alerts carry `entityId` (visible to entity-restricted API keys and entity-filtered views), while workspace-level quota alerts and unassigned transactions omit `entityId` (`null`). Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by alert status.",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "acknowledged"
              ]
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Filter by compliance alert category.",
            "schema": {
              "type": "string",
              "enum": [
                "nexus",
                "filing",
                "exemption",
                "quota"
              ]
            }
          },
          {
            "name": "severity",
            "in": "query",
            "required": false,
            "description": "Filter by severity level.",
            "schema": {
              "type": "string",
              "enum": [
                "info",
                "warning",
                "critical"
              ]
            }
          },
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Filter by legal entity ID (ent_...).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of alerts to return (1-100, default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered list of compliance alerts and workspace open alert count.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlertsListResponse"
                },
                "example": {
                  "count": 1,
                  "openCount": 1,
                  "alerts": [
                    {
                      "alertId": "alt_0123456789abcdef01234567",
                      "category": "nexus",
                      "severity": "critical",
                      "eventType": "nexus.exceeded",
                      "entityId": "ent_0123456789abcdef0123456789abcdef",
                      "stateCode": "FL",
                      "resourceId": null,
                      "title": "Florida economic nexus threshold exceeded",
                      "message": "Trailing-12-month Florida sales reached $112,450.00 against the $100,000.00 statutory threshold.",
                      "status": "open",
                      "acknowledgedAt": null,
                      "acknowledgedBy": null,
                      "metadata": {
                        "salesDollars": 112450,
                        "thresholdDollars": 100000,
                        "percentOfThreshold": 112.45
                      },
                      "createdAt": 1776211200000,
                      "updatedAt": 1776211200000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid path parameter or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Invalid parameter value."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Query parameters are not supported on this endpoint."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Compliance alerts requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Compliance alerts requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Compliance alerts require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This credential is not authorized to access the requested alert scope."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to list compliance alerts."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Compliance alerts could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Compliance alerts are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/alerts/{alertId}/acknowledge": {
      "post": {
        "tags": [
          "Alerts"
        ],
        "operationId": "acknowledgeComplianceAlert",
        "summary": "Acknowledge a compliance alert",
        "description": "Mark a proactive compliance alert as acknowledged. Calling acknowledge on an already acknowledged alert is idempotent and returns the existing alert. Accepts an empty request body or `{}`. Maximum request body size is 4,096 bytes. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "alertId",
            "in": "path",
            "required": true,
            "description": "Compliance alert identifier (alt_...).",
            "schema": {
              "type": "string",
              "pattern": "^alt_[a-f0-9]{24}$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {}
              },
              "examples": {
                "emptyObject": {
                  "summary": "Empty JSON object body",
                  "value": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Compliance alert acknowledged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlertResponse"
                },
                "example": {
                  "alert": {
                    "alertId": "alt_0123456789abcdef01234567",
                    "category": "nexus",
                    "severity": "critical",
                    "eventType": "nexus.exceeded",
                    "entityId": "ent_0123456789abcdef0123456789abcdef",
                    "stateCode": "FL",
                    "resourceId": null,
                    "title": "Florida economic nexus threshold exceeded",
                    "message": "Trailing-12-month Florida sales reached $112,450.00 against the $100,000.00 statutory threshold.",
                    "status": "acknowledged",
                    "acknowledgedAt": 1776214800000,
                    "acknowledgedBy": "api_key",
                    "metadata": {
                      "salesDollars": 112450,
                      "thresholdDollars": 100000,
                      "percentOfThreshold": 112.45
                    },
                    "createdAt": 1776211200000,
                    "updatedAt": 1776214800000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid input fields, or unsupported query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid input field",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "Request body failed input validation."
                      }
                    }
                  },
                  "invalidJson": {
                    "summary": "Malformed JSON",
                    "value": {
                      "error": {
                        "code": "invalid_json",
                        "message": "The request body must contain valid JSON."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter or invalid request",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "A JSON request body is required."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Compliance alerts requires the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), or the credential lacks permission for the requested scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Compliance alerts requires Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Compliance alerts require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "This credential is not authorized to access the requested alert scope."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Compliance alert was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "alert_not_found",
                    "message": "Compliance alert was not found."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use POST.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use POST to acknowledge a compliance alert."
                  }
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds the maximum size limit of 4,096 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "request_too_large",
                    "message": "The request body must not exceed 4,096 bytes."
                  }
                }
              }
            }
          },
          "415": {
            "description": "Request Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unsupported_media_type",
                    "message": "Use Content-Type: application/json."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit exceeded. Retry after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Compliance alerts could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Compliance alerts are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/audit-logs": {
      "get": {
        "tags": [
          "Audit Logs"
        ],
        "operationId": "listAuditLogs",
        "summary": "List workspace audit logs (JSON or CSV)",
        "description": "List immutable workspace audit log entries ordered newest-first with opaque cursor pagination (`hasMore`, `nextCursor`) and optional RFC 4180 CSV export (`format=csv`). Filter by exact `action`, `resourceType`, `entityId`, and inclusive UTC calendar dates (`from`, `to`). JSON responses return 1-100 entries (default 50); CSV exports return 1-1000 entries (default 500) and emit `X-Truncated: true` and `X-Next-Cursor` headers when additional rows match. Organization dashboard sessions require the Admin role (personal workspace owners resolve to `admin`; `403 forbidden` for lower roles). Entity-restricted API keys only see entries bound to their allowed entities. Requires the Starter plan or higher. Always free (0 billable requests).",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": false,
            "description": "Filter by exact audit action name (e.g., entity.created, filing.marked_filed, webhook.created, alert.acknowledged).",
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9._]{1,80}$"
            }
          },
          {
            "name": "resourceType",
            "in": "query",
            "required": false,
            "description": "Filter by audited resource type.",
            "schema": {
              "type": "string",
              "enum": [
                "entity",
                "registration",
                "product",
                "rule",
                "exemption",
                "transaction",
                "filing",
                "api_key",
                "webhook",
                "connection",
                "team_member",
                "alert"
              ]
            }
          },
          {
            "name": "entityId",
            "in": "query",
            "required": false,
            "description": "Filter by legal entity ID (ent_...).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Inclusive start UTC calendar date (YYYY-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Inclusive end UTC calendar date (YYYY-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "Response format: json (default) or csv (RFC 4180 CSV attachment).",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "csv"
              ],
              "default": "json"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of audit log entries to return: 1-100 (default 50) for JSON, 1-1000 (default 500) for CSV.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque unpadded base64url nextCursor token returned by a previous page or X-Next-Cursor CSV header.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered workspace audit log page in JSON or RFC 4180 CSV format.",
            "headers": {
              "X-Truncated": {
                "description": "Present with value \"true\" on CSV exports when more matching audit entries exist beyond the returned rows.",
                "schema": {
                  "type": "string",
                  "const": "true"
                }
              },
              "X-Next-Cursor": {
                "description": "Opaque unpadded base64url cursor header present on truncated CSV exports for fetching the next page.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditLogsListResponse"
                },
                "example": {
                  "count": 1,
                  "hasMore": false,
                  "nextCursor": null,
                  "entries": [
                    {
                      "auditId": "aud_0123456789abcdef01234567",
                      "actorType": "user",
                      "actorId": "user_0123456789abcdef",
                      "actorLabel": "user_0123456789abcdef",
                      "action": "filing.marked_filed",
                      "resourceType": "filing",
                      "resourceId": "flg_0123456789abcdef01234567",
                      "entityId": "ent_0123456789abcdef0123456789abcdef",
                      "summary": "Marked FL Q3 2026 filing as filed",
                      "metadata": {
                        "stateCode": "FL",
                        "periodStart": "2026-07-01",
                        "periodEnd": "2026-09-30"
                      },
                      "createdAt": 1776211200000
                    }
                  ]
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string",
                  "description": "RFC 4180 CSV attachment (`audit-logs.csv`, up to 1,000 rows per request; emits `X-Truncated: true` and `X-Next-Cursor` headers when more rows match) with columns audit_id, created_at, actor_type, actor_id, actor_label, action, resource_type, resource_id, entity_id, summary, and metadata."
                }
              }
            }
          },
          "400": {
            "description": "Invalid or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid query parameter value",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "from must be a valid YYYY-MM-DD calendar date."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Only optional action, resourceType, entityId, from, to, format, limit, and cursor query parameters are supported."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Workspace audit logs require the Starter ($100/region/mo) or Growth plan (or Pro/Enterprise in usage-credits mode), the Admin role for organization sessions (personal workspace owners resolve to `admin`), or permitted API key entity scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "planUpgradeRequired": {
                    "summary": "Workspace audit logs require Starter or Growth (or Pro+ in usage-credits mode)",
                    "value": {
                      "error": {
                        "code": "plan_upgrade_required",
                        "message": "Transaction persistence and audit ledger require the Starter ($100/region/mo) or Growth plan. Start a subscription at https://netamount.com/dashboard/billing."
                      }
                    }
                  },
                  "forbidden": {
                    "summary": "Forbidden by Admin workspace role or API key entity scope",
                    "value": {
                      "error": {
                        "code": "forbidden",
                        "message": "Workspace audit logs require Admin access, or an API key authorized for the requested entity scope."
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to list workspace audit logs."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Audit logs could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "Audit logs are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/logs/requests": {
      "get": {
        "tags": [
          "Request Logs"
        ],
        "operationId": "listApiRequestLogs",
        "summary": "List API request logs",
        "description": "List metadata-only API request logs retained for 30 days (HTTP method, normalized route template, status code, durationMs, authType, API key prefix/label, billed flag, and errorCode — never request/response bodies, query strings, headers, or PII) ordered newest-first with cursor pagination. Logs are scheduled asynchronously via Convex scheduler so the log write does not block the API response; unauthenticated 401 and rate-limited 429 rejections are skipped. Entity-restricted API keys cannot read workspace-wide request logs. Available on all plans (Starter and Growth; or Hobby, Pro, and Enterprise in usage-credits mode). Always free (0 billable requests).",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by exact HTTP status code (200-599) or status class (\"2xx\", \"4xx\", or \"5xx\").",
            "schema": {
              "oneOf": [
                {
                  "type": "integer",
                  "minimum": 200,
                  "maximum": 599
                },
                {
                  "type": "string",
                  "enum": [
                    "2xx",
                    "4xx",
                    "5xx"
                  ]
                }
              ]
            }
          },
          {
            "name": "path",
            "in": "query",
            "required": false,
            "description": "Filter by normalized route template (e.g., /tax/calculate, /exemptions/{certificateId}).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            }
          },
          {
            "name": "keyPrefix",
            "in": "query",
            "required": false,
            "description": "Filter by API key prefix (e.g., na_a1b2c3d4).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            }
          },
          {
            "name": "errorCode",
            "in": "query",
            "required": false,
            "description": "Filter by machine-readable error code (e.g., invalid_input, address_imprecise).",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Inclusive start UTC calendar date (YYYY-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Inclusive end UTC calendar date (YYYY-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of request logs to return (1-100, default 50).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque nextCursor token returned by a previous page.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered page of metadata-only API request logs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRequestLogsListResponse"
                },
                "example": {
                  "count": 1,
                  "hasMore": false,
                  "nextCursor": null,
                  "logs": [
                    {
                      "logId": "log_0123456789abcdef01234567",
                      "authType": "api_key",
                      "keyPrefix": "na_a1b2c3d4",
                      "keyLabel": "Checkout Service",
                      "method": "POST",
                      "path": "/tax/calculate",
                      "statusCode": 200,
                      "durationMs": 42,
                      "billed": true,
                      "errorCode": null,
                      "createdAt": 1776211200000
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid status or date filter",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "status must be an integer between 200 and 599, or \"2xx\", \"4xx\", or \"5xx\"."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Only optional status, path, keyPrefix, errorCode, from, to, limit, and cursor query parameters are supported."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Entity-restricted API keys cannot read workspace-wide request logs, or the workspace role lacks permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Entity-restricted API keys cannot access workspace-wide API request logs."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to list API request logs."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "API request logs could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "API request logs are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/logs/summary": {
      "get": {
        "tags": [
          "Request Logs"
        ],
        "operationId": "getApiRequestLogSummary",
        "summary": "Get API request usage analytics",
        "description": "Aggregate metadata-only API request metrics over a rolling `24h`, `7d` (default), or `30d` window, including total requests, status class counts, success rate, billed volume, p50 and p95 latency, truncation flag (capped at the 5,000 most recent logged requests), and top breakdowns by endpoint, API key, and error code. Request logs are scheduled asynchronously via Convex scheduler so the log write does not block the API response and exclude unauthenticated 401 and rate-limited 429 rejections. Entity-restricted API keys cannot read workspace-wide request analytics. Available on all plans (Starter and Growth; or Hobby, Pro, and Enterprise in usage-credits mode). Always free (0 billable requests).",
        "parameters": [
          {
            "name": "window",
            "in": "query",
            "required": false,
            "description": "Rolling analytics window preset: 24h, 7d (default), or 30d.",
            "schema": {
              "type": "string",
              "enum": [
                "24h",
                "7d",
                "30d"
              ],
              "default": "7d"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Aggregated API request analytics for the selected window.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRequestLogsSummaryResponse"
                },
                "example": {
                  "window": "7d",
                  "windowStart": 1775606400000,
                  "windowEnd": 1776211200000,
                  "totalRequests": 1240,
                  "successCount": 1218,
                  "clientErrorCount": 20,
                  "serverErrorCount": 2,
                  "successRate": 0.9823,
                  "billedCount": 1150,
                  "p50DurationMs": 38,
                  "p95DurationMs": 145,
                  "truncated": false,
                  "byEndpoint": [
                    {
                      "path": "/tax/calculate",
                      "method": "POST",
                      "count": 1150,
                      "errorCount": 12,
                      "avgDurationMs": 44
                    }
                  ],
                  "byKey": [
                    {
                      "authType": "api_key",
                      "keyPrefix": "na_a1b2c3d4",
                      "keyLabel": "Checkout Service",
                      "count": 1200,
                      "errorCount": 18,
                      "billedCount": 1150
                    }
                  ],
                  "byErrorCode": [
                    {
                      "code": "address_imprecise",
                      "count": 12
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid or unsupported query parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "invalidInput": {
                    "summary": "Invalid window parameter",
                    "value": {
                      "error": {
                        "code": "invalid_input",
                        "message": "window must be \"24h\", \"7d\", or \"30d\"."
                      }
                    }
                  },
                  "invalidRequest": {
                    "summary": "Unsupported query parameter",
                    "value": {
                      "error": {
                        "code": "invalid_request",
                        "message": "Only an optional window query parameter is supported."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid Bearer API key or session credential.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Authentication challenge scheme.",
                "schema": {
                  "type": "string",
                  "const": "Bearer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "A valid API key or access token is required."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Entity-restricted API keys cannot read workspace-wide request analytics, or the workspace role lacks permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Entity-restricted API keys cannot access workspace-wide API request logs."
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported HTTP method. Use GET.",
            "headers": {
              "Allow": {
                "description": "Allowed HTTP methods for this endpoint.",
                "schema": {
                  "type": "string",
                  "const": "GET"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "Use GET to view API request usage analytics."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account rate limit exceeded.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Request limit reached. Try again after the indicated delay."
                  }
                }
              }
            }
          },
          "502": {
            "description": "Upstream backend could not be reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "API request analytics could not be reached. Try again."
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "service_unavailable",
                    "message": "API request logs are temporarily unavailable. Try again later."
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Net Amount API key",
        "description": "Create a key at /dashboard/keys. Paste the complete key; the client adds the Bearer prefix."
      }
    },
    "schemas": {
      "Coordinates": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "latitude",
          "longitude"
        ],
        "properties": {
          "latitude": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "longitude": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          }
        }
      },
      "AddressInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "address"
        ],
        "properties": {
          "address": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "Full street address, city, state, and postal code. Trimmed length: 1–500 characters. No control characters."
          }
        }
      },
      "LineItemInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "amount"
        ],
        "not": {
          "required": [
            "taxable",
            "itemKey"
          ]
        },
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "amount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000,
            "description": "Unit price in USD with at most 2 decimal places."
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "taxable": {
            "type": "boolean",
            "description": "Explicit taxable flag (default true when neither taxable nor itemKey is supplied). Cannot be combined with itemKey. Setting `taxable: false` prevents `targetType: \"all\"` custom rules from taxing the line, while narrower `product` or `item_key` rules still apply."
          },
          "itemKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Optional taxability itemKey slug (from GET /taxability/items) resolved from the database. Cannot be combined with taxable."
          },
          "productCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Optional customer-defined productCode resolved from your custom product catalog and custom tax rules (requires Starter or Growth)."
          },
          "discountAmount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000,
            "description": "Optional line-level discount amount in USD with at most 2 decimal places."
          },
          "discountType": {
            "type": "string",
            "enum": [
              "retailer",
              "manufacturer"
            ],
            "description": "Optional line-level discount classification: retailer (default, reduces taxable base) or manufacturer (third-party coupon; reduces taxable base only in CT, MA, MO, PA, TX, and no-sales-tax states)."
          }
        }
      },
      "LocationInput": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/Coordinates"
          },
          {
            "$ref": "#/components/schemas/AddressInput"
          }
        ]
      },
      "TaxSourcingDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "rule",
          "appliedLocation",
          "interstate",
          "originState",
          "destinationState",
          "originCoordinates",
          "destinationCoordinates",
          "note"
        ],
        "properties": {
          "rule": {
            "type": "string",
            "enum": [
              "interstate_destination",
              "intrastate_origin",
              "intrastate_modified_origin",
              "intrastate_destination",
              "unresolved"
            ]
          },
          "appliedLocation": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "shipFrom",
              "shipTo",
              null
            ]
          },
          "interstate": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "originState": {
            "type": [
              "string",
              "null"
            ]
          },
          "destinationState": {
            "type": [
              "string",
              "null"
            ]
          },
          "originCoordinates": {
            "$ref": "#/components/schemas/Coordinates"
          },
          "destinationCoordinates": {
            "$ref": "#/components/schemas/Coordinates"
          },
          "originGeocoding": {
            "$ref": "#/components/schemas/Geocoding",
            "description": "Google Maps attribution and formatted address when shipFrom was supplied as an address."
          },
          "destinationGeocoding": {
            "$ref": "#/components/schemas/Geocoding",
            "description": "Google Maps attribution and formatted address when shipTo was supplied as an address."
          },
          "note": {
            "type": "string"
          }
        }
      },
      "StateEconomicNexusRule": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stateCode",
          "stateName",
          "hasStateSalesTax",
          "hasEconomicNexus",
          "scope",
          "salesThresholdDollars",
          "transactionThreshold",
          "logic",
          "measurementPeriod",
          "note"
        ],
        "properties": {
          "stateCode": {
            "type": "string"
          },
          "stateName": {
            "type": "string"
          },
          "hasStateSalesTax": {
            "type": "boolean"
          },
          "hasEconomicNexus": {
            "type": "boolean"
          },
          "scope": {
            "type": "string",
            "enum": [
              "statewide",
              "local_only",
              "none"
            ]
          },
          "salesThresholdDollars": {
            "type": [
              "integer",
              "null"
            ]
          },
          "transactionThreshold": {
            "type": [
              "integer",
              "null"
            ]
          },
          "logic": {
            "type": "string",
            "enum": [
              "sales_only",
              "sales_or_transactions",
              "sales_and_transactions",
              "none"
            ]
          },
          "measurementPeriod": {
            "type": [
              "string",
              "null"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "NexusThresholdsResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "thresholds",
          "disclaimer"
        ],
        "properties": {
          "count": {
            "type": "integer"
          },
          "thresholds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StateEconomicNexusRule"
            }
          },
          "disclaimer": {
            "type": "string"
          }
        }
      },
      "NexusStateActivityInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "state",
          "sales"
        ],
        "properties": {
          "state": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "sales": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "transactions": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000
          }
        }
      },
      "NexusEvaluateRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "states"
        ],
        "properties": {
          "states": {
            "type": "array",
            "minItems": 1,
            "maxItems": 52,
            "items": {
              "$ref": "#/components/schemas/NexusStateActivityInput"
            }
          },
          "approachingPercent": {
            "type": "integer",
            "minimum": 1,
            "maximum": 99
          }
        }
      },
      "NexusStateEvaluation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stateCode",
          "stateName",
          "status",
          "triggeredBy",
          "sales",
          "transactions",
          "salesPercentOfThreshold",
          "transactionsPercentOfThreshold",
          "threshold",
          "note"
        ],
        "properties": {
          "stateCode": {
            "type": "string"
          },
          "stateName": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "exceeded",
              "approaching",
              "below_threshold",
              "no_nexus_rule",
              "needs_transaction_count"
            ]
          },
          "triggeredBy": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "sales",
              "transactions",
              "both",
              null
            ]
          },
          "sales": {
            "type": "number"
          },
          "transactions": {
            "type": [
              "integer",
              "null"
            ]
          },
          "salesPercentOfThreshold": {
            "type": [
              "number",
              "null"
            ]
          },
          "transactionsPercentOfThreshold": {
            "type": [
              "number",
              "null"
            ]
          },
          "threshold": {
            "$ref": "#/components/schemas/StateEconomicNexusRule"
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "NexusEvaluateResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "asOf",
          "approachingPercent",
          "summary",
          "results",
          "disclaimer"
        ],
        "properties": {
          "asOf": {
            "type": "string",
            "format": "date"
          },
          "approachingPercent": {
            "type": "integer"
          },
          "summary": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "totalEvaluated",
              "exceededCount",
              "approachingCount",
              "belowThresholdCount",
              "noNexusRuleCount",
              "needsTransactionCount"
            ],
            "properties": {
              "totalEvaluated": {
                "type": "integer"
              },
              "exceededCount": {
                "type": "integer"
              },
              "approachingCount": {
                "type": "integer"
              },
              "belowThresholdCount": {
                "type": "integer"
              },
              "noNexusRuleCount": {
                "type": "integer"
              },
              "needsTransactionCount": {
                "type": "integer"
              }
            }
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NexusStateEvaluation"
            }
          },
          "disclaimer": {
            "type": "string"
          }
        }
      },
      "TaxCalculateRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "Provide either address, latitude/longitude, or both shipFrom and shipTo for sourcing-aware calculation, plus either amount or lineItems.",
        "properties": {
          "address": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "latitude": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "longitude": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          },
          "shipFrom": {
            "$ref": "#/components/schemas/LocationInput"
          },
          "shipTo": {
            "$ref": "#/components/schemas/LocationInput"
          },
          "amount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000,
            "description": "Single USD amount with at most 2 decimal places."
          },
          "lineItems": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/LineItemInput"
            }
          },
          "shipping": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "shippingTaxable": {
            "type": "boolean",
            "description": "Explicit shipping taxability flag (default false when neither shippingTaxable nor shippingType is supplied). Cannot be combined with shippingType."
          },
          "shippingType": {
            "type": "string",
            "enum": [
              "separately_stated",
              "bundled"
            ],
            "description": "Optional shipping classification resolved from the taxability database when shipping > 0. Cannot be combined with shippingTaxable."
          },
          "mode": {
            "type": "string",
            "enum": [
              "exclusive",
              "inclusive"
            ]
          },
          "rounding": {
            "type": "string",
            "enum": [
              "half_up",
              "half_even"
            ]
          },
          "customerId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "Optional customer identifier used to auto-match an active exemption certificate (Starter or Growth; Pro+ in usage-credits mode) and tag committed transactions."
          },
          "exemptionCertificateId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96,
            "description": "Optional specific exemption certificate ID (e.g., exc_...) to apply to this calculation (Starter or Growth; Pro+ in usage-credits mode)."
          },
          "commit": {
            "type": "boolean",
            "description": "When true, atomically persist the matched calculation as a committed sale transaction (Starter or Growth; Pro+ in usage-credits mode)."
          },
          "externalId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "description": "Optional unique caller order/invoice identifier for idempotent commit deduplication. Requires commit: true."
          },
          "transactionDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Optional YYYY-MM-DD effective and transaction date (defaults to current UTC date). Controls effective-dated platform taxability rules, custom tax rules, and exemption matching even when commit is false, and sets the ledger accounting date when commit is true."
          },
          "metadata": {
            "type": "object",
            "maxProperties": 10,
            "additionalProperties": {
              "type": "string",
              "maxLength": 256
            },
            "description": "Optional flat string key-value metadata (up to 10 entries, keys 1–64 chars, values up to 256 chars) stored on committed transactions. Requires commit: true. Keys must match ^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$.",
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
            }
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96,
            "description": "Optional legal entity ID (ent_...) for entity-scoped exemptions, custom products, custom rules, default shipFrom, and committed transactions."
          },
          "entityCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Optional legal entity code slug to resolve entity scope."
          },
          "ein": {
            "type": "string",
            "minLength": 9,
            "maxLength": 12,
            "description": "Optional legal entity US EIN (XX-XXXXXXX or 9 digits) to resolve entity scope."
          },
          "buyerType": {
            "type": "string",
            "enum": [
              "b2b",
              "b2c"
            ],
            "description": "Optional buyer classification (b2b or b2c) for B2B/B2C statutory platform taxability rules and custom tax rule matching. Omitting buyerType uses the platform B2B baseline rule (e.g., CT 1%, MD 3%, IA exempt, OH taxable for SaaS; pass buyerType: \"b2c\" for B2C consumer rules such as IA SaaS taxable)."
          },
          "customerTags": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9_-]{0,47}$"
            },
            "description": "Optional lowercase buyer/customer tags (0-20 tags; empty array permitted) for custom tax rule matching."
          },
          "discountAmount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000,
            "description": "Optional order-level discount amount in USD with at most 2 decimal places, proportionally allocated across line items."
          },
          "discountType": {
            "type": "string",
            "enum": [
              "retailer",
              "manufacturer"
            ],
            "description": "Optional order-level discount classification: retailer (default, reduces taxable base) or manufacturer (third-party coupon; reduces taxable base only in CT, MA, MO, PA, TX, and no-sales-tax states)."
          },
          "includeRetailDeliveryFees": {
            "type": "boolean",
            "description": "When true, evaluate applicable state Retail Delivery Fees (Colorado C.R.S. 43-4-218 and Minnesota Minn. Stat. 168E.03) and include them in calculation.fees and calculation.totalFees."
          },
          "retailDeliveryFeeExempt": {
            "type": "boolean",
            "description": "When true, suppress state Retail Delivery Fees for this order (for example, when the merchant qualifies for a small-seller exemption)."
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "sellers_use",
              "consumers_use"
            ],
            "description": "Tax schedule and sourcing classification: sales (default), sellers_use (destination seller use tax), or consumers_use (destination self-assessed consumer use tax)."
          },
          "taxPaid": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000,
            "description": "Optional sales/use tax already paid to another state (USD, max 2 decimal places) credited against destination use tax due. Only valid when taxType is consumers_use."
          }
        },
        "allOf": [
          {
            "oneOf": [
              {
                "required": [
                  "address"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "latitude"
                      ]
                    },
                    {
                      "required": [
                        "longitude"
                      ]
                    },
                    {
                      "required": [
                        "shipFrom"
                      ]
                    },
                    {
                      "required": [
                        "shipTo"
                      ]
                    }
                  ]
                }
              },
              {
                "required": [
                  "latitude",
                  "longitude"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "address"
                      ]
                    },
                    {
                      "required": [
                        "shipFrom"
                      ]
                    },
                    {
                      "required": [
                        "shipTo"
                      ]
                    }
                  ]
                }
              },
              {
                "required": [
                  "shipFrom",
                  "shipTo"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "address"
                      ]
                    },
                    {
                      "required": [
                        "latitude"
                      ]
                    },
                    {
                      "required": [
                        "longitude"
                      ]
                    }
                  ]
                }
              },
              {
                "description": "Buyer delivery location using the resolved entity defaultShipFrom origin (Starter or Growth).",
                "required": [
                  "shipTo"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "address"
                      ]
                    },
                    {
                      "required": [
                        "latitude"
                      ]
                    },
                    {
                      "required": [
                        "longitude"
                      ]
                    },
                    {
                      "required": [
                        "shipFrom"
                      ]
                    }
                  ]
                }
              }
            ]
          },
          {
            "oneOf": [
              {
                "required": [
                  "amount"
                ],
                "not": {
                  "required": [
                    "lineItems"
                  ]
                }
              },
              {
                "required": [
                  "lineItems"
                ],
                "not": {
                  "required": [
                    "amount"
                  ]
                }
              }
            ]
          },
          {
            "not": {
              "required": [
                "shippingTaxable",
                "shippingType"
              ]
            }
          }
        ]
      },
      "CalculatedLineItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "quantity",
          "unitAmount",
          "subtotal",
          "taxable",
          "taxAmount",
          "total"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "unitAmount": {
            "type": "number"
          },
          "subtotal": {
            "type": "number"
          },
          "taxable": {
            "type": "boolean"
          },
          "itemKey": {
            "type": "string"
          },
          "taxAmount": {
            "type": "number"
          },
          "total": {
            "type": "number"
          },
          "taxableAmount": {
            "type": "number"
          },
          "exemptAmount": {
            "type": "number"
          },
          "effectiveRate": {
            "type": "number"
          },
          "appliedRule": {
            "$ref": "#/components/schemas/AppliedLineRuleDetail"
          },
          "productCode": {
            "type": "string"
          },
          "discountAmount": {
            "type": "number"
          }
        }
      },
      "TaxBreakdownComponent": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "jurisdictionName",
          "rateName",
          "jurisdictionType",
          "rate",
          "taxAmount"
        ],
        "properties": {
          "jurisdictionName": {
            "type": "string"
          },
          "rateName": {
            "type": "string"
          },
          "jurisdictionType": {
            "type": "string",
            "enum": [
              "state",
              "county",
              "city",
              "special_district",
              "locality",
              "minor_civil_division",
              "unknown"
            ]
          },
          "rate": {
            "type": "number"
          },
          "taxAmount": {
            "type": "number"
          }
        }
      },
      "TaxCalculationDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "currency",
          "mode",
          "rounding",
          "subtotal",
          "taxableAmount",
          "exemptAmount",
          "shippingAmount",
          "taxAmount",
          "total",
          "lineItems",
          "breakdown"
        ],
        "properties": {
          "currency": {
            "type": "string",
            "const": "USD"
          },
          "mode": {
            "type": "string",
            "enum": [
              "exclusive",
              "inclusive"
            ]
          },
          "rounding": {
            "type": "string",
            "enum": [
              "half_up",
              "half_even"
            ]
          },
          "subtotal": {
            "type": "number"
          },
          "taxableAmount": {
            "type": "number"
          },
          "exemptAmount": {
            "type": "number"
          },
          "shippingAmount": {
            "type": "number"
          },
          "taxAmount": {
            "type": "number"
          },
          "total": {
            "type": "number"
          },
          "lineItems": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CalculatedLineItem"
            }
          },
          "breakdown": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxBreakdownComponent"
            }
          },
          "discountAmount": {
            "type": "number"
          },
          "fees": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxFeeDetail"
            }
          },
          "totalFees": {
            "type": "number"
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "sellers_use",
              "consumers_use"
            ],
            "description": "Tax schedule and sourcing classification: sales (default), sellers_use (destination seller use tax), or consumers_use (destination self-assessed consumer use tax)."
          },
          "shippingTaxAmount": {
            "type": "number"
          },
          "useTax": {
            "$ref": "#/components/schemas/UseTaxSummaryDetail",
            "description": "Present when taxType is consumers_use. Lump-sum taxPaid credits are allocated proportionally across each line and shipping jurisdiction tax cell; top-level taxRate remains the gross statutory Use rate while taxAmount reflects net tax due after creditApplied."
          },
          "sellersUseNotice": {
            "$ref": "#/components/schemas/SellersUseNoticeDetail"
          }
        }
      },
      "SellersUseNoticeDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "appliedSchedule",
          "salesRate",
          "useRate",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "illinois_lpf_rot_applied",
              "sales_use_rate_differs"
            ]
          },
          "appliedSchedule": {
            "type": "string",
            "enum": [
              "sales",
              "use"
            ]
          },
          "salesRate": {
            "type": "number"
          },
          "useRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "TaxFeeDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "name",
          "stateCode",
          "amount",
          "taxable",
          "statutoryCitation",
          "note"
        ],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "CO_RDF",
              "MN_RDF"
            ]
          },
          "name": {
            "type": "string"
          },
          "stateCode": {
            "type": "string",
            "enum": [
              "CO",
              "MN"
            ]
          },
          "amount": {
            "type": "number"
          },
          "taxable": {
            "type": "boolean",
            "const": false
          },
          "statutoryCitation": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        }
      },
      "TaxCalculateBatchItemRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "Single order calculation request inside POST /tax/calculate/batch. Supports all TaxCalculateRequest fields plus an optional batchItemId.",
        "properties": {
          "batchItemId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Optional caller-defined identifier echoed in the matching batch result item."
          },
          "address": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "latitude": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "longitude": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          },
          "shipFrom": {
            "$ref": "#/components/schemas/LocationInput"
          },
          "shipTo": {
            "$ref": "#/components/schemas/LocationInput"
          },
          "amount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000,
            "description": "Single USD amount with at most 2 decimal places."
          },
          "lineItems": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/LineItemInput"
            }
          },
          "shipping": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "shippingTaxable": {
            "type": "boolean"
          },
          "shippingType": {
            "type": "string",
            "enum": [
              "separately_stated",
              "bundled"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "exclusive",
              "inclusive"
            ]
          },
          "rounding": {
            "type": "string",
            "enum": [
              "half_up",
              "half_even"
            ]
          },
          "customerId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "exemptionCertificateId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "commit": {
            "type": "boolean"
          },
          "externalId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "transactionDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "metadata": {
            "type": "object",
            "maxProperties": 10,
            "additionalProperties": {
              "type": "string",
              "maxLength": 256
            },
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
            }
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "entityCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "ein": {
            "type": "string",
            "minLength": 9,
            "maxLength": 12
          },
          "buyerType": {
            "type": "string",
            "enum": [
              "b2b",
              "b2c"
            ],
            "description": "Optional buyer classification (b2b or b2c). Omitting buyerType uses the platform B2B baseline rule (e.g., IA SaaS exempt for B2B, taxable when buyerType is \"b2c\")."
          },
          "customerTags": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9_-]{0,47}$"
            }
          },
          "discountAmount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "discountType": {
            "type": "string",
            "enum": [
              "retailer",
              "manufacturer"
            ]
          },
          "includeRetailDeliveryFees": {
            "type": "boolean"
          },
          "retailDeliveryFeeExempt": {
            "type": "boolean"
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "sellers_use",
              "consumers_use"
            ],
            "description": "Tax schedule and sourcing classification: sales (default), sellers_use (destination seller use tax), or consumers_use (destination self-assessed consumer use tax)."
          },
          "taxPaid": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000,
            "description": "Optional sales/use tax already paid to another state (USD, max 2 decimal places) credited against destination use tax due. Only valid when taxType is consumers_use."
          }
        },
        "allOf": [
          {
            "oneOf": [
              {
                "required": [
                  "address"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "latitude"
                      ]
                    },
                    {
                      "required": [
                        "longitude"
                      ]
                    },
                    {
                      "required": [
                        "shipFrom"
                      ]
                    },
                    {
                      "required": [
                        "shipTo"
                      ]
                    }
                  ]
                }
              },
              {
                "required": [
                  "latitude",
                  "longitude"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "address"
                      ]
                    },
                    {
                      "required": [
                        "shipFrom"
                      ]
                    },
                    {
                      "required": [
                        "shipTo"
                      ]
                    }
                  ]
                }
              },
              {
                "required": [
                  "shipFrom",
                  "shipTo"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "address"
                      ]
                    },
                    {
                      "required": [
                        "latitude"
                      ]
                    },
                    {
                      "required": [
                        "longitude"
                      ]
                    }
                  ]
                }
              },
              {
                "description": "Buyer delivery location using the resolved entity defaultShipFrom origin (Starter or Growth).",
                "required": [
                  "shipTo"
                ],
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "address"
                      ]
                    },
                    {
                      "required": [
                        "latitude"
                      ]
                    },
                    {
                      "required": [
                        "longitude"
                      ]
                    },
                    {
                      "required": [
                        "shipFrom"
                      ]
                    }
                  ]
                }
              }
            ]
          },
          {
            "oneOf": [
              {
                "required": [
                  "amount"
                ],
                "not": {
                  "required": [
                    "lineItems"
                  ]
                }
              },
              {
                "required": [
                  "lineItems"
                ],
                "not": {
                  "required": [
                    "amount"
                  ]
                }
              }
            ]
          },
          {
            "not": {
              "required": [
                "shippingTaxable",
                "shippingType"
              ]
            }
          }
        ]
      },
      "TaxCalculateBatchRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "minItems": 1,
            "maxItems": 25,
            "items": {
              "$ref": "#/components/schemas/TaxCalculateBatchItemRequest"
            }
          }
        }
      },
      "TaxCalculateBatchItemResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "index",
          "status",
          "httpStatus"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "minimum": 0
          },
          "batchItemId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "error"
            ]
          },
          "httpStatus": {
            "type": "integer"
          },
          "response": {
            "$ref": "#/components/schemas/TaxCalculateResponse"
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "TaxCalculateBatchResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "succeeded",
          "failed",
          "results"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 1
          },
          "succeeded": {
            "type": "integer",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "minimum": 0
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxCalculateBatchItemResult"
            }
          }
        }
      },
      "TaxCalculateResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "coordinates",
          "status",
          "hasMissingRates",
          "taxRate",
          "jurisdictions",
          "calculation"
        ],
        "properties": {
          "coordinates": {
            "$ref": "#/components/schemas/Coordinates"
          },
          "status": {
            "type": "string",
            "enum": [
              "matched",
              "no_match",
              "ambiguous",
              "missing_rates",
              "invalid_rates"
            ]
          },
          "hasMissingRates": {
            "type": "boolean"
          },
          "taxRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "jurisdictions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Jurisdiction"
            }
          },
          "geocoding": {
            "$ref": "#/components/schemas/Geocoding"
          },
          "sourcing": {
            "$ref": "#/components/schemas/TaxSourcingDetail"
          },
          "calculation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TaxCalculationDetail"
              },
              {
                "type": "null"
              }
            ]
          },
          "exemption": {
            "$ref": "#/components/schemas/TaxExemptionDetail"
          },
          "transaction": {
            "$ref": "#/components/schemas/CommittedTransactionSummary"
          },
          "entity": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TaxCalculateEntitySummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "use"
            ],
            "description": "Optional tax rate schedule: sales (default) or use (general use tax rates; local jurisdictions without a use tax rate contribute 0%)."
          }
        }
      },
      "JurisdictionSearchRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "query"
        ],
        "properties": {
          "query": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "state": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Optional US state name or two-letter code (e.g., FL or Florida)."
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 25
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "use"
            ],
            "description": "Optional tax rate schedule: sales (default) or use (general use tax rates; local jurisdictions without a use tax rate contribute 0%)."
          }
        }
      },
      "JurisdictionSearchResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "stateName",
          "countyNames",
          "jurisdictionTypes",
          "rates"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "stateName": {
            "type": [
              "string",
              "null"
            ]
          },
          "countyNames": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "jurisdictionTypes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "state",
                "county",
                "city",
                "special_district",
                "locality",
                "minor_civil_division",
                "unknown"
              ]
            }
          },
          "rates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SalesRate"
            }
          }
        }
      },
      "JurisdictionSearchResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "query",
          "stateName",
          "asOf",
          "results",
          "note"
        ],
        "properties": {
          "query": {
            "type": "string"
          },
          "stateName": {
            "type": [
              "string",
              "null"
            ]
          },
          "asOf": {
            "type": "string",
            "format": "date"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JurisdictionSearchResult"
            }
          },
          "note": {
            "type": "string"
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "use"
            ],
            "description": "Optional tax rate schedule: sales (default) or use (general use tax rates; local jurisdictions without a use tax rate contribute 0%)."
          }
        }
      },
      "AccountBalanceResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "billingEnabled",
          "exempt",
          "pricingModel",
          "plan",
          "usageMonth",
          "usedThisMonth",
          "reservedInFlight",
          "includedRemaining",
          "usedCreditDollars",
          "creditRemainingDollars",
          "overageThisMonth",
          "estimatedOverageDollars",
          "currentPeriodEnd"
        ],
        "properties": {
          "billingEnabled": {
            "type": "boolean"
          },
          "exempt": {
            "type": "boolean"
          },
          "pricingModel": {
            "type": "string",
            "enum": [
              "region_flat",
              "usage_credits"
            ],
            "description": "Active workspace pricing model."
          },
          "plan": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": false,
            "required": [
              "pricingModel",
              "id",
              "name",
              "billingCycle",
              "subscriptionStatus",
              "monthlyPriceDollars",
              "pricePerRegionDollars",
              "activeRegions",
              "minRegions",
              "maxRegions",
              "includedCreditDollars",
              "hardCap",
              "includedRequests",
              "overagePerRequestDollars",
              "rateLimitPerMinute",
              "burst",
              "maxActiveKeys",
              "entitled",
              "features"
            ],
            "properties": {
              "pricingModel": {
                "type": "string",
                "enum": [
                  "region_flat",
                  "usage_credits"
                ]
              },
              "id": {
                "type": "string",
                "enum": [
                  "starter",
                  "growth",
                  "hobby",
                  "pro",
                  "enterprise"
                ]
              },
              "name": {
                "type": "string"
              },
              "billingCycle": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "monthly",
                  "annual",
                  null
                ]
              },
              "subscriptionStatus": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "active",
                  "trialing",
                  "past_due",
                  "canceled",
                  "incomplete",
                  "unpaid",
                  null
                ]
              },
              "monthlyPriceDollars": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "pricePerRegionDollars": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "activeRegions": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "minRegions": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "maxRegions": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "includedCreditDollars": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "hardCap": {
                "type": "boolean"
              },
              "includedRequests": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "overagePerRequestDollars": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "rateLimitPerMinute": {
                "type": "integer"
              },
              "burst": {
                "type": "integer"
              },
              "maxActiveKeys": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "entitled": {
                "type": "boolean"
              },
              "features": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "nexusEvaluate",
                  "taxability",
                  "exemptions",
                  "transactions"
                ],
                "properties": {
                  "nexusEvaluate": {
                    "type": "boolean"
                  },
                  "taxability": {
                    "type": "boolean"
                  },
                  "exemptions": {
                    "type": "boolean"
                  },
                  "transactions": {
                    "type": "boolean"
                  }
                }
              }
            }
          },
          "usageMonth": {
            "type": "string"
          },
          "usedThisMonth": {
            "type": "integer"
          },
          "reservedInFlight": {
            "type": "integer"
          },
          "includedRemaining": {
            "type": [
              "integer",
              "null"
            ]
          },
          "usedCreditDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "creditRemainingDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "overageThisMonth": {
            "type": "integer"
          },
          "estimatedOverageDollars": {
            "type": "number"
          },
          "currentPeriodEnd": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "LookupResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "coordinates",
          "status",
          "hasMissingRates",
          "taxRate",
          "jurisdictions"
        ],
        "properties": {
          "coordinates": {
            "$ref": "#/components/schemas/Coordinates"
          },
          "status": {
            "type": "string",
            "enum": [
              "matched",
              "no_match",
              "ambiguous",
              "missing_rates",
              "invalid_rates"
            ],
            "description": "matched: a tax rate is available. no_match: no named jurisdiction matched. ambiguous: the point is on a boundary. missing_rates: a named jurisdiction has no rate. invalid_rates: rate components failed validation."
          },
          "hasMissingRates": {
            "type": "boolean",
            "description": "True when a matched named jurisdiction has no rate record."
          },
          "taxRate": {
            "type": [
              "number",
              "null"
            ],
            "description": "Sales tax rate as a decimal. 0.075 means 7.5%. Null means no usable total is available; do not treat null as zero."
          },
          "jurisdictions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Jurisdiction"
            }
          },
          "geocoding": {
            "$ref": "#/components/schemas/Geocoding"
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "use"
            ],
            "description": "Optional tax rate schedule: sales (default) or use (general use tax rates; local jurisdictions without a use tax rate contribute 0%)."
          }
        }
      },
      "Jurisdiction": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "stateName",
          "relation",
          "rates"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "stateName": {
            "type": [
              "string",
              "null"
            ]
          },
          "relation": {
            "type": "string",
            "enum": [
              "inside",
              "boundary"
            ]
          },
          "rates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SalesRate"
            }
          }
        }
      },
      "SalesRate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "jurisdictionType",
          "taxType",
          "rate",
          "effectiveDate",
          "endDate"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "jurisdictionType": {
            "type": "string",
            "enum": [
              "state",
              "county",
              "city",
              "special_district",
              "locality",
              "minor_civil_division",
              "unknown"
            ]
          },
          "taxType": {
            "type": "string",
            "enum": [
              "Sales",
              "Use"
            ]
          },
          "rate": {
            "type": "number",
            "description": "Decimal rate. For example, 0.06 means 6%."
          },
          "effectiveDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "endDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          }
        }
      },
      "Geocoding": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "provider",
          "formattedAddress",
          "precision",
          "attribution"
        ],
        "properties": {
          "provider": {
            "type": "string",
            "const": "Google Maps"
          },
          "formattedAddress": {
            "type": "string"
          },
          "precision": {
            "type": "string",
            "const": "ROOFTOP"
          },
          "attribution": {
            "type": "string",
            "const": "Google Maps"
          }
        }
      },
      "TaxabilityItemSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "itemKey",
          "label",
          "stateCount"
        ],
        "properties": {
          "itemKey": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "stateCount": {
            "type": "integer"
          }
        }
      },
      "TaxabilityItemsResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "items"
        ],
        "properties": {
          "count": {
            "type": "integer"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxabilityItemSummary"
            }
          }
        }
      },
      "TaxabilityCheckRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "state",
          "items"
        ],
        "properties": {
          "state": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "maxItems": 50,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          "jurisdiction": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Optional local jurisdiction name (e.g., Denver, City and County, Chicago, Nassau) to check local taxability overrides."
          },
          "jurisdictionType": {
            "type": "string",
            "enum": [
              "county",
              "city",
              "district"
            ],
            "description": "Optional local jurisdiction type (county, city, or district). Requires jurisdiction."
          },
          "asOf": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Optional YYYY-MM-DD effective date (defaults to today UTC) for evaluating date-bounded statutory taxability rules (such as Jan 1, 2027 CA/CO SaaS transitions)."
          },
          "buyerType": {
            "type": "string",
            "enum": [
              "b2b",
              "b2c"
            ],
            "description": "Optional buyer type to select B2B vs. B2C statutory platform rules. Omitting buyerType uses the platform B2B baseline rule (e.g., CT 1%, MD 3%, IA exempt, OH taxable for SaaS; pass buyerType: \"b2c\" for B2C consumer rules such as IA SaaS taxable)."
          }
        }
      },
      "TaxabilityCheckResultItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "itemKey",
          "label",
          "treatment",
          "reducedRate",
          "reducedRateScope",
          "thresholdDollars",
          "thresholdMode",
          "taxablePercent",
          "effectiveDate",
          "endDate",
          "localOverride",
          "note"
        ],
        "properties": {
          "itemKey": {
            "type": "string"
          },
          "label": {
            "type": [
              "string",
              "null"
            ]
          },
          "buyerType": {
            "type": "string",
            "enum": [
              "b2b",
              "b2c"
            ]
          },
          "treatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt",
              "reduced_rate",
              "unknown"
            ]
          },
          "reducedRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "reducedRateScope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only",
              null
            ]
          },
          "thresholdDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "thresholdMode": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "exempt_below_full_above",
              "exempt_up_to_excess_taxable",
              null
            ]
          },
          "taxablePercent": {
            "type": [
              "number",
              "null"
            ]
          },
          "localOverride": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TaxabilityLocalOverrideDetail"
              },
              {
                "type": "null"
              }
            ]
          },
          "localOverrides": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxabilityLocalOverrideDetail"
            }
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "effectiveDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Inclusive YYYY-MM-DD start date of this rule, or null if open-ended."
          },
          "endDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Inclusive YYYY-MM-DD end date of this rule, or null if open-ended."
          }
        }
      },
      "TaxabilityCheckResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stateCode",
          "stateName",
          "asOf",
          "results"
        ],
        "properties": {
          "stateCode": {
            "type": "string"
          },
          "stateName": {
            "type": "string"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxabilityCheckResultItem"
            }
          },
          "jurisdiction": {
            "type": "string"
          },
          "jurisdictionType": {
            "type": "string",
            "enum": [
              "county",
              "city",
              "district"
            ]
          },
          "asOf": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Effective date (YYYY-MM-DD) evaluated for this taxability check."
          },
          "buyerType": {
            "type": "string",
            "enum": [
              "b2b",
              "b2c"
            ]
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "invalid_request",
                  "invalid_json",
                  "invalid_input",
                  "unauthorized",
                  "quota_exceeded",
                  "plan_upgrade_required",
                  "forbidden",
                  "not_found",
                  "method_not_allowed",
                  "request_too_large",
                  "unsupported_media_type",
                  "address_not_found",
                  "address_ambiguous",
                  "address_imprecise",
                  "taxability_unknown",
                  "duplicate_transaction",
                  "exemption_not_found",
                  "exemption_invalid",
                  "commit_not_possible",
                  "exemption_limit_reached",
                  "transaction_not_found",
                  "transaction_already_voided",
                  "transaction_has_refunds",
                  "refund_limit_reached",
                  "invalid_transaction_state",
                  "refund_exceeds_remaining",
                  "rate_limited",
                  "service_unavailable",
                  "geocoding_unavailable",
                  "lookup_unavailable",
                  "billing_unavailable",
                  "entity_not_found",
                  "entity_conflict",
                  "entity_limit_reached",
                  "registration_not_found",
                  "registration_conflict",
                  "product_not_found",
                  "product_code_conflict",
                  "product_limit_reached",
                  "rule_not_found",
                  "rule_limit_reached",
                  "entity_ambiguous",
                  "entity_in_use",
                  "duplicate_entity_code",
                  "entity_has_active_children",
                  "filing_not_found",
                  "filing_already_exists",
                  "filing_locked",
                  "invalid_filing_state",
                  "filing_period_locked",
                  "document_not_found",
                  "document_already_exists",
                  "exemption_revoked",
                  "upload_link_not_found",
                  "connection_not_found",
                  "connection_limit_reached",
                  "invalid_signature",
                  "webhook_not_found",
                  "webhook_limit_reached",
                  "alert_not_found"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "TaxabilityLocalOverrideDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "jurisdictionType",
          "jurisdictionName",
          "treatment",
          "reducedRate",
          "reducedRateScope",
          "thresholdDollars",
          "thresholdMode",
          "taxablePercent",
          "effectiveDate",
          "endDate",
          "note"
        ],
        "properties": {
          "jurisdictionType": {
            "type": "string",
            "enum": [
              "county",
              "city",
              "district"
            ]
          },
          "jurisdictionName": {
            "type": "string"
          },
          "buyerType": {
            "type": "string",
            "enum": [
              "b2b",
              "b2c"
            ]
          },
          "treatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt",
              "reduced_rate"
            ]
          },
          "reducedRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "reducedRateScope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only",
              null
            ]
          },
          "thresholdDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "thresholdMode": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "exempt_below_full_above",
              "exempt_up_to_excess_taxable",
              null
            ]
          },
          "taxablePercent": {
            "type": [
              "number",
              "null"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "effectiveDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Inclusive YYYY-MM-DD start date of this local override, or null if open-ended."
          },
          "endDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Inclusive YYYY-MM-DD end date of this local override, or null if open-ended."
          }
        }
      },
      "AppliedLineRuleDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "treatment"
        ],
        "properties": {
          "treatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt",
              "reduced_rate",
              "exempt_certificate",
              "rate_adjustment"
            ]
          },
          "reducedRate": {
            "type": "number"
          },
          "reducedRateScope": {
            "type": "string",
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only"
            ]
          },
          "thresholdDollars": {
            "type": "number"
          },
          "thresholdMode": {
            "type": "string",
            "enum": [
              "exempt_below_full_above",
              "exempt_up_to_excess_taxable"
            ]
          },
          "taxablePercent": {
            "type": "number"
          },
          "localOverride": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "jurisdictionType",
              "jurisdictionName",
              "treatment"
            ],
            "properties": {
              "jurisdictionType": {
                "type": "string",
                "enum": [
                  "county",
                  "city",
                  "district"
                ]
              },
              "jurisdictionName": {
                "type": "string"
              },
              "treatment": {
                "type": "string",
                "enum": [
                  "taxable",
                  "exempt",
                  "reduced_rate"
                ]
              },
              "reducedRate": {
                "type": "number"
              },
              "reducedRateScope": {
                "type": "string",
                "enum": [
                  "state_only",
                  "combined",
                  "jurisdiction_only"
                ]
              }
            }
          },
          "certificateId": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "exemption_certificate",
              "custom_rule",
              "platform_local_override",
              "platform_state_rule",
              "product_default",
              "explicit_flag"
            ]
          },
          "ruleId": {
            "type": "string"
          },
          "ruleSummary": {
            "type": "string"
          },
          "taxCapped": {
            "type": "boolean"
          },
          "rateDelta": {
            "type": "number",
            "description": "Signed additive rate adjustment applied by a rate_adjustment custom rule."
          },
          "rateMultiplier": {
            "type": "number",
            "description": "Multiplicative rate factor applied by a rate_adjustment custom rule."
          },
          "rateScope": {
            "type": "string",
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only"
            ],
            "description": "Scope of a custom rate_adjustment or local exempt rule."
          }
        }
      },
      "TaxExemptionDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "applied",
          "certificateId",
          "customerId",
          "customerName",
          "exemptionReason",
          "certificateNumber",
          "scope",
          "appliedState"
        ],
        "properties": {
          "applied": {
            "type": "boolean"
          },
          "certificateId": {
            "type": [
              "string",
              "null"
            ]
          },
          "customerId": {
            "type": [
              "string",
              "null"
            ]
          },
          "customerName": {
            "type": [
              "string",
              "null"
            ]
          },
          "exemptionReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "certificateNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "scope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "blanket",
              "item_specific",
              null
            ]
          },
          "appliedState": {
            "type": "string"
          },
          "itemKeys": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "reason": {
            "type": "string"
          },
          "certificateIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every item-specific certificate that exempted at least one line, when more than one certificate applied."
          }
        }
      },
      "CommittedTransactionSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "transactionId",
          "externalId",
          "type",
          "status",
          "transactionDate",
          "committedAt"
        ],
        "properties": {
          "transactionId": {
            "type": "string"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "type": "string",
            "const": "sale"
          },
          "status": {
            "type": "string",
            "const": "committed"
          },
          "transactionDate": {
            "type": "string",
            "format": "date"
          },
          "committedAt": {
            "type": "integer"
          },
          "entityId": {
            "type": [
              "string",
              "null"
            ]
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "sellers_use",
              "consumers_use"
            ],
            "description": "Tax schedule and sourcing classification: sales (default), sellers_use (destination seller use tax), or consumers_use (destination self-assessed consumer use tax)."
          }
        }
      },
      "CreateExemptionCertificateRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "customerId",
          "customerName",
          "exemptionReason",
          "certificateNumber",
          "states",
          "effectiveDate"
        ],
        "properties": {
          "customerId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "customerName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "exemptionReason": {
            "type": "string",
            "enum": [
              "resale",
              "nonprofit",
              "government",
              "manufacturing",
              "agriculture",
              "direct_pay",
              "other"
            ]
          },
          "certificateNumber": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "states": {
            "type": "array",
            "minItems": 1,
            "maxItems": 52,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          "effectiveDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "expirationDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "itemKeys": {
            "type": "array",
            "minItems": 1,
            "maxItems": 50,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          "notes": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96,
            "description": "Optional legal entity ID (ent_...) scoping this certificate."
          },
          "inheritToChildren": {
            "type": "boolean",
            "description": "Whether descendant entities inherit this certificate when entityId is set (default true)."
          }
        }
      },
      "ExemptionCertificate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "certificateId",
          "customerId",
          "customerName",
          "exemptionReason",
          "certificateNumber",
          "states",
          "status",
          "effectiveDate",
          "expirationDate",
          "itemKeys",
          "notes",
          "createdAt",
          "updatedAt",
          "revokedAt"
        ],
        "properties": {
          "certificateId": {
            "type": "string"
          },
          "customerId": {
            "type": "string"
          },
          "customerName": {
            "type": "string"
          },
          "exemptionReason": {
            "type": "string",
            "enum": [
              "resale",
              "nonprofit",
              "government",
              "manufacturing",
              "agriculture",
              "direct_pay",
              "other"
            ]
          },
          "certificateNumber": {
            "type": "string"
          },
          "states": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "revoked"
            ]
          },
          "effectiveDate": {
            "type": "string",
            "format": "date"
          },
          "expirationDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "itemKeys": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          },
          "revokedAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "entityId": {
            "type": [
              "string",
              "null"
            ]
          },
          "inheritToChildren": {
            "type": "boolean"
          },
          "document": {
            "$ref": "#/components/schemas/ExemptionDocumentSummary"
          }
        }
      },
      "ExemptionCertificateResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "certificate"
        ],
        "properties": {
          "certificate": {
            "$ref": "#/components/schemas/ExemptionCertificate"
          }
        }
      },
      "ExemptionsListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "certificates"
        ],
        "properties": {
          "count": {
            "type": "integer"
          },
          "certificates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExemptionCertificate"
            }
          }
        }
      },
      "TaxTransactionSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "transactionId",
          "externalId",
          "type",
          "status",
          "parentTransactionId",
          "transactionDate",
          "customerId",
          "exemptionCertificateId",
          "exemptionReason",
          "stateCode",
          "stateName",
          "currency",
          "mode",
          "rounding",
          "taxRate",
          "subtotal",
          "taxableAmount",
          "exemptAmount",
          "shippingAmount",
          "taxAmount",
          "total",
          "committedAt",
          "voidedAt",
          "voidReason",
          "metadata"
        ],
        "properties": {
          "transactionId": {
            "type": "string"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "sale",
              "refund"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "committed",
              "voided"
            ]
          },
          "parentTransactionId": {
            "type": [
              "string",
              "null"
            ]
          },
          "transactionDate": {
            "type": "string",
            "format": "date"
          },
          "customerId": {
            "type": [
              "string",
              "null"
            ]
          },
          "exemptionCertificateId": {
            "type": [
              "string",
              "null"
            ]
          },
          "exemptionReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "stateCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "stateName": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency": {
            "type": "string",
            "const": "USD"
          },
          "mode": {
            "type": "string",
            "enum": [
              "exclusive",
              "inclusive"
            ]
          },
          "rounding": {
            "type": "string",
            "enum": [
              "half_up",
              "half_even"
            ]
          },
          "taxRate": {
            "type": "number"
          },
          "subtotal": {
            "type": "number"
          },
          "taxableAmount": {
            "type": "number"
          },
          "exemptAmount": {
            "type": "number"
          },
          "shippingAmount": {
            "type": "number"
          },
          "taxAmount": {
            "type": "number"
          },
          "totalFees": {
            "type": "number",
            "description": "Optional total state Retail Delivery Fees in USD (negative on refund credit memos when fees are refunded)."
          },
          "total": {
            "type": "number"
          },
          "committedAt": {
            "type": "integer"
          },
          "voidedAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "voidReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {
              "type": "string"
            }
          },
          "entityId": {
            "type": [
              "string",
              "null"
            ]
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "sellers_use",
              "consumers_use"
            ],
            "description": "Tax schedule and sourcing classification: sales (default), sellers_use (destination seller use tax), or consumers_use (destination self-assessed consumer use tax)."
          },
          "taxPaid": {
            "type": "number"
          },
          "taxCredit": {
            "type": "number"
          }
        }
      },
      "TaxTransactionDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/TaxTransactionSummary"
          },
          {
            "type": "object",
            "required": [
              "snapshot"
            ],
            "properties": {
              "snapshot": {
                "type": "object",
                "additionalProperties": true,
                "description": "Stored calculation or refund snapshot (never contains provider internal identifiers).",
                "properties": {
                  "refundReason": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "isFullRefund": {
                    "type": "boolean"
                  },
                  "refundedLineItems": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  },
                  "refundedShipping": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "subtotal",
                      "taxableAmount",
                      "exemptAmount",
                      "taxAmount",
                      "total"
                    ],
                    "properties": {
                      "subtotal": {
                        "type": "number"
                      },
                      "taxableAmount": {
                        "type": "number"
                      },
                      "exemptAmount": {
                        "type": "number"
                      },
                      "taxAmount": {
                        "type": "number"
                      },
                      "total": {
                        "type": "number"
                      }
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "TaxTransactionsLedgerSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "saleCount",
          "refundCount",
          "voidedCount",
          "grossSales",
          "taxableSales",
          "exemptSales",
          "taxCollected",
          "taxRefunded",
          "netTax"
        ],
        "properties": {
          "saleCount": {
            "type": "integer"
          },
          "refundCount": {
            "type": "integer"
          },
          "voidedCount": {
            "type": "integer"
          },
          "grossSales": {
            "type": "number"
          },
          "taxableSales": {
            "type": "number"
          },
          "exemptSales": {
            "type": "number"
          },
          "taxCollected": {
            "type": "number"
          },
          "taxRefunded": {
            "type": "number"
          },
          "netTax": {
            "type": "number"
          }
        }
      },
      "TaxTransactionsListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "hasMore",
          "nextCursor",
          "truncated",
          "summary",
          "transactions"
        ],
        "properties": {
          "count": {
            "type": "integer"
          },
          "hasMore": {
            "type": "boolean",
            "description": "True when additional matching transactions exist after this page."
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Opaque cursor token to pass as the cursor query parameter for the next page, or null on the final page."
          },
          "truncated": {
            "type": "boolean",
            "description": "True when more than 10,000 rows matched the filters on page 1 so summary totals cover the newest 10,000 rows."
          },
          "summary": {
            "$ref": "#/components/schemas/TaxTransactionsLedgerSummary"
          },
          "transactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxTransactionSummary"
            }
          }
        }
      },
      "TaxTransactionGetResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "transaction",
          "refunds"
        ],
        "properties": {
          "transaction": {
            "$ref": "#/components/schemas/TaxTransactionDetail"
          },
          "refunds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxTransactionSummary"
            }
          }
        }
      },
      "VoidTransactionRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        }
      },
      "TaxTransactionVoidResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "transaction"
        ],
        "properties": {
          "transaction": {
            "$ref": "#/components/schemas/TaxTransactionSummary"
          }
        }
      },
      "RefundLineItemInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000,
            "description": "Unit quantity to refund. Provide exactly one of quantity or amount."
          },
          "amount": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 1000000000,
            "description": "Explicit USD subtotal to refund for this line item (at most 2 decimal places). Provide exactly one of quantity or amount."
          }
        },
        "oneOf": [
          {
            "required": [
              "quantity"
            ],
            "not": {
              "required": [
                "amount"
              ]
            }
          },
          {
            "required": [
              "amount"
            ],
            "not": {
              "required": [
                "quantity"
              ]
            }
          }
        ]
      },
      "RefundTransactionRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "externalId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "transactionDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "lineItems": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/RefundLineItemInput"
            }
          },
          "shipping": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "refundFees": {
            "type": "boolean",
            "description": "Optional flag controlling whether remaining state Retail Delivery Fees (CO/MN) are refunded. Full refunds default to refunding remaining fees unless set to false; partial refunds do not refund fees unless set to true."
          },
          "metadata": {
            "type": "object",
            "maxProperties": 10,
            "additionalProperties": {
              "type": "string",
              "maxLength": 256
            },
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
            },
            "description": "Optional flat string key-value metadata. Keys must match ^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$."
          }
        }
      },
      "TaxTransactionRefundResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "refund",
          "parentTransaction"
        ],
        "properties": {
          "refund": {
            "$ref": "#/components/schemas/TaxTransactionDetail"
          },
          "parentTransaction": {
            "$ref": "#/components/schemas/TaxTransactionSummary"
          }
        }
      },
      "NexusMonitorStateResult": {
        "allOf": [
          {
            "$ref": "#/components/schemas/NexusStateEvaluation"
          },
          {
            "type": "object",
            "required": [
              "saleCount",
              "refundCount",
              "grossSales",
              "refundedSales",
              "netSales",
              "taxableSales",
              "exemptSales",
              "netTax"
            ],
            "properties": {
              "saleCount": {
                "type": "integer"
              },
              "refundCount": {
                "type": "integer"
              },
              "grossSales": {
                "type": "number"
              },
              "refundedSales": {
                "type": "number"
              },
              "netSales": {
                "type": "number"
              },
              "taxableSales": {
                "type": "number"
              },
              "exemptSales": {
                "type": "number"
              },
              "netTax": {
                "type": "number"
              },
              "registered": {
                "type": "boolean"
              },
              "permitNumber": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        ]
      },
      "NexusMonitorResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "asOf",
          "period",
          "salesBasis",
          "approachingPercent",
          "stateFilter",
          "truncated",
          "transactionCount",
          "unassignedTransactionCount",
          "summary",
          "results",
          "disclaimer"
        ],
        "properties": {
          "asOf": {
            "type": "string",
            "format": "date"
          },
          "period": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "preset",
              "from",
              "to"
            ],
            "properties": {
              "preset": {
                "type": "string",
                "enum": [
                  "rolling_12_months",
                  "current_calendar_year",
                  "previous_calendar_year",
                  "custom"
                ]
              },
              "from": {
                "type": "string",
                "format": "date"
              },
              "to": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "salesBasis": {
            "type": "string",
            "enum": [
              "gross",
              "taxable"
            ]
          },
          "approachingPercent": {
            "type": "integer"
          },
          "stateFilter": {
            "type": [
              "string",
              "null"
            ]
          },
          "truncated": {
            "type": "boolean"
          },
          "transactionCount": {
            "type": "integer"
          },
          "unassignedTransactionCount": {
            "type": "integer"
          },
          "summary": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "totalEvaluated",
              "exceededCount",
              "approachingCount",
              "belowThresholdCount",
              "noNexusRuleCount",
              "needsTransactionCount"
            ],
            "properties": {
              "totalEvaluated": {
                "type": "integer"
              },
              "exceededCount": {
                "type": "integer"
              },
              "approachingCount": {
                "type": "integer"
              },
              "belowThresholdCount": {
                "type": "integer"
              },
              "noNexusRuleCount": {
                "type": "integer"
              },
              "needsTransactionCount": {
                "type": "integer"
              }
            }
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NexusMonitorStateResult"
            }
          },
          "disclaimer": {
            "type": "string"
          },
          "entity": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ReportingEntityScope"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "FilingReportJurisdictionLine": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "jurisdictionName",
          "rateName",
          "jurisdictionType",
          "rate",
          "saleCount",
          "refundCount",
          "taxCollected",
          "taxRefunded",
          "netTax"
        ],
        "properties": {
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "sellers_use",
              "consumers_use"
            ]
          },
          "jurisdictionName": {
            "type": "string"
          },
          "rateName": {
            "type": "string"
          },
          "jurisdictionType": {
            "type": "string"
          },
          "rate": {
            "type": "number"
          },
          "saleCount": {
            "type": "integer"
          },
          "refundCount": {
            "type": "integer"
          },
          "taxCollected": {
            "type": "number"
          },
          "taxRefunded": {
            "type": "number"
          },
          "netTax": {
            "type": "number"
          }
        }
      },
      "FilingReportTotals": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "saleCount",
          "refundCount",
          "grossSales",
          "refundedSales",
          "netSales",
          "taxableSales",
          "exemptSales",
          "shippingAmount",
          "taxCollected",
          "taxRefunded",
          "netTax"
        ],
        "properties": {
          "saleCount": {
            "type": "integer"
          },
          "refundCount": {
            "type": "integer"
          },
          "grossSales": {
            "type": "number"
          },
          "refundedSales": {
            "type": "number"
          },
          "netSales": {
            "type": "number"
          },
          "taxableSales": {
            "type": "number"
          },
          "exemptSales": {
            "type": "number"
          },
          "shippingAmount": {
            "type": "number"
          },
          "taxCollected": {
            "type": "number"
          },
          "taxRefunded": {
            "type": "number"
          },
          "consumerUsePurchases": {
            "type": "number",
            "description": "Net buyer AP purchases subject to consumer's use tax (kept separate from seller grossSales on combined returns)."
          },
          "consumerUseTaxablePurchases": {
            "type": "number"
          },
          "consumerUseTaxDue": {
            "type": "number"
          },
          "consumerUseTaxCredit": {
            "type": "number"
          },
          "taxPaid": {
            "type": "number"
          },
          "taxCredit": {
            "type": "number"
          },
          "netTax": {
            "type": "number"
          }
        }
      },
      "FilingReportStateSummary": {
        "allOf": [
          {
            "$ref": "#/components/schemas/FilingReportTotals"
          },
          {
            "type": "object",
            "required": [
              "stateCode",
              "stateName",
              "jurisdictions"
            ],
            "properties": {
              "stateCode": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "stateName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "byTaxType": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "sales": {
                    "$ref": "#/components/schemas/FilingReportTotals"
                  },
                  "sellers_use": {
                    "$ref": "#/components/schemas/FilingReportTotals"
                  },
                  "consumers_use": {
                    "$ref": "#/components/schemas/FilingReportTotals"
                  }
                }
              },
              "jurisdictions": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/FilingReportJurisdictionLine"
                }
              }
            }
          }
        ]
      },
      "TaxFilingReportResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "period",
          "stateFilter",
          "generatedAt",
          "truncated",
          "transactionCount",
          "totals",
          "states"
        ],
        "properties": {
          "period": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "from",
              "to"
            ],
            "properties": {
              "from": {
                "type": "string",
                "format": "date"
              },
              "to": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "stateFilter": {
            "type": [
              "string",
              "null"
            ]
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "truncated": {
            "type": "boolean"
          },
          "transactionCount": {
            "type": "integer"
          },
          "totals": {
            "$ref": "#/components/schemas/FilingReportTotals"
          },
          "states": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingReportStateSummary"
            }
          },
          "entity": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ReportingEntityScope"
              },
              {
                "type": "null"
              }
            ]
          },
          "taxTypeFilter": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "sales",
              "sellers_use",
              "consumers_use",
              null
            ]
          },
          "byTaxType": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "sales": {
                "$ref": "#/components/schemas/FilingReportTotals"
              },
              "sellers_use": {
                "$ref": "#/components/schemas/FilingReportTotals"
              },
              "consumers_use": {
                "$ref": "#/components/schemas/FilingReportTotals"
              }
            }
          }
        }
      },
      "TaxCalculateEntitySummary": {
        "type": "object",
        "required": [
          "entityId",
          "legalName",
          "ein"
        ],
        "properties": {
          "entityId": {
            "type": "string"
          },
          "legalName": {
            "type": "string"
          },
          "ein": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ReportingEntityScope": {
        "type": "object",
        "required": [
          "entityId",
          "legalName",
          "ein",
          "includeChildren",
          "includedEntityIds"
        ],
        "properties": {
          "entityId": {
            "type": "string"
          },
          "legalName": {
            "type": "string"
          },
          "ein": {
            "type": [
              "string",
              "null"
            ]
          },
          "includeChildren": {
            "type": "boolean"
          },
          "includedEntityIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "EntityDefaultShipFrom": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "address": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          },
          "lat": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "lon": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          },
          "stateCode": {
            "type": "string",
            "minLength": 2,
            "maxLength": 64
          }
        }
      },
      "PublicEntity": {
        "type": "object",
        "required": [
          "entityId",
          "legalName",
          "dbaName",
          "code",
          "ein",
          "einLast4",
          "structureType",
          "parentEntityId",
          "taxReportingMode",
          "isDefault",
          "status",
          "defaultShipFrom",
          "metadata",
          "depth",
          "childCount",
          "reportingParentEntityId",
          "createdAt",
          "updatedAt",
          "archivedAt"
        ],
        "properties": {
          "entityId": {
            "type": "string"
          },
          "legalName": {
            "type": "string"
          },
          "dbaName": {
            "type": [
              "string",
              "null"
            ]
          },
          "code": {
            "type": [
              "string",
              "null"
            ]
          },
          "ein": {
            "type": [
              "string",
              "null"
            ]
          },
          "einLast4": {
            "type": [
              "string",
              "null"
            ]
          },
          "structureType": {
            "type": "string",
            "enum": [
              "corporation",
              "llc",
              "partnership",
              "sole_proprietor",
              "nonprofit",
              "government",
              "disregarded_entity",
              "division"
            ]
          },
          "parentEntityId": {
            "type": [
              "string",
              "null"
            ]
          },
          "taxReportingMode": {
            "type": "string",
            "enum": [
              "separate_filer",
              "consolidated_with_parent"
            ]
          },
          "isDefault": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived"
            ]
          },
          "defaultShipFrom": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EntityDefaultShipFrom"
              },
              {
                "type": "null"
              }
            ]
          },
          "metadata": {
            "oneOf": [
              {
                "type": "object",
                "maxProperties": 10,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 256
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "depth": {
            "type": "integer",
            "minimum": 0,
            "maximum": 4
          },
          "childCount": {
            "type": "integer",
            "minimum": 0
          },
          "reportingParentEntityId": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          },
          "archivedAt": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "EntityChildSummary": {
        "type": "object",
        "required": [
          "entityId",
          "legalName",
          "dbaName",
          "code",
          "structureType",
          "taxReportingMode",
          "status",
          "depth",
          "childCount"
        ],
        "properties": {
          "entityId": {
            "type": "string"
          },
          "legalName": {
            "type": "string"
          },
          "dbaName": {
            "type": [
              "string",
              "null"
            ]
          },
          "code": {
            "type": [
              "string",
              "null"
            ]
          },
          "structureType": {
            "type": "string",
            "enum": [
              "corporation",
              "llc",
              "partnership",
              "sole_proprietor",
              "nonprofit",
              "government",
              "disregarded_entity",
              "division"
            ]
          },
          "taxReportingMode": {
            "type": "string",
            "enum": [
              "separate_filer",
              "consolidated_with_parent"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived"
            ]
          },
          "depth": {
            "type": "integer"
          },
          "childCount": {
            "type": "integer"
          }
        }
      },
      "PublicEntityRegistration": {
        "type": "object",
        "required": [
          "entityId",
          "stateCode",
          "stateName",
          "permitNumber",
          "filingFrequency",
          "effectiveDate",
          "status",
          "notes",
          "createdAt",
          "updatedAt",
          "closedAt"
        ],
        "properties": {
          "entityId": {
            "type": "string"
          },
          "stateCode": {
            "type": "string"
          },
          "stateName": {
            "type": "string"
          },
          "permitNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "filingFrequency": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "monthly",
              "quarterly",
              "annual",
              null
            ]
          },
          "effectiveDate": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "closed"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          },
          "closedAt": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "CreateEntityRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "legalName"
        ],
        "properties": {
          "legalName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "dbaName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "code": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{0,63}$"
          },
          "ein": {
            "type": "string",
            "minLength": 9,
            "maxLength": 12
          },
          "structureType": {
            "type": "string",
            "enum": [
              "corporation",
              "llc",
              "partnership",
              "sole_proprietor",
              "nonprofit",
              "government",
              "disregarded_entity",
              "division"
            ]
          },
          "parentEntityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "taxReportingMode": {
            "type": "string",
            "enum": [
              "separate_filer",
              "consolidated_with_parent"
            ]
          },
          "isDefault": {
            "type": "boolean"
          },
          "defaultShipFrom": {
            "$ref": "#/components/schemas/EntityDefaultShipFrom"
          },
          "metadata": {
            "type": "object",
            "maxProperties": 10,
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
            },
            "additionalProperties": {
              "type": "string",
              "maxLength": 256
            }
          }
        }
      },
      "UpdateEntityRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "legalName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "dbaName": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "ein": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 12
          },
          "structureType": {
            "type": "string",
            "enum": [
              "corporation",
              "llc",
              "partnership",
              "sole_proprietor",
              "nonprofit",
              "government",
              "disregarded_entity",
              "division"
            ]
          },
          "parentEntityId": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 96
          },
          "taxReportingMode": {
            "type": "string",
            "enum": [
              "separate_filer",
              "consolidated_with_parent"
            ]
          },
          "isDefault": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived"
            ]
          },
          "defaultShipFrom": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EntityDefaultShipFrom"
              },
              {
                "type": "null"
              }
            ]
          },
          "metadata": {
            "oneOf": [
              {
                "type": "object",
                "maxProperties": 10,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 256
                }
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "EntitiesListResponse": {
        "type": "object",
        "required": [
          "count",
          "entities"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "entities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicEntity"
            }
          }
        }
      },
      "EntityResponse": {
        "type": "object",
        "required": [
          "entity"
        ],
        "properties": {
          "entity": {
            "$ref": "#/components/schemas/PublicEntity"
          }
        }
      },
      "EntityDetailResponse": {
        "type": "object",
        "required": [
          "entity",
          "registrations",
          "children"
        ],
        "properties": {
          "entity": {
            "$ref": "#/components/schemas/PublicEntity"
          },
          "registrations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicEntityRegistration"
            }
          },
          "children": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EntityChildSummary"
            }
          }
        }
      },
      "EntityRegistrationsListResponse": {
        "type": "object",
        "required": [
          "entityId",
          "count",
          "registrations"
        ],
        "properties": {
          "entityId": {
            "type": "string"
          },
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "registrations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicEntityRegistration"
            }
          }
        }
      },
      "UpsertEntityRegistrationRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "permitNumber": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 128
          },
          "filingFrequency": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "monthly",
              "quarterly",
              "annual",
              null
            ]
          },
          "effectiveDate": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "closed"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          }
        }
      },
      "EntityRegistrationResponse": {
        "type": "object",
        "required": [
          "registration"
        ],
        "properties": {
          "registration": {
            "$ref": "#/components/schemas/PublicEntityRegistration"
          }
        }
      },
      "PublicCustomProduct": {
        "type": "object",
        "required": [
          "productId",
          "entityId",
          "productCode",
          "name",
          "description",
          "baseItemKey",
          "defaultTreatment",
          "status",
          "metadata",
          "createdAt",
          "updatedAt",
          "archivedAt"
        ],
        "properties": {
          "productId": {
            "type": "string"
          },
          "entityId": {
            "type": [
              "string",
              "null"
            ]
          },
          "productCode": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "baseItemKey": {
            "type": [
              "string",
              "null"
            ]
          },
          "defaultTreatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived"
            ]
          },
          "metadata": {
            "oneOf": [
              {
                "type": "object",
                "maxProperties": 10,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 256
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          },
          "archivedAt": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "CreateCustomProductRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "productCode",
          "name"
        ],
        "properties": {
          "productCode": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "baseItemKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "defaultTreatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt"
            ]
          },
          "metadata": {
            "type": "object",
            "maxProperties": 10,
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
            },
            "additionalProperties": {
              "type": "string",
              "maxLength": 256
            }
          }
        }
      },
      "UpdateCustomProductRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "baseItemKey": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "defaultTreatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "archived"
            ]
          },
          "metadata": {
            "oneOf": [
              {
                "type": "object",
                "maxProperties": 10,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 256
                }
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ProductsListResponse": {
        "type": "object",
        "required": [
          "count",
          "products"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "products": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicCustomProduct"
            }
          }
        }
      },
      "CustomProductResponse": {
        "type": "object",
        "required": [
          "product"
        ],
        "properties": {
          "product": {
            "$ref": "#/components/schemas/PublicCustomProduct"
          }
        }
      },
      "PublicCustomTaxRule": {
        "type": "object",
        "required": [
          "ruleId",
          "entityId",
          "targetType",
          "targetKey",
          "jurisdictionScope",
          "stateCode",
          "jurisdictionName",
          "effectiveDate",
          "endDate",
          "buyerType",
          "customerTags",
          "minUnitAmountDollars",
          "maxUnitAmountDollars",
          "minLineSubtotalDollars",
          "maxLineSubtotalDollars",
          "sourcingType",
          "treatment",
          "reducedRate",
          "reducedRateScope",
          "rateDelta",
          "rateMultiplier",
          "rateScope",
          "thresholdDollars",
          "thresholdMode",
          "taxablePercent",
          "maxTaxPerUnitDollars",
          "maxTaxPerLineDollars",
          "priority",
          "status",
          "note",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "ruleId": {
            "type": "string"
          },
          "entityId": {
            "type": [
              "string",
              "null"
            ]
          },
          "targetType": {
            "type": "string",
            "enum": [
              "product",
              "item_key",
              "all"
            ]
          },
          "targetKey": {
            "type": [
              "string",
              "null"
            ]
          },
          "jurisdictionScope": {
            "type": "string",
            "enum": [
              "all_us",
              "state",
              "county",
              "city",
              "district"
            ]
          },
          "stateCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "jurisdictionName": {
            "type": [
              "string",
              "null"
            ]
          },
          "effectiveDate": {
            "type": [
              "string",
              "null"
            ]
          },
          "endDate": {
            "type": [
              "string",
              "null"
            ]
          },
          "buyerType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "b2b",
              "b2c",
              null
            ]
          },
          "customerTags": {
            "oneOf": [
              {
                "type": "array",
                "minItems": 1,
                "maxItems": 20,
                "items": {
                  "type": "string",
                  "pattern": "^[a-z0-9][a-z0-9_-]{0,47}$"
                },
                "description": "Optional lowercase buyer/customer tags (1-20 tags) for custom tax rule matching."
              },
              {
                "type": "null"
              }
            ]
          },
          "minUnitAmountDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "maxUnitAmountDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "minLineSubtotalDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "maxLineSubtotalDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "sourcingType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "intrastate",
              "interstate",
              null
            ]
          },
          "treatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt",
              "reduced_rate",
              "rate_adjustment"
            ]
          },
          "reducedRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "reducedRateScope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only",
              null
            ]
          },
          "rateDelta": {
            "type": [
              "number",
              "null"
            ]
          },
          "rateMultiplier": {
            "type": [
              "number",
              "null"
            ]
          },
          "rateScope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only",
              null
            ],
            "description": "Scope for rate_adjustment rules or local county/city/district exempt rules."
          },
          "thresholdDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "thresholdMode": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "exempt_below_full_above",
              "exempt_up_to_excess_taxable",
              null
            ]
          },
          "taxablePercent": {
            "type": [
              "number",
              "null"
            ]
          },
          "maxTaxPerUnitDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "maxTaxPerLineDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "priority": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "description": "Explicit tie-break priority (0-10000). Lower priority number wins."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disabled"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          }
        }
      },
      "CreateCustomRuleRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "targetType",
          "jurisdictionScope",
          "treatment"
        ],
        "properties": {
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "targetType": {
            "type": "string",
            "enum": [
              "product",
              "item_key",
              "all"
            ]
          },
          "targetKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "jurisdictionScope": {
            "type": "string",
            "enum": [
              "all_us",
              "state",
              "county",
              "city",
              "district"
            ]
          },
          "state": {
            "type": "string",
            "minLength": 2,
            "maxLength": 64
          },
          "jurisdictionName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "effectiveDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "endDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "buyerType": {
            "type": "string",
            "enum": [
              "b2b",
              "b2c"
            ]
          },
          "customerTags": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9_-]{0,47}$"
            },
            "description": "Optional lowercase buyer/customer tags (1-20 tags) for custom tax rule matching."
          },
          "minUnitAmountDollars": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "maxUnitAmountDollars": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "minLineSubtotalDollars": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "maxLineSubtotalDollars": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "sourcingType": {
            "type": "string",
            "enum": [
              "intrastate",
              "interstate"
            ]
          },
          "treatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt",
              "reduced_rate",
              "rate_adjustment"
            ]
          },
          "reducedRate": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "reducedRateScope": {
            "type": "string",
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only"
            ]
          },
          "rateDelta": {
            "type": "number",
            "minimum": -1,
            "maximum": 1
          },
          "rateMultiplier": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "rateScope": {
            "type": "string",
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only"
            ],
            "description": "Scope for rate_adjustment rules, or optional scope (jurisdiction_only default, or combined) for local county/city/district exempt rules."
          },
          "thresholdDollars": {
            "type": "number",
            "maximum": 1000000,
            "exclusiveMinimum": 0
          },
          "thresholdMode": {
            "type": "string",
            "enum": [
              "exempt_below_full_above",
              "exempt_up_to_excess_taxable"
            ]
          },
          "taxablePercent": {
            "type": "number",
            "maximum": 100,
            "exclusiveMinimum": 0
          },
          "maxTaxPerUnitDollars": {
            "type": "number",
            "maximum": 1000000000,
            "exclusiveMinimum": 0
          },
          "maxTaxPerLineDollars": {
            "type": "number",
            "maximum": 1000000000,
            "exclusiveMinimum": 0
          },
          "priority": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "description": "Explicit tie-break priority (0-10000, default 100). Lower priority number wins."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disabled"
            ]
          },
          "note": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          }
        }
      },
      "UpdateCustomRuleRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "entityId": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 96
          },
          "targetType": {
            "type": "string",
            "enum": [
              "product",
              "item_key",
              "all"
            ]
          },
          "targetKey": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "jurisdictionScope": {
            "type": "string",
            "enum": [
              "all_us",
              "state",
              "county",
              "city",
              "district"
            ]
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "jurisdictionName": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "effectiveDate": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "endDate": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "buyerType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "b2b",
              "b2c",
              null
            ]
          },
          "customerTags": {
            "oneOf": [
              {
                "type": "array",
                "minItems": 1,
                "maxItems": 20,
                "items": {
                  "type": "string",
                  "pattern": "^[a-z0-9][a-z0-9_-]{0,47}$"
                },
                "description": "Optional lowercase buyer/customer tags (1-20 tags) for custom tax rule matching."
              },
              {
                "type": "null"
              }
            ]
          },
          "minUnitAmountDollars": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000000
          },
          "maxUnitAmountDollars": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000000
          },
          "minLineSubtotalDollars": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000000
          },
          "maxLineSubtotalDollars": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000000
          },
          "sourcingType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "intrastate",
              "interstate",
              null
            ]
          },
          "treatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt",
              "reduced_rate",
              "rate_adjustment"
            ]
          },
          "reducedRate": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1
          },
          "reducedRateScope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only",
              null
            ]
          },
          "rateDelta": {
            "type": [
              "number",
              "null"
            ],
            "minimum": -1,
            "maximum": 1
          },
          "rateMultiplier": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 2
          },
          "rateScope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "state_only",
              "combined",
              "jurisdiction_only",
              null
            ],
            "description": "Scope for rate_adjustment rules, or optional scope (jurisdiction_only default, or combined) for local county/city/district exempt rules."
          },
          "thresholdDollars": {
            "type": [
              "number",
              "null"
            ],
            "maximum": 1000000,
            "exclusiveMinimum": 0
          },
          "thresholdMode": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "exempt_below_full_above",
              "exempt_up_to_excess_taxable",
              null
            ]
          },
          "taxablePercent": {
            "type": [
              "number",
              "null"
            ],
            "maximum": 100,
            "exclusiveMinimum": 0
          },
          "maxTaxPerUnitDollars": {
            "type": [
              "number",
              "null"
            ],
            "maximum": 1000000000,
            "exclusiveMinimum": 0
          },
          "maxTaxPerLineDollars": {
            "type": [
              "number",
              "null"
            ],
            "maximum": 1000000000,
            "exclusiveMinimum": 0
          },
          "priority": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "description": "Explicit tie-break priority (0-10000, default 100). Lower priority number wins."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disabled"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          }
        }
      },
      "RulesListResponse": {
        "type": "object",
        "required": [
          "count",
          "rules"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicCustomTaxRule"
            }
          }
        }
      },
      "CustomRuleResponse": {
        "type": "object",
        "required": [
          "rule"
        ],
        "properties": {
          "rule": {
            "$ref": "#/components/schemas/PublicCustomTaxRule"
          }
        }
      },
      "DeleteCustomRuleResponse": {
        "type": "object",
        "required": [
          "deleted",
          "ruleId"
        ],
        "properties": {
          "deleted": {
            "type": "boolean",
            "const": true
          },
          "ruleId": {
            "type": "string"
          }
        }
      },
      "TestCustomRuleRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "state"
        ],
        "properties": {
          "state": {
            "type": "string",
            "minLength": 2,
            "maxLength": 64
          },
          "jurisdiction": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "jurisdictionType": {
            "type": "string",
            "enum": [
              "county",
              "city",
              "district"
            ]
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "productCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "itemKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "transactionDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "buyerType": {
            "type": "string",
            "enum": [
              "b2b",
              "b2c"
            ]
          },
          "customerTags": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9_-]{0,47}$"
            },
            "description": "Optional lowercase buyer/customer tags (0-20 tags; empty array permitted) for custom tax rule matching."
          },
          "unitAmount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "sourcingType": {
            "type": "string",
            "enum": [
              "intrastate",
              "interstate"
            ]
          },
          "baseStateRate": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "baseLocalRate": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "baseCombinedRate": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          }
        }
      },
      "RuleDryRunPreview": {
        "type": "object",
        "required": [
          "baseCombinedRate",
          "effectiveCombinedRate",
          "effectiveStateRate",
          "effectiveLocalRate",
          "subtotalDollars",
          "taxableAmountDollars",
          "exemptAmountDollars",
          "estimatedTaxDollars",
          "taxCapped"
        ],
        "properties": {
          "baseCombinedRate": {
            "type": "number"
          },
          "effectiveCombinedRate": {
            "type": "number"
          },
          "effectiveStateRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "effectiveLocalRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "subtotalDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "taxableAmountDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "exemptAmountDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "estimatedTaxDollars": {
            "type": [
              "number",
              "null"
            ]
          },
          "taxCapped": {
            "type": "boolean"
          }
        }
      },
      "RuleTestResponse": {
        "type": "object",
        "required": [
          "matched",
          "rule",
          "summary",
          "matchedJurisdiction",
          "entityScope",
          "candidatesEvaluated",
          "matchedCount",
          "reason",
          "preview"
        ],
        "properties": {
          "matched": {
            "type": "boolean"
          },
          "rule": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PublicCustomTaxRule"
              },
              {
                "type": "null"
              }
            ]
          },
          "summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "matchedJurisdiction": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "jurisdictionType",
                  "jurisdictionName"
                ],
                "properties": {
                  "jurisdictionType": {
                    "type": "string",
                    "enum": [
                      "county",
                      "city",
                      "district"
                    ]
                  },
                  "jurisdictionName": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "entityScope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "exact",
              "inherited",
              "workspace",
              null
            ]
          },
          "candidatesEvaluated": {
            "type": "integer",
            "minimum": 0
          },
          "matchedCount": {
            "type": "integer",
            "minimum": 0
          },
          "reason": {
            "type": "string"
          },
          "preview": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RuleDryRunPreview"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "FilingTaxTypeSummaryCents": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "saleCount",
          "refundCount",
          "grossAmountCents",
          "refundedAmountCents",
          "taxableAmountCents",
          "exemptAmountCents",
          "shippingCents",
          "taxCollectedCents",
          "taxRefundedCents",
          "netTaxDueCents"
        ],
        "properties": {
          "saleCount": {
            "type": "integer"
          },
          "refundCount": {
            "type": "integer"
          },
          "grossAmountCents": {
            "type": "integer"
          },
          "refundedAmountCents": {
            "type": "integer"
          },
          "taxableAmountCents": {
            "type": "integer"
          },
          "exemptAmountCents": {
            "type": "integer"
          },
          "shippingCents": {
            "type": "integer"
          },
          "taxCollectedCents": {
            "type": "integer"
          },
          "taxRefundedCents": {
            "type": "integer"
          },
          "netTaxDueCents": {
            "type": "integer"
          },
          "taxPaidCents": {
            "type": "integer"
          },
          "taxCreditCents": {
            "type": "integer"
          }
        }
      },
      "FilingJurisdictionSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "jurisdictionName",
          "rateName",
          "jurisdictionType",
          "rate",
          "saleCount",
          "refundCount",
          "taxCollectedCents",
          "taxRefundedCents",
          "netTaxCents"
        ],
        "properties": {
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "sellers_use",
              "consumers_use"
            ]
          },
          "jurisdictionName": {
            "type": "string"
          },
          "rateName": {
            "type": "string"
          },
          "jurisdictionType": {
            "type": "string"
          },
          "rate": {
            "type": "number"
          },
          "saleCount": {
            "type": "integer"
          },
          "refundCount": {
            "type": "integer"
          },
          "taxCollectedCents": {
            "type": "integer"
          },
          "taxRefundedCents": {
            "type": "integer"
          },
          "netTaxCents": {
            "type": "integer"
          }
        }
      },
      "FilingSummarySnapshot": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "saleCount",
          "refundCount",
          "totalGrossSalesCents",
          "totalRefundedSalesCents",
          "totalTaxableSalesCents",
          "totalExemptSalesCents",
          "totalShippingCents",
          "totalTaxCollectedCents",
          "totalTaxRefundedCents",
          "netTaxDueCents",
          "transactionCount",
          "truncated",
          "jurisdictions",
          "generatedAt"
        ],
        "properties": {
          "saleCount": {
            "type": "integer"
          },
          "refundCount": {
            "type": "integer"
          },
          "totalGrossSalesCents": {
            "type": "integer"
          },
          "totalRefundedSalesCents": {
            "type": "integer"
          },
          "totalTaxableSalesCents": {
            "type": "integer"
          },
          "totalExemptSalesCents": {
            "type": "integer"
          },
          "totalShippingCents": {
            "type": "integer"
          },
          "totalTaxCollectedCents": {
            "type": "integer"
          },
          "totalTaxRefundedCents": {
            "type": "integer"
          },
          "consumerUseCount": {
            "type": "integer"
          },
          "consumerUseRefundCount": {
            "type": "integer"
          },
          "consumerUsePurchasesCents": {
            "type": "integer"
          },
          "consumerUseTaxablePurchasesCents": {
            "type": "integer"
          },
          "consumerUseTaxDueCents": {
            "type": "integer"
          },
          "consumerUseTaxCreditCents": {
            "type": "integer"
          },
          "byTaxType": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "sales": {
                "$ref": "#/components/schemas/FilingTaxTypeSummaryCents"
              },
              "sellers_use": {
                "$ref": "#/components/schemas/FilingTaxTypeSummaryCents"
              },
              "consumers_use": {
                "$ref": "#/components/schemas/FilingTaxTypeSummaryCents"
              }
            }
          },
          "netTaxDueCents": {
            "type": "integer"
          },
          "transactionCount": {
            "type": "integer"
          },
          "truncated": {
            "type": "boolean"
          },
          "jurisdictions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingJurisdictionSummary"
            }
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "priorNetTaxDueCents": {
            "type": "integer"
          },
          "deltaTaxDueCents": {
            "type": "integer"
          }
        }
      },
      "FilingRecord": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "filingId",
          "entityId",
          "stateCode",
          "stateName",
          "periodStart",
          "periodEnd",
          "filingFrequency",
          "dueDate",
          "status",
          "amendedFromFilingId",
          "summary",
          "totalGrossSalesCents",
          "totalTaxableSalesCents",
          "totalExemptSalesCents",
          "totalTaxCollectedCents",
          "totalTaxRefundedCents",
          "netTaxDueCents",
          "deltaTaxDueCents",
          "transactionCount",
          "truncated",
          "confirmationNumber",
          "notes",
          "metadata",
          "lockedAt",
          "filedAt",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "filingId": {
            "type": "string",
            "pattern": "^flg_[a-f0-9]{16,32}$"
          },
          "entityId": {
            "type": "string",
            "pattern": "^ent_[a-f0-9]{16,64}$"
          },
          "stateCode": {
            "type": "string"
          },
          "stateName": {
            "type": "string"
          },
          "periodStart": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "periodEnd": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "filingFrequency": {
            "type": "string",
            "enum": [
              "monthly",
              "quarterly",
              "annual"
            ]
          },
          "dueDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "ready",
              "filed",
              "amended"
            ]
          },
          "amendedFromFilingId": {
            "type": [
              "string",
              "null"
            ]
          },
          "summary": {
            "$ref": "#/components/schemas/FilingSummarySnapshot"
          },
          "totalGrossSalesCents": {
            "type": "integer"
          },
          "totalTaxableSalesCents": {
            "type": "integer"
          },
          "totalExemptSalesCents": {
            "type": "integer"
          },
          "totalTaxCollectedCents": {
            "type": "integer"
          },
          "totalTaxRefundedCents": {
            "type": "integer"
          },
          "netTaxDueCents": {
            "type": "integer"
          },
          "deltaTaxDueCents": {
            "type": [
              "integer",
              "null"
            ]
          },
          "transactionCount": {
            "type": "integer"
          },
          "truncated": {
            "type": "boolean"
          },
          "confirmationNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "oneOf": [
              {
                "type": "object",
                "maxProperties": 10,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 256
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "lockedAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "filedAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          }
        }
      },
      "FilingCalendarItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "entityId",
          "stateCode",
          "stateName",
          "filingFrequency",
          "periodStart",
          "periodEnd",
          "dueDate",
          "status",
          "filingId",
          "isOverdue"
        ],
        "properties": {
          "entityId": {
            "type": "string",
            "pattern": "^ent_[a-f0-9]{16,64}$"
          },
          "stateCode": {
            "type": "string"
          },
          "stateName": {
            "type": "string"
          },
          "filingFrequency": {
            "type": "string",
            "enum": [
              "monthly",
              "quarterly",
              "annual"
            ]
          },
          "periodStart": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "periodEnd": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "dueDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "status": {
            "type": "string",
            "enum": [
              "unstarted",
              "draft",
              "ready",
              "filed",
              "amended"
            ]
          },
          "filingId": {
            "type": [
              "string",
              "null"
            ]
          },
          "isOverdue": {
            "type": "boolean"
          }
        }
      },
      "CreateFilingRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "entityId",
          "periodStart",
          "periodEnd"
        ],
        "properties": {
          "entityId": {
            "type": "string",
            "pattern": "^ent_[a-f0-9]{16,64}$"
          },
          "state": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "stateCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "periodStart": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "periodEnd": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "filingFrequency": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "monthly",
              "quarterly",
              "annual",
              null
            ]
          },
          "dueDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "confirmationNumber": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 120
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 1000
          },
          "metadata": {
            "oneOf": [
              {
                "type": "object",
                "maxProperties": 10,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 256
                }
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "UpdateFilingRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "ready",
              "filed"
            ]
          },
          "confirmationNumber": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 120
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 1000
          },
          "metadata": {
            "oneOf": [
              {
                "type": "object",
                "maxProperties": 10,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 256
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "refreshSnapshot": {
            "type": "boolean"
          }
        }
      },
      "AmendFilingRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "maxLength": 1000
          },
          "metadata": {
            "oneOf": [
              {
                "type": "object",
                "maxProperties": 10,
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 256
                }
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "FilingsListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "filings"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "filings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingRecord"
            }
          }
        }
      },
      "FilingCalendarResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "from",
          "to",
          "asOf",
          "count",
          "items"
        ],
        "properties": {
          "from": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "to": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "asOf": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FilingCalendarItem"
            }
          }
        }
      },
      "FilingResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "filing"
        ],
        "properties": {
          "filing": {
            "$ref": "#/components/schemas/FilingRecord"
          }
        }
      },
      "AmendFilingResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "filing",
          "originalFiling",
          "deltaTaxDueCents"
        ],
        "properties": {
          "filing": {
            "$ref": "#/components/schemas/FilingRecord"
          },
          "originalFiling": {
            "$ref": "#/components/schemas/FilingRecord"
          },
          "deltaTaxDueCents": {
            "type": "integer"
          }
        }
      },
      "TransactionImportRowInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "transactionDate",
          "state",
          "subtotal",
          "taxAmount"
        ],
        "properties": {
          "externalId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "transactionDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "state": {
            "type": "string",
            "minLength": 2,
            "maxLength": 64
          },
          "subtotal": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "taxableAmount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "exemptAmount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "shipping": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "taxAmount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "totalFees": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000
          },
          "taxRate": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "type": {
            "type": "string",
            "enum": [
              "sale",
              "refund"
            ]
          },
          "customerId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "exemptionReason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "metadata": {
            "type": "object",
            "maxProperties": 10,
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
            },
            "additionalProperties": {
              "type": "string",
              "maxLength": 256
            }
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "sellers_use",
              "consumers_use"
            ],
            "description": "Tax schedule and sourcing classification: sales (default), sellers_use (destination seller use tax), or consumers_use (destination self-assessed consumer use tax)."
          }
        }
      },
      "TransactionsImportRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "format"
        ],
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "json",
              "csv"
            ]
          },
          "rows": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "$ref": "#/components/schemas/TransactionImportRowInput"
            }
          },
          "csv": {
            "type": "string",
            "minLength": 1
          },
          "preset": {
            "type": "string",
            "enum": [
              "generic",
              "stripe",
              "shopify"
            ]
          },
          "dryRun": {
            "type": "boolean"
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "entityCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "ein": {
            "type": "string",
            "minLength": 9,
            "maxLength": 12
          }
        }
      },
      "TransactionImportRowResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "row",
          "status"
        ],
        "properties": {
          "row": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "imported",
              "valid",
              "skipped_duplicate",
              "error"
            ]
          },
          "transactionId": {
            "type": "string"
          },
          "existingTransactionId": {
            "type": "string"
          },
          "externalId": {
            "type": "string"
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "TransactionsImportResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "dryRun",
          "totalRows",
          "imported",
          "valid",
          "skippedDuplicates",
          "failed",
          "results"
        ],
        "properties": {
          "dryRun": {
            "type": "boolean"
          },
          "totalRows": {
            "type": "integer",
            "minimum": 0
          },
          "imported": {
            "type": "integer",
            "minimum": 0
          },
          "valid": {
            "type": "integer",
            "minimum": 0
          },
          "skippedDuplicates": {
            "type": "integer",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "minimum": 0
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TransactionImportRowResult"
            }
          }
        }
      },
      "ExemptionsImportRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "format"
        ],
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "json",
              "csv"
            ]
          },
          "rows": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/CreateExemptionRequest"
            }
          },
          "csv": {
            "type": "string",
            "minLength": 1
          },
          "dryRun": {
            "type": "boolean"
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "entityCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "ein": {
            "type": "string",
            "minLength": 9,
            "maxLength": 12
          }
        }
      },
      "ExemptionImportRowResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "row",
          "status"
        ],
        "properties": {
          "row": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "imported",
              "valid",
              "skipped_duplicate",
              "error"
            ]
          },
          "certificateId": {
            "type": "string"
          },
          "existingCertificateId": {
            "type": "string"
          },
          "customerId": {
            "type": "string"
          },
          "certificateNumber": {
            "type": "string"
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "ExemptionsImportResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "dryRun",
          "totalRows",
          "imported",
          "valid",
          "skippedDuplicates",
          "failed",
          "results"
        ],
        "properties": {
          "dryRun": {
            "type": "boolean"
          },
          "totalRows": {
            "type": "integer",
            "minimum": 0
          },
          "imported": {
            "type": "integer",
            "minimum": 0
          },
          "valid": {
            "type": "integer",
            "minimum": 0
          },
          "skippedDuplicates": {
            "type": "integer",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "minimum": 0
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExemptionImportRowResult"
            }
          }
        }
      },
      "ProductsImportRowInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "productCode",
          "name"
        ],
        "properties": {
          "productCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "baseItemKey": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "defaultTreatment": {
            "type": "string",
            "enum": [
              "taxable",
              "exempt"
            ]
          },
          "sku": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "tags": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "metadata": {
            "type": "object",
            "maxProperties": 10,
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"
            },
            "additionalProperties": {
              "type": "string",
              "maxLength": 256
            }
          }
        }
      },
      "ProductsImportRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "format"
        ],
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "json",
              "csv"
            ]
          },
          "rows": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/ProductsImportRowInput"
            }
          },
          "csv": {
            "type": "string",
            "minLength": 1
          },
          "dryRun": {
            "type": "boolean"
          },
          "upsert": {
            "type": "boolean"
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "entityCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "ein": {
            "type": "string",
            "minLength": 9,
            "maxLength": 12
          }
        }
      },
      "ProductImportRowResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "row",
          "status"
        ],
        "properties": {
          "row": {
            "type": "integer",
            "minimum": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "imported",
              "updated",
              "valid",
              "skipped_duplicate",
              "error"
            ]
          },
          "productId": {
            "type": "string"
          },
          "existingProductId": {
            "type": "string"
          },
          "productCode": {
            "type": "string"
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "ProductsImportResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "dryRun",
          "upsert",
          "totalRows",
          "imported",
          "updated",
          "valid",
          "skippedDuplicates",
          "failed",
          "results"
        ],
        "properties": {
          "dryRun": {
            "type": "boolean"
          },
          "upsert": {
            "type": "boolean"
          },
          "totalRows": {
            "type": "integer",
            "minimum": 0
          },
          "imported": {
            "type": "integer",
            "minimum": 0
          },
          "updated": {
            "type": "integer",
            "minimum": 0
          },
          "valid": {
            "type": "integer",
            "minimum": 0
          },
          "skippedDuplicates": {
            "type": "integer",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "minimum": 0
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductImportRowResult"
            }
          }
        }
      },
      "ExemptionDocumentSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "filename",
          "contentType",
          "sizeBytes",
          "sha256",
          "uploadedAt"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "contentType": {
            "type": "string",
            "enum": [
              "application/pdf",
              "image/png",
              "image/jpeg"
            ]
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3145728
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "uploadedAt": {
            "type": "integer"
          }
        }
      },
      "ExemptionDocumentDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "filename",
          "contentType",
          "sizeBytes",
          "sha256",
          "uploadedAt",
          "contentBase64"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "contentType": {
            "type": "string",
            "enum": [
              "application/pdf",
              "image/png",
              "image/jpeg"
            ]
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3145728
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "uploadedAt": {
            "type": "integer"
          },
          "contentBase64": {
            "type": "string",
            "minLength": 4,
            "description": "Standard RFC 4648 base64-encoded file contents (up to 3 MiB decoded binary)."
          }
        }
      },
      "UploadExemptionDocumentRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "filename",
          "contentType",
          "contentBase64"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "contentType": {
            "type": "string",
            "enum": [
              "application/pdf",
              "image/png",
              "image/jpeg"
            ]
          },
          "contentBase64": {
            "type": "string",
            "minLength": 4
          }
        }
      },
      "ExemptionDocumentGetResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "certificateId",
          "document"
        ],
        "properties": {
          "certificateId": {
            "type": "string"
          },
          "document": {
            "$ref": "#/components/schemas/ExemptionDocumentDetail"
          }
        }
      },
      "ExemptionDocumentUploadResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "certificateId",
          "document"
        ],
        "properties": {
          "certificateId": {
            "type": "string"
          },
          "document": {
            "$ref": "#/components/schemas/ExemptionDocumentSummary"
          }
        }
      },
      "ExemptionDocumentDeleteResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "certificateId",
          "deleted"
        ],
        "properties": {
          "certificateId": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "CreateExemptionUploadLinkRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "expiresInHours": {
            "type": "integer",
            "minimum": 1,
            "maximum": 720,
            "default": 168
          }
        }
      },
      "CreateExemptionUploadLinkResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "certificateId",
          "uploadToken",
          "uploadPath",
          "expiresAt"
        ],
        "properties": {
          "certificateId": {
            "type": "string"
          },
          "uploadToken": {
            "type": "string",
            "pattern": "^upl_[A-Za-z0-9_-]{43,64}$"
          },
          "uploadPath": {
            "type": "string"
          },
          "expiresAt": {
            "type": "integer"
          }
        }
      },
      "CommerceConnection": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "connectionId",
          "entityId",
          "provider",
          "label",
          "status",
          "syncMode",
          "webhookSecretLast4",
          "ingestPath",
          "syncedCount",
          "lastSyncedAt",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "connectionId": {
            "type": "string",
            "pattern": "^conn_[a-f0-9]{24}$"
          },
          "entityId": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider": {
            "type": "string",
            "enum": [
              "stripe",
              "shopify"
            ]
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "paused"
            ]
          },
          "syncMode": {
            "type": "string",
            "enum": [
              "commit",
              "dry_run"
            ]
          },
          "webhookSecretLast4": {
            "type": "string",
            "minLength": 4,
            "maxLength": 4
          },
          "ingestPath": {
            "type": "string"
          },
          "syncedCount": {
            "type": "integer",
            "minimum": 0
          },
          "lastSyncedAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          }
        }
      },
      "CreateCommerceConnectionRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "provider",
          "label"
        ],
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "stripe",
              "shopify"
            ]
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "entityId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 96
          },
          "syncMode": {
            "type": "string",
            "enum": [
              "commit",
              "dry_run"
            ],
            "default": "commit"
          },
          "webhookSecret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 256,
            "description": "Optional provider webhook signing secret copied from Stripe (whsec_...) or Shopify (16-256 characters)."
          }
        }
      },
      "UpdateCommerceConnectionRequest": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "paused"
            ]
          },
          "syncMode": {
            "type": "string",
            "enum": [
              "commit",
              "dry_run"
            ]
          },
          "webhookSecret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 256,
            "description": "Optional provider webhook signing secret copied from Stripe (whsec_...) or Shopify (16-256 characters) to replace the stored signing secret."
          },
          "rotateSecret": {
            "type": "boolean"
          }
        }
      },
      "ConnectionsListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "connections"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "connections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CommerceConnection"
            }
          }
        }
      },
      "ConnectionResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "connection"
        ],
        "properties": {
          "connection": {
            "$ref": "#/components/schemas/CommerceConnection"
          },
          "webhookSigningSecret": {
            "type": "string",
            "pattern": "^whsec_[a-f0-9]{48}$"
          }
        }
      },
      "ConnectionDeleteResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "deleted",
          "connectionId"
        ],
        "properties": {
          "deleted": {
            "type": "boolean",
            "const": true
          },
          "connectionId": {
            "type": "string"
          }
        }
      },
      "SyncCommerceConnectionRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "events"
        ],
        "properties": {
          "events": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "type": "object"
            }
          },
          "dryRun": {
            "type": "boolean"
          }
        }
      },
      "SyncEventResultItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "index",
          "externalId",
          "status"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "minimum": 0
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "committed",
              "dry_run",
              "skipped_duplicate",
              "filing_period_locked",
              "skipped"
            ]
          },
          "transactionId": {
            "type": "string"
          },
          "existingTransactionId": {
            "type": "string"
          },
          "filingId": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "sale",
              "refund"
            ]
          },
          "stateCode": {
            "type": "string"
          },
          "transactionDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "subtotalCents": {
            "type": "integer"
          },
          "taxAmountCents": {
            "type": "integer"
          },
          "totalCents": {
            "type": "integer"
          }
        }
      },
      "ConnectionSyncResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "connectionId",
          "provider",
          "syncMode",
          "received",
          "committed",
          "dryRunCount",
          "duplicates",
          "locked",
          "skipped",
          "dryRun",
          "results"
        ],
        "properties": {
          "connectionId": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "stripe",
              "shopify"
            ]
          },
          "syncMode": {
            "type": "string",
            "enum": [
              "commit",
              "dry_run"
            ]
          },
          "received": {
            "type": "integer",
            "minimum": 0
          },
          "committed": {
            "type": "integer",
            "minimum": 0
          },
          "dryRunCount": {
            "type": "integer",
            "minimum": 0
          },
          "duplicates": {
            "type": "integer",
            "minimum": 0
          },
          "locked": {
            "type": "integer",
            "minimum": 0
          },
          "skipped": {
            "type": "integer",
            "minimum": 0
          },
          "dryRun": {
            "type": "boolean"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SyncEventResultItem"
            }
          }
        }
      },
      "SubscribableWebhookEventType": {
        "type": "string",
        "enum": [
          "nexus.approaching",
          "nexus.exceeded",
          "filing.due_soon",
          "filing.status_changed",
          "exemption.expiring_soon",
          "usage.quota_warning",
          "usage.quota_exceeded",
          "transaction.committed",
          "transaction.voided",
          "transaction.refunded"
        ]
      },
      "WebhookEventType": {
        "type": "string",
        "enum": [
          "nexus.approaching",
          "nexus.exceeded",
          "filing.due_soon",
          "filing.status_changed",
          "exemption.expiring_soon",
          "usage.quota_warning",
          "usage.quota_exceeded",
          "transaction.committed",
          "transaction.voided",
          "transaction.refunded",
          "webhook.test"
        ]
      },
      "WebhookEventEnvelope": {
        "type": "object",
        "additionalProperties": false,
        "description": "Canonical JSON payload envelope delivered in outbound webhook HTTP POST requests for all live and test events.",
        "required": [
          "id",
          "type",
          "apiVersion",
          "createdAt",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^evt_[a-f0-9]{24}$",
            "description": "Unique event identifier (evt_...)."
          },
          "type": {
            "$ref": "#/components/schemas/WebhookEventType",
            "description": "Event type identifier (including webhook.test for synthetic test deliveries)."
          },
          "apiVersion": {
            "type": "string",
            "const": "2026-01",
            "description": "Outbound webhook envelope schema version."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO-8601 UTC timestamp when the event was created."
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "Event-specific JSON payload object."
          }
        },
        "example": {
          "id": "evt_0123456789abcdef01234567",
          "type": "nexus.exceeded",
          "apiVersion": "2026-01",
          "createdAt": "2026-11-29T13:00:00.000Z",
          "data": {
            "alertId": "alt_0123456789abcdef01234567",
            "entityId": "ent_0123456789abcdef0123456789abcdef",
            "stateCode": "FL",
            "sales": 125000,
            "salesThresholdDollars": 100000
          }
        }
      },
      "WebhookEndpoint": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "webhookId",
          "url",
          "description",
          "events",
          "signingSecretLast4",
          "status",
          "consecutiveFailures",
          "lastDeliveryAt",
          "lastSuccessAt",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "webhookId": {
            "type": "string",
            "pattern": "^whk_[a-f0-9]{24}$"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 512
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "signingSecretLast4": {
            "type": "string",
            "minLength": 4,
            "maxLength": 4
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disabled"
            ]
          },
          "consecutiveFailures": {
            "type": "integer",
            "minimum": 0
          },
          "lastDeliveryAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "lastSuccessAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          }
        }
      },
      "WebhooksListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "webhooks"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "webhooks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEndpoint"
            }
          }
        }
      },
      "CreateWebhookRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "url",
          "events"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "minLength": 1,
            "maxLength": 512,
            "description": "Public HTTPS destination URL (no localhost, private IPs, or embedded credentials)."
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/SubscribableWebhookEventType"
            }
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          }
        }
      },
      "UpdateWebhookRequest": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "minLength": 1,
            "maxLength": 512
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/SubscribableWebhookEventType"
            }
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "disabled"
            ]
          },
          "rotateSecret": {
            "type": "boolean"
          }
        }
      },
      "WebhookResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "webhook"
        ],
        "properties": {
          "webhook": {
            "$ref": "#/components/schemas/WebhookEndpoint"
          },
          "signingSecret": {
            "type": "string",
            "pattern": "^whsec_[a-f0-9]{48}$",
            "description": "Returned only once on creation or when rotateSecret is true."
          }
        }
      },
      "WebhookDeleteResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "deleted",
          "webhookId"
        ],
        "properties": {
          "deleted": {
            "type": "boolean",
            "const": true
          },
          "webhookId": {
            "type": "string",
            "pattern": "^whk_[a-f0-9]{24}$"
          }
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "deliveryId",
          "webhookId",
          "eventId",
          "eventType",
          "status",
          "attemptCount",
          "maxAttempts",
          "nextAttemptAt",
          "lastHttpStatus",
          "lastError",
          "deliveredAt",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "deliveryId": {
            "type": "string",
            "pattern": "^dlv_[a-f0-9]{24}$"
          },
          "webhookId": {
            "type": "string",
            "pattern": "^whk_[a-f0-9]{24}$"
          },
          "eventId": {
            "type": "string",
            "pattern": "^evt_[a-f0-9]{24}$"
          },
          "eventType": {
            "$ref": "#/components/schemas/WebhookEventType"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "succeeded",
              "retrying",
              "failed"
            ]
          },
          "attemptCount": {
            "type": "integer",
            "minimum": 0
          },
          "maxAttempts": {
            "type": "integer",
            "minimum": 1
          },
          "nextAttemptAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "lastHttpStatus": {
            "type": [
              "integer",
              "null"
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "deliveredAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          }
        }
      },
      "WebhookDeliveriesListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "webhookId",
          "count",
          "deliveries"
        ],
        "properties": {
          "webhookId": {
            "type": "string",
            "pattern": "^whk_[a-f0-9]{24}$"
          },
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "deliveries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookDelivery"
            }
          }
        }
      },
      "TestWebhookRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "eventType": {
            "$ref": "#/components/schemas/WebhookEventType",
            "default": "webhook.test"
          }
        }
      },
      "WebhookTestResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "delivery"
        ],
        "properties": {
          "delivery": {
            "$ref": "#/components/schemas/WebhookDelivery"
          }
        }
      },
      "ComplianceAlert": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "alertId",
          "category",
          "severity",
          "eventType",
          "entityId",
          "stateCode",
          "resourceId",
          "title",
          "message",
          "status",
          "acknowledgedAt",
          "acknowledgedBy",
          "metadata",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "alertId": {
            "type": "string",
            "pattern": "^alt_[a-f0-9]{24}$"
          },
          "category": {
            "type": "string",
            "enum": [
              "nexus",
              "filing",
              "exemption",
              "quota"
            ]
          },
          "severity": {
            "type": "string",
            "enum": [
              "info",
              "warning",
              "critical"
            ]
          },
          "eventType": {
            "$ref": "#/components/schemas/WebhookEventType"
          },
          "entityId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Entity scope for entity-bound nexus, filing, and exemption alerts. Null for workspace-level quota alerts and alerts derived from unassigned transactions."
          },
          "stateCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "resourceId": {
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "acknowledged"
            ]
          },
          "acknowledgedAt": {
            "type": [
              "integer",
              "null"
            ]
          },
          "acknowledgedBy": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "createdAt": {
            "type": "integer"
          },
          "updatedAt": {
            "type": "integer"
          }
        }
      },
      "AlertsListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "openCount",
          "alerts"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "openCount": {
            "type": "integer",
            "minimum": 0
          },
          "alerts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ComplianceAlert"
            }
          }
        }
      },
      "AlertResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "alert"
        ],
        "properties": {
          "alert": {
            "$ref": "#/components/schemas/ComplianceAlert"
          }
        }
      },
      "AuditLogEntry": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "auditId",
          "actorType",
          "actorId",
          "actorLabel",
          "action",
          "resourceType",
          "resourceId",
          "entityId",
          "summary",
          "metadata",
          "createdAt"
        ],
        "properties": {
          "auditId": {
            "type": "string",
            "pattern": "^aud_[a-f0-9]{24}$"
          },
          "actorType": {
            "type": "string",
            "enum": [
              "user",
              "api_key",
              "system"
            ]
          },
          "actorId": {
            "type": "string"
          },
          "actorLabel": {
            "type": [
              "string",
              "null"
            ]
          },
          "action": {
            "type": "string",
            "pattern": "^[a-z0-9._]{1,80}$"
          },
          "resourceType": {
            "type": "string",
            "enum": [
              "entity",
              "registration",
              "product",
              "rule",
              "exemption",
              "transaction",
              "filing",
              "api_key",
              "webhook",
              "connection",
              "team_member",
              "alert"
            ]
          },
          "resourceId": {
            "type": "string"
          },
          "entityId": {
            "type": [
              "string",
              "null"
            ]
          },
          "summary": {
            "type": "string"
          },
          "metadata": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "createdAt": {
            "type": "integer"
          }
        }
      },
      "AuditLogsListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "hasMore",
          "nextCursor",
          "entries"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "hasMore": {
            "type": "boolean"
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AuditLogEntry"
            }
          }
        }
      },
      "ApiRequestLogEntry": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "logId",
          "authType",
          "keyPrefix",
          "keyLabel",
          "method",
          "path",
          "statusCode",
          "durationMs",
          "billed",
          "errorCode",
          "createdAt"
        ],
        "properties": {
          "logId": {
            "type": "string",
            "pattern": "^log_[a-f0-9]{24}$"
          },
          "authType": {
            "type": "string",
            "enum": [
              "api_key",
              "session"
            ]
          },
          "keyPrefix": {
            "type": [
              "string",
              "null"
            ]
          },
          "keyLabel": {
            "type": [
              "string",
              "null"
            ]
          },
          "method": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "statusCode": {
            "type": "integer",
            "minimum": 100,
            "maximum": 599
          },
          "durationMs": {
            "type": "integer",
            "minimum": 0
          },
          "billed": {
            "type": "boolean"
          },
          "errorCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "integer"
          }
        }
      },
      "ApiRequestLogsListResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "count",
          "logs",
          "hasMore",
          "nextCursor"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "logs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiRequestLogEntry"
            }
          },
          "hasMore": {
            "type": "boolean"
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "EndpointUsageMetric": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "path",
          "method",
          "count",
          "errorCount",
          "avgDurationMs"
        ],
        "properties": {
          "path": {
            "type": "string"
          },
          "method": {
            "type": "string"
          },
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "errorCount": {
            "type": "integer",
            "minimum": 0
          },
          "avgDurationMs": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "KeyUsageMetric": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "authType",
          "keyPrefix",
          "keyLabel",
          "count",
          "errorCount",
          "billedCount"
        ],
        "properties": {
          "authType": {
            "type": "string",
            "enum": [
              "api_key",
              "session"
            ]
          },
          "keyPrefix": {
            "type": [
              "string",
              "null"
            ]
          },
          "keyLabel": {
            "type": [
              "string",
              "null"
            ]
          },
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "errorCount": {
            "type": "integer",
            "minimum": 0
          },
          "billedCount": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "ErrorCodeUsageMetric": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "count"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "count": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "ApiRequestLogsSummaryResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "window",
          "windowStart",
          "windowEnd",
          "totalRequests",
          "successCount",
          "clientErrorCount",
          "serverErrorCount",
          "successRate",
          "billedCount",
          "p50DurationMs",
          "p95DurationMs",
          "truncated",
          "byEndpoint",
          "byKey",
          "byErrorCode"
        ],
        "properties": {
          "window": {
            "type": "string",
            "enum": [
              "24h",
              "7d",
              "30d"
            ]
          },
          "windowStart": {
            "type": "integer"
          },
          "windowEnd": {
            "type": "integer"
          },
          "totalRequests": {
            "type": "integer",
            "minimum": 0
          },
          "successCount": {
            "type": "integer",
            "minimum": 0
          },
          "clientErrorCount": {
            "type": "integer",
            "minimum": 0
          },
          "serverErrorCount": {
            "type": "integer",
            "minimum": 0
          },
          "successRate": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "billedCount": {
            "type": "integer",
            "minimum": 0
          },
          "p50DurationMs": {
            "type": "integer",
            "minimum": 0
          },
          "p95DurationMs": {
            "type": "integer",
            "minimum": 0
          },
          "truncated": {
            "type": "boolean"
          },
          "byEndpoint": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EndpointUsageMetric"
            }
          },
          "byKey": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/KeyUsageMetric"
            }
          },
          "byErrorCode": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ErrorCodeUsageMetric"
            }
          }
        }
      },
      "RateLookupCoordinatesRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "latitude",
          "longitude"
        ],
        "properties": {
          "latitude": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "longitude": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "use"
            ],
            "description": "Optional tax rate schedule: sales (default) or use (general use tax rates; local jurisdictions without a use tax rate contribute 0%)."
          }
        }
      },
      "RateLookupAddressRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "address"
        ],
        "properties": {
          "address": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "taxType": {
            "type": "string",
            "enum": [
              "sales",
              "use"
            ],
            "description": "Optional tax rate schedule: sales (default) or use (general use tax rates; local jurisdictions without a use tax rate contribute 0%)."
          }
        }
      },
      "UseTaxSummaryDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "grossTaxAmount",
          "taxPaid",
          "creditApplied",
          "netTaxDue"
        ],
        "properties": {
          "grossTaxAmount": {
            "type": "number"
          },
          "taxPaid": {
            "type": "number"
          },
          "creditApplied": {
            "type": "number"
          },
          "netTaxDue": {
            "type": "number"
          }
        }
      }
    }
  }
}
