{
  "openapi": "3.0.3",
  "info": {
    "title": "gigstack API v2",
    "description": "# gigstack API v2\n\nBuild customer, invoice and payment integrations. Start with the [quickstart](https://docs.gigstack.io/quickstart), then select the [issuing country](https://docs.gigstack.io/concepts/shared-fields).\n\n## Authentication and environments\n\nUse Authorization: Bearer YOUR_API_KEY. Standard live and test keys use https://api.gigstack.io/v2. Internal staging uses https://gigstack-staging-9z9nnaat.uc.gateway.dev/v2 and separate keys. Test mode is a data mode within an environment; a body field does not switch a key's mode.\n\nSee [authentication](https://docs.gigstack.io/authentication) for key handling, OAuth team scope and gigstack Connect. Internal partner provisioning is outside this public contract; health probes have their own security declarations. Operations marked unavailable have no configured public gateway route.\n\n## Read the operation contract\n\nResponse envelopes, pagination and retry rules differ by endpoint. HTTP success alone does not prove external fiscal completion or movement of money. Reconcile ambiguous writes before retrying. Use [responses and recovery](https://docs.gigstack.io/responses) and the operation's error codes; document credits and daily limits are not generic retryable rate limits.\n\nThe issuing team's configuration selects Mexico or Colombia; customer country and currency do not. Read [Mexico](https://docs.gigstack.io/countries/mexico) or [Colombia](https://docs.gigstack.io/countries/colombia) before choosing fiscal fields. Accepted public input differs from a provider's direct payload.\n\nExamples and schema checks do not imply every operation has been executed live. [Verification coverage](https://docs.gigstack.io/verification) distinguishes source review, offline checks and observed staging behavior. Documentation describes operations and does not authorize execution.\n",
    "version": "2.0.0",
    "contact": {
      "name": "Gigstack API Support",
      "url": "https://gigstack.io",
      "email": "support@gigstack.io"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://gigstack.io/terms"
    },
    "termsOfService": "https://gigstack.io/terms"
  },
  "servers": [
    {
      "url": "https://api.gigstack.io/v2",
      "description": "Public API for standard live and test-mode keys. Test data is isolated by the key mode\n(`livemode: false`). Internal staging is a separate deployment and key store; see\nhttps://docs.gigstack.io/authentication#environments for its base URL.\n"
    }
  ],
  "externalDocs": {
    "description": "Complete API Documentation & Guides",
    "url": "https://docs.gigstack.io"
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "**Authentication Method:** HTTP Bearer token.\n\nThe runtime requires the literal `Bearer ` prefix — a bare token in the\n`Authorization` header is rejected with `401 unauthorized`.\n\n**Header Format:** `Authorization: Bearer YOUR_API_KEY`\n\nYour API key is a JWT. Live keys operate on live data (`livemode: true`);\ntest keys operate on isolated test data (`livemode: false`).\n\n**Get your key at:** [app.gigstack.pro/settings?tab=api](https://app.gigstack.pro/settings?tab=api)\n\n**Errors:** credential failures are answered by the authentication layer with a raw\n`{ \"message\": … }` body, not the standardized envelope — `401` for a missing, malformed or\nexpired token, `403` for a revoked key or a plan without API access. See the `Unauthorized`\nand `AuthForbidden` responses.\n"
      }
    },
    "parameters": {
      "TeamParameter": {
        "name": "team",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "**gigstack Connect:** Target team ID for multi-team access.\n\nRequires gigstack Connect enabled on your team and shared billing account.\n\nAlso requires the `multipleIssuerAccounts` feature on your plan. Requests targeting a\nteam other than the one your API key belongs to return `403` without it.\n\nOnly API keys can use it: an OAuth access token sent with another team's id is rejected with\n`403 Team mismatch with OAuth token`.\n\n**Optional — omit it entirely** unless you are acting on another team. It deliberately\ncarries no example value so generated snippets do not emit `?team=undefined`; when the\nparameter is absent, the team is derived from your API key.\n\n**Example:** `?team=team_xyz789`\n"
      },
      "LimitParam": {
        "name": "limit",
        "in": "query",
        "description": "Maximum number of items to return (default 10, max 100)",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 10
        }
      },
      "NextParam": {
        "name": "next",
        "in": "query",
        "description": "Pagination cursor for the next page of results",
        "required": false,
        "schema": {
          "type": "string",
          "nullable": true
        }
      },
      "OrderByParam": {
        "name": "order_by",
        "in": "query",
        "description": "Field name to order results by",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "name",
            "timestamp"
          ],
          "default": "timestamp"
        }
      },
      "SortParam": {
        "name": "sort",
        "in": "query",
        "description": "Sort direction for the results",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/OrderDirection"
        }
      },
      "CreatedGteParam": {
        "name": "created[gte]",
        "in": "query",
        "description": "Filter results created on or after this timestamp. Accepts Unix timestamp in seconds (e.g., 1733011200), milliseconds (e.g., 1733011200000), or ISO 8601 date string (e.g., 2024-12-01).",
        "required": false,
        "schema": {
          "oneOf": [
            {
              "type": "integer",
              "format": "int64"
            },
            {
              "type": "string",
              "format": "date"
            }
          ]
        }
      },
      "CreatedGtParam": {
        "name": "created[gt]",
        "in": "query",
        "description": "Filter results created after this timestamp. Accepts Unix timestamp in seconds (e.g., 1733011200), milliseconds (e.g., 1733011200000), or ISO 8601 date string (e.g., 2024-12-01).",
        "required": false,
        "schema": {
          "oneOf": [
            {
              "type": "integer",
              "format": "int64"
            },
            {
              "type": "string",
              "format": "date"
            }
          ]
        }
      },
      "CreatedLteParam": {
        "name": "created[lte]",
        "in": "query",
        "description": "Filter results created on or before this timestamp. Accepts Unix timestamp in seconds (e.g., 1735689599), milliseconds (e.g., 1735689599000), or ISO 8601 date string (e.g., 2024-12-31).",
        "required": false,
        "schema": {
          "oneOf": [
            {
              "type": "integer",
              "format": "int64"
            },
            {
              "type": "string",
              "format": "date"
            }
          ]
        }
      },
      "CreatedLtParam": {
        "name": "created[lt]",
        "in": "query",
        "description": "Filter results created before this timestamp. Accepts Unix timestamp in seconds (e.g., 1735689599), milliseconds (e.g., 1735689599000), or ISO 8601 date string (e.g., 2024-12-31).",
        "required": false,
        "schema": {
          "oneOf": [
            {
              "type": "integer",
              "format": "int64"
            },
            {
              "type": "string",
              "format": "date"
            }
          ]
        }
      },
      "ClientsSearchFieldsParam": {
        "name": "fields",
        "in": "query",
        "description": "Comma-separated fields to search `q` in (they do not shape the response): the listed fields or any custom `metadata.<key>`. Omit to search the default fields. Any other value is rejected with 400 `invalid_fields`.",
        "required": false,
        "style": "form",
        "explode": false,
        "schema": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "name",
                  "email",
                  "legal_name",
                  "rfc",
                  "company",
                  "phone",
                  "objectId"
                ]
              },
              {
                "type": "string",
                "pattern": "^metadata\\.[A-Za-z0-9_.]{1,52}$"
              }
            ]
          }
        }
      },
      "InvoicesSearchFieldsParam": {
        "name": "fields",
        "in": "query",
        "description": "Comma-separated fields to search `q` in (they do not shape the response): the listed fields or any custom `metadata.<key>`. Omit to search the default fields. Any other value is rejected with 400 `invalid_fields`.",
        "required": false,
        "style": "form",
        "explode": false,
        "schema": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "client.name",
                  "client.email",
                  "uuid",
                  "client.legal_name",
                  "client.rfc",
                  "metadata.orderId",
                  "objectId",
                  "whmcsInvoiceId",
                  "series",
                  "folio_number",
                  "metadata.internalId",
                  "metadata.internalID",
                  "metadata.idIntelisis",
                  "metadata.movId"
                ]
              },
              {
                "type": "string",
                "pattern": "^metadata\\.[A-Za-z0-9_.]{1,52}$"
              }
            ]
          }
        }
      },
      "PaymentsSearchFieldsParam": {
        "name": "fields",
        "in": "query",
        "description": "Comma-separated fields to search `q` in (they do not shape the response): the listed fields or any custom `metadata.<key>`. Omit to search the default fields. Any other value is rejected with 400 `invalid_fields`.",
        "required": false,
        "style": "form",
        "explode": false,
        "schema": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "client.name",
                  "client.email",
                  "client.legal_name",
                  "fid",
                  "objectId",
                  "charge",
                  "whmcsInvoiceId",
                  "metadata.orderId",
                  "metadata.internalId",
                  "metadata.internalID",
                  "metadata.idIntelisis",
                  "metadata.movId"
                ]
              },
              {
                "type": "string",
                "pattern": "^metadata\\.[A-Za-z0-9_.]{1,52}$"
              }
            ]
          }
        }
      },
      "ReceiptsSearchFieldsParam": {
        "name": "fields",
        "in": "query",
        "description": "Comma-separated fields to search `q` in (they do not shape the response): the listed fields or any custom `metadata.<key>`. Omit to search the default fields. Any other value is rejected with 400 `invalid_fields`.",
        "required": false,
        "style": "form",
        "explode": false,
        "schema": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "client.name",
                  "client.email",
                  "client.legal_name",
                  "objectId",
                  "whmcsInvoiceId",
                  "metadata.idIntelisis",
                  "metadata.movId",
                  "metadata.internalID"
                ]
              },
              {
                "type": "string",
                "pattern": "^metadata\\.[A-Za-z0-9_.]{1,52}$"
              }
            ]
          }
        }
      },
      "ProductKeysSearchFieldsParam": {
        "name": "fields",
        "in": "query",
        "description": "Comma-separated fields to search `q` in (they do not shape the response). Omit to search the default fields. Any other value is rejected with 400 `invalid_fields`.",
        "required": false,
        "style": "form",
        "explode": false,
        "schema": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "division",
              "group",
              "type",
              "code",
              "description"
            ]
          }
        }
      },
      "UnitKeysSearchFieldsParam": {
        "name": "fields",
        "in": "query",
        "description": "Comma-separated fields to search `q` in (they do not shape the response). Omit to search the default fields. Any other value is rejected with 400 `invalid_fields`.",
        "required": false,
        "style": "form",
        "explode": false,
        "schema": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "name",
              "unit"
            ]
          }
        }
      },
      "PaymentStatusParam": {
        "name": "status",
        "in": "query",
        "description": "Filter payments by status",
        "required": false,
        "schema": {
          "type": "string",
          "enum": [
            "requires_payment_method",
            "succeeded",
            "partially_paid",
            "canceled"
          ]
        }
      },
      "PaymentCurrencyParam": {
        "name": "currency",
        "in": "query",
        "description": "Filter payments by currency code (e.g., MXN, USD)",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "PaymentClientIdParam": {
        "name": "client_id",
        "in": "query",
        "description": "Filter payments by client ID",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "PaymentEmailParam": {
        "name": "email",
        "in": "query",
        "description": "Filter payments by client email address",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "PaymentTaxIdParam": {
        "name": "tax_id",
        "in": "query",
        "description": "Filter payments by client tax ID (RFC)",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "PaymentClientNameParam": {
        "name": "client_name",
        "in": "query",
        "description": "Filter payments by client name",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "PaymentAmountParam": {
        "name": "amount",
        "in": "query",
        "description": "Filter payments by amount",
        "required": false,
        "schema": {
          "type": "number"
        }
      },
      "ClientIdFilterParam": {
        "name": "client_id",
        "in": "query",
        "description": "Filter results by the gigstack client ID (e.g., `client_xxx`)",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "TaxIdFilterParam": {
        "name": "tax_id",
        "in": "query",
        "description": "Filter results by the client's tax ID / RFC (e.g., `PEGJ800101ABC`)",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "SearchQueryParam": {
        "name": "q",
        "in": "query",
        "description": "Search query text (primary parameter). Searches across relevant fields depending on the collection\n(e.g., client name, email, payment ID, description, metadata). The `query` parameter is also accepted\nas a backward-compatible alternative.\n",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "SearchQueryBackwardCompatParam": {
        "name": "query",
        "in": "query",
        "description": "Alternative to `q`, kept for backward compatibility. If both are provided, `q` takes precedence.",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "SearchPageParam": {
        "name": "page",
        "in": "query",
        "description": "Page number for pagination (default 1)",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Authentication failed. Two different bodies can come back with a `401`:\n\n1. **From the authentication layer**, before the endpoint runs: a raw object with\n   `message` and — for OAuth access tokens only — `error` / `error_description`. It does\n   **not** use the standardized envelope (`success` and `timestamp` are absent). Messages:\n   `Unauthorized` (missing header, missing `Bearer ` prefix, unparseable token),\n   `Unauthorized, missing team in token`, `Unauthorized, not a master team` and\n   `Unauthorized, no matched teams` (gigstack Connect), `Invalid access token`,\n   `Access token has expired. Please refresh your token.`, `Access token has been revoked`.\n2. **From the endpoint itself**: the standardized envelope with `error.code: unauthorized`.\n\nBranch on the HTTP status, not on the body shape.\n",
        "content": {
          "application/json": {
            "schema": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/AuthMiddlewareError"
                },
                {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              ]
            },
            "examples": {
              "missing_or_invalid_key": {
                "summary": "Authentication layer — missing or unparseable API key",
                "value": {
                  "message": "Unauthorized"
                }
              },
              "oauth_token_expired": {
                "summary": "Authentication layer — expired OAuth access token",
                "value": {
                  "message": "Access token has expired. Please refresh your token.",
                  "error": "token_expired",
                  "error_description": "Access token has expired. Please refresh your token."
                }
              },
              "connect_not_master_team": {
                "summary": "Authentication layer — `team` sent by a team without gigstack Connect",
                "value": {
                  "message": "Unauthorized, not a master team"
                }
              },
              "endpoint_envelope": {
                "summary": "Endpoint — standardized envelope",
                "value": {
                  "success": false,
                  "error": {
                    "code": "unauthorized",
                    "message": "Unauthorized access"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          }
        }
      },
      "AuthForbidden": {
        "description": "Rejected by the authentication layer after the credential was recognised. The body is a raw\nobject (`message`, sometimes `details`), **not** the standardized envelope. Causes:\n\n- The API key was revoked or disabled: `message: \"API Key inválida.\"`, `details: \"Invalid API Key\"`.\n- Legacy plans only: the billing account's plan does not include API access. `message` is a\n  Spanish sentence containing an HTML link to `https://app.gigstack.pro/memberships`. Branch on\n  the status code; do not display or match the text. Pricing v3 accounts always have API access.\n- gigstack Connect: the account lacks gigstack Connect (Pricing v3) or its legacy plan lacks the\n  `multipleIssuerAccounts` feature (Spanish message; on Pricing v3 it starts `Tu cuenta no\n  tiene gigstack Connect`, on legacy plans `Tu plan no incluye múltiples cuentas emisoras.`), or\n  an OAuth access token was\n  sent with a `team` other than its own (`Team mismatch with OAuth token`).\n\nAn endpoint may also answer `403` for its own reasons; those are documented on the\noperation when they exist.\n",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AuthMiddlewareError"
            },
            "examples": {
              "revoked_api_key": {
                "summary": "API key revoked or disabled",
                "value": {
                  "message": "API Key inválida.",
                  "details": "Invalid API Key"
                }
              },
              "plan_without_api_access": {
                "summary": "Plan does not include API access",
                "value": {
                  "message": "La API se encuentra disponible para un plan más grande, por favor actualiza tu plan <a href='https://app.gigstack.pro/memberships'>aquí</a> o ponte en contacto con soporte."
                }
              },
              "connect_plan_without_multiple_issuers": {
                "summary": "gigstack Connect — plan lacks multipleIssuerAccounts",
                "value": {
                  "message": "Tu plan no incluye múltiples cuentas emisoras. Actualiza tu plan en https://app.gigstack.pro/memberships o ponte en contacto con soporte para operar sobre otros equipos."
                }
              },
              "connect_v3_without_connect": {
                "summary": "gigstack Connect — Pricing v3 account without gigstack Connect",
                "value": {
                  "message": "Tu cuenta no tiene gigstack Connect, que incluye múltiples cuentas emisoras. Actívalo en Ajustes > General > Facturación (https://app.gigstack.pro/settings?tab=general&subtab=billing) o ponte en contacto con soporte para operar sobre otros equipos."
                }
              },
              "oauth_team_mismatch": {
                "summary": "gigstack Connect — OAuth token used for another team",
                "value": {
                  "message": "Team mismatch with OAuth token"
                }
              }
            }
          }
        }
      },
      "ServerError": {
        "description": "Unexpected server error (`error.code: internal_server_error`). The failure is logged on gigstack's side.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/StandardErrorResponse"
            },
            "example": {
              "success": false,
              "error": {
                "code": "internal_server_error",
                "message": "An internal server error occurred"
              },
              "timestamp": 1767225600000
            }
          }
        }
      }
    },
    "schemas": {
      "CiecConnection": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "none",
              "verifying",
              "verified",
              "rejected"
            ]
          },
          "rfc": {
            "type": "string",
            "nullable": true
          },
          "verified_at": {
            "type": "number",
            "nullable": true,
            "description": "Epoch milliseconds"
          },
          "rejected_at": {
            "type": "number",
            "nullable": true,
            "description": "Epoch milliseconds"
          }
        }
      },
      "CiecConnectResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/CiecConnection"
          }
        }
      },
      "CiecErrorResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "message": {
            "type": "string"
          },
          "error": {
            "type": "string",
            "enum": [
              "ciec_rejected",
              "ciec_inconclusive",
              "sat_service_unavailable",
              "livemode_required",
              "billing_not_activated",
              "rfc_invalid",
              "password_required",
              "password_too_long",
              "ciec_verification_in_progress",
              "too_many_attempts"
            ]
          },
          "retryable": {
            "type": "boolean"
          }
        }
      },
      "GlobalPeriodicity": {
        "description": "Periodicity of a factura global (`InformacionGlobal/@Periodicidad`): the SAT\n`c_Periodicidad` code or its name — `01`/`day`, `02`/`week`, `03`/`fortnight`,\n`04`/`month`, `05`/`two_months`. gigstack stores and returns the name. With `05`,\n`months` must be a bimester (`13`–`18`); otherwise a month (`01`–`12`).\n",
        "enum": [
          "01",
          "02",
          "03",
          "04",
          "05",
          "day",
          "week",
          "fortnight",
          "month",
          "two_months"
        ],
        "example": "04",
        "type": "string"
      },
      "StripeConnectionStatus": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "billing_account_id",
          "livemode",
          "generation",
          "managed",
          "active_operation_id",
          "connected",
          "method",
          "account_id",
          "connect_account_id",
          "connect_webhooks_configured",
          "transfer_webhooks_configured",
          "encrypted_credentials_present",
          "provider_revocation",
          "provider_webhook_removal",
          "platform_account"
        ],
        "properties": {
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "billing_account_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "livemode": {
            "type": "boolean"
          },
          "generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "managed": {
            "type": "boolean"
          },
          "active_operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
            "nullable": true,
            "description": "The operation holding the team's connection slot. Null when none is open, or when the last one expired before any provider effect (the next session supersedes it)."
          },
          "connected": {
            "type": "boolean"
          },
          "method": {
            "type": "string",
            "enum": [
              "manual_key",
              "oauth",
              "platform_standard"
            ],
            "nullable": true
          },
          "account_id": {
            "type": "string",
            "pattern": "^acct_[A-Za-z0-9]+$",
            "nullable": true
          },
          "connect_account_id": {
            "type": "string",
            "pattern": "^acct_[A-Za-z0-9]+$",
            "nullable": true
          },
          "connect_webhooks_configured": {
            "type": "boolean",
            "description": "Only for a team whose own Stripe account is a Connect platform (method connect_webhooks). False after a manual_key or oauth connection is expected; manual_key creates its own payment webhook and oauth uses gigstack's platform webhook."
          },
          "transfer_webhooks_configured": {
            "type": "boolean"
          },
          "encrypted_credentials_present": {
            "type": "boolean"
          },
          "provider_revocation": {
            "type": "string",
            "enum": [
              "not_performed",
              "observed_deauthorized"
            ]
          },
          "provider_webhook_removal": {
            "type": "string",
            "enum": [
              "not_performed"
            ]
          },
          "platform_account": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "account_id",
              "type",
              "details_submitted",
              "charges_enabled",
              "payouts_enabled",
              "status"
            ],
            "properties": {
              "account_id": {
                "type": "string",
                "pattern": "^acct_[A-Za-z0-9]+$"
              },
              "type": {
                "type": "string",
                "enum": [
                  "standard"
                ]
              },
              "details_submitted": {
                "type": "boolean"
              },
              "charges_enabled": {
                "type": "boolean"
              },
              "payouts_enabled": {
                "type": "boolean"
              },
              "status": {
                "type": "string",
                "enum": [
                  "onboarding_required",
                  "details_submitted",
                  "charges_enabled"
                ]
              }
            },
            "nullable": true
          }
        }
      },
      "StripeUnconfirmedClosureReceipt": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "target_operation_id",
          "team_id",
          "billing_account_id",
          "livemode",
          "expected_generation",
          "generation",
          "status",
          "provider_revocation",
          "provider_webhook_removal",
          "provider_effects_reconciled",
          "local_credentials_removed"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "target_operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "billing_account_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "livemode": {
            "type": "boolean"
          },
          "expected_generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "status": {
            "type": "string",
            "enum": [
              "closed_unconfirmed"
            ]
          },
          "provider_revocation": {
            "type": "string",
            "enum": [
              "not_performed"
            ]
          },
          "provider_webhook_removal": {
            "type": "string",
            "enum": [
              "not_performed"
            ]
          },
          "provider_effects_reconciled": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "local_credentials_removed": {
            "type": "boolean",
            "enum": [
              false
            ]
          }
        }
      },
      "StripeLocalDisconnectReceipt": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "team_id",
          "billing_account_id",
          "livemode",
          "effect_scope",
          "status",
          "generation",
          "local_credentials_removed",
          "provider_revocation",
          "provider_webhook_removal"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "billing_account_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "livemode": {
            "type": "boolean"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared_credentials"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "completed"
            ]
          },
          "generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "local_credentials_removed": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "provider_revocation": {
            "type": "string",
            "enum": [
              "not_performed"
            ]
          },
          "provider_webhook_removal": {
            "type": "string",
            "enum": [
              "not_performed"
            ]
          }
        }
      },
      "StripeConnectionSession": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "team_id",
          "billing_account_id",
          "requester",
          "method",
          "livemode",
          "expected_generation",
          "generation",
          "status",
          "created_at",
          "expires_at",
          "updated_at",
          "steps",
          "provider_revocation",
          "provider_webhook_removal"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "billing_account_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "requester": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "credential_kind",
              "source_team_id",
              "credential_id",
              "person_id"
            ],
            "properties": {
              "credential_kind": {
                "type": "string",
                "enum": [
                  "firebase",
                  "mcp",
                  "api",
                  "oauth"
                ]
              },
              "source_team_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "credential_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$",
                "nullable": true
              },
              "person_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$",
                "nullable": true
              }
            }
          },
          "method": {
            "type": "string",
            "enum": [
              "oauth",
              "manual_key",
              "connect_webhooks",
              "account_onboarding",
              "platform_account_create"
            ]
          },
          "livemode": {
            "type": "boolean"
          },
          "expected_generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "expired",
              "awaiting_oauth",
              "in_progress",
              "completed",
              "outcome_unknown",
              "cancelled"
            ]
          },
          "created_at": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "expires_at": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "updated_at": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "steps": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "oauth_exchange": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_started",
                      "in_progress",
                      "completed",
                      "outcome_unknown"
                    ]
                  },
                  "remote_id": {
                    "type": "string",
                    "maxLength": 160
                  }
                }
              },
              "account_verification": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_started",
                      "in_progress",
                      "completed",
                      "outcome_unknown"
                    ]
                  },
                  "remote_id": {
                    "type": "string",
                    "maxLength": 160
                  }
                }
              },
              "manual_webhook": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_started",
                      "in_progress",
                      "completed",
                      "outcome_unknown"
                    ]
                  },
                  "remote_id": {
                    "type": "string",
                    "maxLength": 160
                  }
                }
              },
              "connect_webhook": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_started",
                      "in_progress",
                      "completed",
                      "outcome_unknown"
                    ]
                  },
                  "remote_id": {
                    "type": "string",
                    "maxLength": 160
                  }
                }
              },
              "transfer_webhook": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_started",
                      "in_progress",
                      "completed",
                      "outcome_unknown"
                    ]
                  },
                  "remote_id": {
                    "type": "string",
                    "maxLength": 160
                  }
                }
              },
              "credential_commit": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_started",
                      "in_progress",
                      "completed",
                      "outcome_unknown"
                    ]
                  },
                  "remote_id": {
                    "type": "string",
                    "maxLength": 160
                  }
                }
              },
              "account_onboarding_link": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_started",
                      "in_progress",
                      "completed",
                      "outcome_unknown"
                    ]
                  },
                  "remote_id": {
                    "type": "string",
                    "maxLength": 160
                  }
                }
              },
              "platform_account_create": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_started",
                      "in_progress",
                      "completed",
                      "outcome_unknown"
                    ]
                  },
                  "remote_id": {
                    "type": "string",
                    "maxLength": 160
                  }
                }
              }
            }
          },
          "provider_revocation": {
            "type": "string",
            "enum": [
              "not_performed"
            ]
          },
          "provider_webhook_removal": {
            "type": "string",
            "enum": [
              "not_performed"
            ]
          },
          "provider_account_id": {
            "type": "string",
            "pattern": "^acct_[A-Za-z0-9]+$"
          }
        }
      },
      "StripeConnectionTerminalInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "livemode"
        ],
        "properties": {
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "StripeLocalDisconnectInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_generation",
          "livemode"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
            "format": "uuid"
          },
          "expected_generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "StripeStandardAccountCreateInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_generation",
          "livemode"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
            "format": "uuid"
          },
          "expected_generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "StripeStandardAccountRefreshInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_generation",
          "livemode"
        ],
        "properties": {
          "expected_generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "StripeStandardAccountActivation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "account_id",
          "type",
          "details_submitted",
          "charges_enabled",
          "payouts_enabled",
          "status",
          "team_id",
          "billing_account_id",
          "livemode",
          "generation"
        ],
        "properties": {
          "account_id": {
            "type": "string",
            "pattern": "^acct_[A-Za-z0-9]+$"
          },
          "type": {
            "type": "string",
            "enum": [
              "standard"
            ]
          },
          "details_submitted": {
            "type": "boolean"
          },
          "charges_enabled": {
            "type": "boolean"
          },
          "payouts_enabled": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "onboarding_required",
              "details_submitted",
              "charges_enabled"
            ]
          },
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "billing_account_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "livemode": {
            "type": "boolean"
          },
          "generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        }
      },
      "StripeConnectionCreateInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "method",
          "expected_generation",
          "livemode"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
            "format": "uuid"
          },
          "method": {
            "type": "string",
            "enum": [
              "oauth",
              "manual_key",
              "connect_webhooks",
              "account_onboarding"
            ]
          },
          "expected_generation": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "livemode": {
            "type": "boolean"
          }
        }
      },
      "PortalAccessOperation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "family",
          "team_id",
          "client_id",
          "replaces_operation_id",
          "livemode",
          "status",
          "created_at",
          "preparation_expires_at",
          "expires_at",
          "access_lifetime_seconds",
          "exchanged_session_lifetime_seconds",
          "scopes",
          "effects",
          "secret_available",
          "browser_handoff",
          "recovery"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "family": {
            "type": "string",
            "enum": [
              "customer",
              "invoices"
            ]
          },
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "client_id": {
            "type": "string",
            "nullable": true,
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "replaces_operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
            "nullable": true
          },
          "livemode": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "prepared",
              "outcome_unknown",
              "completed",
              "cancelled",
              "revoked"
            ]
          },
          "created_at": {
            "type": "integer",
            "minimum": 0
          },
          "preparation_expires_at": {
            "type": "integer",
            "minimum": 0
          },
          "expires_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "access_lifetime_seconds": {
            "type": "integer",
            "minimum": 1,
            "maximum": 432000,
            "description": "Customer challenge 432000 (5 days); invoice grant 1–86400 (default 3600)."
          },
          "exchanged_session_lifetime_seconds": {
            "type": "integer",
            "nullable": true,
            "enum": [
              259200,
              null
            ],
            "description": "Customer JWT 3 days; invoice family null."
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "customer:read",
                "customer:update",
                "files:download",
                "session:renew",
                "invoices:read"
              ]
            }
          },
          "effects": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "customer_data_read",
                "customer_data_update",
                "invoice_receipt_payment_read",
                "file_download_or_render",
                "session_validation",
                "invoice_read",
                "invoice_file_download"
              ]
            }
          },
          "secret_available": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "browser_handoff": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "url"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "private_browser_review"
                ]
              },
              "url": {
                "type": "string",
                "format": "uri",
                "description": "Opaque private browser route only; never an OTP, JWT or execution proof."
              }
            }
          },
          "recovery": {
            "type": "string",
            "enum": [
              "first_response_secret_not_replayed",
              "read_current_operation"
            ]
          }
        }
      },
      "TeamEmailTemplateCatalog": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "effect_scope",
          "source",
          "is_nonprofit",
          "english_enabled",
          "templates_by_language",
          "legacy_is_nonprofit",
          "legacy_templates"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "editor_baseline"
            ]
          },
          "is_nonprofit": {
            "type": "boolean"
          },
          "english_enabled": {
            "type": "boolean"
          },
          "templates_by_language": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "es",
              "en"
            ],
            "properties": {
              "es": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "invoices",
                  "invoicesComplements",
                  "invoicesEgress",
                  "payments",
                  "paymentsReminders",
                  "paymentsRemindersAfter",
                  "receipts",
                  "receiptsReminders",
                  "bankReview"
                ],
                "properties": {
                  "invoices": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "invoicesComplements": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "invoicesEgress": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "payments": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "paymentsReminders": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "paymentsRemindersAfter": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "receipts": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "receiptsReminders": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "bankReview": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "en": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "invoices",
                  "invoicesComplements",
                  "invoicesEgress",
                  "payments",
                  "paymentsReminders",
                  "paymentsRemindersAfter",
                  "receipts",
                  "receiptsReminders",
                  "bankReview"
                ],
                "properties": {
                  "invoices": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "invoicesComplements": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "invoicesEgress": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "payments": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "paymentsReminders": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "paymentsRemindersAfter": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "receipts": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "receiptsReminders": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  },
                  "bankReview": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "body",
                      "subject"
                    ],
                    "properties": {
                      "body": {
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "legacy_is_nonprofit": {
            "type": "boolean",
            "description": "Exact strict boolean used by the original eight-key editor response."
          },
          "legacy_templates": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "invoiceMessage",
              "invoiceMessageComplements",
              "invoiceMessageEgress",
              "paymentsEmailsTemplate",
              "paymentsReminderTemplate",
              "paymentsReminderAfterTemplate",
              "receiptsEmailsTemplate",
              "receiptsRemindersTemplate"
            ],
            "properties": {
              "invoiceMessage": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "body",
                  "subject"
                ],
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                }
              },
              "invoiceMessageComplements": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "body",
                  "subject"
                ],
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                }
              },
              "invoiceMessageEgress": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "body",
                  "subject"
                ],
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                }
              },
              "paymentsEmailsTemplate": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "body",
                  "subject"
                ],
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                }
              },
              "paymentsReminderTemplate": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "body",
                  "subject"
                ],
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                }
              },
              "paymentsReminderAfterTemplate": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "body",
                  "subject"
                ],
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                }
              },
              "receiptsEmailsTemplate": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "body",
                  "subject"
                ],
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                }
              },
              "receiptsRemindersTemplate": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "body",
                  "subject"
                ],
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "WebhookConfigurationOperation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "team_id",
          "webhook_id",
          "action",
          "status",
          "created_at",
          "effect_scope",
          "secret_attempts",
          "error",
          "credential_delivery"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid"
          },
          "team_id": {
            "type": "string"
          },
          "webhook_id": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "processing",
              "completed",
              "outcome_unknown",
              "conflict"
            ]
          },
          "created_at": {
            "type": "number"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "shared_team_webhooks"
            ]
          },
          "secret_attempts": {
            "type": "integer",
            "minimum": 0
          },
          "error": {
            "type": "string",
            "nullable": true
          },
          "credential_delivery": {
            "type": "string",
            "enum": [
              "not_replayed"
            ]
          }
        }
      },
      "WebhookConfigurationResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "data",
          "operation"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "url",
              "events",
              "status",
              "owner",
              "created_at",
              "version",
              "type",
              "revision",
              "effect_scope",
              "security",
              "signing"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "events": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/WebhookEventType"
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "inactive"
                ]
              },
              "description": {
                "type": "string",
                "nullable": true
              },
              "owner": {
                "type": "string"
              },
              "created_at": {
                "type": "number"
              },
              "version": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "v1",
                  "v2",
                  null
                ]
              },
              "type": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "gigstack_connect",
                  null
                ]
              },
              "revision": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "effect_scope": {
                "type": "string",
                "enum": [
                  "shared_team_webhooks"
                ]
              },
              "security": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "header_names",
                  "configured",
                  "status"
                ],
                "properties": {
                  "header_names": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "configured": {
                    "type": "boolean"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_configured",
                      "configured",
                      "pending",
                      "failed"
                    ]
                  }
                }
              },
              "signing": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "enabled",
                  "configured",
                  "status"
                ],
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "configured": {
                    "type": "boolean"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "disabled",
                      "configured",
                      "pending",
                      "failed"
                    ]
                  }
                }
              }
            },
            "nullable": true
          },
          "operation": {
            "$ref": "#/components/schemas/WebhookConfigurationOperation"
          }
        }
      },
      "WebhookConfigurationWriteResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "data",
          "operation"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "url",
              "events",
              "status",
              "owner",
              "created_at",
              "version",
              "type",
              "revision",
              "effect_scope",
              "security",
              "signing"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "events": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/WebhookEventType"
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "inactive"
                ]
              },
              "description": {
                "type": "string",
                "nullable": true
              },
              "owner": {
                "type": "string"
              },
              "created_at": {
                "type": "number"
              },
              "version": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "v1",
                  "v2",
                  null
                ]
              },
              "type": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "gigstack_connect",
                  null
                ]
              },
              "revision": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "effect_scope": {
                "type": "string",
                "enum": [
                  "shared_team_webhooks"
                ]
              },
              "security": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "header_names",
                  "configured",
                  "status"
                ],
                "properties": {
                  "header_names": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "configured": {
                    "type": "boolean"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "not_configured",
                      "configured",
                      "pending",
                      "failed"
                    ]
                  }
                }
              },
              "signing": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "enabled",
                  "configured",
                  "status"
                ],
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "configured": {
                    "type": "boolean"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "disabled",
                      "configured",
                      "pending",
                      "failed"
                    ]
                  }
                }
              }
            },
            "nullable": true
          },
          "operation": {
            "$ref": "#/components/schemas/WebhookConfigurationOperation"
          },
          "signing_secret": {
            "type": "string",
            "description": "New signing key, only on first successful authenticated-browser response. Never replayed."
          },
          "credential_delivery": {
            "type": "string",
            "enum": [
              "first_response"
            ]
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "WebhookConfigurationAccess": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "can_manage",
          "can_configure",
          "team_id",
          "webhook_id",
          "actor_id",
          "revision"
        ],
        "properties": {
          "can_manage": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "can_configure": {
            "type": "boolean"
          },
          "team_id": {
            "type": "string"
          },
          "webhook_id": {
            "type": "string"
          },
          "actor_id": {
            "type": "string"
          },
          "revision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "ManualWebhookTestInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_livemode",
          "confirmed",
          "event",
          "resource_id"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "expected_livemode": {
            "type": "boolean",
            "description": "Assertion of the currently authenticated mode; never selects or overrides it. For get, identifies the frozen operation mode."
          },
          "confirmed": {
            "enum": [
              true
            ],
            "type": "boolean"
          },
          "event": {
            "type": "string",
            "enum": [
              "payment.created",
              "payment.updated",
              "payment.succeeded",
              "payment.canceled",
              "payment.deleted",
              "payment.upcoming_due_date",
              "invoice.created",
              "invoice.canceled",
              "invoice.failed",
              "receipt.created",
              "receipt.updated",
              "receipt.completed",
              "receipt.deleted",
              "customer.created",
              "customer.updated",
              "customer.deleted",
              "service.created",
              "service.updated",
              "service.deleted",
              "teams.created",
              "teams.sat.completed",
              "teams.stripe.completed",
              "teams.openpay.completed",
              "teams.sat.manifest.signed"
            ]
          },
          "resource_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,200}$"
          },
          "source_team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,200}$"
          }
        }
      },
      "ManualWebhookRetryInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_livemode",
          "confirmed",
          "acknowledge_duplicate_delivery"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "expected_livemode": {
            "type": "boolean",
            "description": "Assertion of the currently authenticated mode; never selects or overrides it. For get, identifies the frozen operation mode."
          },
          "confirmed": {
            "enum": [
              true
            ],
            "type": "boolean"
          },
          "acknowledge_duplicate_delivery": {
            "enum": [
              true
            ],
            "type": "boolean"
          }
        }
      },
      "ManualWebhookResendCurrentInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_livemode",
          "confirmed",
          "event",
          "resource_id",
          "acknowledge_duplicate_delivery"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "expected_livemode": {
            "type": "boolean",
            "description": "Assertion of the currently authenticated mode; never selects or overrides it. For get, identifies the frozen operation mode."
          },
          "confirmed": {
            "enum": [
              true
            ],
            "type": "boolean"
          },
          "event": {
            "type": "string",
            "enum": [
              "payment.created",
              "payment.updated",
              "payment.succeeded",
              "payment.canceled",
              "payment.deleted",
              "payment.upcoming_due_date",
              "invoice.created",
              "invoice.canceled",
              "invoice.failed",
              "receipt.created",
              "receipt.updated",
              "receipt.completed",
              "receipt.deleted",
              "customer.created",
              "customer.updated",
              "customer.deleted",
              "service.created",
              "service.updated",
              "service.deleted",
              "teams.created",
              "teams.sat.completed",
              "teams.stripe.completed",
              "teams.openpay.completed",
              "teams.sat.manifest.signed"
            ]
          },
          "resource_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,200}$"
          },
          "source_team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,200}$"
          },
          "log_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,200}$"
          },
          "acknowledge_duplicate_delivery": {
            "enum": [
              true
            ],
            "type": "boolean"
          }
        }
      },
      "ManualWebhookOperation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "action",
          "team_id",
          "livemode",
          "endpoint_id",
          "delivery_id",
          "log_id",
          "submission",
          "delivery",
          "attempts",
          "duplicate_delivery_possible",
          "payload_semantics",
          "v2_state"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "action": {
            "type": "string",
            "enum": [
              "test",
              "retry",
              "resend_current"
            ]
          },
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,200}$"
          },
          "livemode": {
            "type": "boolean"
          },
          "endpoint_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,200}$"
          },
          "delivery_id": {
            "type": "string",
            "pattern": "^manual-[0-9a-f]{64}$"
          },
          "log_id": {
            "type": "string",
            "pattern": "^manual-[0-9a-f]{64}$",
            "description": "Same identifier as delivery_id."
          },
          "submission": {
            "type": "string",
            "enum": [
              "attempting",
              "submitted",
              "unknown",
              "prevented"
            ]
          },
          "delivery": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "delivered",
              "retrying",
              "failed"
            ]
          },
          "attempts": {
            "type": "integer",
            "minimum": 0
          },
          "duplicate_delivery_possible": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "payload_semantics": {
            "type": "string",
            "enum": [
              "stored_event_snapshot",
              "current_resource"
            ]
          },
          "v2_state": {
            "type": "string",
            "enum": [
              "current_at_delivery"
            ]
          }
        }
      },
      "AirtableRegisterInput": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 250,
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "expected_livemode": {
            "type": "boolean"
          },
          "base_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 250,
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "table_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 250,
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "field_map": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "minLength": 1,
              "maxLength": 250
            },
            "minProperties": 1,
            "maxProperties": 100
          },
          "mapping_config": {
            "type": "object",
            "properties": {
              "currencyDefault": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "paymentFormDefault": {
                "type": "string",
                "pattern": "^\\d{2}$"
              },
              "statusDefault": {
                "type": "string",
                "enum": [
                  "succeeded",
                  "requires_payment_method",
                  "processing",
                  "canceled"
                ]
              },
              "defaultClientEmail": {
                "type": "string",
                "minLength": 1,
                "maxLength": 320,
                "pattern": "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$"
              }
            },
            "additionalProperties": false
          },
          "confirmed": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "operation_id",
          "expected_livemode",
          "base_id",
          "table_id",
          "field_map",
          "confirmed"
        ],
        "additionalProperties": false
      },
      "AirtableUnregisterInput": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 250,
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "expected_livemode": {
            "type": "boolean"
          },
          "scope": {
            "type": "string",
            "enum": [
              "mode",
              "shared"
            ]
          },
          "recovery_operation_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 250,
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "acknowledge_unconfirmed_effects": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "acknowledge_shared_connection": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "confirmed": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "operation_id",
          "expected_livemode",
          "confirmed"
        ],
        "additionalProperties": false
      },
      "AirtableDisconnectInput": {
        "type": "object",
        "properties": {
          "recovery_operation_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 250,
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "acknowledge_unconfirmed_effects": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "operation_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 250,
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "expected_livemode": {
            "type": "boolean"
          },
          "confirmed": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "acknowledge_shared_connection": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "operation_id",
          "expected_livemode",
          "confirmed",
          "acknowledge_shared_connection"
        ],
        "additionalProperties": false
      },
      "AirtableReconcileInput": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "AirtableWebhook": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "base_id": {
            "type": "string",
            "nullable": true
          },
          "table_id": {
            "type": "string",
            "nullable": true
          },
          "table_name": {
            "type": "string",
            "nullable": true
          },
          "field_map": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "mapping_valid": {
            "type": "boolean"
          },
          "mapping_config": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "currencyDefault": {
                "type": "string",
                "pattern": "^[A-Z]{3}$"
              },
              "paymentFormDefault": {
                "type": "string",
                "pattern": "^\\d{2}$"
              },
              "statusDefault": {
                "type": "string",
                "enum": [
                  "succeeded",
                  "requires_payment_method",
                  "processing",
                  "canceled"
                ]
              },
              "defaultClientEmail": {
                "type": "string",
                "minLength": 1,
                "maxLength": 320,
                "pattern": "^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$"
              }
            }
          },
          "livemode": {
            "type": "boolean",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "expired",
              "disabled",
              "unknown"
            ]
          },
          "created_at": {
            "type": "number",
            "nullable": true
          },
          "expires_at": {
            "type": "number",
            "nullable": true
          },
          "last_notification_at": {
            "type": "number",
            "nullable": true
          },
          "last_error_at": {
            "type": "number",
            "nullable": true
          }
        },
        "required": [
          "id",
          "base_id",
          "table_id",
          "table_name",
          "field_map",
          "mapping_valid",
          "mapping_config",
          "livemode",
          "status",
          "created_at",
          "expires_at",
          "last_notification_at",
          "last_error_at"
        ]
      },
      "AirtableBases": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "permission_level": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name",
                "permission_level"
              ]
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "shared_connection"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "production"
            ]
          }
        },
        "required": [
          "data",
          "has_more",
          "next_cursor",
          "effect_scope",
          "provider_environment"
        ]
      },
      "AirtableTables": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "primary_field_id": {
                  "type": "string",
                  "nullable": true
                },
                "fields": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "type": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id",
                      "name",
                      "type"
                    ]
                  }
                }
              },
              "required": [
                "id",
                "name",
                "primary_field_id",
                "fields"
              ]
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "shared_connection"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "production"
            ]
          }
        },
        "required": [
          "data",
          "has_more",
          "next_cursor",
          "effect_scope",
          "provider_environment"
        ]
      },
      "AirtableRemoteWebhooks": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "id": {
                  "type": "string"
                },
                "notifications_enabled": {
                  "type": "boolean"
                },
                "enabled": {
                  "type": "boolean"
                },
                "expires_at": {
                  "type": "number",
                  "nullable": true
                },
                "local_match": {
                  "type": "boolean"
                }
              },
              "required": [
                "id",
                "notifications_enabled",
                "enabled",
                "expires_at",
                "local_match"
              ]
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "shared_connection"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "production"
            ]
          }
        },
        "required": [
          "data",
          "has_more",
          "next_cursor",
          "effect_scope",
          "provider_environment"
        ]
      },
      "AirtableWebhooks": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AirtableWebhook"
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "scope": {
            "type": "string",
            "enum": [
              "mode",
              "shared_connection"
            ]
          },
          "livemode": {
            "type": "boolean",
            "nullable": true
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "production"
            ]
          },
          "can_manage": {
            "type": "boolean"
          },
          "can_recover_registration": {
            "type": "boolean"
          },
          "blocking_operation_id": {
            "type": "string",
            "nullable": true
          },
          "connection": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "connected": {
                "type": "boolean"
              },
              "restricted": {
                "type": "boolean"
              },
              "recovery_session_id": {
                "type": "string",
                "nullable": true
              },
              "identity_verification": {
                "type": "string",
                "enum": [
                  "same",
                  "different",
                  "unverified",
                  null
                ],
                "nullable": true
              },
              "effect_scope": {
                "type": "string",
                "enum": [
                  "shared_connection"
                ]
              },
              "oauth_credentials_retained": {
                "type": "boolean",
                "enum": [
                  true
                ]
              }
            },
            "required": [
              "connected",
              "restricted",
              "recovery_session_id",
              "identity_verification",
              "effect_scope",
              "oauth_credentials_retained"
            ]
          }
        },
        "required": [
          "data",
          "has_more",
          "next_cursor",
          "scope",
          "livemode",
          "provider_environment",
          "can_manage",
          "can_recover_registration",
          "blocking_operation_id",
          "connection"
        ]
      },
      "AirtableOperation": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "team_id": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "register",
              "unregister",
              "disconnect"
            ]
          },
          "livemode": {
            "type": "boolean"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "mode",
              "shared_connection"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "processing",
              "completed",
              "failed",
              "outcome_unknown"
            ]
          },
          "created_at": {
            "type": "number"
          },
          "updated_at": {
            "type": "number"
          },
          "snapshot_complete": {
            "type": "boolean"
          },
          "target_count": {
            "type": "integer",
            "minimum": 0
          },
          "processed_count": {
            "type": "integer",
            "minimum": 0
          },
          "local_disabled_count": {
            "type": "integer",
            "minimum": 0
          },
          "remote_deleted_count": {
            "type": "integer",
            "minimum": 0
          },
          "unknown_count": {
            "type": "integer",
            "minimum": 0
          },
          "error_code": {
            "type": "string",
            "nullable": true
          },
          "webhook_id": {
            "type": "string",
            "nullable": true
          },
          "recovery_operation_id": {
            "type": "string",
            "nullable": true
          },
          "cleanup_operation_id": {
            "type": "string",
            "nullable": true
          },
          "recovery_session_id": {
            "type": "string",
            "nullable": true
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "production"
            ]
          },
          "oauth_credentials_retained": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "continuation_required": {
            "type": "boolean"
          },
          "partial_cleanup": {
            "type": "boolean"
          },
          "targets": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "data": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "base_id": {
                      "type": "string",
                      "nullable": true
                    },
                    "local_disabled": {
                      "type": "boolean"
                    },
                    "remote_status": {
                      "type": "string",
                      "enum": [
                        "not_attempted",
                        "unknown",
                        "deleted"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "base_id",
                    "local_disabled",
                    "remote_status"
                  ]
                }
              },
              "has_more": {
                "type": "boolean"
              },
              "next_cursor": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "data",
              "has_more",
              "next_cursor"
            ]
          },
          "webhook": {
            "$ref": "#/components/schemas/AirtableWebhook"
          }
        },
        "required": [
          "id",
          "team_id",
          "action",
          "livemode",
          "effect_scope",
          "status",
          "created_at",
          "updated_at",
          "snapshot_complete",
          "target_count",
          "processed_count",
          "local_disabled_count",
          "remote_deleted_count",
          "unknown_count",
          "error_code",
          "webhook_id",
          "recovery_operation_id",
          "cleanup_operation_id",
          "recovery_session_id",
          "provider_environment",
          "oauth_credentials_retained",
          "continuation_required",
          "partial_cleanup",
          "targets"
        ]
      },
      "AuthMiddlewareError": {
        "type": "object",
        "description": "Raw error body produced by the authentication layer (before any endpoint runs). It is not\nthe standardized envelope: there is no `success` and no `timestamp`.\n",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "Human-readable reason. Some messages are in Spanish; branch on the HTTP status, not on this text.",
            "example": "Unauthorized"
          },
          "error": {
            "type": "string",
            "description": "OAuth error code. Present only when an OAuth access token was presented.",
            "enum": [
              "invalid_token",
              "token_expired",
              "token_revoked",
              "server_error"
            ],
            "example": "token_expired"
          },
          "error_description": {
            "type": "string",
            "description": "Same text as `message`. Present only alongside `error`.",
            "example": "Access token has expired. Please refresh your token."
          },
          "details": {
            "description": "Extra detail, e.g. `Invalid API Key` when a revoked key is rejected with `403`.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object"
              }
            ],
            "example": "Invalid API Key"
          }
        }
      },
      "WebhookEventType": {
        "type": "string",
        "description": "Event type a webhook can subscribe to.",
        "enum": [
          "payment.created",
          "payment.updated",
          "payment.succeeded",
          "payment.canceled",
          "payment.deleted",
          "payment.upcoming_due_date",
          "invoice.created",
          "invoice.canceled",
          "invoice.failed",
          "invoice_batch.completed",
          "payment_batch.completed",
          "receipt.created",
          "receipt.updated",
          "receipt.completed",
          "receipt.deleted",
          "customer.created",
          "customer.updated",
          "customer.deleted",
          "service.created",
          "service.updated",
          "service.deleted",
          "sat.invoice.synced",
          "teams.created",
          "teams.sat.completed",
          "teams.stripe.completed",
          "teams.openpay.completed",
          "teams.sat.manifest.signed"
        ],
        "example": "sat.invoice.synced"
      },
      "WebhookCreated": {
        "$ref": "#/components/schemas/ApiPublicWebhook"
      },
      "WebhookEventPayload": {
        "description": "Body of a webhook delivery (`Content-Type: application/json`). There are three formats:\n\n- **Resource events** (`payment.*`, `invoice.*`, `receipt.*`, `customer.*`, `service.*`) use the\n  webhook's payload version:\n  - `WebhookPayloadV1`: the default for webhooks created with `POST /webhooks`.\n  - `WebhookPayloadV2`: for webhooks created or last saved in the gigstack dashboard, or on teams\n    whose default is v2.\n- **`sat.invoice.synced`** always uses `SatInvoiceSyncedWebhookEvent`.\n- **`invoice_batch.completed`** always uses `InvoiceBatchCompletedWebhookEvent`.\n- **`payment_batch.completed`** always uses `PaymentBatchCompletedWebhookEvent`.\n\nTell them apart by shape:\n- v2 has `type` and `data.object`.\n- v1 has `event`, `team` and `webhook`.\n- The SAT and batch events have `event` and `created_at`; read `event` to tell them apart.\n",
        "oneOf": [
          {
            "$ref": "#/components/schemas/WebhookPayloadV1"
          },
          {
            "$ref": "#/components/schemas/WebhookPayloadV2"
          },
          {
            "$ref": "#/components/schemas/SatInvoiceSyncedWebhookEvent"
          },
          {
            "$ref": "#/components/schemas/InvoiceBatchCompletedWebhookEvent"
          },
          {
            "$ref": "#/components/schemas/PaymentBatchCompletedWebhookEvent"
          }
        ]
      },
      "WebhookPayloadV1": {
        "type": "object",
        "description": "`v1` body of a resource event. It has no event id, so de-duplicate on `event` plus `data.id`.\n\nTeams on the legacy `v1.1` default receive this object wrapped as `{ \"payload\": { … } }`. For\n`invoice.created`, their `data` also includes a `customer` object with the full address, and\n`date` is shifted by −6 hours.\n",
        "required": [
          "event",
          "team",
          "webhook",
          "livemode",
          "data"
        ],
        "properties": {
          "event": {
            "$ref": "#/components/schemas/WebhookEventType"
          },
          "team": {
            "type": "string",
            "description": "Team that owns the webhook.",
            "example": "team_1234567890"
          },
          "webhook": {
            "type": "string",
            "description": "ID of the webhook receiving this delivery.",
            "example": "wh_dyS2ZVTj"
          },
          "livemode": {
            "type": "boolean",
            "description": "`false` for test-mode resources.",
            "example": true
          },
          "data": {
            "type": "object",
            "description": "The resource at the moment of the event, in gigstack's internal (camelCase) format.\n`metadata` values are sent as strings.\n",
            "additionalProperties": true
          },
          "connectedTeam": {
            "type": "string",
            "description": "Only on deliveries to a gigstack Connect master team. The connected team the event came from."
          },
          "connectedTeamMetadata": {
            "type": "object",
            "description": "Only with `connectedTeam`, when that team has metadata. Values are strings.",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "WebhookPayloadV2": {
        "type": "object",
        "description": "`v2` body of a resource event (Stripe-style envelope).",
        "required": [
          "id",
          "type",
          "created",
          "livemode",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique per event and webhook. Stays the same across every retry and resend of that delivery,\nso use it to de-duplicate.\n",
            "example": "log_4GqT7mZx9LpR2vWc8NdK--wh_dyS2ZVTj"
          },
          "type": {
            "$ref": "#/components/schemas/WebhookEventType"
          },
          "created": {
            "type": "integer",
            "format": "int64",
            "description": "When the delivery was queued, Unix epoch **milliseconds**.",
            "example": 1767225600000
          },
          "livemode": {
            "type": "boolean",
            "description": "`false` for test-mode resources.",
            "example": true
          },
          "data": {
            "type": "object",
            "required": [
              "object"
            ],
            "properties": {
              "object": {
                "type": "object",
                "description": "The resource in the same format the API returns. It is read when the delivery is sent,\nso a retried delivery can show a newer state than the event. For `*.deleted` events it\nis the last known state.\n",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "SatInvoiceSyncedWebhookEvent": {
        "type": "object",
        "description": "Body of a `sat.invoice.synced` delivery. It is the same regardless of the webhook's payload version.\nNote the field names: the type is in `event` (not `type`), and `created_at` is in **seconds**.\nThere is no `livemode`.\n",
        "required": [
          "id",
          "event",
          "created_at",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique event id, `evt_` followed by 16 hexadecimal characters. Use it to de-duplicate.",
            "example": "evt_4f1c9a7e2b3d5c6a"
          },
          "event": {
            "type": "string",
            "enum": [
              "sat.invoice.synced"
            ],
            "example": "sat.invoice.synced"
          },
          "created_at": {
            "type": "integer",
            "description": "When the event was dispatched, Unix epoch **seconds**.",
            "example": 1767225600
          },
          "data": {
            "$ref": "#/components/schemas/SatInvoiceSyncedWebhookData"
          }
        }
      },
      "SatInvoiceSyncedWebhookData": {
        "type": "object",
        "description": "`data` of a `sat.invoice.synced` delivery. Sent when the XML of an invoice downloaded from the\nSAT (Descarga Masiva) has been fetched and stored, either by the automatic download or by\n`POST /invoices/sat/{uuid}/retry-xml`.\n",
        "required": [
          "uuid",
          "resource_status",
          "team"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "description": "Folio fiscal (UUID) of the CFDI.",
            "example": "9D9B0E5B-0341-4C2B-8F3A-6E1D2C4B5A70"
          },
          "direction": {
            "type": "string",
            "enum": [
              "issued",
              "received"
            ],
            "description": "Whether your team issued or received the CFDI.",
            "example": "received"
          },
          "resource_status": {
            "type": "string",
            "enum": [
              "ready"
            ],
            "description": "Always `ready` — the XML is stored and the invoice can be read.",
            "example": "ready"
          },
          "issuer": {
            "type": "object",
            "description": "Issuer of the CFDI, as stored for the SAT invoice.",
            "additionalProperties": true,
            "example": {
              "rfc": "EKU9003173C9",
              "name": "ESCUELA KEMPER URGATE"
            }
          },
          "receiver": {
            "type": "object",
            "description": "Receiver of the CFDI, as stored for the SAT invoice.",
            "additionalProperties": true,
            "example": {
              "rfc": "MEE200101ABC",
              "name": "MI EMPRESA EJEMPLO"
            }
          },
          "total": {
            "type": "number",
            "description": "CFDI total.",
            "example": 1160
          },
          "currency": {
            "type": "string",
            "example": "MXN"
          },
          "issue_date": {
            "type": "string",
            "description": "CFDI issue date as stored for the SAT invoice.",
            "example": "2026-01-15T10:30:00"
          },
          "invoice_type": {
            "type": "string",
            "enum": [
              "I",
              "E",
              "P",
              "N",
              "T"
            ],
            "description": "SAT comprobante type.",
            "example": "I"
          },
          "status": {
            "type": "string",
            "description": "SAT status of the CFDI.",
            "example": "Vigente"
          },
          "team": {
            "type": "string",
            "description": "Team that owns the invoice.",
            "example": "team_1234567890"
          },
          "credit_charged": {
            "type": "boolean",
            "description": "Whether a Descarga Masiva credit was charged for this XML.",
            "example": true
          },
          "retried": {
            "type": "boolean",
            "description": "Present and `true` only when the delivery was triggered by `POST /invoices/sat/{uuid}/retry-xml`.",
            "example": true
          }
        }
      },
      "InvoiceBatchCompletedWebhookEvent": {
        "type": "object",
        "description": "Body of an `invoice_batch.completed` delivery, sent once when every accepted item of an income invoice\nbatch (`POST /invoices/income/batch`) has a final status. It is the same regardless of the webhook's\npayload version. As with `sat.invoice.synced`, the type is in `event` (not `type`) and `created_at`\nis in **seconds**. A batch whose items were all rejected up front completes without any stamping and\nalso sends this event.\n",
        "required": [
          "id",
          "event",
          "created_at",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique event id, `evt_` followed by 16 hexadecimal characters. Use it to de-duplicate.",
            "example": "evt_9a2b7c4d1e6f3a8b"
          },
          "event": {
            "type": "string",
            "enum": [
              "invoice_batch.completed"
            ],
            "example": "invoice_batch.completed"
          },
          "created_at": {
            "type": "integer",
            "description": "When the event was dispatched, Unix epoch **seconds**.",
            "example": 1790784000
          },
          "data": {
            "$ref": "#/components/schemas/InvoiceBatchCompletedWebhookData"
          }
        }
      },
      "InvoiceBatchCompletedWebhookData": {
        "type": "object",
        "description": "Summary of the finished batch. It carries counts only: to see each invoice, page through\n`GET /invoices/income/batch/{id}/items`; for the rejected items' reasons, read `rejected` on\n`GET /invoices/income/batch/{id}`.\n",
        "required": [
          "id",
          "livemode",
          "total",
          "accepted",
          "rejected",
          "counts",
          "result"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Batch id, as returned by `POST /invoices/income/batch`.",
            "example": "ibatch_5d41402abc4b2a76b9719d911017c592"
          },
          "livemode": {
            "type": "boolean",
            "description": "Mode of the credential that created the batch.",
            "example": true
          },
          "total": {
            "type": "integer",
            "description": "Invoices in the request.",
            "example": 250
          },
          "accepted": {
            "type": "integer",
            "description": "Invoices that passed validation and were processed.",
            "example": 248
          },
          "rejected": {
            "type": "integer",
            "description": "**Number** of invoices refused by validation before anything was stamped. Note that on the batch\nobject `rejected` is the list of those items, not a count.\n",
            "example": 2
          },
          "counts": {
            "$ref": "#/components/schemas/InvoiceBatchCounts"
          },
          "result": {
            "$ref": "#/components/schemas/InvoiceBatchResultEnum"
          }
        }
      },
      "PaymentBatchCompletedWebhookEvent": {
        "type": "object",
        "description": "Body of a `payment_batch.completed` delivery, sent once when every accepted item of a payment batch\n(`POST /payments/register/batch`) has a final status. Same conventions as `invoice_batch.completed`:\nthe type is in `event` (not `type`), `created_at` is in **seconds**, one attempt, never retried, and a\nbatch whose items were all rejected up front also sends it.\n",
        "required": [
          "id",
          "event",
          "created_at",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique event id, `evt_` followed by 16 hexadecimal characters. Use it to de-duplicate.",
            "example": "evt_3c8d1e5f7a9b2c4d"
          },
          "event": {
            "type": "string",
            "enum": [
              "payment_batch.completed"
            ],
            "example": "payment_batch.completed"
          },
          "created_at": {
            "type": "integer",
            "description": "When the event was dispatched, Unix epoch **seconds**.",
            "example": 1790784000
          },
          "data": {
            "$ref": "#/components/schemas/PaymentBatchCompletedWebhookData"
          }
        }
      },
      "PaymentBatchCompletedWebhookData": {
        "type": "object",
        "description": "Summary of the finished batch. It carries counts only: to see each payment, page through\n`GET /payments/register/batch/{id}/items`; for the rejected items' reasons, read `rejected` on\n`GET /payments/register/batch/{id}`.\n",
        "required": [
          "id",
          "livemode",
          "total",
          "accepted",
          "rejected",
          "counts",
          "result"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Batch id, as returned by `POST /payments/register/batch`.",
            "example": "pbatch_7f3a9c1e5b2d4f6a8c0e2a4b6d8f0a1c"
          },
          "livemode": {
            "type": "boolean",
            "description": "Mode of the credential that created the batch.",
            "example": true
          },
          "total": {
            "type": "integer",
            "description": "Payments in the request.",
            "example": 120
          },
          "accepted": {
            "type": "integer",
            "description": "Payments that passed validation and were processed.",
            "example": 119
          },
          "rejected": {
            "type": "integer",
            "description": "**Number** of payments refused by validation before anything was registered. Note that on the\nbatch object `rejected` is the list of those items, not a count.\n",
            "example": 1
          },
          "counts": {
            "$ref": "#/components/schemas/PaymentBatchCounts"
          },
          "result": {
            "$ref": "#/components/schemas/InvoiceBatchResultEnum"
          }
        }
      },
      "SatInvoice": {
        "type": "object",
        "description": "An invoice downloaded from SAT via Descarga Masiva",
        "properties": {
          "id": {
            "type": "string",
            "description": "Document ID (same as UUID)"
          },
          "uuid": {
            "type": "string",
            "description": "SAT UUID (globally unique CFDI identifier)",
            "example": "6741A863-04BE-49FE-BB76-E1657AB6B7EA"
          },
          "direction": {
            "type": "string",
            "enum": [
              "issued",
              "received"
            ],
            "description": "Whether this RFC issued or received the invoice"
          },
          "issuer": {
            "type": "object",
            "properties": {
              "rfc": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "receiver": {
            "type": "object",
            "properties": {
              "rfc": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "invoice_type": {
            "type": "string",
            "enum": [
              "I",
              "E",
              "P",
              "N",
              "T"
            ],
            "description": "CFDI type (I=Income, E=Egress, P=Payment, N=Nomina, T=Transfer)"
          },
          "series": {
            "type": "string",
            "nullable": true
          },
          "folio": {
            "type": "string",
            "nullable": true
          },
          "subtotal": {
            "type": "number"
          },
          "total": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "example": "MXN"
          },
          "exchange_rate": {
            "type": "number",
            "nullable": true
          },
          "issue_date": {
            "type": "string",
            "description": "Issue date (YYYY-MM-DD or datetime from SAT)"
          },
          "stamp_date": {
            "type": "string",
            "description": "Timestamp when PAC stamped the CFDI"
          },
          "cancellation_date": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "Vigente",
              "Cancelado"
            ]
          },
          "pac_rfc": {
            "type": "string",
            "description": "RFC of the PAC that stamped the invoice"
          },
          "version": {
            "type": "string",
            "example": "4.0"
          },
          "certificate_number": {
            "type": "string"
          },
          "download_request_id": {
            "type": "string",
            "nullable": true,
            "description": "ID of the satreq_ document that downloaded this invoice"
          },
          "has_xml": {
            "type": "boolean",
            "description": "Whether the XML has been downloaded and stored"
          },
          "created_at": {
            "type": "integer",
            "description": "Unix timestamp (ms) when first downloaded"
          },
          "updated_at": {
            "type": "integer",
            "description": "Unix timestamp (ms) of last update"
          }
        }
      },
      "OrderDirection": {
        "type": "string",
        "enum": [
          "asc",
          "desc"
        ],
        "description": "Sort direction for list queries"
      },
      "ApiPublicProductKey": {
        "type": "object",
        "required": [
          "code",
          "description"
        ],
        "properties": {
          "code": {
            "type": "string",
            "example": "81112101",
            "description": "SAT product/service key (c_ClaveProdServ). Use this value as an item's product_key."
          },
          "description": {
            "type": "string",
            "nullable": true,
            "example": "Servicios de programación de aplicaciones",
            "description": "Official SAT description of the key"
          },
          "similar": {
            "type": "string",
            "example": "desarrollo de software, programación",
            "description": "Synonyms published by the SAT. Omitted when the entry has none."
          },
          "type": {
            "type": "string",
            "example": "Clase",
            "description": "SAT taxonomy level. Omitted when the entry has none."
          },
          "division": {
            "type": "string",
            "example": "Servicios de Tecnologías de la Información",
            "description": "SAT taxonomy division. Omitted when the entry has none."
          },
          "group": {
            "type": "string",
            "example": "Servicios de programación informática",
            "description": "SAT taxonomy group. Omitted when the entry has none."
          }
        }
      },
      "ApiPublicUnitKey": {
        "type": "object",
        "required": [
          "code",
          "name"
        ],
        "properties": {
          "code": {
            "type": "string",
            "example": "E48",
            "description": "SAT unit key (c_ClaveUnidad). Use this value as an item's unit_key."
          },
          "name": {
            "type": "string",
            "nullable": true,
            "example": "Unidad de servicio",
            "description": "Human-readable unit name. Commonly stored alongside the key as unit_name."
          }
        }
      },
      "ApiPublicClient": {
        "type": "object",
        "required": [
          "id",
          "email",
          "from",
          "livemode",
          "owner",
          "team",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "client_1234567890",
            "description": "Unique client identifier"
          },
          "address": {
            "$ref": "#/components/schemas/ClientAddress"
          },
          "name": {
            "type": "string",
            "nullable": true,
            "example": "Juan Pérez García",
            "description": "Client name"
          },
          "company": {
            "type": "string",
            "nullable": true,
            "example": "Empresa SA de CV",
            "description": "Client company name"
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "example": "+52 55 1234 5678",
            "description": "Client phone number"
          },
          "email": {
            "type": "string",
            "format": "email",
            "nullable": true,
            "example": "juan.perez@ejemplo.com",
            "description": "Client email address"
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            },
            "nullable": true,
            "example": [
              "admin@empresa.com"
            ],
            "description": "BCC email addresses for client communications"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "example": {
              "custom_field": "value"
            },
            "description": "Additional metadata for the client"
          },
          "is_valid": {
            "type": "boolean",
            "nullable": true,
            "example": true,
            "description": "Whether the client data is valid"
          },
          "from": {
            "type": "string",
            "example": "api",
            "description": "Source of client creation. Documents created through the public API are stored with `api`; requests carrying the `X-Gigstack-Client: mcp` header (the gigstack MCP server) are stored with `mcp` and behave identically."
          },
          "legal_name": {
            "type": "string",
            "nullable": true,
            "example": "Juan Pérez García",
            "description": "Legal name for tax purposes"
          },
          "livemode": {
            "type": "boolean",
            "example": true,
            "description": "Whether this client is in live mode"
          },
          "owner": {
            "type": "string",
            "example": "user_1234567890",
            "description": "User ID who owns this client"
          },
          "tax_id": {
            "type": "string",
            "nullable": true,
            "example": "PEGJ800101ABC",
            "description": "RFC (Tax ID) for Mexican tax compliance"
          },
          "use": {
            "type": "string",
            "nullable": true,
            "example": "G03",
            "description": "CFDI use code"
          },
          "tax_system": {
            "type": "string",
            "nullable": true,
            "example": "601",
            "description": "SAT tax system code"
          },
          "team": {
            "type": "string",
            "example": "team_1234567890",
            "description": "Team ID this client belongs to"
          },
          "created_at": {
            "type": "number",
            "example": 1677651234,
            "description": "Unix timestamp of client creation"
          },
          "efos": {
            "type": "object",
            "nullable": true,
            "properties": {
              "is_valid": {
                "type": "boolean",
                "nullable": true,
                "example": true,
                "description": "true = RFC is NOT on the EFOS (Art. 69-B) blacklist (safe). false = RFC appears on the blacklist."
              }
            },
            "description": "EFOS (Art. 69-B CFF) blacklist check. Independent from `fiscal_validation` — an RFC can fail one and pass the other."
          },
          "fiscal_validation": {
            "type": "object",
            "nullable": true,
            "description": "Result of attempting to stamp a test CFDI against the PAC. Only returned on create/update/validate; not persisted on the client doc.",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "valid",
                  "not_valid",
                  "skipped"
                ],
                "example": "not_valid",
                "description": "`valid` = PAC accepted; `not_valid` = PAC rejected (RFC/legal_name/CP do not match SAT registry); `skipped` = required fields missing."
              },
              "message": {
                "type": "string",
                "nullable": true,
                "example": "Fiscal info validation failed. El campo DomicilioFiscalReceptor del receptor, debe pertenecer al nombre asociado al RFC registrado en el campo Rfc del Receptor.",
                "description": "Human-readable reason when status is not_valid or skipped."
              }
            }
          },
          "sat_status": {
            "type": "object",
            "nullable": true,
            "description": "Unified SAT risk signal combining the EFOS check with 20 SAT Datos Abiertos lists (Art. 69, 69-B, 69-B Bis)\nsynced weekly into Firestore. A hit on any \"risky\" list (Cancelados, No localizados, CSD sin efectos, Definitivos 69-B,\nPresuntos 69-B, etc.) or a failed EFOS check sets `is_risky: true`.\n",
            "properties": {
              "is_risky": {
                "type": "boolean",
                "example": true,
                "description": "true if any risky list hit OR `efos.is_valid === false`."
              },
              "efos": {
                "type": "object",
                "nullable": true,
                "properties": {
                  "is_valid": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  }
                },
                "description": "EFOS check result (duplicated here for convenience)."
              },
              "hits": {
                "type": "array",
                "description": "Every SAT list the RFC appears on, with the full row from the source CSV.",
                "items": {
                  "type": "object",
                  "properties": {
                    "list": {
                      "type": "string",
                      "example": "art_69b_definitivos",
                      "description": "List key (matches the source filename). See /sat_rfc_list_entries for all."
                    },
                    "label": {
                      "type": "string",
                      "example": "Definitivos 69-B"
                    },
                    "source": {
                      "type": "string",
                      "enum": [
                        "art_69",
                        "art_69b",
                        "art_69b_bis"
                      ],
                      "example": "art_69b"
                    },
                    "is_risky": {
                      "type": "boolean",
                      "example": true,
                      "description": "Whether a hit on this specific list marks the RFC unsafe."
                    },
                    "detail": {
                      "type": "object",
                      "additionalProperties": true,
                      "description": "Full SAT record (razón social, situación, dates, oficios DOF, etc.). Shape varies per list."
                    }
                  }
                }
              },
              "checked_at": {
                "type": "number",
                "example": 1776887458784,
                "description": "Unix timestamp (ms) of when this check was run."
              }
            }
          },
          "defaults": {
            "type": "object",
            "nullable": true,
            "properties": {
              "keep_full_legal_name": {
                "type": "boolean",
                "nullable": true,
                "example": false,
                "description": "Keep full legal name in documents"
              },
              "issue_automatic_invoices": {
                "type": "boolean",
                "nullable": true,
                "example": false,
                "description": "Issue automatic invoices"
              },
              "issue_invoiceable_receipts": {
                "type": "boolean",
                "nullable": true,
                "example": true,
                "description": "Issue invoiceable receipts"
              }
            },
            "description": "Client default settings"
          },
          "document_type": {
            "type": "string",
            "nullable": true,
            "description": "Colombia (DIAN) only: identification document code (`11`, `12`, `13`, `21`, `22`, `31`, `41`, `42`, `47`, `48`, `50`, `91`)."
          },
          "organization_type": {
            "anyOf": [
              {
                "description": "Colombia (DIAN) only: `1` legal entity, `2` natural person.",
                "oneOf": [
                  {
                    "type": "integer"
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ]
          },
          "tribute_code": {
            "type": "string",
            "nullable": true,
            "description": "Colombia (DIAN) only: `01` IVA responsible, `ZZ` not applicable."
          },
          "fiscal_responsibilities": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            },
            "description": "Colombia (DIAN) only: fiscal responsibilities (list 53), e.g. `O-13`, `R-99-PN`."
          },
          "dv": {
            "type": "string",
            "nullable": true,
            "description": "Colombia (DIAN) only: NIT verification digit (informational)."
          },
          "municipality_code": {
            "type": "string",
            "nullable": true,
            "description": "Colombia (DIAN) only: 5-digit DANE municipality code."
          }
        }
      },
      "ApiPublicService": {
        "type": "object",
        "required": [
          "team",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "nullable": true,
            "example": "service_1234567890",
            "description": "Unique service identifier"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "example": "Consulting services",
            "description": "Service description"
          },
          "from": {
            "type": "string",
            "nullable": true,
            "example": "api",
            "description": "Source of service creation. Documents created through the public API are stored with `api`; requests carrying the `X-Gigstack-Client: mcp` header (the gigstack MCP server) are stored with `mcp` and behave identically."
          },
          "sku": {
            "type": "string",
            "nullable": true,
            "example": "CONS-001",
            "description": "Stock Keeping Unit identifier"
          },
          "product_key": {
            "type": "string",
            "nullable": true,
            "example": "80141503",
            "description": "SAT product key for tax compliance"
          },
          "unit_key": {
            "type": "string",
            "nullable": true,
            "example": "E48",
            "description": "SAT unit key for tax compliance"
          },
          "unit_name": {
            "type": "string",
            "nullable": true,
            "example": "Servicio",
            "description": "Unit name for the service"
          },
          "unit_price": {
            "type": "number",
            "nullable": true,
            "example": 1000,
            "description": "Price per unit"
          },
          "taxes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaxElement"
            },
            "nullable": true,
            "description": "Tax configuration for this service"
          },
          "team": {
            "type": "string",
            "example": "team_1234567890",
            "description": "Team ID this service belongs to"
          },
          "created_at": {
            "type": "number",
            "example": 1677651234,
            "description": "Unix timestamp of service creation"
          },
          "quantity": {
            "type": "number",
            "nullable": true,
            "example": 1,
            "description": "Quantity (used in transactions)"
          },
          "discount": {
            "type": "number",
            "nullable": true,
            "description": "Discount applied to the item."
          },
          "third_party": {
            "type": "object",
            "nullable": true,
            "description": "Third party on whose behalf the item is billed (A cuenta de terceros).",
            "properties": {
              "legal_name": {
                "type": "string"
              },
              "tax_id": {
                "type": "string"
              },
              "tax_system": {
                "type": "string"
              },
              "zip": {
                "type": "string"
              }
            }
          },
          "item_complement": {
            "type": "object",
            "nullable": true,
            "description": "Item-level CFDI complement, when configured."
          }
        }
      },
      "PendingReceiptsSummary": {
        "type": "object",
        "description": "Summary of pending-receipt invoicing attempts triggered by a client update.",
        "properties": {
          "attempted": {
            "type": "integer",
            "description": "Number of pending receipts that were submitted for invoicing.",
            "example": 3
          },
          "succeeded": {
            "type": "integer",
            "description": "Number of receipts successfully invoiced.",
            "example": 2
          },
          "failed": {
            "type": "integer",
            "description": "Number of receipts that failed to invoice.",
            "example": 1
          },
          "skipped": {
            "type": "integer",
            "description": "Number of receipts skipped (e.g., `disallowInvoice: true`).",
            "example": 0
          },
          "failures": {
            "type": "array",
            "description": "Per-receipt failure details.",
            "items": {
              "type": "object",
              "properties": {
                "receipt_id": {
                  "type": "string",
                  "example": "receipt_1234567890"
                },
                "error": {
                  "type": "string",
                  "example": "Failed to process receipt: 400 Bad Request"
                }
              }
            }
          }
        }
      },
      "ClientInput": {
        "description": "Creation body for `POST /v2/clients`. `name` is required when creating a client.\nFor `PUT /v2/clients/{id}`, use `ClientUpdateInput`: an omitted name is preserved\nfrom the existing client before validation.\n\nUnknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`);\n`metadata` is the one object that accepts arbitrary keys. `team`, `livemode` and\n`owner` are reserved and injected by the auth middleware.\n\nThe `document_type`, `organization_type`, `tribute_code`, `fiscal_responsibilities`,\n`dv` and `municipality_code`\nfields are the Colombian DIAN identification set. They are accepted for every team\nregardless of country; each also accepts the empty string, which means \"not set\" and is\ndropped before the client is stored.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name"
        ],
        "properties": {
          "search": {
            "description": "Search for an existing client before creating. If a match is found, the existing client is returned (or updated if `update: true`).\nThis enables upsert-like behavior to avoid duplicate clients.\n",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "on_key",
              "on_value"
            ],
            "properties": {
              "on_key": {
                "description": "The field to search on (e.g., 'tax_id', 'email', 'name')",
                "example": "tax_id",
                "type": "string"
              },
              "on_value": {
                "description": "The value to match against the specified field",
                "example": "PEGJ800101ABC",
                "type": "string"
              },
              "auto_create": {
                "type": "boolean",
                "nullable": true
              },
              "safety_check": {
                "type": "boolean",
                "nullable": true
              },
              "update": {
                "description": "If true and a match is found, update the existing client with the provided data. If false, return the existing client without modifications.",
                "example": false,
                "type": "boolean",
                "nullable": true
              }
            },
            "nullable": true
          },
          "address": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "country": {
                "example": "MEX",
                "type": "string",
                "nullable": true,
                "maxLength": 3
              },
              "street": {
                "example": "Av. Insurgentes Sur",
                "type": "string",
                "nullable": true
              },
              "zip": {
                "example": "03100",
                "type": "string",
                "nullable": true
              },
              "city": {
                "example": "Ciudad de México",
                "type": "string",
                "nullable": true
              },
              "state": {
                "example": "CDMX",
                "type": "string",
                "nullable": true
              },
              "exterior": {
                "example": "123",
                "type": "string",
                "nullable": true
              },
              "interior": {
                "example": "4B",
                "type": "string",
                "nullable": true
              },
              "municipality": {
                "example": "Benito Juárez",
                "type": "string",
                "nullable": true
              },
              "neighborhood": {
                "example": "Del Valle",
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "name": {
            "example": "Juan Pérez García",
            "type": "string"
          },
          "company": {
            "example": "Empresa SA de CV",
            "type": "string",
            "nullable": true
          },
          "phone": {
            "example": "+52 55 1234 5678",
            "type": "string",
            "nullable": true
          },
          "email": {
            "example": "juan.perez@ejemplo.com",
            "type": "string",
            "nullable": true,
            "format": "email"
          },
          "bcc": {
            "example": [
              "admin@empresa.com"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "metadata": {
            "example": {
              "custom_field": "value"
            },
            "type": "object",
            "additionalProperties": true,
            "properties": {}
          },
          "legal_name": {
            "example": "Juan Pérez García",
            "type": "string",
            "nullable": true
          },
          "tax_id": {
            "example": "PEGJ800101ABC",
            "type": "string",
            "nullable": true
          },
          "use": {
            "example": "G03",
            "type": "string",
            "nullable": true
          },
          "tax_system": {
            "example": "601",
            "type": "string",
            "nullable": true
          },
          "defaults": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "keep_full_legal_name": {
                "example": false,
                "type": "boolean"
              },
              "issue_automatic_invoices": {
                "example": false,
                "type": "boolean"
              },
              "issue_invoiceable_receipts": {
                "example": true,
                "type": "boolean"
              }
            }
          },
          "document_type": {
            "description": "**Colombia (DIAN).** Identification document code.\n`11` registro civil, `12` tarjeta de identidad, `13` cédula de ciudadanía,\n`21` tarjeta de extranjería, `22` cédula de extranjería, `31` NIT,\n`41` pasaporte, `42` documento de identificación extranjero,\n`47` PEP, `48` PPT, `50` NIT de otro país, `91` NUIP.\nThe empty string means \"not set\" and is dropped before the client is stored.\n",
            "example": "31",
            "type": "string",
            "enum": [
              "",
              "11",
              "12",
              "13",
              "21",
              "22",
              "31",
              "41",
              "42",
              "47",
              "48",
              "50",
              "91",
              null
            ],
            "nullable": true
          },
          "organization_type": {
            "description": "**Colombia (DIAN).** `1` = persona jurídica, `2` = persona natural.\nAccepted as either a number (`1`, `2`) or a string (`\"1\"`, `\"2\"`).\nThe empty string means \"not set\".\n",
            "example": "2",
            "oneOf": [
              {
                "type": "string",
                "enum": [
                  "",
                  "1",
                  "2",
                  null
                ],
                "nullable": true
              },
              {
                "type": "number",
                "enum": [
                  1,
                  2
                ]
              }
            ]
          },
          "tribute_code": {
            "description": "**Colombia (DIAN).** `01` = responsable de IVA, `ZZ` = no aplica.\nThe empty string means \"not set\".\n",
            "example": "01",
            "type": "string",
            "enum": [
              "",
              "01",
              "ZZ",
              null
            ],
            "nullable": true
          },
          "fiscal_responsibilities": {
            "description": "**Colombia (DIAN).** Responsabilidades fiscales del cliente (lista 53).\n`O-13` gran contribuyente, `O-15` autorretenedor,\n`O-23` agente de retención de IVA, `O-47` régimen simple de tributación,\n`R-99-PN` no responsable.\nOmit the field (or send an empty array) to leave it unset — the client is\nthen reported as `R-99-PN`, which is also the value that applies when the\narray carries only that code. `R-99-PN` excludes every `O-*` code: if both\nare sent, only the `O-*` ones are reported.\n",
            "example": [
              "O-15",
              "O-23"
            ],
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "O-13",
                "O-15",
                "O-23",
                "O-47",
                "R-99-PN"
              ]
            },
            "nullable": true
          },
          "dv": {
            "description": "**Colombia (DIAN).** NIT verification digit — a single digit, or the empty\nstring for \"not set\".\n",
            "example": "7",
            "type": "string",
            "nullable": true,
            "pattern": "^[0-9]?$"
          },
          "municipality_code": {
            "description": "**Colombia (DIAN).** DANE municipality code — exactly five digits, or the empty\nstring for \"not set\". Only meaningful for clients domiciled in Colombia.\n",
            "example": "05001",
            "type": "string",
            "nullable": true,
            "pattern": "^([0-9]{5})?$"
          },
          "check_pending_receipts": {
            "description": "Only applies to `PUT /clients/{id}`. When `true` (default) and the updated client passes fiscal validation, all of the client's pending receipts are automatically invoiced using the new client data. Set to `false` to skip this behavior.\n",
            "example": true,
            "default": true,
            "type": "boolean"
          }
        }
      },
      "ServiceInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`) — body\nvalidation runs in strict allowlist mode. `team`, `livemode` and `owner` are reserved\nand injected by the auth middleware.\n",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "description": {
            "example": "Consulting services",
            "type": "string",
            "nullable": true
          },
          "sku": {
            "example": "CONS-001",
            "type": "string",
            "nullable": true
          },
          "product_key": {
            "example": "80141503",
            "type": "string",
            "nullable": true
          },
          "unit_key": {
            "example": "E48",
            "type": "string",
            "nullable": true
          },
          "unit_name": {
            "example": "Servicio",
            "type": "string",
            "nullable": true
          },
          "unit_price": {
            "example": 1000,
            "type": "number",
            "nullable": true
          },
          "taxes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "base": {
                  "description": "Taxable base amount. Accepts number or numeric string. If null, calculated automatically from item price.",
                  "example": 100,
                  "oneOf": [
                    {
                      "type": "number",
                      "nullable": true
                    },
                    {
                      "type": "string",
                      "description": "Numeric string accepted by the request validator."
                    }
                  ]
                },
                "factor": {
                  "example": "Tasa",
                  "type": "string",
                  "nullable": true
                },
                "inclusive": {
                  "example": false,
                  "type": "boolean",
                  "nullable": true
                },
                "rate": {
                  "example": 0.16,
                  "type": "number",
                  "nullable": true
                },
                "type": {
                  "example": "IVA",
                  "type": "string",
                  "enum": [
                    "IVA",
                    "ISR",
                    "IEPS",
                    null
                  ],
                  "nullable": true
                },
                "withholding": {
                  "example": false,
                  "type": "boolean",
                  "nullable": true
                }
              },
              "nullable": true
            }
          },
          "item_complement": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "hydrocarbons": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "permit_type",
                  "permit_number",
                  "fuel_code",
                  "fuel_sub_product"
                ],
                "properties": {
                  "permit_type": {
                    "type": "string"
                  },
                  "permit_number": {
                    "type": "string"
                  },
                  "fuel_code": {
                    "type": "string"
                  },
                  "fuel_sub_product": {
                    "type": "string"
                  }
                },
                "nullable": true
              }
            },
            "nullable": true
          }
        }
      },
      "CfdiError": {
        "type": "object",
        "required": [
          "code",
          "description",
          "explanation",
          "solution",
          "type"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Unique CFDI error code identifier",
            "example": "CFDI140223"
          },
          "description": {
            "type": "string",
            "description": "Brief description of the error (typically in Spanish as provided by SAT)",
            "example": "El campo Rfc del receptor no es valido"
          },
          "explanation": {
            "type": "string",
            "description": "Detailed explanation of why this error occurs",
            "example": "The RFC (tax ID) provided for the receiver does not meet the validation requirements or format specified by SAT"
          },
          "solution": {
            "type": "string",
            "description": "Actionable steps to resolve the error",
            "example": "Verify that the receiver's RFC is correct, properly formatted (13 characters for individuals, 12 for legal entities), and matches SAT's registered information"
          },
          "type": {
            "type": "string",
            "enum": [
              "invoice",
              "receiver",
              "sender",
              "unknown"
            ],
            "description": "Category of the error",
            "example": "receiver"
          }
        }
      },
      "DraftInvoiceInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`) — body\nvalidation runs in strict allowlist mode. `team`, `livemode` and `owner` are reserved\nand injected by the auth middleware.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "invoice_type"
        ],
        "properties": {
          "invoice_type": {
            "description": "Type of invoice to draft:\n- `I`: Income (Ingreso)\n- `E`: Egress (Egreso / Credit Note)\n",
            "example": "I",
            "type": "string",
            "enum": [
              "I",
              "E"
            ]
          },
          "client": {
            "description": "Client information (optional at creation, required for stamping)",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "example": "client_1234567890",
                "type": "string",
                "nullable": true
              },
              "search": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "on_key",
                  "on_value"
                ],
                "properties": {
                  "on_key": {
                    "example": "tax_id",
                    "type": "string"
                  },
                  "on_value": {
                    "example": "PEGJ800101ABC",
                    "type": "string"
                  },
                  "auto_create": {
                    "example": true,
                    "type": "boolean",
                    "nullable": true
                  },
                  "safety_check": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "update": {
                    "type": "boolean",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "address": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "country": {
                    "example": "MEX",
                    "type": "string",
                    "nullable": true,
                    "maxLength": 3
                  },
                  "street": {
                    "example": "Av. Insurgentes Sur",
                    "type": "string",
                    "nullable": true
                  },
                  "zip": {
                    "example": "03100",
                    "type": "string",
                    "nullable": true
                  },
                  "city": {
                    "example": "Ciudad de México",
                    "type": "string",
                    "nullable": true
                  },
                  "state": {
                    "example": "CDMX",
                    "type": "string",
                    "nullable": true
                  },
                  "exterior": {
                    "example": "123",
                    "type": "string",
                    "nullable": true
                  },
                  "interior": {
                    "example": "4B",
                    "type": "string",
                    "nullable": true
                  },
                  "municipality": {
                    "example": "Benito Juárez",
                    "type": "string",
                    "nullable": true
                  },
                  "neighborhood": {
                    "example": "Del Valle",
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "company": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "bcc": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "metadata": {
                "type": "object",
                "additionalProperties": true,
                "properties": {}
              },
              "legal_name": {
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "type": "string",
                "nullable": true
              },
              "use": {
                "type": "string",
                "nullable": true
              },
              "tax_system": {
                "type": "string",
                "nullable": true
              },
              "document_type": {
                "description": "DIAN identification document code",
                "type": "string",
                "enum": [
                  "",
                  "11",
                  "12",
                  "13",
                  "21",
                  "22",
                  "31",
                  "41",
                  "42",
                  "47",
                  "48",
                  "50",
                  "91",
                  null
                ],
                "nullable": true
              },
              "organization_type": {
                "description": "1 = persona jurídica, 2 = persona natural",
                "oneOf": [
                  {
                    "type": "string",
                    "enum": [
                      "",
                      "1",
                      "2",
                      null
                    ],
                    "nullable": true
                  },
                  {
                    "type": "number",
                    "enum": [
                      1,
                      2
                    ]
                  }
                ]
              },
              "tribute_code": {
                "description": "'01' = responsable de IVA, 'ZZ' = no aplica",
                "type": "string",
                "enum": [
                  "",
                  "01",
                  "ZZ",
                  null
                ],
                "nullable": true
              },
              "fiscal_responsibilities": {
                "description": "DIAN responsabilidades fiscales (lista 53). Omitted means 'R-99-PN' (no responsable)",
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "O-13",
                    "O-15",
                    "O-23",
                    "O-47",
                    "R-99-PN"
                  ]
                },
                "nullable": true
              },
              "dv": {
                "description": "NIT verification digit",
                "type": "string",
                "nullable": true,
                "pattern": "^[0-9]?$"
              },
              "municipality_code": {
                "description": "DANE municipality code, only for clients domiciled in Colombia",
                "type": "string",
                "nullable": true,
                "pattern": "^([0-9]{5})?$"
              }
            },
            "nullable": true
          },
          "currency": {
            "description": "Currency code (optional at creation, required for stamping)",
            "example": "MXN",
            "type": "string"
          },
          "exchange_rate": {
            "description": "Exchange rate (auto-fetched if not provided at stamp time)",
            "example": 1,
            "type": "number"
          },
          "use": {
            "description": "CFDI use code (optional at creation, required for stamping)",
            "example": "G03",
            "type": "string"
          },
          "payment_form": {
            "description": "Payment form code (optional at creation, required for stamping)",
            "example": "03",
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "08",
              "12",
              "13",
              "14",
              "15",
              "17",
              "23",
              "24",
              "25",
              "26",
              "27",
              "28",
              "29",
              "30",
              "31",
              "99"
            ]
          },
          "payment_method": {
            "description": "Payment method (optional at creation, required for stamping)",
            "example": "PUE",
            "type": "string",
            "enum": [
              "PPD",
              "PUE"
            ]
          },
          "payment_due_date": {
            "description": "Colombia (DIAN) only. Due date of a credit invoice (`payment_method: PPD`), as YYYY-MM-DD. Required for a Colombian PPD invoice, on or after the stamping day in Bogotá; printed on the DIAN document as \"Fecha de vencimiento\", with the term (\"Plazo: N días\") at the start of the observations. Refused for other countries and for PUE.",
            "example": "2026-11-19",
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "items": {
            "description": "Invoice line items (optional at creation, required for stamping)",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItemSchema"
            }
          },
          "series": {
            "description": "Invoice series",
            "example": "A",
            "type": "string"
          },
          "folio_number": {
            "description": "Custom folio number (auto-assigned if not provided at stamp time)",
            "type": "number"
          },
          "exports": {
            "description": "Export classification",
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              null
            ],
            "nullable": true
          },
          "complements": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "type",
                "data"
              ],
              "properties": {
                "type": {
                  "type": "string"
                },
                "data": {
                  "type": "string"
                }
              }
            },
            "nullable": true
          },
          "related_documents": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "relationship",
                "documents"
              ],
              "properties": {
                "relationship": {
                  "type": "string"
                },
                "documents": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            },
            "nullable": true
          },
          "invoice_pdf_notes": {
            "description": "Custom notes to include in the PDF",
            "type": "string"
          },
          "addenda": {
            "description": "XML addenda to include",
            "type": "string",
            "nullable": true
          },
          "global": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "periodicity",
              "months",
              "year"
            ],
            "properties": {
              "periodicity": {
                "$ref": "#/components/schemas/GlobalPeriodicity"
              },
              "months": {
                "type": "string"
              },
              "year": {
                "type": "integer"
              }
            },
            "nullable": true
          },
          "automation_type": {
            "description": "Automation to trigger after stamping",
            "type": "string",
            "enum": [
              "payment",
              "none"
            ]
          },
          "send_email": {
            "description": "Whether to send the document via email to the client. Defaults to `true`.",
            "type": "boolean"
          },
          "ignore_emails": {
            "description": "Suppress all notification emails for this document. Takes precedence over\n`send_email` — when `true`, no mail is sent even if `send_email` is `true`.\n",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "metadata": {
            "description": "Custom key-value metadata",
            "type": "object",
            "additionalProperties": true,
            "properties": {}
          }
        }
      },
      "DraftInvoiceUpdateInput": {
        "description": "Same accepted fields as `DraftInvoiceInput`, all optional in validation. This does not\nimply PATCH semantics: omitted items become an empty array and other omitted fields\nreceive mapper defaults. Send the complete intended body and read it back before\nstamping. Unknown top-level keys are still rejected\n(`400 validation_failed` / `unexpected_key`).\n",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "invoice_type": {
            "type": "string",
            "enum": [
              "I",
              "E"
            ]
          },
          "client": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "nullable": true
              },
              "search": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "on_key",
                  "on_value"
                ],
                "properties": {
                  "on_key": {
                    "type": "string"
                  },
                  "on_value": {
                    "type": "string"
                  },
                  "auto_create": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "safety_check": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "update": {
                    "type": "boolean",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "address": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "country": {
                    "example": "MEX",
                    "type": "string",
                    "nullable": true,
                    "maxLength": 3
                  },
                  "street": {
                    "example": "Av. Insurgentes Sur",
                    "type": "string",
                    "nullable": true
                  },
                  "zip": {
                    "example": "03100",
                    "type": "string",
                    "nullable": true
                  },
                  "city": {
                    "example": "Ciudad de México",
                    "type": "string",
                    "nullable": true
                  },
                  "state": {
                    "example": "CDMX",
                    "type": "string",
                    "nullable": true
                  },
                  "exterior": {
                    "example": "123",
                    "type": "string",
                    "nullable": true
                  },
                  "interior": {
                    "example": "4B",
                    "type": "string",
                    "nullable": true
                  },
                  "municipality": {
                    "example": "Benito Juárez",
                    "type": "string",
                    "nullable": true
                  },
                  "neighborhood": {
                    "example": "Del Valle",
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "company": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "bcc": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "metadata": {
                "type": "object",
                "additionalProperties": true,
                "properties": {}
              },
              "legal_name": {
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "type": "string",
                "nullable": true
              },
              "use": {
                "type": "string",
                "nullable": true
              },
              "tax_system": {
                "type": "string",
                "nullable": true
              },
              "document_type": {
                "description": "DIAN identification document code",
                "type": "string",
                "enum": [
                  "",
                  "11",
                  "12",
                  "13",
                  "21",
                  "22",
                  "31",
                  "41",
                  "42",
                  "47",
                  "48",
                  "50",
                  "91",
                  null
                ],
                "nullable": true
              },
              "organization_type": {
                "description": "1 = persona jurídica, 2 = persona natural",
                "oneOf": [
                  {
                    "type": "string",
                    "enum": [
                      "",
                      "1",
                      "2",
                      null
                    ],
                    "nullable": true
                  },
                  {
                    "type": "number",
                    "enum": [
                      1,
                      2
                    ]
                  }
                ]
              },
              "tribute_code": {
                "description": "'01' = responsable de IVA, 'ZZ' = no aplica",
                "type": "string",
                "enum": [
                  "",
                  "01",
                  "ZZ",
                  null
                ],
                "nullable": true
              },
              "fiscal_responsibilities": {
                "description": "DIAN responsabilidades fiscales (lista 53). Omitted means 'R-99-PN' (no responsable)",
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "O-13",
                    "O-15",
                    "O-23",
                    "O-47",
                    "R-99-PN"
                  ]
                },
                "nullable": true
              },
              "dv": {
                "description": "NIT verification digit",
                "type": "string",
                "nullable": true,
                "pattern": "^[0-9]?$"
              },
              "municipality_code": {
                "description": "DANE municipality code, only for clients domiciled in Colombia",
                "type": "string",
                "nullable": true,
                "pattern": "^([0-9]{5})?$"
              }
            },
            "nullable": true
          },
          "currency": {
            "type": "string"
          },
          "exchange_rate": {
            "type": "number"
          },
          "use": {
            "type": "string"
          },
          "payment_form": {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "08",
              "12",
              "13",
              "14",
              "15",
              "17",
              "23",
              "24",
              "25",
              "26",
              "27",
              "28",
              "29",
              "30",
              "31",
              "99"
            ]
          },
          "payment_method": {
            "type": "string",
            "enum": [
              "PPD",
              "PUE"
            ]
          },
          "payment_due_date": {
            "description": "Colombia (DIAN) only. Due date of a credit invoice (PPD), YYYY-MM-DD. Send null to clear it.",
            "type": "string",
            "nullable": true,
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItemSchema"
            }
          },
          "series": {
            "type": "string"
          },
          "folio_number": {
            "type": "number"
          },
          "exports": {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              null
            ],
            "nullable": true
          },
          "complements": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "type",
                "data"
              ],
              "properties": {
                "type": {
                  "type": "string"
                },
                "data": {
                  "type": "string"
                }
              }
            },
            "nullable": true
          },
          "related_documents": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "relationship",
                "documents"
              ],
              "properties": {
                "relationship": {
                  "type": "string"
                },
                "documents": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            },
            "nullable": true
          },
          "invoice_pdf_notes": {
            "type": "string"
          },
          "addenda": {
            "type": "string",
            "nullable": true
          },
          "global": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "periodicity",
              "months",
              "year"
            ],
            "properties": {
              "periodicity": {
                "$ref": "#/components/schemas/GlobalPeriodicity"
              },
              "months": {
                "type": "string"
              },
              "year": {
                "type": "integer"
              }
            },
            "nullable": true
          },
          "automation_type": {
            "type": "string",
            "enum": [
              "payment",
              "none"
            ]
          },
          "send_email": {
            "description": "Whether to send the document via email to the client. Defaults to `true`.",
            "type": "boolean"
          },
          "ignore_emails": {
            "description": "Suppress all notification emails for this document. Takes precedence over\n`send_email` — when `true`, no mail is sent even if `send_email` is `true`.\n",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "properties": {}
          }
        }
      },
      "DraftInvoiceOutput": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Draft document ID",
            "example": "abc123def456"
          },
          "draft": {
            "type": "boolean",
            "example": true,
            "description": "Always `true` for draft documents"
          },
          "invoice_type": {
            "type": "string",
            "enum": [
              "I",
              "E"
            ],
            "example": "I"
          },
          "client": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ApiPublicClient"
              },
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ]
          },
          "created_at": {
            "type": "number",
            "format": "int64",
            "description": "Unix timestamp in milliseconds",
            "example": 1677651234000
          },
          "updated_at": {
            "type": "number",
            "format": "int64",
            "description": "Unix timestamp in milliseconds of last update",
            "example": 1677651234000
          },
          "currency": {
            "type": "string",
            "example": "MXN"
          },
          "exchange_rate": {
            "type": "number",
            "example": 1
          },
          "total": {
            "type": "number",
            "example": 5800
          },
          "subtotal": {
            "type": "number",
            "example": 5000
          },
          "discount": {
            "type": "number",
            "example": 0
          },
          "series": {
            "type": "string",
            "example": "A"
          },
          "folio_number": {
            "type": "integer",
            "nullable": true
          },
          "use": {
            "type": "string",
            "example": "G03"
          },
          "payment_form": {
            "type": "string",
            "example": "03"
          },
          "payment_method": {
            "type": "string",
            "example": "PUE"
          },
          "payment_due_date": {
            "type": "string",
            "example": "2026-11-19",
            "description": "Colombia (DIAN) credit invoices only; omitted when not set."
          },
          "date": {
            "type": "number",
            "nullable": true,
            "description": "Invoice date in milliseconds"
          },
          "livemode": {
            "type": "boolean"
          },
          "owner": {
            "type": "string"
          },
          "from": {
            "type": "string",
            "example": "api",
            "description": "Source of draft creation. Documents created through the public API are stored with `api`; requests carrying the `X-Gigstack-Client: mcp` header (the gigstack MCP server) are stored with `mcp` and behave identically."
          },
          "status": {
            "type": "string",
            "example": "draft",
            "description": "Always `draft` for draft documents"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItemSchema"
            }
          },
          "addenda": {
            "type": "string"
          },
          "exports": {
            "type": "string"
          },
          "invoice_pdf_notes": {
            "type": "string"
          },
          "global": {
            "type": "object",
            "nullable": true
          },
          "related_documents": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "complements": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "CartaPorteInput": {
        "description": "Mexico, carriers and freight forwarders only: bills the freight as a CFDI de ingreso with the\nCarta Porte 3.1 complement (road transport). Same object and SAT attribute names as\n`POST /invoices/transfer`. At least one item must be a transport service\n(`product_key` 78101500-78102205, 78121603, 78141500/01, 84121806, 92121800-02); the goods\ngo in `carta_porte.Mercancias`. Not available on global invoices or debit notes, in\ncurrency `XXX`, or next to a donatarias complement.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "TranspInternac",
          "TotalDistRec",
          "Ubicaciones",
          "Mercancias",
          "FiguraTransporte",
          "Autotransporte"
        ],
        "properties": {
          "TranspInternac": {
            "type": "string",
            "enum": [
              "Sí",
              "Si",
              "No"
            ]
          },
          "EntradaSalidaMerc": {
            "type": "string",
            "enum": [
              "Entrada",
              "Salida"
            ]
          },
          "PaisOrigenDestino": {
            "type": "string",
            "maxLength": 3,
            "pattern": "^$|^(?=[\\s\\S]{3,})(?:[\\s\\S]*$)"
          },
          "ViaEntradaSalida": {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04"
            ]
          },
          "TotalDistRec": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string",
                "description": "Numeric string accepted by the request validator."
              }
            ],
            "minimum": 0.01,
            "maximum": 99999
          },
          "RegistroISTMO": {
            "type": "string",
            "enum": [
              "Sí",
              "Si"
            ]
          },
          "UbicacionPoloOrigen": {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06"
            ]
          },
          "UbicacionPoloDestino": {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06"
            ]
          },
          "RegimenesAduaneros": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "RegimenAduanero"
              ],
              "properties": {
                "RegimenAduanero": {
                  "type": "string",
                  "enum": [
                    "IMD",
                    "EXD",
                    "ITR",
                    "ITE",
                    "ETR",
                    "ETE",
                    "DFI",
                    "RFE",
                    "RFS",
                    "TRA"
                  ]
                }
              }
            },
            "minItems": 1,
            "maxItems": 10
          },
          "Ubicaciones": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "TipoUbicacion",
                "RFCRemitenteDestinatario",
                "FechaHoraSalidaLlegada",
                "Domicilio"
              ],
              "properties": {
                "TipoUbicacion": {
                  "type": "string",
                  "enum": [
                    "Origen",
                    "Destino"
                  ]
                },
                "IDUbicacion": {
                  "type": "string",
                  "pattern": "^$|^(?=[\\s\\S]{1,})(?:^(OR|DE)[0-9]{6}$)"
                },
                "RFCRemitenteDestinatario": {
                  "type": "string",
                  "minLength": 12,
                  "maxLength": 13
                },
                "NombreRemitenteDestinatario": {
                  "type": "string",
                  "maxLength": 254,
                  "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                },
                "NumRegIdTrib": {
                  "type": "string",
                  "maxLength": 40,
                  "pattern": "^$|^(?=[\\s\\S]{6,})(?:[\\s\\S]*$)"
                },
                "ResidenciaFiscal": {
                  "type": "string",
                  "maxLength": 3,
                  "pattern": "^$|^(?=[\\s\\S]{3,})(?:[\\s\\S]*$)"
                },
                "FechaHoraSalidaLlegada": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2})?$"
                },
                "DistanciaRecorrida": {
                  "oneOf": [
                    {
                      "type": "number",
                      "nullable": true
                    },
                    {
                      "type": "string",
                      "description": "Numeric string accepted by the request validator."
                    }
                  ],
                  "minimum": 0,
                  "maximum": 99999
                },
                "Domicilio": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "Estado",
                    "Pais",
                    "CodigoPostal"
                  ],
                  "properties": {
                    "Calle": {
                      "type": "string",
                      "maxLength": 100,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "NumeroExterior": {
                      "type": "string",
                      "maxLength": 55,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "NumeroInterior": {
                      "type": "string",
                      "maxLength": 55,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Colonia": {
                      "type": "string",
                      "maxLength": 120,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Localidad": {
                      "type": "string",
                      "maxLength": 120,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Referencia": {
                      "type": "string",
                      "maxLength": 250,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Municipio": {
                      "type": "string",
                      "maxLength": 120,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Estado": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 30
                    },
                    "Pais": {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 3
                    },
                    "CodigoPostal": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 12
                    }
                  }
                }
              }
            },
            "minItems": 2
          },
          "Mercancias": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "PesoBrutoTotal",
              "UnidadPeso",
              "NumTotalMercancias",
              "Mercancia"
            ],
            "properties": {
              "PesoBrutoTotal": {
                "oneOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string",
                    "description": "Numeric string accepted by the request validator."
                  }
                ],
                "minimum": 0.001
              },
              "UnidadPeso": {
                "type": "string",
                "minLength": 1,
                "maxLength": 8
              },
              "PesoNetoTotal": {
                "oneOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string",
                    "description": "Numeric string accepted by the request validator."
                  }
                ],
                "minimum": 0.001
              },
              "NumTotalMercancias": {
                "oneOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "string",
                    "description": "Numeric string accepted by the request validator."
                  }
                ],
                "minimum": 1
              },
              "LogisticaInversaRecoleccionDevolucion": {
                "type": "string",
                "enum": [
                  "Sí",
                  "Si"
                ]
              },
              "Mercancia": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "BienesTransp",
                    "Descripcion",
                    "Cantidad",
                    "ClaveUnidad",
                    "PesoEnKg"
                  ],
                  "properties": {
                    "BienesTransp": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 8
                    },
                    "Descripcion": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 1000
                    },
                    "Cantidad": {
                      "oneOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string",
                          "description": "Numeric string accepted by the request validator."
                        }
                      ],
                      "minimum": 0.000001
                    },
                    "ClaveUnidad": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 3
                    },
                    "Unidad": {
                      "type": "string",
                      "maxLength": 20,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Dimensiones": {
                      "type": "string",
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:^([0-9]{1,3}\\/){2}[0-9]{1,3}(cm|plg)$)"
                    },
                    "MaterialPeligroso": {
                      "type": "string",
                      "enum": [
                        "Sí",
                        "Si",
                        "No"
                      ]
                    },
                    "CveMaterialPeligroso": {
                      "type": "string",
                      "maxLength": 8,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Embalaje": {
                      "type": "string",
                      "maxLength": 8,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "DescripEmbalaje": {
                      "type": "string",
                      "maxLength": 100,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "SectorCOFEPRIS": {
                      "type": "string",
                      "enum": [
                        "01",
                        "02",
                        "03",
                        "04",
                        "05"
                      ]
                    },
                    "NombreIngredienteActivo": {
                      "type": "string",
                      "maxLength": 1000,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "NomQuimico": {
                      "type": "string",
                      "maxLength": 150,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "DenominacionGenericaProd": {
                      "type": "string",
                      "maxLength": 50,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "DenominacionDistintivaProd": {
                      "type": "string",
                      "maxLength": 50,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Fabricante": {
                      "type": "string",
                      "maxLength": 240,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "FechaCaducidad": {
                      "type": "string",
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:^\\d{4}-\\d{2}-\\d{2}$)"
                    },
                    "LoteMedicamento": {
                      "type": "string",
                      "maxLength": 10,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "FormaFarmaceutica": {
                      "type": "string",
                      "enum": [
                        "01",
                        "02",
                        "03",
                        "04",
                        "05",
                        "06",
                        "07",
                        "08",
                        "09",
                        "10",
                        "11",
                        "12",
                        "13",
                        "14",
                        "15",
                        "16",
                        "17",
                        "18",
                        "19",
                        "20"
                      ]
                    },
                    "CondicionesEspTransp": {
                      "type": "string",
                      "enum": [
                        "01",
                        "02",
                        "03",
                        "04"
                      ]
                    },
                    "RegistroSanitarioFolioAutorizacion": {
                      "type": "string",
                      "maxLength": 15,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "PermisoImportacion": {
                      "type": "string",
                      "maxLength": 6,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "FolioImpoVUCEM": {
                      "type": "string",
                      "maxLength": 25,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "NumCAS": {
                      "type": "string",
                      "maxLength": 15,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "RazonSocialEmpImp": {
                      "type": "string",
                      "maxLength": 80,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "NumRegSanPlagCOFEPRIS": {
                      "type": "string",
                      "maxLength": 60,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "DatosFabricante": {
                      "type": "string",
                      "maxLength": 600,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "DatosFormulador": {
                      "type": "string",
                      "maxLength": 600,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "DatosMaquilador": {
                      "type": "string",
                      "maxLength": 600,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "UsoAutorizado": {
                      "type": "string",
                      "maxLength": 1000,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "PesoEnKg": {
                      "oneOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string",
                          "description": "Numeric string accepted by the request validator."
                        }
                      ],
                      "minimum": 0.001
                    },
                    "ValorMercancia": {
                      "oneOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string",
                          "description": "Numeric string accepted by the request validator."
                        }
                      ],
                      "minimum": 0
                    },
                    "Moneda": {
                      "type": "string",
                      "maxLength": 3,
                      "pattern": "^$|^(?=[\\s\\S]{3,})(?:[\\s\\S]*$)"
                    },
                    "FraccionArancelaria": {
                      "type": "string",
                      "maxLength": 10,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "UUIDComercioExt": {
                      "type": "string",
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$)"
                    },
                    "TipoMateria": {
                      "type": "string",
                      "enum": [
                        "01",
                        "02",
                        "03",
                        "04",
                        "05"
                      ]
                    },
                    "DescripcionMateria": {
                      "type": "string",
                      "maxLength": 50,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "DocumentacionAduanera": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "TipoDocumento"
                        ],
                        "properties": {
                          "TipoDocumento": {
                            "type": "string",
                            "enum": [
                              "01",
                              "02",
                              "03",
                              "04",
                              "05",
                              "06",
                              "07",
                              "08",
                              "09",
                              "10",
                              "11",
                              "12",
                              "13",
                              "14",
                              "15",
                              "16",
                              "17",
                              "18",
                              "19",
                              "20"
                            ]
                          },
                          "NumPedimento": {
                            "type": "string",
                            "pattern": "^$|^(?=[\\s\\S]{1,})(?:^[0-9]{2} {2}[0-9]{2} {2}[0-9]{4} {2}[0-9]{7}$)"
                          },
                          "IdentDocAduanero": {
                            "type": "string",
                            "maxLength": 150,
                            "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                          },
                          "RFCImpo": {
                            "type": "string",
                            "maxLength": 13,
                            "pattern": "^$|^(?=[\\s\\S]{12,})(?:[\\s\\S]*$)"
                          }
                        }
                      },
                      "minItems": 1
                    },
                    "GuiasIdentificacion": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "NumeroGuiaIdentificacion",
                          "DescripGuiaIdentificacion",
                          "PesoGuiaIdentificacion"
                        ],
                        "properties": {
                          "NumeroGuiaIdentificacion": {
                            "type": "string",
                            "minLength": 10,
                            "maxLength": 30
                          },
                          "DescripGuiaIdentificacion": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 1000
                          },
                          "PesoGuiaIdentificacion": {
                            "oneOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string",
                                "description": "Numeric string accepted by the request validator."
                              }
                            ],
                            "minimum": 0.001
                          }
                        }
                      },
                      "minItems": 1
                    },
                    "CantidadTransporta": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "Cantidad",
                          "IDOrigen",
                          "IDDestino"
                        ],
                        "properties": {
                          "Cantidad": {
                            "oneOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string",
                                "description": "Numeric string accepted by the request validator."
                              }
                            ],
                            "minimum": 0.000001
                          },
                          "IDOrigen": {
                            "type": "string",
                            "pattern": "^OR[0-9]{6}$"
                          },
                          "IDDestino": {
                            "type": "string",
                            "pattern": "^DE[0-9]{6}$"
                          }
                        }
                      },
                      "minItems": 1
                    }
                  }
                },
                "minItems": 1
              }
            }
          },
          "FiguraTransporte": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "TipoFigura",
                "NombreFigura"
              ],
              "properties": {
                "TipoFigura": {
                  "type": "string",
                  "enum": [
                    "01",
                    "02",
                    "03",
                    "04",
                    "05"
                  ]
                },
                "RFCFigura": {
                  "type": "string",
                  "maxLength": 13,
                  "pattern": "^$|^(?=[\\s\\S]{12,})(?:[\\s\\S]*$)"
                },
                "NumLicencia": {
                  "type": "string",
                  "maxLength": 16,
                  "pattern": "^$|^(?=[\\s\\S]{6,})(?:[\\s\\S]*$)"
                },
                "NombreFigura": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 254
                },
                "NumRegIdTribFigura": {
                  "type": "string",
                  "maxLength": 40,
                  "pattern": "^$|^(?=[\\s\\S]{6,})(?:[\\s\\S]*$)"
                },
                "ResidenciaFiscalFigura": {
                  "type": "string",
                  "maxLength": 3,
                  "pattern": "^$|^(?=[\\s\\S]{3,})(?:[\\s\\S]*$)"
                },
                "PartesTransporte": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "ParteTransporte"
                    ],
                    "properties": {
                      "ParteTransporte": {
                        "type": "string",
                        "enum": [
                          "PT01",
                          "PT02",
                          "PT03",
                          "PT04",
                          "PT05",
                          "PT06",
                          "PT07",
                          "PT08",
                          "PT09",
                          "PT10",
                          "PT11",
                          "PT12"
                        ]
                      }
                    }
                  },
                  "minItems": 1
                },
                "Domicilio": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "Estado",
                    "Pais",
                    "CodigoPostal"
                  ],
                  "properties": {
                    "Calle": {
                      "type": "string",
                      "maxLength": 100,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "NumeroExterior": {
                      "type": "string",
                      "maxLength": 55,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "NumeroInterior": {
                      "type": "string",
                      "maxLength": 55,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Colonia": {
                      "type": "string",
                      "maxLength": 120,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Localidad": {
                      "type": "string",
                      "maxLength": 120,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Referencia": {
                      "type": "string",
                      "maxLength": 250,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Municipio": {
                      "type": "string",
                      "maxLength": 120,
                      "pattern": "^$|^(?=[\\s\\S]{1,})(?:[\\s\\S]*$)"
                    },
                    "Estado": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 30
                    },
                    "Pais": {
                      "type": "string",
                      "minLength": 3,
                      "maxLength": 3
                    },
                    "CodigoPostal": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 12
                    }
                  }
                }
              }
            },
            "minItems": 1
          },
          "Autotransporte": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "PermSCT",
              "NumPermisoSCT",
              "IdentificacionVehicular",
              "Seguros"
            ],
            "properties": {
              "PermSCT": {
                "type": "string",
                "minLength": 1,
                "maxLength": 6
              },
              "NumPermisoSCT": {
                "type": "string",
                "minLength": 1,
                "maxLength": 50
              },
              "IdentificacionVehicular": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "ConfigVehicular",
                  "PesoBrutoVehicular",
                  "PlacaVM",
                  "AnioModeloVM"
                ],
                "properties": {
                  "ConfigVehicular": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 8
                  },
                  "PesoBrutoVehicular": {
                    "oneOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string",
                        "description": "Numeric string accepted by the request validator."
                      }
                    ],
                    "minimum": 0.01
                  },
                  "PlacaVM": {
                    "type": "string",
                    "pattern": "^[^(?!.*\\s)-]{5,7}$"
                  },
                  "AnioModeloVM": {
                    "oneOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string",
                        "description": "Numeric string accepted by the request validator."
                      }
                    ],
                    "minimum": 1900,
                    "maximum": 2099
                  }
                }
              },
              "Seguros": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "AseguraRespCivil",
                  "PolizaRespCivil"
                ],
                "properties": {
                  "AseguraRespCivil": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 50
                  },
                  "PolizaRespCivil": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 30
                  },
                  "AseguraMedAmbiente": {
                    "type": "string",
                    "maxLength": 50,
                    "pattern": "^$|^(?=[\\s\\S]{3,})(?:[\\s\\S]*$)"
                  },
                  "PolizaMedAmbiente": {
                    "type": "string",
                    "maxLength": 30,
                    "pattern": "^$|^(?=[\\s\\S]{3,})(?:[\\s\\S]*$)"
                  },
                  "AseguraCarga": {
                    "type": "string",
                    "maxLength": 50,
                    "pattern": "^$|^(?=[\\s\\S]{3,})(?:[\\s\\S]*$)"
                  },
                  "PolizaCarga": {
                    "type": "string",
                    "maxLength": 30,
                    "pattern": "^$|^(?=[\\s\\S]{3,})(?:[\\s\\S]*$)"
                  },
                  "PrimaSeguro": {
                    "oneOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string",
                        "description": "Numeric string accepted by the request validator."
                      }
                    ],
                    "minimum": 0
                  }
                }
              },
              "Remolques": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "SubTipoRem",
                    "Placa"
                  ],
                  "properties": {
                    "SubTipoRem": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 6
                    },
                    "Placa": {
                      "type": "string",
                      "pattern": "^[^(?!.*\\s)-]{5,7}$"
                    }
                  }
                },
                "minItems": 1,
                "maxItems": 2
              }
            }
          }
        }
      },
      "InvoiceIncomeInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`) — body\nvalidation runs in strict allowlist mode, so a field the schema does not declare\nproduces that error. In particular there is no `client_id` field: reference an\nexisting client with `client: { \"id\": \"client_…\" }`, or look one up with\n`client: { \"search\": { \"on_key\": \"tax_id\", \"on_value\": \"…\" } }`. Supplying both `id`\nand `search` on the same object is a `400`.\n\n`team`, `livemode` and `owner` are reserved and injected by the auth middleware.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "client",
          "currency",
          "use",
          "items",
          "payment_form",
          "payment_method"
        ],
        "properties": {
          "date": {
            "type": "number"
          },
          "client": {
            "$ref": "#/components/schemas/EmbeddedClientInput"
          },
          "return_files": {
            "description": "Return base64 encoded PDF and XML files in response",
            "example": true,
            "type": "boolean"
          },
          "currency": {
            "example": "MXN",
            "type": "string"
          },
          "exchange_rate": {
            "description": "Exchange rate for currency conversion. If not provided, the latest rate from our rates collection will be used automatically. A rate of 1 on a currency other than the team's local currency is refused with 400.",
            "example": 1,
            "type": "number"
          },
          "folio_number": {
            "example": 123,
            "type": "number"
          },
          "series": {
            "description": "Optional. Defaults to the team's invoice serie. For a Colombian debit note it defaults to the\nteam's debit-note serie, then `ND`, so a debit note never takes a number from the sales-invoice\nserie. In Colombia the series and folio stored on the issued document are the ones DIAN\nassigned (for example `ND3` is series `ND`, folio `3`).\n",
            "example": "A",
            "type": "string"
          },
          "idempotency_key": {
            "description": "Your identifier for this invoice, for example your order id. With it, sending the same request\nagain cannot issue a second CFDI or charge a second credit:\n\n- Once the invoice exists, the same key answers `400` with `duplicate: true` and the existing `uuid`.\n- While another request with the key is being processed, it answers `409` `idempotency_in_progress`.\n- After a `503` `PAC_OUTCOME_UNKNOWN`, a retry with the key resends the exact same XML and folio, so\n  the PAC either stamps it once or reports the stamp it already made.\n- A definitive rejection (for example the SAT refusing the data) frees the key, so you can fix the\n  body and send it again under the same key.\n\nScoped to your team and the credential's mode. Required on every item of `POST /invoices/income/batch`.\n",
            "example": "unique_key_123",
            "type": "string",
            "nullable": true
          },
          "use": {
            "example": "G03",
            "type": "string"
          },
          "exports": {
            "example": "01",
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              null
            ],
            "nullable": true
          },
          "complements": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "type",
                "data"
              ],
              "properties": {
                "type": {
                  "example": "custom",
                  "type": "string"
                },
                "data": {
                  "example": "<xml>...</xml>",
                  "type": "string"
                }
              }
            },
            "nullable": true
          },
          "carta_porte": {
            "$ref": "#/components/schemas/CartaPorteInput"
          },
          "related_documents": {
            "description": "Earlier documents this invoice relates to. In Mexico, `relationship` is a SAT\nCFDI relationship code and `documents` lists fiscal UUIDs.\n\n**Colombia, debit note** (`document_kind: debit_note`): exactly one entry, with\n`relationship: \"02\"` and one document: the invoice being debited, given as its\n`uuid` (CUFE) or its DIAN number (for example `FV69`), or the credit note the debit\nnote reverses, given the same way (for example `NCP27`).\n",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "relationship",
                "documents"
              ],
              "properties": {
                "relationship": {
                  "example": "04",
                  "type": "string"
                },
                "documents": {
                  "type": "array",
                  "items": {
                    "example": "12345678-1234-1234-1234-123456789012",
                    "type": "string"
                  }
                }
              }
            },
            "nullable": true
          },
          "invoice_pdf_notes": {
            "example": "Additional notes for PDF",
            "type": "string"
          },
          "pdf_fields": {
            "description": "**Colombia (DIAN) only.** Label/value pairs printed beside the dates on the PDF gigstack\ndraws for teams that use their own Colombian PDF, for example a purchase order number.\nThey are printed only: they are not part of the DIAN XML. Up to 10. A field with the same\nlabel as one the team prints from `metadata` replaces it; with an empty `value` it hides\nit on this invoice. Ignored in Mexico.\n",
            "type": "array",
            "maxItems": 10,
            "nullable": true,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "label"
              ],
              "properties": {
                "label": {
                  "example": "Número de compra",
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 60
                },
                "value": {
                  "description": "Missing or empty hides a team field with the same label on this invoice",
                  "example": "OC-2026-0458",
                  "type": "string",
                  "nullable": true,
                  "maxLength": 300
                }
              }
            }
          },
          "addenda": {
            "example": "<addenda>...</addenda>",
            "type": "string",
            "nullable": true
          },
          "send_email": {
            "description": "Whether to send the document via email to the client. Defaults to `true`.",
            "example": true,
            "type": "boolean"
          },
          "ignore_emails": {
            "description": "Suppress all notification emails for this document. Takes precedence over\n`send_email` — when `true`, no mail is sent even if `send_email` is `true`.\n",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "emails": {
            "example": [
              "client@example.com"
            ],
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "metadata": {
            "description": "Custom key-value metadata. Colombia: the team setting `order_reference` (e.g. {metadata.orderId?}) can send a metadata value to DIAN as the sales invoice's purchase order.",
            "type": "object",
            "additionalProperties": true,
            "properties": {},
            "example": {
              "orderId": "OC-4501"
            }
          },
          "automation_type": {
            "description": "Optional. Invoice automation type:\n- `payment`: Create invoice with payment automation\n- `none`: No automation, create invoice only\n",
            "example": "payment",
            "type": "string",
            "enum": [
              "payment",
              "none"
            ]
          },
          "global": {
            "description": "Factura global period. Required when the client is PUBLICO EN GENERAL (XAXX010101000); without it the invoice is refused instead of being stamped for the current month.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "periodicity",
              "months",
              "year"
            ],
            "properties": {
              "periodicity": {
                "$ref": "#/components/schemas/GlobalPeriodicity"
              },
              "months": {
                "example": "01",
                "type": "string"
              },
              "year": {
                "example": 2024,
                "type": "integer"
              }
            },
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceItemInput"
            }
          },
          "payment_form": {
            "description": "SAT forma de pago. `99` (Por definir) needs `payment_method` PPD; with PUE it is refused with 400, except on a factura global.",
            "example": "03",
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "08",
              "12",
              "13",
              "14",
              "15",
              "17",
              "23",
              "24",
              "25",
              "26",
              "27",
              "28",
              "29",
              "30",
              "31",
              "99"
            ]
          },
          "payment_method": {
            "example": "PUE",
            "type": "string",
            "enum": [
              "PPD",
              "PUE"
            ]
          },
          "payment_due_date": {
            "description": "Colombia (DIAN) only. Due date of a credit invoice (`payment_method: PPD`), as YYYY-MM-DD. Required for a Colombian PPD invoice, on or after the stamping day in Bogotá; printed on the DIAN document as \"Fecha de vencimiento\", with the term (\"Plazo: N días\") at the start of the observations. Refused for other countries and for PUE.",
            "example": "2026-11-19",
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "document_kind": {
            "description": "**Colombia (DIAN) only.** Which document to issue. Omitted, `null` or `invoice` issues a\nregular sales invoice (factura de venta). `debit_note` issues a DIAN debit note (nota débito)\nthat charges an additional amount on an invoice you already issued. A debit note:\n\n- requires `motive`;\n- must reference exactly one invoice: `related_documents: [{ \"relationship\": \"02\",\n  \"documents\": [\"<invoice uuid or DIAN number>\"] }]`. The referenced document must be a sales\n  invoice of the same team and mode, or a credit note it reverses (see `billing_period`),\n  never another debit note;\n- cannot be combined with `global`;\n- carries in `items` only the **additional** amounts being charged (interest, collection\n  costs, the price increase), not the original invoice's items.\n\nTeams that don't invoice in Colombia get `400` for `debit_note`. These checks run before a\ncredit is consumed or a folio reserved.\n",
            "example": "debit_note",
            "type": "string",
            "enum": [
              "invoice",
              "debit_note",
              null
            ],
            "nullable": true
          },
          "motive": {
            "description": "**Colombia (DIAN) only. Required when `document_kind` is `debit_note`**, refused (`400`) on\nany other invoice. The DIAN concept of the debit note, by code or by name:\n\n| Code | Name | DIAN concept |\n| --- | --- | --- |\n| `1` | `interest` | Intereses |\n| `2` | `collection_expenses` | Gastos por cobrar |\n| `3` | `value_change` | Cambio del valor |\n| `4` | `other` | Otros |\n\nThese codes are not the credit-note or cancellation motives: `2` means \"Gastos por cobrar\"\nhere.\n",
            "example": "1",
            "type": "string",
            "enum": [
              "1",
              "2",
              "3",
              "4",
              "interest",
              "collection_expenses",
              "value_change",
              "other",
              null
            ],
            "nullable": true
          },
          "billing_period": {
            "description": "**Colombia (DIAN) only, debit notes that reverse a credit note.** The period the debit\nnote covers. **Required when the debit note reverses a credit note** (`related_documents`\nnames a credit note): DIAN then issues it as a debit note without an invoice reference\n(operation type 32), which must carry a billing period. Refused (`400`) on a debit note\nthat debits a sales invoice and on any other invoice. Both checks run before a credit is\nconsumed or a folio reserved.\n\n`start_time` defaults to `00:00:00` and `end_time` to `23:59:59`; the dates must be days that\nexist and the period must end no earlier than it starts.\n",
            "type": "object",
            "nullable": true,
            "additionalProperties": false,
            "required": [
              "start_date",
              "end_date"
            ],
            "properties": {
              "start_date": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                "example": "2026-09-01"
              },
              "end_date": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                "example": "2026-09-30"
              },
              "start_time": {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$",
                "example": "00:00:00"
              },
              "end_time": {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$",
                "example": "23:59:59"
              }
            }
          }
        }
      },
      "InvoiceEgressInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`) — body\nvalidation runs in strict allowlist mode, so a field the schema does not declare\nproduces that error. In particular there is no `client_id` field: reference an\nexisting client with `client: { \"id\": \"client_…\" }`, or look one up with\n`client: { \"search\": { \"on_key\": \"tax_id\", \"on_value\": \"…\" } }`. Supplying both `id`\nand `search` on the same object is a `400`.\n\n`team`, `livemode` and `owner` are reserved and injected by the auth middleware.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "client",
          "currency",
          "use",
          "items",
          "payment_form"
        ],
        "properties": {
          "date": {
            "description": "Unix timestamp for invoice date",
            "example": 1640995200,
            "type": "number"
          },
          "client": {
            "$ref": "#/components/schemas/EmbeddedClientInput"
          },
          "return_files": {
            "description": "Return base64 encoded PDF and XML files in response",
            "example": true,
            "type": "boolean"
          },
          "currency": {
            "example": "MXN",
            "type": "string"
          },
          "exchange_rate": {
            "description": "Exchange rate for currency conversion. If not provided, the latest rate from our rates collection will be used automatically.",
            "example": 1,
            "type": "number"
          },
          "folio_number": {
            "example": 123,
            "type": "number"
          },
          "series": {
            "description": "Optional. Defaults to the team's credit-note serie, then 'E'.",
            "example": "A",
            "type": "string"
          },
          "idempotency_key": {
            "description": "Optional idempotency key to prevent duplicate invoices",
            "example": "unique_key_123",
            "type": "string",
            "nullable": true
          },
          "use": {
            "example": "G03",
            "type": "string"
          },
          "exports": {
            "example": "01",
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              null
            ],
            "nullable": true
          },
          "complements": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "type",
                "data"
              ],
              "properties": {
                "type": {
                  "example": "custom",
                  "type": "string"
                },
                "data": {
                  "example": "<xml>...</xml>",
                  "type": "string"
                }
              }
            },
            "nullable": true
          },
          "related_documents": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "relationship",
                "documents"
              ],
              "properties": {
                "relationship": {
                  "example": "04",
                  "type": "string"
                },
                "documents": {
                  "type": "array",
                  "items": {
                    "example": "12345678-1234-1234-1234-123456789012",
                    "type": "string"
                  }
                }
              }
            },
            "nullable": true
          },
          "invoice_pdf_notes": {
            "example": "Additional notes for PDF",
            "type": "string"
          },
          "pdf_fields": {
            "description": "**Colombia (DIAN) only.** Label/value pairs printed beside the dates on the PDF gigstack\ndraws for teams that use their own Colombian PDF, for example a purchase order number.\nThey are printed only: they are not part of the DIAN XML. Up to 10. A field with the same\nlabel as one the team prints from `metadata` replaces it; with an empty `value` it hides\nit on this invoice. Ignored in Mexico.\n",
            "type": "array",
            "maxItems": 10,
            "nullable": true,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "label"
              ],
              "properties": {
                "label": {
                  "example": "Número de compra",
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 60
                },
                "value": {
                  "description": "Missing or empty hides a team field with the same label on this invoice",
                  "example": "OC-2026-0458",
                  "type": "string",
                  "nullable": true,
                  "maxLength": 300
                }
              }
            }
          },
          "addenda": {
            "example": "<addenda>...</addenda>",
            "type": "string",
            "nullable": true
          },
          "send_email": {
            "description": "Whether to send the document via email to the client. Defaults to `true`.",
            "example": true,
            "type": "boolean"
          },
          "ignore_emails": {
            "description": "Suppress all notification emails for this document. Takes precedence over\n`send_email` — when `true`, no mail is sent even if `send_email` is `true`.\n",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "emails": {
            "example": [
              "client@example.com"
            ],
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "properties": {}
          },
          "automation_type": {
            "description": "Payment automation type:\n- `none`: No automation, create invoice only\n",
            "example": "none",
            "type": "string",
            "enum": [
              "none"
            ]
          },
          "items": {
            "description": "Line items. Only `quantity` is required on each item; everything else is optional or resolved from the referenced service.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceItemInput"
            }
          },
          "payment_form": {
            "example": "03",
            "type": "string"
          },
          "payment_method": {
            "description": "CFDI `MetodoPago`. Optional — defaults to `PUE` when omitted, which is how every\negress invoice was stamped before this field existed.\n\nWith `PPD`, SAT requires `payment_form` to be `99` (\"Por definir\"); any other\nvalue you send is overridden to `99` rather than rejected.\n",
            "example": "PUE",
            "default": "PUE",
            "type": "string",
            "enum": [
              "PPD",
              "PUE"
            ]
          }
        }
      },
      "PaymentComplementRelatedDocument": {
        "type": "object",
        "required": [
          "uuid",
          "amount",
          "installment",
          "last_balance",
          "currency"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "description": "UUID (folio fiscal) of the PPD invoice being paid.",
            "example": "A1B2C3D4-E5F6-7890-ABCD-1234567890AB"
          },
          "amount": {
            "type": "number",
            "description": "Amount paid against this invoice in this payment (ImpPagado).",
            "example": 116
          },
          "installment": {
            "type": "integer",
            "description": "Payment number for this invoice (NumParcialidad), starting at 1.",
            "example": 1
          },
          "last_balance": {
            "type": "number",
            "description": "Outstanding balance before this payment (ImpSaldoAnt).",
            "example": 116
          },
          "currency": {
            "type": "string",
            "description": "Currency of the related invoice (MonedaDR).",
            "example": "MXN"
          },
          "exchange": {
            "type": "number",
            "description": "Exchange rate to the payment currency (EquivalenciaDR). Defaults to 1 when currencies match.",
            "example": 1
          },
          "series": {
            "type": "string",
            "nullable": true,
            "description": "Series of the related invoice (optional)."
          },
          "folio_number": {
            "type": "string",
            "nullable": true,
            "description": "Folio of the related invoice (optional)."
          },
          "taxes": {
            "type": "array",
            "description": "Taxes carried by this related document, mirrored onto the payment (ImpuestosDR).",
            "items": {
              "type": "object",
              "required": [
                "base",
                "rate",
                "factor",
                "type"
              ],
              "properties": {
                "base": {
                  "type": "number",
                  "example": 100
                },
                "rate": {
                  "type": "string",
                  "description": "Tax rate as a string, e.g. '0.16'.",
                  "example": "0.16"
                },
                "factor": {
                  "type": "string",
                  "enum": [
                    "Tasa",
                    "Cuota",
                    "Exento"
                  ],
                  "example": "Tasa"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "IVA",
                    "ISR",
                    "IEPS"
                  ],
                  "example": "IVA"
                },
                "key": {
                  "type": "string",
                  "nullable": true
                },
                "withholding": {
                  "type": "boolean",
                  "example": false
                },
                "inclusive": {
                  "type": "boolean",
                  "example": false
                }
              }
            }
          }
        }
      },
      "PaymentComplementPayment": {
        "type": "object",
        "required": [
          "payment_form",
          "date",
          "currency",
          "related_documents"
        ],
        "properties": {
          "payment_form": {
            "type": "string",
            "description": "SAT c_FormaPago code (FormaDePagoP), e.g. '03' for transfer.",
            "example": "03"
          },
          "date": {
            "type": "string",
            "description": "Payment date/time (FechaPago), ISO 8601.",
            "example": "2026-07-24T12:00:00"
          },
          "currency": {
            "type": "string",
            "description": "Payment currency (MonedaP).",
            "example": "MXN"
          },
          "exchange": {
            "type": "number",
            "description": "Payment exchange rate to MXN (TipoCambioP). Defaults to 1.",
            "example": 1
          },
          "numOperacion": {
            "type": "string",
            "nullable": true
          },
          "rfcEmisorCtaOrd": {
            "type": "string",
            "nullable": true
          },
          "nomBancoOrdExt": {
            "type": "string",
            "nullable": true
          },
          "ctaOrdenante": {
            "type": "string",
            "nullable": true
          },
          "rfcEmisorCtaBen": {
            "type": "string",
            "nullable": true
          },
          "ctaBeneficiario": {
            "type": "string",
            "nullable": true
          },
          "related_documents": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/PaymentComplementRelatedDocument"
            }
          }
        }
      },
      "PaymentComplementInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "client",
          "complements"
        ],
        "properties": {
          "date": {
            "description": "Comprobante date in epoch milliseconds. Defaults to now.",
            "example": 1784915988000,
            "type": "number"
          },
          "client": {
            "$ref": "#/components/schemas/EmbeddedClientInput"
          },
          "return_files": {
            "description": "When true, includes base64 XML + PDF in the response.",
            "type": "boolean"
          },
          "currency": {
            "type": "string"
          },
          "exchange_rate": {
            "type": "number"
          },
          "folio_number": {
            "description": "Optional custom folio. When set, stamps with that exact folio.",
            "type": "number"
          },
          "series": {
            "description": "Override the series. Defaults to the team's payments series (invoice_serie_payments).",
            "type": "string"
          },
          "idempotency_key": {
            "type": "string",
            "nullable": true
          },
          "use": {
            "type": "string"
          },
          "exports": {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              null
            ],
            "nullable": true
          },
          "complements": {
            "description": "Payment complement groups. Normally a single entry with type 'payment'.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "data"
              ],
              "properties": {
                "type": {
                  "description": "Complement type. Defaults to 'pago' (required so the parent PPD balance updates).",
                  "example": "pago",
                  "type": "string"
                },
                "data": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "payment_form",
                      "date",
                      "currency",
                      "related_documents"
                    ],
                    "properties": {
                      "payment_form": {
                        "description": "SAT c_FormaPago code (FormaDePagoP), e.g. '03' for transfer.",
                        "example": "03",
                        "type": "string"
                      },
                      "date": {
                        "description": "Payment date/time (FechaPago), ISO 8601.",
                        "example": "2026-07-24T12:00:00.000Z",
                        "type": "string"
                      },
                      "currency": {
                        "description": "Payment currency (MonedaP).",
                        "example": "MXN",
                        "type": "string"
                      },
                      "exchange": {
                        "description": "Payment exchange rate to MXN (TipoCambioP). Defaults to 1.",
                        "example": 1,
                        "type": "number"
                      },
                      "numOperacion": {
                        "type": "string",
                        "nullable": true
                      },
                      "rfcEmisorCtaOrd": {
                        "type": "string",
                        "nullable": true
                      },
                      "nomBancoOrdExt": {
                        "type": "string",
                        "nullable": true
                      },
                      "ctaOrdenante": {
                        "type": "string",
                        "nullable": true
                      },
                      "rfcEmisorCtaBen": {
                        "type": "string",
                        "nullable": true
                      },
                      "ctaBeneficiario": {
                        "type": "string",
                        "nullable": true
                      },
                      "related_documents": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "uuid",
                            "amount",
                            "installment",
                            "last_balance",
                            "currency"
                          ],
                          "properties": {
                            "uuid": {
                              "description": "UUID (folio fiscal) of the PPD invoice being paid.",
                              "example": "A1B2C3D4-E5F6-7890-ABCD-1234567890AB",
                              "type": "string"
                            },
                            "amount": {
                              "description": "Amount paid against this invoice in this payment (ImpPagado).",
                              "example": 116,
                              "type": "number"
                            },
                            "installment": {
                              "description": "Payment number for this invoice (NumParcialidad), starting at 1.",
                              "example": 1,
                              "type": "number"
                            },
                            "last_balance": {
                              "description": "Outstanding balance before this payment (ImpSaldoAnt).",
                              "example": 116,
                              "type": "number"
                            },
                            "currency": {
                              "description": "Currency of the related invoice (MonedaDR).",
                              "example": "MXN",
                              "type": "string"
                            },
                            "exchange": {
                              "description": "Exchange rate to the payment currency (EquivalenciaDR). Defaults to 1 when currencies match.",
                              "example": 1,
                              "type": "number"
                            },
                            "series": {
                              "description": "Series of the related invoice (optional).",
                              "type": "string",
                              "nullable": true
                            },
                            "folio_number": {
                              "description": "Folio of the related invoice (optional).",
                              "type": "string",
                              "nullable": true
                            },
                            "taxes": {
                              "description": "Taxes carried by this related document, mirrored onto the payment (ImpuestosDR).",
                              "type": "array",
                              "items": {
                                "type": "object",
                                "additionalProperties": false,
                                "required": [
                                  "base",
                                  "rate",
                                  "factor",
                                  "type"
                                ],
                                "properties": {
                                  "base": {
                                    "example": 100,
                                    "type": "number"
                                  },
                                  "rate": {
                                    "description": "Tax rate as a string, e.g. '0.16'.",
                                    "example": "0.16",
                                    "type": "string"
                                  },
                                  "factor": {
                                    "example": "Tasa",
                                    "type": "string"
                                  },
                                  "type": {
                                    "example": "IVA",
                                    "type": "string"
                                  },
                                  "key": {
                                    "type": "string",
                                    "nullable": true
                                  },
                                  "withholding": {
                                    "example": false,
                                    "type": "boolean"
                                  },
                                  "inclusive": {
                                    "example": false,
                                    "type": "boolean"
                                  }
                                }
                              },
                              "nullable": true
                            }
                          }
                        },
                        "minItems": 1
                      }
                    }
                  },
                  "minItems": 1
                }
              }
            },
            "minItems": 1
          },
          "related_documents": {
            "description": "Optional CFDI relations (CfdiRelacionados) at the comprobante level.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "relationship",
                "documents"
              ],
              "properties": {
                "relationship": {
                  "description": "SAT c_TipoRelacion code.",
                  "type": "string"
                },
                "documents": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            },
            "nullable": true
          },
          "invoice_pdf_notes": {
            "type": "string"
          },
          "addenda": {
            "type": "string",
            "nullable": true
          },
          "send_email": {
            "type": "boolean"
          },
          "ignore_emails": {
            "type": "boolean",
            "nullable": true
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "properties": {}
          }
        }
      },
      "PaymentItem": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ApiPublicService"
          },
          {
            "type": "object",
            "properties": {
              "third_party": {
                "$ref": "#/components/schemas/ApiPublicThirdParty"
              },
              "search": {
                "$ref": "#/components/schemas/ApiPublicSearch"
              }
            }
          }
        ]
      },
      "PaymentAllowedMethod": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "card",
            "description": "Payment method identifier"
          }
        }
      },
      "ApiPublicPaymentProcessorDetails": {
        "type": "object",
        "additionalProperties": {
          "type": "object",
          "properties": {
            "payment_intent": {
              "type": "string",
              "example": "pi_1234567890",
              "description": "Payment processor intent ID"
            },
            "charge": {
              "type": "string",
              "example": "ch_1234567890",
              "description": "Payment processor charge ID"
            },
            "invoice": {
              "type": "string",
              "example": "in_1234567890",
              "description": "Payment processor invoice ID"
            }
          }
        },
        "example": {
          "stripe": {
            "payment_intent": "pi_1234567890",
            "charge": "ch_1234567890",
            "invoice": "in_1234567890"
          }
        }
      },
      "ApiPublicPayment": {
        "type": "object",
        "required": [
          "id",
          "client",
          "currency",
          "exchange_rate",
          "items",
          "team",
          "idempotency_key",
          "from",
          "invoices",
          "livemode",
          "owner",
          "payment_form",
          "payments",
          "receipts",
          "refunds",
          "short_url",
          "status",
          "total",
          "total_refunded",
          "subtotal",
          "taxes",
          "discount",
          "withholding_taxes",
          "created_at",
          "succeeded_at",
          "payment_processor"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "payment_1234567890",
            "description": "Unique payment identifier"
          },
          "client": {
            "$ref": "#/components/schemas/ApiPublicClient"
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            },
            "nullable": true,
            "example": [
              "client@example.com"
            ],
            "description": "Email addresses to notify"
          },
          "currency": {
            "type": "string",
            "example": "MXN",
            "description": "Payment currency"
          },
          "allowed_payment_methods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentAllowedMethod"
            },
            "nullable": true,
            "description": "Allowed payment methods"
          },
          "exchange_rate": {
            "type": "number",
            "example": 1,
            "description": "Exchange rate used for currency conversion"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentItem"
            },
            "description": "Items included in this payment"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "example": {
              "order_id": "12345"
            },
            "description": "Additional metadata for the payment"
          },
          "invoice_config": {
            "$ref": "#/components/schemas/ApiPublicInvoiceConfig"
          },
          "team": {
            "type": "string",
            "example": "team_1234567890",
            "description": "Team ID this payment belongs to"
          },
          "idempotency_key": {
            "type": "string",
            "example": "unique_key_123",
            "description": "Idempotency key to prevent duplicate payments"
          },
          "from": {
            "type": "string",
            "example": "api",
            "description": "Source of payment creation. Documents created through the public API are stored with `api`; requests carrying the `X-Gigstack-Client: mcp` header (the gigstack MCP server) are stored with `mcp` and behave identically."
          },
          "invoices": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
            ],
            "description": "Associated invoice ids. Invoices stamped by the API are stored under their SAT UUID (folio fiscal)."
          },
          "livemode": {
            "type": "boolean",
            "example": true,
            "description": "Whether this payment is in live mode"
          },
          "owner": {
            "type": "string",
            "example": "user_1234567890",
            "description": "User ID who owns this payment"
          },
          "payment_form": {
            "type": "string",
            "example": "03",
            "description": "SAT payment form code"
          },
          "payments": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [],
            "description": "Related payment IDs"
          },
          "receipts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "receipt_1234567890"
            ],
            "description": "Associated receipt IDs"
          },
          "refunds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiPublicRefund"
            },
            "description": "Refunds associated with this payment"
          },
          "short_url": {
            "type": "string",
            "example": "https://gigstack.xyz/Xk3mP9",
            "description": "Short URL for payment page"
          },
          "success_url": {
            "type": "string",
            "nullable": true,
            "example": "https://tienda.com/pedido/1234/gracias",
            "description": "Where the payment page returns the payer after a successful payment. Null when not set."
          },
          "status": {
            "type": "string",
            "enum": [
              "requires_payment_method",
              "succeeded",
              "partially_paid",
              "canceled"
            ],
            "example": "succeeded",
            "description": "Current payment status. `partially_paid` means the payment was topped up for\nless than its full amount via `POST /payments/{id}/paid` with `amount_received`\nset below the total — see that endpoint's `amount_received` field.\n"
          },
          "total": {
            "type": "number",
            "example": 1160,
            "description": "Total payment amount including taxes"
          },
          "total_refunded": {
            "type": "number",
            "example": 0,
            "description": "Cumulative refunds in minor units (cents), unlike total which is in currency units. Divide by 100 when comparing these fields for the documented MXN flow."
          },
          "subtotal": {
            "type": "number",
            "example": 1000,
            "description": "Subtotal before taxes"
          },
          "taxes": {
            "type": "number",
            "example": 160,
            "description": "Total tax amount"
          },
          "discount": {
            "type": "number",
            "example": 0,
            "description": "Discount applied"
          },
          "withholding_taxes": {
            "type": "number",
            "example": 0,
            "description": "Withholding taxes amount"
          },
          "created_at": {
            "type": "number",
            "example": 1677651234,
            "description": "Unix timestamp of payment creation"
          },
          "succeeded_at": {
            "type": "number",
            "nullable": true,
            "example": 1677651234,
            "description": "Unix timestamp when payment succeeded"
          },
          "payment_processor": {
            "type": "string",
            "example": "stripe",
            "description": "Payment processor used"
          },
          "payment_processor_details": {
            "$ref": "#/components/schemas/ApiPublicPaymentProcessorDetails"
          },
          "transfer_data": {
            "type": "object",
            "nullable": true,
            "description": "Split-payment transfer configuration (gigstack Connect marketplaces)."
          },
          "split_reference": {
            "type": "string",
            "nullable": true
          },
          "split_role": {
            "type": "string",
            "nullable": true,
            "enum": [
              "master",
              "connect",
              null
            ]
          },
          "counterpart_payment_id": {
            "type": "string",
            "nullable": true
          },
          "original_transfer_data": {
            "type": "object",
            "nullable": true
          },
          "split_payment_ids": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            }
          },
          "parent_payment_id": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "RequestPaymentInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`).\n`team`, `livemode` and `owner` are reserved: they are injected by the auth middleware\nand any value you send for them is discarded.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "client",
          "currency",
          "items"
        ],
        "properties": {
          "client": {
            "$ref": "#/components/schemas/EmbeddedClientInput"
          },
          "send_email": {
            "description": "Whether to send an email notification to the customer. Defaults to `true`. Overridden by `ignore_emails`.",
            "example": true,
            "type": "boolean",
            "nullable": true
          },
          "ignore_emails": {
            "description": "Suppress all notification emails for this payment. Takes precedence over\n`send_email` — the handler stores `ignore_emails ?? (send_email === false)`.\n",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "emails": {
            "description": "List of email addresses to send the payment request to",
            "example": [
              "customer@example.com"
            ],
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "automation_type": {
            "description": "Payment automation type. Optional; defaults to `none`.\n- `pue_invoice`: Create PUE (Pago en Una sola Exhibición) invoice immediately when payment succeeds\n- `ppd_invoice_and_complement`: Create PPD (Pago en Parcialidades o Diferido) invoice immediately, then payment complement when payment succeeds\n- `none`: No automation, register payment only\n",
            "example": "pue_invoice",
            "type": "string",
            "enum": [
              "pue_invoice",
              "ppd_invoice_and_complement",
              "none",
              null
            ],
            "nullable": true
          },
          "currency": {
            "description": "Currency code (ISO 4217)",
            "example": "MXN",
            "type": "string"
          },
          "exchange_rate": {
            "description": "Exchange rate for currency conversion. If not provided, the latest rate from our rates collection will be used automatically.",
            "example": 1,
            "type": "number",
            "nullable": true
          },
          "ppd_invoice_id": {
            "type": "string",
            "nullable": true
          },
          "allowed_payment_methods": {
            "description": "Payment methods available to the customer. Optional; when the field is absent it defaults to `['card']`, which every connected processor accepts. An explicit empty list is kept as sent.\n- `card`: Credit/debit card payments\n- `bank`: Mexican bank transfer (SPEI)\n- `oxxo`: OXXO convenience store payments\n- `stripe-spei`: Stripe customer balance payments\n- `mercadopago-wallet`: Mercado Pago wallet (requires `payment_processor: mercadopago`)\n\nThe handler additionally restricts the list to the methods supported by the\nselected `payment_processor` — see the operation description.\n",
            "example": [
              "card",
              "bank",
              "oxxo"
            ],
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "card",
                "bank",
                "oxxo",
                "stripe-spei",
                "mercadopago-wallet"
              ]
            },
            "nullable": true
          },
          "idempotency_key": {
            "description": "Unique key to prevent duplicate payment requests",
            "example": "payment-request-12345",
            "type": "string",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceItemInput"
            }
          },
          "metadata": {
            "description": "Additional metadata to store with the payment",
            "type": "object",
            "additionalProperties": true,
            "properties": {},
            "nullable": true
          },
          "invoice_config": {
            "description": "Optional invoice configuration to force specific folio and/or serie for the invoice. If folio is null or not provided, the automatic incrementing folio will be used.",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "serie": {
                "description": "Invoice serie. Will set/create the series for the team if provided.",
                "example": "A",
                "type": "string",
                "nullable": true
              },
              "folio": {
                "description": "Invoice folio number. If null or not provided, uses automatic incrementing folio. Note: when provided, duplicates may occur.",
                "example": 123,
                "type": "number",
                "nullable": true
              }
            },
            "nullable": true
          },
          "payment_processor": {
            "description": "Processor that will host the checkout. Defaults to `stripe`. Every processor\nother than `stripe` requires `currency: MXN`.\n",
            "example": "stripe",
            "type": "string",
            "enum": [
              "stripe",
              "mercadopago",
              "openpay",
              "pagoralia",
              "conekta",
              null
            ],
            "nullable": true
          },
          "success_url": {
            "description": "Where the hosted payment page returns the payer once the payment succeeds.\nUse it so a checkout does not dead-end on the payment page: point it at your\norder confirmation page.\n\nThe payer is shown the destination host and redirected a few seconds after\nthe payment is confirmed; they can also return immediately with a button.\nFor asynchronous methods (SPEI, OXXO) the redirect happens when the payment\nis confirmed, which may be after the payer has closed the page.\n\nValidated on write — a `400` is returned unless the URL:\n  - uses `https`\n  - carries no credentials (`https://user:pass@host`)\n  - contains no whitespace or control characters\n  - resolves to a fully qualified, publicly reachable host\n    (loopback, private and link-local ranges are rejected)\n  - is at most 2048 characters\n",
            "example": "https://tienda.com/pedido/1234/gracias",
            "type": "string",
            "nullable": true,
            "maxLength": 2048,
            "format": "uri"
          }
        }
      },
      "RegisterPaymentInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`).\n`team`, `livemode` and `owner` are reserved and injected by the auth middleware.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "client",
          "automation_type",
          "currency",
          "items",
          "payment_form"
        ],
        "properties": {
          "client": {
            "$ref": "#/components/schemas/EmbeddedClientInput"
          },
          "automation_type": {
            "description": "Payment automation type:\n- `pue_invoice`: Create PUE (Pago en Una sola Exhibición) invoice immediately when payment succeeds\n- `ppd_invoice_and_complement`: Create PPD (Pago en Parcialidades o Diferido) invoice immediately, then payment complement when payment succeeds\n- `none`: No automation, register payment only\n",
            "example": "pue_invoice",
            "type": "string",
            "enum": [
              "pue_invoice",
              "ppd_invoice_and_complement",
              "none"
            ]
          },
          "currency": {
            "description": "Currency code (ISO 4217)",
            "example": "MXN",
            "type": "string"
          },
          "exchange_rate": {
            "description": "Exchange rate for currency conversion. If not provided, the rate from the payment date (or current date if no date specified) will be fetched automatically from our rates collection.",
            "example": 1,
            "type": "number",
            "nullable": true
          },
          "idempotency_key": {
            "description": "Stable key for one business event. A duplicate returns HTTP 400 with error.code resource_conflict, not the existing payment as a successful response. Reconcile the existing record and retain this key; do not create a new key for a retry. Required on every item of `POST /payments/register/batch`.",
            "example": "payment-register-12345",
            "type": "string",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceItemInput"
            },
            "minItems": 1
          },
          "payment_form": {
            "description": "Mexican SAT payment form code:\n- `01`: Cash\n- `02`: Check\n- `03`: Electronic transfer\n- `04`: Credit card\n- `05`: Electronic money\n- `06`: Digital money\n- `08`: Gift voucher\n- `12`: Credit for unregistered bills\n- `13`: Payment by subrogation\n- `14`: Payment by consignment\n- `15`: Condonation\n- `17`: Compensation\n- `23`: Novation\n- `24`: Confusion\n- `25`: Remission of debt\n- `26`: Prescription or expiration\n- `27`: To creditor's satisfaction\n- `28`: Credit card\n- `29`: Debit card\n- `30`: Service card\n- `31`: Applicable only to the complementary concept of donations\n- `99`: To be defined\n",
            "example": "03",
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "08",
              "12",
              "13",
              "14",
              "15",
              "17",
              "23",
              "24",
              "25",
              "26",
              "27",
              "28",
              "29",
              "30",
              "31",
              "99"
            ]
          },
          "metadata": {
            "description": "Additional metadata to store with the payment",
            "type": "object",
            "additionalProperties": true,
            "properties": {},
            "nullable": true
          },
          "invoice_config": {
            "description": "Optional invoice configuration. Every field is optional. Controls the folio/serie the\ngenerated invoice will use, its issue date, the global (EOM) period it belongs to, and\nhow long the self-invoicing window stays open.\n",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "serie": {
                "description": "Invoice serie. Will set/create the series for the team if provided.",
                "example": "A",
                "type": "string",
                "nullable": true
              },
              "folio": {
                "description": "Invoice folio number. If omitted, the automatic incrementing folio is used. When provided, duplicates may occur.",
                "example": 123,
                "type": "number",
                "nullable": true
              },
              "date": {
                "description": "Invoice issue date as a Unix epoch timestamp in **milliseconds**.",
                "example": 1767225600000,
                "type": "number",
                "nullable": true
              },
              "global": {
                "description": "Period of the global (factura global / EOM) invoice this document belongs to.",
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "year": {
                    "description": "Fiscal year, four digits, from 2021 (the first year SAT accepts on a global invoice) to 2100. A number or a numeric string such as \"2026\"; stored as a number.",
                    "example": 2026,
                    "oneOf": [
                      {
                        "type": "number",
                        "nullable": true
                      },
                      {
                        "type": "string",
                        "description": "Numeric string accepted by the request validator."
                      }
                    ],
                    "minimum": 2021,
                    "maximum": 2100
                  },
                  "months": {
                    "description": "SAT `c_Meses` code. `01`–`12` for a single month; `13`–`18` for the\nbimonthly periods (`13` = Jan–Feb … `18` = Nov–Dec).\n",
                    "example": "01",
                    "type": "string",
                    "nullable": true
                  },
                  "periodicity": {
                    "description": "SAT `c_Periodicidad` code: `01` daily, `02` weekly, `03` fortnightly,\n`04` monthly, `05` bimonthly.\n",
                    "example": "04",
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "validUntil": {
                "description": "Expiry of the self-invoicing window, Unix epoch **milliseconds**.",
                "example": 1769817600000,
                "type": "number",
                "nullable": true
              }
            },
            "nullable": true
          },
          "date": {
            "description": "Unix epoch timestamp in **milliseconds** (13 digits) for when the payment was received. Must be in the past. Defaults to now.",
            "example": 1767225600000,
            "type": "number",
            "nullable": true
          },
          "send_email": {
            "description": "Accepted for compatibility, but on this endpoint it has **no effect** — only\n`ignore_emails` is persisted onto the payment. Use `ignore_emails` to suppress mail.\n",
            "example": true,
            "type": "boolean",
            "nullable": true
          },
          "ignore_emails": {
            "description": "Suppress email and WhatsApp notifications for this payment and any documents\nit automates (invoices, receipts). Defaults to `false`.\n",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "ppd_invoice_id": {
            "description": "UUID of an existing PPD invoice to link this payment to. When provided, a payment complement (complemento de pago) will be automatically generated and linked to the PPD invoice. The referenced invoice must have payment_method='PPD', status='valid' and invoice_type='I' — a payment complement only ever settles an income CFDI, never an egress one.",
            "example": "invoice_ppd_1234567890",
            "type": "string",
            "nullable": true
          },
          "invoice_exchange_rate": {
            "description": "Optional, with `ppd_invoice_id`. The exchange rate your bank applied to the invoice's\ncurrency, in MXN per unit of the invoice currency (e.g. `18.20` MXN per USD). Use it when\nthe PPD invoice is in a foreign currency and the payment is in another one, typically a USD\ninvoice paid in MXN. The payment complement then uses this rate instead of the published one\nto convert the payment to the invoice currency (`EquivalenciaDR = 1 / invoice_exchange_rate`\nfor an MXN payment), and the outstanding-balance check uses it too.\n\nRefused (400) when there is no `ppd_invoice_id`, when the invoice is in MXN or in the\npayment's currency (use `exchange_rate` for the payment's own rate), for teams that do not\ninvoice in MXN, and when it is more than 25 % away from the published rate of the payment\ndate (an inverted rate or a misplaced decimal point). In a Sheets import, leave the mapped\ncolumn empty on rows that do not meet these conditions.\n",
            "example": 18.2,
            "type": "number",
            "nullable": true
          },
          "transfer_data": {
            "description": "Configuration for splitting payments between master and connect teams in a marketplace.\nOnly available for master teams with marketplace-enabled billing accounts.\n\n**All-or-nothing:** the object itself is optional, but when it is present\n`master`, `connect`, `master_to` and `connect_to` are **all required**.\nSending `transfer_data` with any of them missing fails validation with\n`400 validation_failed`. `connect_custom_config` stays optional.\n",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "master",
              "connect",
              "master_to",
              "connect_to"
            ],
            "properties": {
              "master": {
                "description": "Required when `transfer_data` is present. Percentage of the payment retained by the master team. Must be between 0 and 100 inclusive.",
                "example": 10,
                "type": "number",
                "minimum": 0,
                "maximum": 100
              },
              "connect": {
                "description": "Required when `transfer_data` is present. Tax ID (RFC) or Team ID of the connect team. If not found, a new team will be created.",
                "example": "ABC123456789",
                "type": "string",
                "minLength": 1
              },
              "master_to": {
                "description": "Determines which client to assign to the master payment:\n- `client`: Use the original client from the request\n- `connect`: Create the connect team as a client for the master payment\n",
                "example": "client",
                "type": "string",
                "enum": [
                  "client",
                  "connect"
                ]
              },
              "connect_to": {
                "description": "Determines which client to assign to the connect payment:\n- `client`: Use the original client from the request\n- `master`: Create the master team as a client for the connect payment\n",
                "example": "client",
                "type": "string",
                "enum": [
                  "client",
                  "master"
                ]
              },
              "connect_custom_config": {
                "description": "Optional configuration to customize items in the connect payment",
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "product_key": {
                    "description": "SAT product key to use for connect payment items",
                    "example": "01010101",
                    "type": "string",
                    "nullable": true
                  },
                  "unit_key": {
                    "description": "SAT unit key to use for connect payment items",
                    "example": "E48",
                    "type": "string",
                    "nullable": true
                  },
                  "taxes": {
                    "description": "Custom tax configuration for connect payment items (uses same schema as regular item taxes)",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "type",
                        "rate",
                        "withholding"
                      ],
                      "properties": {
                        "type": {
                          "description": "Tax type",
                          "example": "IVA",
                          "type": "string",
                          "enum": [
                            "IVA",
                            "ISR",
                            "IEPS"
                          ]
                        },
                        "rate": {
                          "description": "Tax rate as decimal (0.16 = 16%)",
                          "example": 0.16,
                          "type": "number"
                        },
                        "withholding": {
                          "description": "true = retention (deducted from total), false = regular tax (added to subtotal)",
                          "example": false,
                          "type": "boolean"
                        },
                        "base": {
                          "description": "Optional tax base amount",
                          "type": "number",
                          "nullable": true
                        },
                        "factor": {
                          "description": "Optional tax factor",
                          "example": "Tasa",
                          "type": "string",
                          "nullable": true
                        },
                        "inclusive": {
                          "description": "Whether tax is included in the price",
                          "type": "boolean",
                          "nullable": true
                        }
                      }
                    },
                    "nullable": true
                  },
                  "custom_description": {
                    "description": "Custom description for connect payment items",
                    "example": "Professional consulting services",
                    "type": "string",
                    "nullable": true
                  },
                  "custom_price": {
                    "description": "Fixed amount for connect payment (overrides percentage calculation). When set, connect gets this exact amount and master gets the remainder.",
                    "example": 250,
                    "type": "number",
                    "nullable": true,
                    "minimum": 0
                  }
                },
                "nullable": true
              }
            },
            "nullable": true
          }
        }
      },
      "RefundPaymentInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "reason",
          "amount"
        ],
        "properties": {
          "reason": {
            "description": "Reason for the refund",
            "example": "Customer requested cancellation",
            "type": "string"
          },
          "amount": {
            "description": "Amount to refund, in the payment currency. Validation requires **at least 0.01**.\nThe cumulative refunded total may not exceed the payment amount.\n",
            "example": 1160,
            "type": "number",
            "minimum": 0.01
          },
          "external_processor_refund": {
            "description": "Whether to process refund through external payment processor",
            "example": false,
            "type": "boolean",
            "nullable": true
          }
        }
      },
      "InvoiceConfigInput": {
        "type": "object",
        "nullable": true,
        "additionalProperties": false,
        "description": "Optional invoice configuration. Every field is optional. Controls the folio/serie the\ngenerated invoice will use, its issue date, the global (EOM) period it belongs to, and\nhow long the self-invoicing window stays open.\n",
        "properties": {
          "serie": {
            "type": "string",
            "nullable": true,
            "example": "A",
            "description": "Invoice serie. Will set/create the series for the team if provided."
          },
          "folio": {
            "type": "number",
            "nullable": true,
            "example": 123,
            "description": "Invoice folio number. If omitted, the automatic incrementing folio is used. When provided, duplicates may occur."
          },
          "date": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "example": 1767225600000,
            "description": "Invoice issue date as a Unix epoch timestamp in **milliseconds**."
          },
          "global": {
            "type": "object",
            "nullable": true,
            "additionalProperties": false,
            "description": "Period of the global (factura global / EOM) invoice this document belongs to.",
            "properties": {
              "year": {
                "type": "number",
                "nullable": true,
                "example": 2026,
                "description": "Fiscal year, four digits."
              },
              "months": {
                "type": "string",
                "nullable": true,
                "example": "01",
                "description": "SAT `c_Meses` code. `01`–`12` for a single month; `13`–`18` for the\nbimonthly periods (`13` = Jan–Feb … `18` = Nov–Dec).\n"
              },
              "periodicity": {
                "type": "string",
                "nullable": true,
                "example": "04",
                "description": "SAT `c_Periodicidad` code: `01` daily, `02` weekly, `03` fortnightly,\n`04` monthly, `05` bimonthly.\n"
              }
            }
          },
          "validUntil": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "example": 1769817600000,
            "description": "Expiry of the self-invoicing window, Unix epoch **milliseconds**."
          }
        }
      },
      "MarkPaymentAsPaidInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "payment_form"
        ],
        "properties": {
          "date": {
            "description": "When the payment was received, as a Unix epoch timestamp in **milliseconds**\n(13 digits). The handler feeds this value directly to `Luxon.fromMillis()` and\ncompares it to `Luxon.now().toMillis()`, so a seconds-precision value is\ninterpreted as a 1970 date rather than rejected. Defaults to now; a future\nvalue returns `400`.\n",
            "example": 1767225600000,
            "type": "number",
            "nullable": true
          },
          "send_email": {
            "description": "Whether to send email notifications. Overridden by `ignore_emails`.",
            "example": true,
            "type": "boolean",
            "nullable": true
          },
          "ignore_emails": {
            "description": "Suppress notification emails. Takes precedence over `send_email` — the handler\nresolves `ignore_emails ?? (send_email === false)`.\n",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "amount_received": {
            "description": "Cumulative amount received so far, in the payment's currency (**not** cents —\nconverted internally to match the payment's stored amount). Omit it, or pass\nthe full payment amount, to mark the payment fully `succeeded` (the default\nbehavior). Pass a value **less than** the payment amount to record a partial\ntop-up instead: the payment is set to `partially_paid` with this cumulative\namount, which must exceed the amount already received. A value **greater than**\nthe payment amount is rejected with `400`.\n\nPartial funding additionally requires the team's\n`automatePartialPaymentComplements` default to be enabled and the payment to\nalready carry a `payment_complement` automation (i.e. it originated from a PPD\ninvoice flow) — otherwise the request is rejected with `400`.\n",
            "example": 500,
            "type": "number",
            "nullable": true,
            "minimum": 0.01
          },
          "payment_form": {
            "description": "SAT payment form code",
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "08",
              "12",
              "13",
              "14",
              "15",
              "17",
              "23",
              "24",
              "25",
              "26",
              "27",
              "28",
              "29",
              "30",
              "31",
              "99"
            ]
          }
        }
      },
      "UpdatePaymentInput": {
        "description": "Body for the PUT /payments/{id} endpoint. At least one of `items`, `automation_type` or `client` must be present.\n\n- `items`: Update the `description` of one or more items in the payment, matched by item `id`. Only `description` can be modified — taxes, discounts, quantities and unit prices are immutable from this endpoint and any other field is rejected.\n- `automation_type`: Add automations to a payment that does not have any. If the payment already has automations, the request is rejected with 400. When non-empty automations are added and the payment status is `succeeded`, the status is flipped to `succeeded_` after the update so the automation trigger can re-fire.\n- `client`: Update fields of the client embedded in the payment (name, email, fiscal info, address, etc.). The client `id` cannot be changed. Any provided field is also written to the matching `/clients/{id}` document via a partial merge, so the client master record stays in sync with the payment. Fiscal/SAT validation is **not** re-run from this endpoint — use `PUT /clients/{id}` if you need that.\n",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "items": {
            "description": "List of items to update. Only the `description` of each item can be modified.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "description"
              ],
              "properties": {
                "id": {
                  "description": "Item id within the payment",
                  "example": "service_1234567890",
                  "type": "string",
                  "minLength": 1
                },
                "description": {
                  "description": "New description for the item",
                  "example": "Servicio de consultoría profesional - corregido",
                  "type": "string",
                  "minLength": 1
                }
              }
            },
            "nullable": true,
            "minItems": 1
          },
          "automation_type": {
            "description": "Automation to attach to the payment. Only allowed if the payment currently has no automations.",
            "example": "pue_invoice",
            "type": "string",
            "enum": [
              "pue_invoice",
              "ppd_invoice_and_complement",
              "none",
              null
            ],
            "nullable": true
          },
          "invoice_config": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "serie": {
                "type": "string",
                "nullable": true
              },
              "folio": {
                "type": "number",
                "nullable": true
              },
              "date": {
                "type": "number",
                "nullable": true
              },
              "global": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "year": {
                    "description": "Fiscal year, four digits, from 2021 to 2100. A number or a numeric string such as \"2026\"; stored as a number.",
                    "oneOf": [
                      {
                        "type": "number",
                        "nullable": true
                      },
                      {
                        "type": "string",
                        "description": "Numeric string accepted by the request validator."
                      }
                    ],
                    "minimum": 2021,
                    "maximum": 2100
                  },
                  "months": {
                    "type": "string",
                    "nullable": true
                  },
                  "periodicity": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "validUntil": {
                "type": "number",
                "nullable": true
              }
            },
            "nullable": true
          },
          "client": {
            "description": "Partial update for the client embedded in the payment. Only the listed fields can be modified — the client `id` cannot be changed. Each provided field is propagated to the `/clients/{id}` master document via a partial merge.\n",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "example": "Juan Pérez García",
                "type": "string",
                "nullable": true
              },
              "company": {
                "example": "Acme S.A. de C.V.",
                "type": "string",
                "nullable": true
              },
              "phone": {
                "example": "+525555555555",
                "type": "string",
                "nullable": true
              },
              "email": {
                "example": "juan.perez@ejemplo.com",
                "type": "string",
                "nullable": true,
                "format": "email"
              },
              "bcc": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "nullable": true
              },
              "metadata": {
                "type": "object",
                "additionalProperties": true,
                "properties": {},
                "nullable": true
              },
              "legal_name": {
                "example": "JUAN PEREZ GARCIA",
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "description": "Mexican SAT RFC. Mirrored to the legacy `rfc` field on the client document.",
                "example": "PEGJ800101ABC",
                "type": "string",
                "nullable": true
              },
              "use": {
                "example": "G03",
                "type": "string",
                "nullable": true
              },
              "tax_system": {
                "example": "601",
                "type": "string",
                "nullable": true
              },
              "address": {
                "description": "Partial address update. Only fields present in the request are merged onto the existing address; absent fields are kept as-is.",
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "country": {
                    "example": "MEX",
                    "type": "string",
                    "nullable": true,
                    "maxLength": 3
                  },
                  "street": {
                    "type": "string",
                    "nullable": true
                  },
                  "zip": {
                    "type": "string",
                    "nullable": true
                  },
                  "city": {
                    "type": "string",
                    "nullable": true
                  },
                  "state": {
                    "type": "string",
                    "nullable": true
                  },
                  "exterior": {
                    "type": "string",
                    "nullable": true
                  },
                  "interior": {
                    "type": "string",
                    "nullable": true
                  },
                  "municipality": {
                    "type": "string",
                    "nullable": true
                  },
                  "neighborhood": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              }
            },
            "nullable": true
          }
        }
      },
      "PaymentLinkHistoryInvoice": {
        "properties": {
          "uuid": {
            "type": "string",
            "nullable": true
          },
          "client": {
            "properties": {
              "id": {
                "type": "string",
                "nullable": true
              },
              "address": {
                "additionalProperties": false,
                "properties": {
                  "country": {
                    "maxLength": 3,
                    "type": "string",
                    "nullable": true
                  },
                  "street": {
                    "type": "string",
                    "nullable": true
                  },
                  "zip": {
                    "type": "string",
                    "nullable": true
                  },
                  "city": {
                    "type": "string",
                    "nullable": true
                  },
                  "state": {
                    "type": "string",
                    "nullable": true
                  },
                  "exterior": {
                    "type": "string",
                    "nullable": true
                  },
                  "interior": {
                    "type": "string",
                    "nullable": true
                  },
                  "municipality": {
                    "type": "string",
                    "nullable": true
                  },
                  "neighborhood": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "type": "object",
                "nullable": true
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "company": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "bcc": {
                "items": {
                  "type": "string",
                  "nullable": true
                },
                "type": "array",
                "nullable": true
              },
              "metadata": {
                "additionalProperties": true,
                "type": "object",
                "nullable": true
              },
              "is_valid": {
                "type": "boolean",
                "nullable": true
              },
              "from": {
                "type": "string",
                "nullable": true
              },
              "legal_name": {
                "type": "string",
                "nullable": true
              },
              "livemode": {
                "type": "boolean",
                "nullable": true
              },
              "owner": {
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "type": "string",
                "nullable": true
              },
              "use": {
                "type": "string",
                "nullable": true
              },
              "tax_system": {
                "type": "string",
                "nullable": true
              },
              "team": {
                "type": "string",
                "nullable": true
              },
              "created_at": {
                "type": "number",
                "nullable": true
              },
              "efos": {
                "properties": {
                  "is_valid": {
                    "type": "boolean",
                    "nullable": true
                  }
                },
                "additionalProperties": false,
                "type": "object",
                "nullable": true
              },
              "fiscal_validation": {
                "properties": {
                  "status": {
                    "type": "string",
                    "nullable": true
                  },
                  "message": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "additionalProperties": false,
                "type": "object",
                "nullable": true
              },
              "sat_status": {
                "properties": {
                  "is_risky": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "efos": {
                    "properties": {
                      "is_valid": {
                        "type": "boolean",
                        "nullable": true
                      }
                    },
                    "additionalProperties": false,
                    "type": "object",
                    "nullable": true
                  },
                  "hits": {
                    "items": {
                      "properties": {
                        "list": {
                          "type": "string",
                          "nullable": true
                        },
                        "label": {
                          "type": "string",
                          "nullable": true
                        },
                        "source": {
                          "type": "string",
                          "nullable": true
                        },
                        "is_risky": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "detail": {
                          "additionalProperties": true,
                          "type": "object",
                          "nullable": true
                        }
                      },
                      "additionalProperties": false,
                      "type": "object",
                      "nullable": true
                    },
                    "type": "array",
                    "nullable": true
                  },
                  "checked_at": {
                    "type": "number",
                    "nullable": true
                  }
                },
                "additionalProperties": false,
                "type": "object",
                "nullable": true
              },
              "defaults": {
                "properties": {
                  "keep_full_legal_name": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "issue_automatic_invoices": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "issue_invoiceable_receipts": {
                    "type": "boolean",
                    "nullable": true
                  }
                },
                "additionalProperties": false,
                "type": "object",
                "nullable": true
              },
              "document_type": {
                "type": "string",
                "nullable": true
              },
              "organization_type": {
                "anyOf": [
                  {
                    "type": "integer",
                    "nullable": true
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "tribute_code": {
                "type": "string",
                "nullable": true
              },
              "fiscal_responsibilities": {
                "items": {
                  "type": "string",
                  "nullable": true
                },
                "type": "array",
                "nullable": true
              },
              "dv": {
                "type": "string",
                "nullable": true
              },
              "municipality_code": {
                "type": "string",
                "nullable": true
              }
            },
            "additionalProperties": false,
            "type": "object",
            "nullable": true
          },
          "created_at": {
            "type": "number",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "exchange_rate": {
            "type": "number",
            "nullable": true
          },
          "total": {
            "type": "number",
            "nullable": true
          },
          "subtotal": {
            "type": "number",
            "nullable": true
          },
          "taxes": {
            "type": "number",
            "nullable": true
          },
          "discount": {
            "type": "number",
            "nullable": true
          },
          "withholding_taxes": {
            "type": "number",
            "nullable": true
          },
          "series": {
            "type": "string",
            "nullable": true
          },
          "folio_number": {
            "type": "number",
            "nullable": true
          },
          "invoice_type": {
            "type": "string",
            "nullable": true
          },
          "use": {
            "type": "string",
            "nullable": true
          },
          "payment_form": {
            "type": "string",
            "nullable": true
          },
          "payment_method": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "livemode": {
            "type": "boolean"
          },
          "owner": {
            "type": "string",
            "nullable": true
          },
          "from": {
            "type": "string",
            "nullable": true
          },
          "items": {
            "items": {
              "properties": {
                "id": {
                  "type": "string",
                  "nullable": true
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "product_key": {
                  "type": "string",
                  "nullable": true
                },
                "quantity": {
                  "type": "number",
                  "nullable": true
                },
                "unit_price": {
                  "type": "number",
                  "nullable": true
                },
                "unit_key": {
                  "type": "string",
                  "nullable": true
                },
                "unit_name": {
                  "type": "string",
                  "nullable": true
                },
                "sku": {
                  "type": "string",
                  "nullable": true
                },
                "taxability": {
                  "type": "string",
                  "nullable": true
                },
                "taxes": {
                  "items": {
                    "properties": {
                      "base": {
                        "anyOf": [
                          {
                            "type": "number",
                            "nullable": true
                          },
                          {
                            "type": "string"
                          }
                        ]
                      },
                      "rate": {
                        "anyOf": [
                          {
                            "type": "number",
                            "nullable": true
                          },
                          {
                            "type": "string"
                          }
                        ]
                      },
                      "type": {
                        "type": "string",
                        "nullable": true
                      },
                      "factor": {
                        "type": "string",
                        "nullable": true
                      },
                      "inclusive": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "withholding": {
                        "type": "boolean",
                        "nullable": true
                      }
                    },
                    "additionalProperties": false,
                    "type": "object",
                    "nullable": true
                  },
                  "type": "array",
                  "nullable": true
                },
                "discount": {
                  "type": "number",
                  "nullable": true
                },
                "customs_request": {
                  "type": "string",
                  "nullable": true
                },
                "complement": {
                  "type": "string",
                  "nullable": true
                },
                "property_tax_account": {
                  "type": "string",
                  "nullable": true
                },
                "third_party": {
                  "properties": {
                    "legal_name": {
                      "type": "string",
                      "nullable": true
                    },
                    "tax_id": {
                      "type": "string",
                      "nullable": true
                    },
                    "tax_system": {
                      "type": "string",
                      "nullable": true
                    },
                    "zip": {
                      "type": "string",
                      "nullable": true
                    }
                  },
                  "additionalProperties": false,
                  "type": "object",
                  "nullable": true
                }
              },
              "additionalProperties": false,
              "type": "object",
              "nullable": true
            },
            "type": "array",
            "nullable": true
          },
          "payments": {
            "items": {
              "type": "string",
              "nullable": true
            },
            "type": "array",
            "nullable": true
          },
          "invoices": {
            "items": {
              "type": "string",
              "nullable": true
            },
            "type": "array",
            "nullable": true
          },
          "stamp": {
            "properties": {
              "sello": {
                "type": "string",
                "nullable": true
              },
              "stamp_at": {
                "type": "number",
                "nullable": true
              },
              "provider": {
                "type": "string",
                "nullable": true
              }
            },
            "additionalProperties": false,
            "type": "object",
            "nullable": true
          },
          "cancellation": {
            "properties": {
              "cancellation_status": {
                "type": "string",
                "nullable": true
              },
              "cancelled_at": {
                "type": "number",
                "nullable": true
              },
              "motive": {
                "type": "string",
                "nullable": true
              },
              "code": {
                "type": "string",
                "nullable": true
              },
              "requested_by": {
                "type": "string",
                "nullable": true
              },
              "cancellation_receipt": {
                "type": "string",
                "nullable": true
              },
              "cancellation_type": {
                "type": "string",
                "nullable": true
              },
              "last_checked": {
                "type": "number",
                "nullable": true
              },
              "requested_at": {
                "type": "number",
                "nullable": true
              },
              "substitution_uuid": {
                "type": "string",
                "nullable": true
              }
            },
            "additionalProperties": false,
            "type": "object",
            "nullable": true
          },
          "verification_url": {
            "type": "string",
            "nullable": true
          },
          "exports": {
            "type": "string",
            "nullable": true
          },
          "addenda": {
            "type": "string",
            "nullable": true
          },
          "invoice_pdf_notes": {
            "type": "string",
            "nullable": true
          },
          "files": {
            "properties": {
              "pdf": {
                "type": "string",
                "nullable": true
              },
              "xml": {
                "type": "string",
                "nullable": true
              }
            },
            "additionalProperties": false,
            "required": [
              "pdf",
              "xml"
            ],
            "type": "object"
          },
          "idempotency_key": {
            "type": "string",
            "nullable": true
          },
          "team": {
            "type": "string"
          },
          "billing_account": {
            "type": "string",
            "nullable": true
          },
          "date": {
            "type": "integer",
            "nullable": true
          },
          "payment_conditions": {
            "type": "string",
            "nullable": true
          },
          "global": {
            "properties": {
              "periodicity": {
                "type": "string",
                "nullable": true
              },
              "months": {
                "type": "string",
                "nullable": true
              },
              "year": {
                "type": "number",
                "nullable": true
              }
            },
            "additionalProperties": false,
            "type": "object",
            "nullable": true
          },
          "related_documents": {
            "items": {
              "properties": {
                "relationship": {
                  "type": "string",
                  "nullable": true
                },
                "documents": {
                  "items": {
                    "type": "string",
                    "nullable": true
                  },
                  "type": "array",
                  "nullable": true
                }
              },
              "additionalProperties": false,
              "type": "object",
              "nullable": true
            },
            "type": "array",
            "nullable": true
          },
          "complements": {
            "items": {
              "properties": {
                "type": {
                  "type": "string",
                  "nullable": true
                },
                "data": {
                  "type": "string",
                  "nullable": true
                }
              },
              "additionalProperties": false,
              "type": "object",
              "nullable": true
            },
            "type": "array",
            "nullable": true
          },
          "metadata": {
            "additionalProperties": true,
            "type": "object",
            "nullable": true
          },
          "emails": {
            "items": {
              "type": "string",
              "nullable": true
            },
            "type": "array",
            "nullable": true
          },
          "issuer_info": {
            "properties": {
              "legal_name": {
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "type": "string",
                "nullable": true
              },
              "tax_system": {
                "type": "string",
                "nullable": true
              },
              "zip": {
                "type": "string",
                "nullable": true
              }
            },
            "additionalProperties": false,
            "type": "object",
            "nullable": true
          },
          "namespaces": {
            "items": {
              "properties": {
                "prefix": {
                  "type": "string",
                  "nullable": true
                },
                "uri": {
                  "type": "string",
                  "nullable": true
                },
                "schema_location": {
                  "type": "string",
                  "nullable": true
                }
              },
              "additionalProperties": false,
              "type": "object",
              "nullable": true
            },
            "type": "array",
            "nullable": true
          },
          "id": {
            "pattern": "^[A-Za-z0-9_-]{1,160}$",
            "type": "string"
          },
          "payment_complements": {
            "type": "number",
            "nullable": true
          },
          "last_balance": {
            "type": "number",
            "nullable": true
          },
          "installments": {
            "type": "number",
            "nullable": true
          },
          "automations": {
            "items": {
              "properties": {
                "type": {
                  "type": "string",
                  "nullable": true
                },
                "from": {
                  "type": "string",
                  "nullable": true
                },
                "ref": {
                  "type": "string",
                  "nullable": true
                },
                "action": {
                  "type": "string",
                  "nullable": true
                }
              },
              "additionalProperties": false,
              "type": "object",
              "nullable": true
            },
            "type": "array",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "team",
          "livemode",
          "files"
        ],
        "type": "object"
      },
      "PaymentLinkHistoryReceipt": {
        "properties": {
          "id": {
            "type": "string"
          },
          "client": {
            "properties": {
              "id": {
                "type": "string",
                "nullable": true
              },
              "address": {
                "additionalProperties": false,
                "properties": {
                  "country": {
                    "maxLength": 3,
                    "type": "string",
                    "nullable": true
                  },
                  "street": {
                    "type": "string",
                    "nullable": true
                  },
                  "zip": {
                    "type": "string",
                    "nullable": true
                  },
                  "city": {
                    "type": "string",
                    "nullable": true
                  },
                  "state": {
                    "type": "string",
                    "nullable": true
                  },
                  "exterior": {
                    "type": "string",
                    "nullable": true
                  },
                  "interior": {
                    "type": "string",
                    "nullable": true
                  },
                  "municipality": {
                    "type": "string",
                    "nullable": true
                  },
                  "neighborhood": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "type": "object",
                "nullable": true
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "company": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "bcc": {
                "items": {
                  "type": "string",
                  "nullable": true
                },
                "type": "array",
                "nullable": true
              },
              "metadata": {
                "additionalProperties": true,
                "type": "object",
                "nullable": true
              },
              "is_valid": {
                "type": "boolean",
                "nullable": true
              },
              "from": {
                "type": "string",
                "nullable": true
              },
              "legal_name": {
                "type": "string",
                "nullable": true
              },
              "livemode": {
                "type": "boolean",
                "nullable": true
              },
              "owner": {
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "type": "string",
                "nullable": true
              },
              "use": {
                "type": "string",
                "nullable": true
              },
              "tax_system": {
                "type": "string",
                "nullable": true
              },
              "team": {
                "type": "string",
                "nullable": true
              },
              "created_at": {
                "type": "number",
                "nullable": true
              },
              "efos": {
                "properties": {
                  "is_valid": {
                    "type": "boolean",
                    "nullable": true
                  }
                },
                "additionalProperties": false,
                "type": "object",
                "nullable": true
              },
              "fiscal_validation": {
                "properties": {
                  "status": {
                    "type": "string",
                    "nullable": true
                  },
                  "message": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "additionalProperties": false,
                "type": "object",
                "nullable": true
              },
              "sat_status": {
                "properties": {
                  "is_risky": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "efos": {
                    "properties": {
                      "is_valid": {
                        "type": "boolean",
                        "nullable": true
                      }
                    },
                    "additionalProperties": false,
                    "type": "object",
                    "nullable": true
                  },
                  "hits": {
                    "items": {
                      "properties": {
                        "list": {
                          "type": "string",
                          "nullable": true
                        },
                        "label": {
                          "type": "string",
                          "nullable": true
                        },
                        "source": {
                          "type": "string",
                          "nullable": true
                        },
                        "is_risky": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "detail": {
                          "additionalProperties": true,
                          "type": "object",
                          "nullable": true
                        }
                      },
                      "additionalProperties": false,
                      "type": "object",
                      "nullable": true
                    },
                    "type": "array",
                    "nullable": true
                  },
                  "checked_at": {
                    "type": "number",
                    "nullable": true
                  }
                },
                "additionalProperties": false,
                "type": "object",
                "nullable": true
              },
              "defaults": {
                "properties": {
                  "keep_full_legal_name": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "issue_automatic_invoices": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "issue_invoiceable_receipts": {
                    "type": "boolean",
                    "nullable": true
                  }
                },
                "additionalProperties": false,
                "type": "object",
                "nullable": true
              },
              "document_type": {
                "type": "string",
                "nullable": true
              },
              "organization_type": {
                "anyOf": [
                  {
                    "type": "integer",
                    "nullable": true
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "tribute_code": {
                "type": "string",
                "nullable": true
              },
              "fiscal_responsibilities": {
                "items": {
                  "type": "string",
                  "nullable": true
                },
                "type": "array",
                "nullable": true
              },
              "dv": {
                "type": "string",
                "nullable": true
              },
              "municipality_code": {
                "type": "string",
                "nullable": true
              }
            },
            "additionalProperties": false,
            "type": "object",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "exchange_rate": {
            "type": "number",
            "nullable": true
          },
          "from": {
            "type": "string",
            "nullable": true
          },
          "url": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "number",
            "nullable": true
          },
          "invoices": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "nullable": true
          },
          "items": {
            "items": {
              "properties": {
                "id": {
                  "type": "string",
                  "nullable": true
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "from": {
                  "type": "string",
                  "nullable": true
                },
                "sku": {
                  "type": "string",
                  "nullable": true
                },
                "product_key": {
                  "type": "string",
                  "nullable": true
                },
                "unit_key": {
                  "type": "string",
                  "nullable": true
                },
                "unit_name": {
                  "type": "string",
                  "nullable": true
                },
                "unit_price": {
                  "type": "number",
                  "nullable": true
                },
                "taxes": {
                  "items": {
                    "properties": {
                      "base": {
                        "anyOf": [
                          {
                            "type": "number",
                            "nullable": true
                          },
                          {
                            "type": "string"
                          }
                        ]
                      },
                      "rate": {
                        "anyOf": [
                          {
                            "type": "number",
                            "nullable": true
                          },
                          {
                            "type": "string"
                          }
                        ]
                      },
                      "type": {
                        "type": "string",
                        "nullable": true
                      },
                      "factor": {
                        "type": "string",
                        "nullable": true
                      },
                      "inclusive": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "withholding": {
                        "type": "boolean",
                        "nullable": true
                      }
                    },
                    "additionalProperties": false,
                    "type": "object",
                    "nullable": true
                  },
                  "type": "array",
                  "nullable": true
                },
                "team": {
                  "type": "string",
                  "nullable": true
                },
                "created_at": {
                  "type": "number",
                  "nullable": true
                },
                "quantity": {
                  "type": "number",
                  "nullable": true
                },
                "discount": {
                  "type": "number",
                  "nullable": true
                },
                "third_party": {
                  "properties": {
                    "legal_name": {
                      "type": "string",
                      "nullable": true
                    },
                    "tax_id": {
                      "type": "string",
                      "nullable": true
                    },
                    "tax_system": {
                      "type": "string",
                      "nullable": true
                    },
                    "zip": {
                      "type": "string",
                      "nullable": true
                    }
                  },
                  "additionalProperties": false,
                  "type": "object",
                  "nullable": true
                },
                "item_complement": {
                  "properties": {
                    "hydrocarbons": {
                      "properties": {
                        "permit_type": {
                          "type": "string",
                          "nullable": true
                        },
                        "permit_number": {
                          "type": "string",
                          "nullable": true
                        },
                        "fuel_code": {
                          "type": "string",
                          "nullable": true
                        },
                        "fuel_sub_product": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "additionalProperties": false,
                      "type": "object",
                      "nullable": true
                    }
                  },
                  "additionalProperties": false,
                  "type": "object",
                  "nullable": true
                }
              },
              "additionalProperties": false,
              "type": "object",
              "nullable": true
            },
            "type": "array",
            "nullable": true
          },
          "livemode": {
            "type": "boolean"
          },
          "metadata": {
            "additionalProperties": true,
            "type": "object",
            "nullable": true
          },
          "owner": {
            "type": "string",
            "nullable": true
          },
          "payments": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "nullable": true
          },
          "periodicity": {
            "type": "string",
            "nullable": true
          },
          "short_url": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "team": {
            "type": "string"
          },
          "valid_until": {
            "type": "number",
            "nullable": true
          },
          "invoice_config": {
            "properties": {
              "serie": {
                "type": "string",
                "nullable": true
              },
              "folio": {
                "anyOf": [
                  {
                    "type": "number",
                    "nullable": true
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "date": {
                "type": "number",
                "nullable": true
              },
              "global": {
                "properties": {
                  "periodicity": {
                    "type": "string",
                    "nullable": true
                  },
                  "months": {
                    "type": "string",
                    "nullable": true
                  },
                  "year": {
                    "type": "number",
                    "nullable": true
                  }
                },
                "additionalProperties": false,
                "type": "object",
                "nullable": true
              },
              "validUntil": {
                "type": "number",
                "nullable": true
              }
            },
            "additionalProperties": false,
            "type": "object",
            "nullable": true
          },
          "automatic_invoice_error": {
            "type": "string",
            "nullable": true
          },
          "payment_form": {
            "type": "string",
            "nullable": true
          },
          "files": {
            "properties": {
              "pdf": {
                "type": "string",
                "nullable": true
              },
              "xml": {
                "type": "string",
                "nullable": true
              }
            },
            "additionalProperties": false,
            "required": [
              "pdf",
              "xml"
            ],
            "type": "object"
          },
          "total": {
            "type": "number",
            "nullable": true
          },
          "total_refunded": {
            "type": "number",
            "nullable": true
          },
          "subtotal": {
            "type": "number",
            "nullable": true
          },
          "taxes": {
            "type": "number",
            "nullable": true
          },
          "discount": {
            "type": "number",
            "nullable": true
          },
          "withholding_taxes": {
            "type": "number",
            "nullable": true
          },
          "idempotency_key": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "team",
          "livemode",
          "files"
        ],
        "type": "object"
      },
      "PaymentLinkHistoryResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "data"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "data": {
            "properties": {
              "resource_type": {
                "enum": [
                  "invoices",
                  "receipts"
                ],
                "type": "string"
              },
              "resource_id": {
                "type": "string"
              },
              "team_id": {
                "type": "string"
              },
              "livemode": {
                "type": "boolean"
              },
              "storage_project_id": {
                "pattern": "^[a-z][a-z0-9-]{4,62}$",
                "type": "string"
              },
              "document": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/PaymentLinkHistoryInvoice"
                  },
                  {
                    "$ref": "#/components/schemas/PaymentLinkHistoryReceipt"
                  }
                ],
                "description": "Full mapped public invoice or receipt. All nested related IDs remain hints requiring separate authorization."
              },
              "file_status": {
                "properties": {
                  "pdf": {
                    "enum": [
                      "available",
                      "unavailable"
                    ],
                    "type": "string"
                  },
                  "xml": {
                    "enum": [
                      "available",
                      "unavailable"
                    ],
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "pdf",
                  "xml"
                ],
                "type": "object"
              }
            },
            "additionalProperties": false,
            "required": [
              "resource_type",
              "resource_id",
              "team_id",
              "livemode",
              "storage_project_id",
              "document",
              "file_status"
            ],
            "type": "object"
          }
        }
      },
      "PaymentLinkHistoryFileResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "data"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "data": {
            "properties": {
              "resource_type": {
                "enum": [
                  "invoices",
                  "receipts"
                ],
                "type": "string"
              },
              "resource_id": {
                "type": "string"
              },
              "team_id": {
                "type": "string"
              },
              "livemode": {
                "type": "boolean"
              },
              "storage_project_id": {
                "pattern": "^[a-z][a-z0-9-]{4,62}$",
                "type": "string"
              },
              "available": {
                "type": "boolean"
              },
              "file": {
                "anyOf": [
                  {
                    "properties": {
                      "kind": {
                        "enum": [
                          "pdf",
                          "xml"
                        ],
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "type": {
                        "enum": [
                          "application/pdf",
                          "application/xml"
                        ],
                        "type": "string"
                      },
                      "content": {
                        "type": "string"
                      },
                      "size_bytes": {
                        "minimum": 0,
                        "type": "integer"
                      }
                    },
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "filename",
                      "type",
                      "content",
                      "size_bytes"
                    ],
                    "type": "object"
                  },
                  {
                    "type": "object",
                    "nullable": true,
                    "enum": [
                      null
                    ]
                  }
                ]
              }
            },
            "additionalProperties": false,
            "required": [
              "resource_type",
              "resource_id",
              "team_id",
              "livemode",
              "storage_project_id",
              "available",
              "file"
            ],
            "type": "object"
          }
        }
      },
      "ApiPublicIncomeInvoice": {
        "type": "object",
        "properties": {
          "uuid": {
            "type": "string",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
            "description": "SAT UUID (folio fiscal)"
          },
          "client": {
            "$ref": "#/components/schemas/ApiPublicClient"
          },
          "created_at": {
            "type": "number",
            "example": 1677651234,
            "description": "Invoice creation timestamp"
          },
          "currency": {
            "type": "string",
            "example": "MXN",
            "description": "Invoice currency"
          },
          "exchange_rate": {
            "type": "number",
            "example": 1,
            "description": "Exchange rate used"
          },
          "total": {
            "type": "number",
            "example": 1160,
            "description": "Total invoice amount"
          },
          "subtotal": {
            "type": "number",
            "example": 1000,
            "description": "Subtotal before taxes"
          },
          "taxes": {
            "type": "number",
            "example": 160,
            "description": "Total tax amount"
          },
          "discount": {
            "type": "number",
            "example": 0,
            "description": "Total discount amount"
          },
          "withholding_taxes": {
            "type": "number",
            "example": 0,
            "description": "Total withholding tax amount"
          },
          "series": {
            "type": "string",
            "example": "A",
            "description": "Invoice series"
          },
          "folio_number": {
            "type": "number",
            "example": 123,
            "description": "Invoice folio number"
          },
          "invoice_type": {
            "type": "string",
            "enum": [
              "I",
              "E",
              "P",
              "N"
            ],
            "example": "I",
            "description": "Invoice type (I=Income, E=Egress, P=Payment, N=Nomina). A Colombian debit note is an `I`."
          },
          "document_kind": {
            "type": "string",
            "enum": [
              "debit_note"
            ],
            "example": "debit_note",
            "description": "**Colombia (DIAN) only.** Present, with `debit_note`, only when the document is a DIAN\ndebit note (nota débito). Absent on every other invoice, including Colombian sales invoices.\n"
          },
          "motive": {
            "type": "string",
            "nullable": true,
            "example": "1",
            "description": "**Colombia (DIAN) only.** Present only on debit notes: the DIAN concept as sent in the\nrequest (`1`/`interest` Intereses, `2`/`collection_expenses` Gastos por cobrar,\n`3`/`value_change` Cambio del valor, `4`/`other` Otros).\n"
          },
          "billing_period": {
            "type": "object",
            "nullable": true,
            "description": "**Colombia (DIAN) only.** Present only on debit notes: the billing period sent in the\nrequest (`start_date`, `end_date` and optional `start_time`/`end_time`), or `null`.\n",
            "properties": {
              "start_date": {
                "type": "string",
                "example": "2026-09-01"
              },
              "end_date": {
                "type": "string",
                "example": "2026-09-30"
              },
              "start_time": {
                "type": "string",
                "example": "00:00:00"
              },
              "end_time": {
                "type": "string",
                "example": "23:59:59"
              }
            }
          },
          "use": {
            "type": "string",
            "example": "G03",
            "description": "Mexican SAT usage code"
          },
          "payment_form": {
            "type": "string",
            "example": "03",
            "description": "Mexican SAT payment form code"
          },
          "payment_method": {
            "type": "string",
            "example": "PUE",
            "description": "Payment method (PUE/PPD)"
          },
          "payment_due_date": {
            "type": "string",
            "example": "2026-11-19",
            "description": "Colombia (DIAN) credit invoices only: due date printed on the document. Omitted when not set."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "pending",
              "valid",
              "canceled",
              "cancelled"
            ],
            "example": "valid",
            "description": "Invoice status as stored. A stamped invoice is `valid`; a cancelled one is\n`canceled`. `cancelled` (double L) appears only on older records — new writes\nalways use `canceled`. `draft` is a pre-factura that has not been stamped.\n"
          },
          "livemode": {
            "type": "boolean",
            "example": true,
            "description": "Whether this is a live invoice"
          },
          "owner": {
            "type": "string",
            "example": "user_1234567890",
            "description": "User who created the invoice"
          },
          "from": {
            "type": "string",
            "example": "api",
            "description": "Source of invoice creation. Documents created through the public API are stored with `api`; requests carrying the `X-Gigstack-Client: mcp` header (the gigstack MCP server) are stored with `mcp` and behave identically."
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "item_1234567890"
                },
                "description": {
                  "type": "string",
                  "example": "Professional consulting services"
                },
                "product_key": {
                  "type": "string",
                  "example": "80141503"
                },
                "quantity": {
                  "type": "number",
                  "example": 1
                },
                "unit_price": {
                  "type": "number",
                  "example": 1000
                },
                "unit_key": {
                  "type": "string",
                  "example": "E48"
                },
                "unit_name": {
                  "type": "string",
                  "example": "Servicio"
                },
                "sku": {
                  "type": "string",
                  "example": "CONS-001"
                },
                "taxability": {
                  "type": "string",
                  "enum": [
                    "01",
                    "02"
                  ],
                  "example": "01"
                },
                "taxes": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaxSchema"
                  }
                }
              }
            }
          },
          "payments": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "payment_1234567890"
            ],
            "description": "Associated payment IDs"
          },
          "invoices": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [],
            "description": "Related invoice IDs"
          },
          "stamp": {
            "type": "object",
            "nullable": true,
            "properties": {
              "sello": {
                "type": "string",
                "example": "ABC123..."
              },
              "stamp_at": {
                "type": "number",
                "example": 1677651234
              }
            }
          },
          "cancellation": {
            "type": "object",
            "nullable": true,
            "properties": {
              "cancellation_status": {
                "type": "string",
                "example": "cancelled"
              },
              "cancelled_at": {
                "type": "number",
                "example": 1677651234
              },
              "motive": {
                "type": "string",
                "example": "02"
              },
              "code": {
                "type": "string",
                "example": "201"
              }
            }
          },
          "verification_url": {
            "type": "string",
            "example": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx",
            "description": "SAT verification URL"
          },
          "exports": {
            "type": "string",
            "example": "01",
            "description": "Export indicator"
          },
          "addenda": {
            "type": "string",
            "example": "",
            "description": "Additional XML addenda"
          },
          "invoice_pdf_notes": {
            "type": "string",
            "example": "Additional notes for PDF",
            "description": "Custom notes for PDF generation"
          },
          "files": {
            "type": "object",
            "nullable": true,
            "description": "Base64 encoded files (only returned when return_files=true)",
            "properties": {
              "pdf": {
                "type": "string",
                "example": "JVBERi0xLjQKJeLjz9MKMSAwIG9ia...",
                "description": "Base64 encoded PDF file"
              },
              "xml": {
                "type": "string",
                "example": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4...",
                "description": "Base64 encoded XML file"
              }
            }
          },
          "idempotency_key": {
            "type": "string",
            "nullable": true
          },
          "team": {
            "type": "string",
            "example": "team_1234567890"
          },
          "billing_account": {
            "type": "string",
            "nullable": true
          },
          "date": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Comprobante date, epoch ms."
          },
          "payment_conditions": {
            "type": "string",
            "nullable": true
          },
          "global": {
            "type": "object",
            "nullable": true,
            "description": "Global-invoice period (see the Global Invoices guide).",
            "properties": {
              "periodicity": {
                "type": "string"
              },
              "months": {
                "type": "string"
              },
              "year": {
                "type": "integer"
              }
            }
          },
          "related_documents": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "object",
              "properties": {
                "relationship": {
                  "type": "string"
                },
                "documents": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "complements": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "object"
            }
          },
          "metadata": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "emails": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            }
          },
          "issuer_info": {
            "type": "object",
            "nullable": true,
            "properties": {
              "legal_name": {
                "type": "string"
              },
              "tax_id": {
                "type": "string"
              },
              "tax_system": {
                "type": "string"
              },
              "zip": {
                "type": "string"
              }
            }
          },
          "namespaces": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "object",
              "properties": {
                "prefix": {
                  "type": "string"
                },
                "uri": {
                  "type": "string"
                },
                "schema_location": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ApiPublicTeam": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "team_1234567890"
          },
          "legal_name": {
            "type": "string",
            "nullable": true,
            "example": "Empresa de Tecnología S.A. de C.V.",
            "description": "Official registered legal name of the company/team"
          },
          "address": {
            "type": "object",
            "nullable": true,
            "properties": {
              "country": {
                "type": "string",
                "nullable": true,
                "example": "MEX"
              },
              "street": {
                "type": "string",
                "nullable": true,
                "example": "Av. Insurgentes Sur 456"
              },
              "zip": {
                "type": "string",
                "nullable": true,
                "example": "03100"
              },
              "city": {
                "type": "string",
                "nullable": true,
                "example": "Ciudad de México"
              },
              "state": {
                "type": "string",
                "nullable": true,
                "example": "CDMX"
              },
              "exterior": {
                "type": "string",
                "nullable": true,
                "example": "96"
              },
              "interior": {
                "type": "string",
                "nullable": true,
                "example": "10"
              },
              "neighborhood": {
                "type": "string",
                "nullable": true,
                "example": "Polanco"
              }
            }
          },
          "brand": {
            "type": "object",
            "properties": {
              "alias": {
                "type": "string",
                "nullable": true,
                "example": "Mi Empresa"
              },
              "primary_color": {
                "type": "string",
                "nullable": true,
                "example": "#007bff"
              },
              "secondary_color": {
                "type": "string",
                "nullable": true,
                "example": "#6c757d"
              },
              "logo": {
                "type": "string",
                "nullable": true,
                "example": "https://example.com/logo.png"
              }
            }
          },
          "settings": {
            "type": "object",
            "nullable": true,
            "properties": {
              "avoid_legal_name_replacer": {
                "type": "boolean",
                "nullable": true
              },
              "enforce_client_country_taxes": {
                "type": "boolean",
                "nullable": true
              },
              "global_invoice_disabled": {
                "type": "boolean",
                "nullable": true,
                "example": false
              },
              "automate_complement_for_ppd_invoices": {
                "type": "boolean",
                "nullable": true,
                "example": true
              },
              "automate_partial_payment_complements": {
                "type": "boolean",
                "nullable": true
              },
              "use_foreign_public_in_usd": {
                "type": "boolean",
                "nullable": true
              },
              "avoid_receipts": {
                "type": "boolean",
                "nullable": true
              },
              "cancel_receipts_on_refunds": {
                "type": "boolean",
                "nullable": true
              },
              "invoice_per_receipt": {
                "type": "boolean",
                "nullable": true
              },
              "allow_notes_on_self_invoice": {
                "type": "boolean",
                "nullable": true
              },
              "allow_product_code_on_self_invoice": {
                "type": "boolean",
                "nullable": true
              },
              "send_invoice_english_pdf": {
                "type": "boolean",
                "nullable": true
              },
              "default_description": {
                "type": "string",
                "nullable": true,
                "example": "Default invoice description"
              },
              "override_item_description": {
                "type": "string",
                "nullable": true,
                "example": "Custom item description"
              },
              "invoice_pdf_notes": {
                "type": "string",
                "nullable": true,
                "example": "Additional notes for PDF"
              },
              "product_key": {
                "type": "string",
                "nullable": true,
                "example": "81112209"
              },
              "unit_key": {
                "type": "string",
                "nullable": true,
                "example": "E48"
              },
              "unit_name": {
                "type": "string",
                "nullable": true
              },
              "use": {
                "type": "string",
                "nullable": true,
                "example": "G03"
              },
              "sku": {
                "type": "string",
                "nullable": true
              },
              "addenda": {
                "type": "string",
                "nullable": true
              },
              "order_reference": {
                "type": "string",
                "nullable": true
              },
              "custom_payment_description": {
                "type": "string",
                "nullable": true
              },
              "customer_portal_id": {
                "type": "string",
                "nullable": true,
                "example": "portal_1234567890"
              },
              "force_series": {
                "type": "string",
                "nullable": true
              },
              "avoid_automations_on_currencies": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "string"
                },
                "example": [
                  "USD",
                  "EUR"
                ]
              },
              "uses_on_self_invoice_portal": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "string"
                },
                "example": [
                  "G03",
                  "S01"
                ]
              },
              "concepts_catalog": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "nullable": true
              },
              "taxes": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "object"
                }
              },
              "taxes_usd": {
                "oneOf": [
                  {
                    "type": "array",
                    "nullable": true,
                    "items": {
                      "type": "object"
                    }
                  },
                  {
                    "type": "boolean",
                    "nullable": true
                  }
                ]
              },
              "withholding_taxes": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "object"
                }
              },
              "local_taxes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {}
                },
                "nullable": true
              },
              "complements": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "string",
                      "nullable": true
                    },
                    "description": {
                      "type": "string",
                      "nullable": true
                    },
                    "type": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              },
              "allowed_product_codes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "key",
                    "description"
                  ],
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                },
                "nullable": true
              },
              "allowed_uses_by_product_key": {
                "description": "Self-invoice portal limit on the uso CFDI per SAT product key. A receipt allows only the uses common to every item whose product key has a rule.",
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "key",
                    "uses"
                  ],
                  "properties": {
                    "key": {
                      "type": "string",
                      "example": "01010101"
                    },
                    "description": {
                      "type": "string",
                      "nullable": true
                    },
                    "uses": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "example": [
                        "G03",
                        "D07"
                      ]
                    }
                  }
                },
                "nullable": true
              },
              "periodicity": {
                "type": "object",
                "nullable": true,
                "properties": {
                  "label": {
                    "type": "string",
                    "example": "Mes"
                  },
                  "value": {
                    "type": "string",
                    "example": "month"
                  }
                }
              },
              "pdf_language": {
                "type": "string",
                "enum": [
                  "en",
                  "es",
                  null
                ],
                "nullable": true
              },
              "global_invoicing_monthly_cuts": {
                "type": "number",
                "enum": [
                  2,
                  3,
                  4,
                  5,
                  null
                ],
                "nullable": true
              },
              "eom_ppd_threshold_days": {
                "type": "integer",
                "nullable": true,
                "minimum": 0,
                "maximum": 31
              },
              "limit_days_to_pay": {
                "type": "integer",
                "nullable": true,
                "minimum": 0
              },
              "payment_reminders": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "days": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 0
                  },
                  "enabled": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "before_body": {
                    "type": "string",
                    "nullable": true
                  },
                  "before_subject": {
                    "type": "string",
                    "nullable": true
                  },
                  "after_body": {
                    "type": "string",
                    "nullable": true
                  },
                  "after_subject": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "reinvoice": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "window_days": {
                    "type": "integer",
                    "nullable": true,
                    "minimum": 0
                  },
                  "handler": {
                    "type": "string",
                    "enum": [
                      "credit_note",
                      "cancel_resources",
                      null
                    ],
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "refunds": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "automatic_refunds": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "current_month_handler": {
                    "type": "string",
                    "enum": [
                      "credit_note",
                      "cancel_resources",
                      null
                    ],
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "emails": {
                "type": "object",
                "properties": {
                  "invoices_bcc": {
                    "type": "array",
                    "nullable": true,
                    "items": {
                      "type": "string"
                    },
                    "example": [
                      "accounting@example.com"
                    ]
                  },
                  "avoid_invoice_emails": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "avoid_test_invoice_emails": {
                    "type": "boolean",
                    "nullable": true,
                    "example": true
                  },
                  "avoid_receipts_emails": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "payments_bcc": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "email"
                    },
                    "nullable": true
                  },
                  "receipts_bcc": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "email"
                    },
                    "nullable": true
                  },
                  "avoid_foreign_receipts_emails": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "invoice_body": {
                    "type": "string",
                    "nullable": true
                  },
                  "invoice_subject": {
                    "type": "string",
                    "nullable": true
                  },
                  "complement_body": {
                    "type": "string",
                    "nullable": true
                  },
                  "complement_subject": {
                    "type": "string",
                    "nullable": true
                  },
                  "credit_note_body": {
                    "type": "string",
                    "nullable": true
                  },
                  "credit_note_subject": {
                    "type": "string",
                    "nullable": true
                  },
                  "payment_body": {
                    "type": "string",
                    "nullable": true
                  },
                  "payment_subject": {
                    "type": "string",
                    "nullable": true
                  },
                  "receipt_body": {
                    "type": "string",
                    "nullable": true
                  },
                  "receipt_subject": {
                    "type": "string",
                    "nullable": true
                  },
                  "receipt_reminder_body": {
                    "type": "string",
                    "nullable": true
                  },
                  "receipt_reminder_subject": {
                    "type": "string",
                    "nullable": true
                  }
                }
              },
              "email_templates": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "invoices": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "es": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      },
                      "en": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "complements": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "es": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      },
                      "en": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "credit_notes": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "es": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      },
                      "en": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "payments": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "es": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      },
                      "en": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "receipts": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "es": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      },
                      "en": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "receipt_reminders": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "es": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      },
                      "en": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "body": {
                            "type": "string",
                            "nullable": true
                          },
                          "subject": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "nullable": true
                      }
                    },
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "default_series": {
                "type": "object",
                "properties": {
                  "income": {
                    "type": "object",
                    "properties": {
                      "serie": {
                        "type": "string",
                        "nullable": true,
                        "example": "A"
                      }
                    }
                  },
                  "complements": {
                    "type": "object",
                    "properties": {
                      "serie": {
                        "type": "string",
                        "nullable": true,
                        "example": "P"
                      }
                    }
                  },
                  "credit_note": {
                    "type": "object",
                    "properties": {
                      "serie": {
                        "type": "string",
                        "nullable": true,
                        "example": "NC"
                      }
                    }
                  }
                }
              }
            }
          },
          "tax_id": {
            "type": "string",
            "nullable": true,
            "example": "EMP800101ABC"
          },
          "tax_system": {
            "type": "string",
            "nullable": true,
            "example": "601"
          },
          "support_email": {
            "type": "string",
            "nullable": true,
            "example": "support@empresa.com"
          },
          "support_phone": {
            "type": "string",
            "nullable": true,
            "example": "+52 55 1234 5678"
          },
          "owner": {
            "type": "string",
            "nullable": true,
            "example": "user_1234567890"
          },
          "created_at": {
            "type": "number",
            "nullable": true,
            "example": 1677651234
          },
          "sat": {
            "type": "object",
            "properties": {
              "completed": {
                "type": "boolean",
                "nullable": true,
                "example": true
              },
              "connected_at": {
                "type": "number",
                "nullable": true,
                "example": 1677651234
              },
              "csd_expires_at": {
                "type": "number",
                "nullable": true,
                "example": 1924991999
              }
            }
          },
          "members": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "nullable": true,
                  "example": "user_1234567890"
                },
                "email": {
                  "type": "string",
                  "nullable": true,
                  "example": "member@empresa.com"
                },
                "role": {
                  "type": "string",
                  "nullable": true,
                  "example": "admin"
                },
                "is_owner": {
                  "type": "boolean"
                },
                "permissions": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "invoices": {
                      "type": "string",
                      "enum": [
                        "editor",
                        "viewer",
                        "none"
                      ]
                    },
                    "receipts": {
                      "type": "string",
                      "enum": [
                        "editor",
                        "viewer",
                        "none"
                      ]
                    },
                    "payments": {
                      "type": "string",
                      "enum": [
                        "editor",
                        "viewer",
                        "none"
                      ]
                    },
                    "services": {
                      "type": "string",
                      "enum": [
                        "editor",
                        "viewer",
                        "none"
                      ]
                    },
                    "expenses": {
                      "type": "string",
                      "enum": [
                        "editor",
                        "viewer",
                        "none"
                      ]
                    }
                  }
                }
              }
            }
          },
          "integrations": {
            "type": "object",
            "properties": {
              "stripe": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "mercadopago": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "clip": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "whmcs": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "paypal": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "openpay": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "conekta": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "bank": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "shopify": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "zapier": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "airtable": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "google_sheets": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "payments"
                  }
                }
              },
              "hilos": {
                "type": "object",
                "properties": {
                  "completed": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false
                  },
                  "category": {
                    "type": "string",
                    "nullable": true,
                    "example": "messaging"
                  }
                }
              }
            }
          },
          "credit_limit": {
            "type": "number",
            "nullable": true,
            "example": 1000,
            "description": "Maximum number of documents (credits) the team can create per billing period. Null means no per-team limit (shared billing account pool)."
          },
          "used_credits": {
            "type": "number",
            "example": 250,
            "description": "Number of credits used by this team in the current billing period."
          },
          "credit_period_start": {
            "type": "number",
            "nullable": true,
            "example": 1677651234000,
            "description": "Unix timestamp (milliseconds) when the current credit period started. Resets each billing cycle."
          },
          "metadata": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true,
            "example": {
              "custom_field": "value"
            }
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "`pending_deletion` after `DELETE /teams/{id}`; otherwise usually absent or `active`.",
            "example": "active"
          },
          "scheduled_deletion": {
            "type": "object",
            "nullable": true,
            "description": "Set when the team is scheduled for deletion.",
            "properties": {
              "date": {
                "description": "When the team will be deleted."
              },
              "flagged_at": {
                "type": "integer",
                "format": "int64"
              },
              "flagged_by": {
                "type": "string"
              }
            }
          },
          "deactivated": {
            "type": "boolean",
            "description": "Pricing v3: the business is dado de baja (`POST /teams/{id}/deactivate`). It keeps its history, issues nothing new and does not pay its RFC fee.",
            "example": false
          },
          "deactivated_at": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "When the business was deactivated (ms), or null.",
            "example": null
          }
        }
      },
      "ApiPublicUser": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "user_1234567890"
          },
          "email": {
            "type": "string",
            "example": "user@example.com"
          },
          "first_name": {
            "type": "string",
            "nullable": true,
            "example": "Juan"
          },
          "last_name": {
            "type": "string",
            "nullable": true,
            "example": "Pérez"
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "example": "+52 55 1234 5678"
          },
          "teams": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "team_1234567890"
            ]
          },
          "created_at": {
            "type": "number",
            "example": 1677651234
          },
          "company_role": {
            "type": "string",
            "nullable": true,
            "example": "CEO"
          },
          "address": {
            "type": "object",
            "nullable": true,
            "properties": {
              "city": {
                "type": "string",
                "nullable": true,
                "example": "Ciudad de México"
              },
              "country": {
                "type": "string",
                "nullable": true,
                "example": "MEX"
              },
              "state": {
                "type": "string",
                "nullable": true,
                "example": "CDMX"
              }
            }
          }
        }
      },
      "ApiPublicWebhook": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "url",
          "events",
          "status",
          "owner",
          "created_at",
          "version",
          "type",
          "revision",
          "effect_scope",
          "security",
          "signing"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive"
            ]
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "owner": {
            "type": "string"
          },
          "created_at": {
            "type": "number"
          },
          "version": {
            "type": "string",
            "nullable": true,
            "enum": [
              "v1",
              "v2",
              null
            ]
          },
          "type": {
            "type": "string",
            "nullable": true,
            "enum": [
              "gigstack_connect",
              null
            ]
          },
          "revision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "shared_team_webhooks"
            ]
          },
          "security": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "header_names",
              "configured",
              "status"
            ],
            "properties": {
              "header_names": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "configured": {
                "type": "boolean"
              },
              "status": {
                "type": "string",
                "enum": [
                  "not_configured",
                  "configured",
                  "pending",
                  "failed"
                ]
              }
            }
          },
          "signing": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "enabled",
              "configured",
              "status"
            ],
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "configured": {
                "type": "boolean"
              },
              "status": {
                "type": "string",
                "enum": [
                  "disabled",
                  "configured",
                  "pending",
                  "failed"
                ]
              }
            }
          }
        }
      },
      "WebhookInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "url",
          "events"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid"
          },
          "expected_revision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 1000
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive"
            ]
          },
          "version": {
            "type": "string",
            "enum": [
              "v1",
              "v2"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "gigstack_connect",
              null
            ],
            "nullable": true
          },
          "security": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "headers"
            ],
            "properties": {
              "headers": {
                "type": "object",
                "additionalProperties": true,
                "properties": {}
              }
            }
          },
          "signing": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "enabled"
            ],
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "rotate": {
                "type": "boolean"
              }
            }
          },
          "url": {
            "type": "string",
            "maxLength": 4096,
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "payment.created",
                "payment.updated",
                "payment.succeeded",
                "payment.canceled",
                "payment.deleted",
                "payment.upcoming_due_date",
                "invoice.created",
                "invoice.canceled",
                "invoice.failed",
                "invoice_batch.completed",
                "payment_batch.completed",
                "receipt.created",
                "receipt.updated",
                "receipt.completed",
                "receipt.deleted",
                "customer.created",
                "customer.updated",
                "customer.deleted",
                "service.created",
                "service.updated",
                "service.deleted",
                "sat.invoice.synced",
                "teams.created",
                "teams.sat.completed",
                "teams.stripe.completed",
                "teams.openpay.completed",
                "teams.sat.manifest.signed"
              ]
            },
            "maxItems": 27
          }
        }
      },
      "WebhookUpdateInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid"
          },
          "expected_revision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 1000
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive"
            ]
          },
          "version": {
            "type": "string",
            "enum": [
              "v1",
              "v2"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "gigstack_connect",
              null
            ],
            "nullable": true
          },
          "security": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "headers"
            ],
            "properties": {
              "headers": {
                "type": "object",
                "additionalProperties": true,
                "properties": {}
              }
            }
          },
          "signing": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "enabled"
            ],
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "rotate": {
                "type": "boolean"
              }
            }
          },
          "url": {
            "type": "string",
            "maxLength": 4096,
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "payment.created",
                "payment.updated",
                "payment.succeeded",
                "payment.canceled",
                "payment.deleted",
                "payment.upcoming_due_date",
                "invoice.created",
                "invoice.canceled",
                "invoice.failed",
                "invoice_batch.completed",
                "payment_batch.completed",
                "receipt.created",
                "receipt.updated",
                "receipt.completed",
                "receipt.deleted",
                "customer.created",
                "customer.updated",
                "customer.deleted",
                "service.created",
                "service.updated",
                "service.deleted",
                "sat.invoice.synced",
                "teams.created",
                "teams.sat.completed",
                "teams.stripe.completed",
                "teams.openpay.completed",
                "teams.sat.manifest.signed"
              ]
            },
            "maxItems": 27
          }
        }
      },
      "TeamInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`) — body\nvalidation runs in strict allowlist mode. `team`, `livemode` and `owner` are reserved\nand injected by the auth middleware.\n",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "address": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "country"
            ],
            "properties": {
              "country": {
                "example": "MEX",
                "type": "string"
              },
              "street": {
                "example": "Av. Insurgentes Sur",
                "type": "string",
                "nullable": true
              },
              "zip": {
                "example": "03100",
                "type": "string",
                "nullable": true
              },
              "city": {
                "example": "Ciudad de México",
                "type": "string",
                "nullable": true
              },
              "state": {
                "example": "CDMX",
                "type": "string",
                "nullable": true
              },
              "exterior": {
                "example": "123",
                "type": "string",
                "nullable": true
              },
              "interior": {
                "example": "4B",
                "type": "string",
                "nullable": true
              },
              "municipality": {
                "example": "Benito Juárez",
                "type": "string",
                "nullable": true
              },
              "neighborhood": {
                "example": "Del Valle",
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "brand": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "alias"
            ],
            "properties": {
              "alias": {
                "example": "My Company",
                "type": "string"
              },
              "primary_color": {
                "example": "#FF0000",
                "type": "string",
                "nullable": true
              },
              "secondary_color": {
                "example": "#00FF00",
                "type": "string",
                "nullable": true
              },
              "logo": {
                "example": "https://example.com/logo.png",
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "support_email": {
            "example": "support@company.com",
            "type": "string",
            "nullable": true
          },
          "support_phone": {
            "example": "+52 55 1234 5678",
            "type": "string",
            "nullable": true
          },
          "legal_name": {
            "description": "Legal name of the team/company",
            "example": "Empresa de Tecnología S.A. de C.V.",
            "type": "string",
            "nullable": true
          },
          "tax_id": {
            "example": "ABC123456789",
            "type": "string",
            "nullable": true
          },
          "tax_system": {
            "example": "601",
            "type": "string",
            "nullable": true
          },
          "generate_onboarding_url": {
            "description": "Generate onboarding URL for team setup",
            "example": true,
            "type": "boolean",
            "nullable": true
          },
          "metadata": {
            "description": "Additional metadata to store with the team",
            "type": "object",
            "additionalProperties": true,
            "properties": {},
            "nullable": true
          },
          "add_members": {
            "description": "Array of members to add to the team on creation",
            "example": [
              {
                "id": "user123abc",
                "role": "editor"
              },
              {
                "id": "user456def",
                "role": "admin"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id"
              ],
              "properties": {
                "id": {
                  "description": "User ID to add as a team member",
                  "example": "user123abc",
                  "type": "string"
                },
                "role": {
                  "description": "Role for the team member. Defaults to \"viewer\" if not specified.",
                  "example": "editor",
                  "default": "viewer",
                  "type": "string",
                  "nullable": true
                }
              }
            },
            "nullable": true
          },
          "add_master_team_members": {
            "description": "When true, copies all members from the master team to the newly created team with their existing permissions",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "credit_limit": {
            "description": "Maximum number of documents (credits) the team can create per billing period. When null or omitted, the team shares the billing account pool with no per-team cap. On update it is applied only when the request is made with an API key of another team of the same billing account (the managing team); a team cannot change its own limit, and the field is ignored in that case.",
            "example": 1000,
            "type": "number",
            "nullable": true
          }
        }
      },
      "TeamUpdateInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "address": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "country": {
                "type": "string",
                "nullable": true
              },
              "street": {
                "type": "string",
                "nullable": true
              },
              "zip": {
                "type": "string",
                "nullable": true
              },
              "city": {
                "type": "string",
                "nullable": true
              },
              "state": {
                "type": "string",
                "nullable": true
              },
              "exterior": {
                "type": "string",
                "nullable": true
              },
              "interior": {
                "type": "string",
                "nullable": true
              },
              "municipality": {
                "type": "string",
                "nullable": true
              },
              "neighborhood": {
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "brand": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "alias": {
                "type": "string",
                "nullable": true
              },
              "primary_color": {
                "type": "string",
                "nullable": true
              },
              "secondary_color": {
                "type": "string",
                "nullable": true
              },
              "logo": {
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "support_email": {
            "type": "string",
            "nullable": true
          },
          "support_phone": {
            "type": "string",
            "nullable": true
          },
          "legal_name": {
            "type": "string",
            "nullable": true
          },
          "tax_id": {
            "type": "string",
            "nullable": true
          },
          "tax_system": {
            "type": "string",
            "nullable": true
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "properties": {},
            "nullable": true
          },
          "credit_limit": {
            "type": "number",
            "nullable": true
          }
        }
      },
      "TeamSettingsInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`) — body\nvalidation runs in strict allowlist mode. `team`, `livemode` and `owner` are reserved\nand injected by the auth middleware.\n",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "avoid_legal_name_replacer": {
            "type": "boolean",
            "nullable": true
          },
          "enforce_client_country_taxes": {
            "type": "boolean",
            "nullable": true
          },
          "global_invoice_disabled": {
            "description": "Disable global invoice functionality",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "automate_complement_for_ppd_invoices": {
            "description": "Automatically create payment complement for PPD invoices",
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "automate_partial_payment_complements": {
            "type": "boolean",
            "nullable": true
          },
          "use_foreign_public_in_usd": {
            "type": "boolean",
            "nullable": true
          },
          "avoid_receipts": {
            "type": "boolean",
            "nullable": true
          },
          "cancel_receipts_on_refunds": {
            "type": "boolean",
            "nullable": true
          },
          "invoice_per_receipt": {
            "type": "boolean",
            "nullable": true
          },
          "allow_notes_on_self_invoice": {
            "type": "boolean",
            "nullable": true
          },
          "allow_product_code_on_self_invoice": {
            "type": "boolean",
            "nullable": true
          },
          "send_invoice_english_pdf": {
            "type": "boolean",
            "nullable": true
          },
          "default_description": {
            "description": "Default description for items",
            "example": "Consulting services",
            "type": "string",
            "nullable": true
          },
          "override_item_description": {
            "description": "Override description for all items",
            "example": "Professional services",
            "type": "string",
            "nullable": true
          },
          "invoice_pdf_notes": {
            "description": "Default notes to include in invoice PDFs",
            "example": "Additional notes for PDF invoices",
            "type": "string",
            "nullable": true
          },
          "product_key": {
            "description": "Default SAT product key",
            "example": "80141503",
            "type": "string",
            "nullable": true
          },
          "unit_key": {
            "description": "Default SAT unit key",
            "example": "E48",
            "type": "string",
            "nullable": true
          },
          "unit_name": {
            "type": "string",
            "nullable": true
          },
          "use": {
            "description": "Default CFDI use",
            "example": "G03",
            "type": "string",
            "nullable": true
          },
          "sku": {
            "type": "string",
            "nullable": true
          },
          "addenda": {
            "type": "string",
            "nullable": true,
            "description": "XML addenda added to every income invoice. May include placeholders filled from each invoice at stamping: {metadata.<key>} or {client.<field>}. Values are XML-escaped. A missing value fails the stamp; with a trailing ? ({metadata.orderId?}) the invoice is stamped without addenda instead. A malformed placeholder or another root is rejected with 400. Placeholders need gigstack stamping (Prodigia); Facturapi-only teams cannot use them.",
            "example": "<OrdenCompra>{metadata.orderId}</OrdenCompra>"
          },
          "order_reference": {
            "type": "string",
            "nullable": true,
            "description": "Colombia (DIAN) only. Template of the customer purchase order sent on every sales invoice as its order reference (cac:OrderReference/cbc:ID). Same placeholders as `addenda`: {metadata.<key>} or {client.<field>}, with a trailing ? for optional ({metadata.orderId?} sends nothing when the invoice has no value). Values are not XML-escaped. Never sent on credit notes, debit notes or global invoices. A malformed placeholder, or one without a field ({client}), is rejected with 400. On the invoice request, a missing required metadata value or a value that is not text or a number is a 400 before any credit is used; {client.*} values are checked when stamping, after the credit.",
            "example": "{metadata.orderId?}"
          },
          "custom_payment_description": {
            "type": "string",
            "nullable": true
          },
          "customer_portal_id": {
            "type": "string",
            "nullable": true,
            "description": "Canonical customer portal slug (top-level customerPortalId). Registers a first slug or repeats the current one; renames use PUT /teams/{id}/customer-portal. Null never unregisters."
          },
          "force_series": {
            "type": "string",
            "nullable": true
          },
          "avoid_automations_on_currencies": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "uses_on_self_invoice_portal": {
            "description": "Available CFDI uses on self-invoice portal",
            "example": [
              "G03",
              "S01"
            ],
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "concepts_catalog": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "taxes": {
            "description": "Default taxes configuration for MXN invoices. Each object follows the TeamTaxDefault schema (type, rate, factor, inclusive, withholding).",
            "example": [
              {
                "type": "IVA",
                "rate": 0.16,
                "factor": "Tasa",
                "inclusive": false,
                "withholding": false
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {}
            },
            "nullable": true
          },
          "taxes_usd": {
            "description": "Default taxes configuration for USD invoices. Each object follows the TeamTaxDefault schema (type, rate, factor, inclusive, withholding).",
            "example": [
              {
                "type": "IVA",
                "rate": 0.16,
                "factor": "Tasa",
                "inclusive": false,
                "withholding": false
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {}
            },
            "nullable": true
          },
          "withholding_taxes": {
            "description": "Withholding taxes configuration (natural persons). Each object follows the TeamTaxDefault schema (type, rate, factor, inclusive, withholding).",
            "example": [
              {
                "type": "ISR",
                "rate": 0.1,
                "factor": "Tasa",
                "withholding": true
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {}
            },
            "nullable": true
          },
          "local_taxes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {}
            },
            "nullable": true
          },
          "complements": {
            "description": "CFDI complements configuration",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "data": {
                  "type": "string",
                  "nullable": true
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "type": {
                  "type": "string",
                  "nullable": true
                }
              }
            },
            "nullable": true
          },
          "allowed_product_codes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "key",
                "description"
              ],
              "properties": {
                "key": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                }
              }
            },
            "nullable": true
          },
          "allowed_uses_by_product_key": {
            "description": "Self-invoice portal limit on the uso CFDI per SAT product key. A receipt allows only the uses common to every item whose product key has a rule.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "key",
                "uses"
              ],
              "properties": {
                "key": {
                  "type": "string",
                  "example": "01010101"
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "uses": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "example": [
                    "G03",
                    "D07"
                  ]
                }
              }
            },
            "nullable": true
          },
          "periodicity": {
            "description": "Default billing/invoicing period for the team",
            "example": "month",
            "type": "string",
            "enum": [
              "day",
              "week",
              "two_weeks",
              "month",
              "two_months",
              null
            ],
            "nullable": true
          },
          "pdf_language": {
            "type": "string",
            "enum": [
              "en",
              "es",
              null
            ],
            "nullable": true
          },
          "global_invoicing_monthly_cuts": {
            "type": "number",
            "enum": [
              2,
              3,
              4,
              5,
              null
            ],
            "nullable": true
          },
          "eom_ppd_threshold_days": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "maximum": 31
          },
          "limit_days_to_pay": {
            "type": "integer",
            "nullable": true,
            "minimum": 0
          },
          "payment_reminders": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "days": {
                "type": "integer",
                "nullable": true,
                "minimum": 0
              },
              "enabled": {
                "type": "boolean",
                "nullable": true
              },
              "before_body": {
                "type": "string",
                "nullable": true
              },
              "before_subject": {
                "type": "string",
                "nullable": true
              },
              "after_body": {
                "type": "string",
                "nullable": true
              },
              "after_subject": {
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "reinvoice": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "window_days": {
                "type": "integer",
                "nullable": true,
                "minimum": 0
              },
              "handler": {
                "type": "string",
                "enum": [
                  "credit_note",
                  "cancel_resources",
                  null
                ],
                "nullable": true
              }
            },
            "nullable": true
          },
          "refunds": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "automatic_refunds": {
                "type": "boolean",
                "nullable": true
              },
              "current_month_handler": {
                "type": "string",
                "enum": [
                  "credit_note",
                  "cancel_resources",
                  null
                ],
                "nullable": true
              }
            },
            "nullable": true
          },
          "emails": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "invoices_bcc": {
                "description": "BCC emails for invoices",
                "example": [
                  "admin@company.com"
                ],
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "nullable": true
              },
              "payments_bcc": {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "nullable": true
              },
              "receipts_bcc": {
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "email"
                },
                "nullable": true
              },
              "avoid_invoice_emails": {
                "description": "Disable invoice emails",
                "example": false,
                "type": "boolean",
                "nullable": true
              },
              "avoid_test_invoice_emails": {
                "description": "Disable test invoice emails",
                "example": true,
                "type": "boolean",
                "nullable": true
              },
              "avoid_receipts_emails": {
                "description": "Disable receipt emails",
                "example": false,
                "type": "boolean",
                "nullable": true
              },
              "avoid_foreign_receipts_emails": {
                "type": "boolean",
                "nullable": true
              },
              "invoice_body": {
                "type": "string",
                "nullable": true
              },
              "invoice_subject": {
                "type": "string",
                "nullable": true
              },
              "complement_body": {
                "type": "string",
                "nullable": true
              },
              "complement_subject": {
                "type": "string",
                "nullable": true
              },
              "credit_note_body": {
                "type": "string",
                "nullable": true
              },
              "credit_note_subject": {
                "type": "string",
                "nullable": true
              },
              "payment_body": {
                "type": "string",
                "nullable": true
              },
              "payment_subject": {
                "type": "string",
                "nullable": true
              },
              "receipt_body": {
                "type": "string",
                "nullable": true
              },
              "receipt_subject": {
                "type": "string",
                "nullable": true
              },
              "receipt_reminder_body": {
                "type": "string",
                "nullable": true
              },
              "receipt_reminder_subject": {
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "email_templates": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "invoices": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "es": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "en": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "complements": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "es": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "en": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "credit_notes": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "es": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "en": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "payments": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "es": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "en": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "receipts": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "es": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "en": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "receipt_reminders": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "es": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  },
                  "en": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "body": {
                        "type": "string",
                        "nullable": true
                      },
                      "subject": {
                        "type": "string",
                        "nullable": true
                      }
                    },
                    "nullable": true
                  }
                },
                "nullable": true
              }
            },
            "nullable": true
          },
          "default_series": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "income": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "serie": {
                    "description": "Default income series",
                    "example": "A",
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "complements": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "serie": {
                    "description": "Default complements series",
                    "example": "C",
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "credit_note": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "serie": {
                    "description": "Default credit note series",
                    "example": "N",
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              }
            },
            "nullable": true
          }
        }
      },
      "UserInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`) — body\nvalidation runs in strict allowlist mode. `team`, `livemode` and `owner` are reserved\nand injected by the auth middleware.\n",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "email": {
            "description": "Required by account creation. On user updates this reserved field is ignored; this endpoint does not change the authentication email.",
            "type": "string",
            "nullable": true
          },
          "first_name": {
            "example": "John",
            "type": "string",
            "nullable": true
          },
          "last_name": {
            "example": "Doe",
            "type": "string",
            "nullable": true
          },
          "phone": {
            "example": "+52 55 1234 5678",
            "type": "string",
            "nullable": true
          },
          "company_role": {
            "example": "Manager",
            "type": "string",
            "nullable": true
          },
          "address": {
            "description": "User address information. Note: municipality field is accepted in requests but not returned in responses.",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "country": {
                "example": "MEX",
                "type": "string",
                "nullable": true
              },
              "street": {
                "example": "Av. Insurgentes Sur",
                "type": "string",
                "nullable": true
              },
              "zip": {
                "example": "03100",
                "type": "string",
                "nullable": true
              },
              "city": {
                "example": "Ciudad de México",
                "type": "string",
                "nullable": true
              },
              "state": {
                "example": "CDMX",
                "type": "string",
                "nullable": true
              },
              "exterior": {
                "example": "123",
                "type": "string",
                "nullable": true
              },
              "municipality": {
                "description": "Municipality name (accepted in requests, stored in database, but not returned in responses)",
                "example": "Benito Juárez",
                "type": "string",
                "nullable": true
              },
              "neighborhood": {
                "example": "Del Valle",
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "auto_join": {
            "description": "If true, automatically adds the user to the team associated with the API key. Defaults to false if not specified. When true and role is specified, the user will be added with that role.",
            "example": true,
            "type": "boolean"
          },
          "role": {
            "description": "Role to assign to the user when auto_join is true. Can be \"editor\", \"admin\", or \"viewer\". Defaults to \"viewer\" if not specified. This parameter works in conjunction with auto_join - when auto_join is true, the user will be added to the team with the specified role.",
            "example": "viewer",
            "type": "string",
            "enum": [
              "admin",
              "editor",
              "viewer"
            ]
          }
        }
      },
      "ReceiptInput": {
        "description": "Unknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`);\n`metadata` is the one object that accepts arbitrary keys. `team`, `livemode` and\n`owner` are reserved and injected by the auth middleware.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "client",
          "currency",
          "items"
        ],
        "properties": {
          "client": {
            "$ref": "#/components/schemas/EmbeddedClientInput"
          },
          "currency": {
            "description": "Currency code (ISO 4217)",
            "example": "MXN",
            "type": "string"
          },
          "exchange_rate": {
            "description": "Exchange rate to use for currency conversion",
            "example": 1,
            "type": "number",
            "nullable": true
          },
          "items": {
            "description": "Receipt items",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItemSchema"
            }
          },
          "metadata": {
            "description": "Additional metadata - accepts any custom properties for tracking business data, references, or integration identifiers. All properties are preserved and returned as-is.",
            "type": "object",
            "additionalProperties": true,
            "properties": {},
            "nullable": true
          },
          "periodicity": {
            "description": "Receipt validity period. `two_month` and `two_months` are both accepted and\nmean the same period (end of the following month).\n",
            "example": "month",
            "type": "string",
            "enum": [
              "day",
              "week",
              "two_weeks",
              "month",
              "two_month",
              "two_months",
              null
            ],
            "nullable": true
          },
          "invoice_config": {
            "description": "Invoice configuration for future stamping. Accepted and validated on this\nendpoint, but note the create-receipt handler does **not** currently persist it\nonto the receipt — it is validated and discarded.\n",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "folio": {
                "type": "number",
                "nullable": true
              },
              "serie": {
                "type": "string",
                "nullable": true
              },
              "date": {
                "type": "number",
                "nullable": true
              },
              "global": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "year": {
                    "description": "Fiscal year, four digits, from 2021 to 2100. A number or a numeric string such as \"2026\"; stored as a number.",
                    "oneOf": [
                      {
                        "type": "number",
                        "nullable": true
                      },
                      {
                        "type": "string",
                        "description": "Numeric string accepted by the request validator."
                      }
                    ],
                    "minimum": 2021,
                    "maximum": 2100
                  },
                  "months": {
                    "type": "string",
                    "nullable": true
                  },
                  "periodicity": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "nullable": true
              },
              "validUntil": {
                "type": "number",
                "nullable": true
              }
            }
          },
          "payment_form": {
            "description": "SAT payment form code",
            "example": "01",
            "type": "string",
            "nullable": true
          },
          "idempotency_key": {
            "description": "Stable key for one business event. A duplicate returns HTTP 400 with error.code resource_conflict, not the existing receipt as a successful response. Reconcile the existing record and retain this key across retries.",
            "example": "receipt-key-12345",
            "type": "string",
            "nullable": true
          },
          "send_email": {
            "description": "Whether to send email and WhatsApp notifications for this receipt. Defaults to `true`.",
            "example": true,
            "type": "boolean",
            "nullable": true
          },
          "ignore_emails": {
            "description": "Suppress email and WhatsApp notifications for this receipt. Takes precedence\nover `send_email` — the handler stores `ignore_emails ?? (send_email === false)`.\n",
            "example": false,
            "type": "boolean",
            "nullable": true
          }
        }
      },
      "DocumentTypeEnum": {
        "type": "string",
        "enum": [
          "contract",
          "delivery_proof",
          "payment_proof",
          "communication"
        ],
        "example": "contract",
        "description": "Kind of supporting document. Only these four values are accepted when creating a\ndocument. The internal type union also contains `payment_confirmation`,\n`subscription_info`, `usage_report` and `cronograma`, but those cannot be set through\nthis API.\n"
      },
      "DocumentComplianceStatusEnum": {
        "type": "string",
        "enum": [
          "pending_review",
          "valid",
          "requires_update",
          "expired",
          "rejected"
        ],
        "example": "pending_review",
        "description": "Compliance review state. Always `pending_review` when a document is created; change it\nwith `PATCH /v2/documents/{id}`.\n"
      },
      "DocumentLinkEntityTypeEnum": {
        "type": "string",
        "enum": [
          "invoice",
          "payment",
          "receipt",
          "client"
        ],
        "example": "invoice",
        "description": "Kind of gigstack entity a document can be linked to."
      },
      "DocumentInput": {
        "type": "object",
        "description": "Metadata for a document that has already been uploaded to storage. Unknown top-level\nkeys are rejected; `metadata` is the one object that accepts arbitrary keys.\n`complianceStatus` cannot be set here — it is always `pending_review` on create.\n",
        "additionalProperties": false,
        "required": [
          "documentType",
          "name",
          "fileUrl",
          "storagePath",
          "fileName"
        ],
        "properties": {
          "documentType": {
            "$ref": "#/components/schemas/DocumentTypeEnum"
          },
          "name": {
            "type": "string",
            "example": "Contrato de servicios 2026 — Cliente ACME"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "example": "Contrato marco de prestación de servicios"
          },
          "fileUrl": {
            "type": "string",
            "description": "Publicly resolvable URL of the stored file.",
            "example": "https://storage.googleapis.com/gigstack-docs/team_123/contrato-acme.pdf"
          },
          "storagePath": {
            "type": "string",
            "description": "Path of the object inside the storage bucket.",
            "example": "teams/team_123/sat_documents/contrato-acme.pdf"
          },
          "fileName": {
            "type": "string",
            "example": "contrato-acme.pdf"
          },
          "fileSize": {
            "type": "number",
            "nullable": true,
            "description": "Size in bytes.",
            "example": 284913
          },
          "mimeType": {
            "type": "string",
            "nullable": true,
            "example": "application/pdf"
          },
          "linkedEntities": {
            "type": "array",
            "nullable": true,
            "description": "Entities to link the document to at creation time.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "entityType",
                "entityId"
              ],
              "properties": {
                "entityType": {
                  "$ref": "#/components/schemas/DocumentLinkEntityTypeEnum"
                },
                "entityId": {
                  "type": "string",
                  "example": "client_1234567890"
                }
              }
            }
          },
          "validFrom": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Start of the document's validity window, epoch **milliseconds**.",
            "example": 1767225600000
          },
          "validUntil": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "End of the document's validity window, epoch **milliseconds**.",
            "example": 1798761600000
          },
          "tags": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            },
            "example": [
              "contrato",
              "acme"
            ]
          },
          "metadata": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "analyzeWithAI": {
            "type": "boolean",
            "nullable": true,
            "description": "Request AI extraction as part of creation.",
            "example": false
          }
        }
      },
      "DocumentUpdateInput": {
        "type": "object",
        "description": "Partial update. Every field is optional and only the keys present in the body are\nwritten. The file itself (`documentType`, `fileUrl`, `storagePath`, `fileName`) is\nimmutable and those keys are rejected as unknown.\n",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "nullable": true,
            "example": "Contrato de servicios 2026 — Cliente ACME (v2)"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "complianceStatus": {
            "$ref": "#/components/schemas/DocumentComplianceStatusEnum"
          },
          "complianceNotes": {
            "type": "string",
            "nullable": true,
            "example": "Revisado por el área fiscal."
          },
          "validFrom": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "example": 1767225600000
          },
          "validUntil": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "example": 1798761600000
          },
          "tags": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string"
            },
            "example": [
              "contrato",
              "revisado"
            ]
          },
          "metadata": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          }
        }
      },
      "DocumentLinkInput": {
        "type": "object",
        "description": "Identifies the entity a document should be linked to or unlinked from.",
        "additionalProperties": false,
        "required": [
          "entityType",
          "entityId"
        ],
        "properties": {
          "entityType": {
            "$ref": "#/components/schemas/DocumentLinkEntityTypeEnum"
          },
          "entityId": {
            "type": "string",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        }
      },
      "ApiPublicDocument": {
        "type": "object",
        "description": "A document as returned by the documents endpoints (snake_case).",
        "properties": {
          "id": {
            "type": "string",
            "example": "doc_1234567890"
          },
          "document_type": {
            "$ref": "#/components/schemas/DocumentTypeEnum"
          },
          "name": {
            "type": "string",
            "nullable": true,
            "example": "Contrato de servicios 2026 — Cliente ACME"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "file_url": {
            "type": "string",
            "example": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_123%2Fsat_documents%2Fcontrato-acme.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43"
          },
          "file_name": {
            "type": "string",
            "example": "contrato-acme.pdf"
          },
          "file_size": {
            "type": "number",
            "nullable": true,
            "example": 284913
          },
          "mime_type": {
            "type": "string",
            "nullable": true,
            "example": "application/pdf"
          },
          "linked_entities": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "entity_type": {
                  "$ref": "#/components/schemas/DocumentLinkEntityTypeEnum"
                },
                "entity_id": {
                  "type": "string",
                  "example": "client_1234567890"
                },
                "linked_at": {
                  "type": "integer",
                  "format": "int64",
                  "example": 1767225600000
                }
              }
            }
          },
          "compliance_status": {
            "type": "string",
            "nullable": true,
            "enum": [
              "pending_review",
              "valid",
              "requires_update",
              "expired",
              "rejected",
              null
            ]
          },
          "compliance_notes": {
            "type": "string",
            "nullable": true
          },
          "valid_from": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "example": 1767225600000
          },
          "valid_until": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "example": 1798761600000
          },
          "ai_extraction": {
            "type": "object",
            "nullable": true,
            "description": "Result of the last AI analysis. `null` until the document is analyzed.",
            "properties": {
              "extracted_at": {
                "type": "integer",
                "format": "int64",
                "example": 1767225600000
              },
              "model": {
                "type": "string",
                "example": "gemini-2.5-flash"
              },
              "confidence": {
                "type": "number",
                "example": 0.92
              },
              "extracted_data": {
                "type": "object",
                "additionalProperties": true,
                "description": "Fields extracted from the document; the shape depends on `document_type`."
              }
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "contrato",
              "acme"
            ]
          },
          "metadata": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "created_at": {
            "type": "integer",
            "format": "int64",
            "example": 1767225600000
          },
          "created_by": {
            "type": "string",
            "example": "user_1234567890"
          },
          "updated_at": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "example": 1767225600000
          },
          "livemode": {
            "type": "boolean",
            "example": true
          }
        }
      },
      "ApiPublicSearch": {
        "type": "object",
        "required": [
          "on_key",
          "on_value",
          "auto_create"
        ],
        "properties": {
          "on_key": {
            "type": "string",
            "example": "tax_id",
            "description": "Field to search on"
          },
          "on_value": {
            "type": "string",
            "example": "PEGJ800101ABC",
            "description": "Value to search for"
          },
          "auto_create": {
            "type": "boolean",
            "example": true,
            "description": "Whether to create the resource if not found"
          },
          "safety_check": {
            "type": "boolean",
            "example": false,
            "description": "When true, prevents using multiple matching results (returns error). When false, uses the first result found. Default: false"
          }
        }
      },
      "ApiPublicThirdParty": {
        "type": "object",
        "required": [
          "legal_name",
          "tax_id",
          "tax_system",
          "zip"
        ],
        "properties": {
          "legal_name": {
            "type": "string",
            "example": "Third Party SA de CV",
            "description": "Legal name of the third party"
          },
          "tax_id": {
            "type": "string",
            "example": "TPR800101ABC",
            "description": "RFC (Tax ID) of the third party"
          },
          "tax_system": {
            "type": "string",
            "example": "601",
            "description": "SAT tax system code"
          },
          "zip": {
            "type": "string",
            "example": "03100",
            "description": "Postal code of the third party"
          }
        }
      },
      "ApiPublicInvoiceConfig": {
        "type": "object",
        "properties": {
          "serie": {
            "type": "string",
            "nullable": true,
            "example": "A",
            "description": "Invoice series"
          },
          "folio": {
            "type": "string",
            "nullable": true,
            "example": "123",
            "description": "Invoice folio number"
          }
        }
      },
      "ApiPublicRefund": {
        "type": "object",
        "required": [
          "id",
          "reason",
          "created_at",
          "total"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "refund_1234567890",
            "description": "Unique refund identifier"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiPublicService"
            },
            "nullable": true,
            "description": "Items being refunded"
          },
          "reason": {
            "type": "string",
            "example": "Customer requested cancellation",
            "description": "Reason for the refund"
          },
          "created_at": {
            "type": "number",
            "example": 1677651234,
            "description": "Unix timestamp of when the refund was created"
          },
          "total": {
            "type": "number",
            "example": 1160,
            "description": "Total refund amount"
          }
        }
      },
      "TeamTaxDefault": {
        "type": "object",
        "required": [
          "type",
          "rate"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "IVA",
              "ISR",
              "IEPS"
            ],
            "example": "IVA",
            "description": "Type of tax"
          },
          "rate": {
            "type": "number",
            "example": 0.16,
            "description": "Tax rate (e.g., 0.16 for 16% IVA)"
          },
          "factor": {
            "type": "string",
            "nullable": true,
            "example": "Tasa",
            "description": "SAT tax factor (Tasa, Cuota, Exento)"
          },
          "inclusive": {
            "type": "boolean",
            "nullable": true,
            "example": false,
            "description": "Whether the tax is included in the unit price"
          },
          "withholding": {
            "type": "boolean",
            "nullable": true,
            "example": false,
            "description": "Whether this is a withholding tax"
          }
        }
      },
      "TaxElement": {
        "type": "object",
        "required": [
          "type",
          "rate"
        ],
        "properties": {
          "base": {
            "oneOf": [
              {
                "type": "number",
                "nullable": true
              },
              {
                "type": "string",
                "nullable": true
              }
            ],
            "example": 100,
            "description": "Taxable base amount. Accepts number or numeric string. If null, calculated automatically from item price."
          },
          "factor": {
            "type": "string",
            "nullable": true,
            "example": "Tasa",
            "description": "SAT tax factor (Tasa, Cuota, Exento)"
          },
          "inclusive": {
            "type": "boolean",
            "nullable": true,
            "example": false,
            "description": "Whether the tax is included in the unit price"
          },
          "rate": {
            "type": "number",
            "example": 0.16,
            "description": "Tax rate (e.g., 0.16 for 16% IVA)"
          },
          "type": {
            "type": "string",
            "enum": [
              "IVA",
              "ISR",
              "IEPS"
            ],
            "example": "IVA",
            "description": "Type of tax"
          },
          "withholding": {
            "type": "boolean",
            "nullable": true,
            "example": false,
            "description": "Whether this is a withholding tax"
          }
        }
      },
      "ClientAddress": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "country": {
            "example": "MEX",
            "type": "string",
            "nullable": true,
            "maxLength": 3
          },
          "street": {
            "example": "Av. Insurgentes Sur",
            "type": "string",
            "nullable": true
          },
          "zip": {
            "example": "03100",
            "type": "string",
            "nullable": true
          },
          "city": {
            "example": "Ciudad de México",
            "type": "string",
            "nullable": true
          },
          "state": {
            "example": "CDMX",
            "type": "string",
            "nullable": true
          },
          "exterior": {
            "example": "123",
            "type": "string",
            "nullable": true
          },
          "interior": {
            "example": "4B",
            "type": "string",
            "nullable": true
          },
          "municipality": {
            "example": "Benito Juárez",
            "type": "string",
            "nullable": true
          },
          "neighborhood": {
            "example": "Del Valle",
            "type": "string",
            "nullable": true
          }
        }
      },
      "TaxSchema": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "base": {
            "description": "Taxable base amount. Accepts number or numeric string. If null, calculated automatically from item price.",
            "example": 100,
            "oneOf": [
              {
                "type": "number",
                "nullable": true
              },
              {
                "type": "string",
                "description": "Numeric string accepted by the request validator."
              }
            ]
          },
          "factor": {
            "example": "Tasa",
            "type": "string",
            "nullable": true
          },
          "inclusive": {
            "example": false,
            "type": "boolean",
            "nullable": true
          },
          "rate": {
            "example": 0.16,
            "type": "number",
            "nullable": true
          },
          "type": {
            "example": "IVA",
            "type": "string",
            "enum": [
              "IVA",
              "ISR",
              "IEPS",
              null
            ],
            "nullable": true
          },
          "withholding": {
            "example": false,
            "type": "boolean",
            "nullable": true
          }
        }
      },
      "StandardSuccessResponse": {
        "type": "object",
        "description": "Standardized success envelope emitted by `sendSuccessResponse`.\n",
        "required": [
          "success",
          "data",
          "timestamp"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true
          },
          "data": {
            "type": "object",
            "description": "The operation payload."
          },
          "message": {
            "type": "string",
            "description": "Human-readable summary. Present only when the handler supplies one.",
            "example": "Operation completed successfully"
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "Server time in **epoch milliseconds** (`Luxon.now().toMillis()`).",
            "example": 1767225600000
          }
        }
      },
      "StandardErrorResponse": {
        "type": "object",
        "description": "Standardized error envelope emitted by `sendErrorResponse` and its helpers\n(`sendValidationError`, `sendNotFoundError`, `sendUnauthorizedError`,\n`sendForbiddenError`, `sendConflictError`, `sendBadRequestError`,\n`sendInternalServerError`).\n",
        "required": [
          "success",
          "error",
          "timestamp"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ],
            "example": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine-readable code. Values emitted by the shared helpers:\n`unauthorized`, `forbidden`, `invalid_token`, `validation_failed`,\n`invalid_request_body`, `missing_required_field`, `invalid_field_value`,\n`resource_not_found`, `resource_already_exists`, `resource_conflict`,\n`business_rule_violation`, `operation_not_allowed`,\n`insufficient_permissions`, `external_service_error`,\n`payment_processor_error`, `cfdi_service_error`,\n`internal_server_error`, `service_unavailable`, `rate_limit_exceeded`,\n`database_error`, `data_integrity_error`, `file_not_found`,\n`file_upload_error`, `invalid_file_format`. Individual handlers may\nemit additional endpoint-specific codes, documented per operation.\n",
                "example": "validation_failed"
              },
              "message": {
                "type": "string",
                "example": "Request validation failed"
              },
              "details": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  {
                    "type": "object"
                  }
                ],
                "description": "Present only when the handler supplies detail. Validation failures\nemit an array of `\"<field path>: <message>\"` strings. An object only\nwhere an operation documents its keys: account billing answers `409`\n`billing_operation_pending` with `{ \"operation_id\": \"<id>\" }`, the\noperation holding the account lock, to reconcile\n(`POST /teams/{id}/billing/operations/{operationId}/reconcile`).\n",
                "example": [
                  "currency: Field is required"
                ]
              }
            }
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "Server time in epoch milliseconds.",
            "example": 1767225600000
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "description": "Raw (non-enveloped) health probe body. Health routes bypass the auth chain entirely.\n",
        "required": [
          "status",
          "module"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ],
            "example": "ok"
          },
          "module": {
            "type": "string",
            "example": "clients"
          }
        }
      },
      "CfdiErrorResponse": {
        "type": "object",
        "description": "Raw CFDI/PAC error body produced by `handleCFDIError`. **Not** the standardized\nenvelope. On `POST /v2/invoices/income`, `/egress` and `/invoices/draft/{id}/stamp`\nthis object is nested one level deeper, under a `message` key\n(`{ \"message\": { \"error\": …, \"code\": …, \"retryable\": … } }`); on\n`DELETE /v2/invoices/{id}` it is returned at the top level.\n",
        "required": [
          "error",
          "code",
          "retryable"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable Spanish error message shown to the end user.",
            "example": "Error al timbrar la factura: El CSD del emisor no es válido."
          },
          "code": {
            "type": "string",
            "description": "CFDI/PAC error code: a SAT/PAC code (e.g. `CFDI40147`) or one of gigstack's own\n(`SAT_NOT_CONNECTED`, `CSD_VALIDATION_ERROR`, `PAC_UNAVAILABLE`, `PAC_OUTCOME_UNKNOWN`,\n`STAMP_NEEDS_REVIEW`, `INVALID_INVOICE`, `STAMPING_ERROR`, …).\n",
            "example": "CSD_VALIDATION_ERROR"
          },
          "providerMessage": {
            "type": "string",
            "description": "Raw message returned by the PAC. Only present on generic (400) stamping failures.",
            "example": "CFDI40147 - El campo UsoCFDI no es válido"
          },
          "retryable": {
            "type": "boolean",
            "description": "Whether sending the **same** request again is safe and can succeed. `true` for `503`\n`PAC_UNAVAILABLE`, and for `503` `PAC_OUTCOME_UNKNOWN` only when the request carried an\n`idempotency_key`. Every `400`, `409` and `412` is `false`.\n",
            "example": false
          },
          "duplicate": {
            "type": "boolean",
            "description": "Present and `true` only on the `400` answered for an `idempotency_key` whose invoice already\nexists. Nothing was stamped or charged by this request; `uuid` names the existing invoice.\n",
            "example": true
          },
          "uuid": {
            "type": "string",
            "description": "With `duplicate`, the folio fiscal (UUID) of the invoice already issued under this `idempotency_key`.",
            "example": "0f8fad5b-d9cb-469f-a165-70867728950e"
          }
        }
      },
      "CreditLimitResponse": {
        "type": "object",
        "description": "Raw credit-limit body (HTTP 429) returned by invoice income creation and draft\nstamping. Not the standardized envelope.\n",
        "required": [
          "message",
          "error"
        ],
        "properties": {
          "message": {
            "type": "string",
            "example": "Team credit limit reached"
          },
          "error": {
            "type": "string",
            "description": "Reason reported by the credit checker.",
            "example": "Credit limit of 100 documents reached for this billing period"
          },
          "credit_limit": {
            "type": "number",
            "example": 100
          },
          "used_credits": {
            "type": "number",
            "example": 100
          }
        }
      },
      "ListResponse": {
        "type": "object",
        "description": "Response shape of the Firestore-backed list handlers. Note this is **not** the\nstandardized envelope: `data` sits at the top level alongside the pagination keys and\n`message`/`success`/`timestamp`, rather than under a `data` wrapper.\n\nA few modules (clients, payments, and the income, egress, payment and transfer invoice\nlists) take a **second code path** when the request carries `metadata.*` / `metadata_*`\nfilters and the team has Typesense configured: Typesense resolves the matching ids and the\ndocuments are then re-read from Firestore. That path returns `has_more`, `total_results`,\n`page` and `per_page` instead of the cursor-style `next`. Modules without a Typesense\nbranch (receipts, retentions, users, invoice drafts) only ever return the cursor form.\n\nOn those invoice lists the invoice type is checked on each matching document, and at most\n2,000 documents are scanned. `truncated: true` means the scan stopped there: `total_results`\nand the pages only cover what was scanned, and narrowing the metadata filter lists the rest.\n\nFull-text `/search` endpoints are different again — see `SearchResponse`.\n",
        "required": [
          "message",
          "data",
          "success",
          "timestamp"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true
          },
          "message": {
            "type": "string",
            "example": "Items retrieved successfully"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "next": {
            "type": "string",
            "nullable": true,
            "description": "Cursor for the next page. Cursor-style (Firestore) path only.",
            "example": "eyJjcmVhdGVkX2F0IjoxNjc3NjUxMjM0fQ=="
          },
          "has_more": {
            "type": "boolean",
            "description": "Metadata-filtered (Typesense-assisted) path only.",
            "example": true
          },
          "total_results": {
            "type": "number",
            "description": "Metadata-filtered (Typesense-assisted) path only.",
            "example": 150
          },
          "page": {
            "type": "integer",
            "description": "Metadata-filtered (Typesense-assisted) path only.",
            "example": 1
          },
          "per_page": {
            "type": "integer",
            "description": "Metadata-filtered (Typesense-assisted) path only.",
            "example": 10
          },
          "truncated": {
            "type": "boolean",
            "description": "Metadata-filtered invoice lists only. True when the scan stopped at its 2,000-document\ncap before the matches ran out: `total_results` and the pages cover only what was\nscanned, and `has_more` is false on the last scanned page even though more matches\nexist. Narrow the metadata filter to reach them.\n",
            "example": false
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "Server time in epoch milliseconds.",
            "example": 1767225600000
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "description": "Response shape of the Typesense-backed `/search` endpoints (clients, invoices, payments,\nreceipts). Distinct from `ListResponse`: it reports `found` (total matches) rather than\n`has_more`/`total_results`, and it has no cursor. It is also not the standardized\nenvelope — `data` is top-level.\n\nThese endpoints require both a `q` (or `query`) parameter and a Typesense key configured\non the team; either missing yields `400` with `missing_query` / `missing_typesense_key`.\n",
        "required": [
          "message",
          "data",
          "found",
          "page",
          "per_page",
          "success",
          "timestamp"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true
          },
          "message": {
            "type": "string",
            "example": "Items searched successfully"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "found": {
            "type": "integer",
            "description": "Total number of matching documents.",
            "example": 15
          },
          "page": {
            "type": "integer",
            "example": 1
          },
          "per_page": {
            "type": "integer",
            "example": 10
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "Server time in epoch milliseconds.",
            "example": 1767225600000
          }
        }
      },
      "AgentSandbox": {
        "type": "object",
        "description": "A test-only sandbox account created by `POST /auth/sandbox`.",
        "required": [
          "team_id",
          "billing_account_id",
          "livemode",
          "api_key",
          "credential_delivery",
          "claim"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "billing_account_id": {
            "type": "string"
          },
          "livemode": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "api_key": {
            "type": "object",
            "required": [
              "test"
            ],
            "properties": {
              "test": {
                "type": "string",
                "nullable": true,
                "description": "Test-mode key. Returned once, in the first `201`; `null` on replay."
              }
            }
          },
          "credential_delivery": {
            "type": "string",
            "enum": [
              "first_response",
              "not_replayed"
            ]
          },
          "claim": {
            "type": "object",
            "required": [
              "sent_to",
              "expires_at"
            ],
            "properties": {
              "sent_to": {
                "type": "string",
                "format": "email"
              },
              "expires_at": {
                "type": "integer",
                "format": "int64",
                "description": "Epoch millis. The claim code and the sandbox expire together."
              },
              "delivery": {
                "type": "string",
                "enum": [
                  "sent",
                  "failed"
                ],
                "description": "Whether the claim email was handed to the mail provider. On `failed`, call again with a new key to re-send."
              }
            }
          },
          "test_issuer": {
            "type": "object",
            "nullable": true,
            "description": "SAT's public test issuer loaded on the sandbox, with its test CSD, so test invoices can be stamped right away. These are SAT test credentials, not the person's: before going live they replace the fiscal data and upload their own CSD (go-live answers 409 csd_test_only until then). `null` if it could not be loaded; upload a CSD to stamp.",
            "properties": {
              "rfc": {
                "type": "string",
                "example": "EKU9003173C9"
              },
              "legal_name": {
                "type": "string",
                "example": "ESCUELA KEMPER URGATE"
              },
              "tax_system": {
                "type": "string",
                "example": "601"
              },
              "zip": {
                "type": "string",
                "example": "42501"
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StandardErrorResponse"
          }
        ],
        "description": "Standardized error envelope.",
        "example": {
          "success": false,
          "error": {
            "code": "invalid_request_body",
            "message": "An error occurred"
          },
          "timestamp": 1767225600000
        }
      },
      "ValidationErrorResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StandardErrorResponse"
          }
        ],
        "description": "Body validation failure. Unknown top-level keys are rejected — the validator runs in\nstrict allowlist mode (`allowUnknown: false`), so a field not declared in the request\nschema produces an `unexpected_key` detail rather than being ignored.\n",
        "example": {
          "success": false,
          "error": {
            "code": "validation_failed",
            "message": "Request validation failed",
            "details": [
              "currency: Field is required",
              "client_id: Unexpected field"
            ]
          },
          "timestamp": 1767225600000
        }
      },
      "UnauthorizedError": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StandardErrorResponse"
          }
        ],
        "example": {
          "success": false,
          "error": {
            "code": "unauthorized",
            "message": "Unauthorized access"
          },
          "timestamp": 1767225600000
        }
      },
      "SatImportJobSummary": {
        "type": "object",
        "description": "A preview or import job over a range of SAT history.",
        "properties": {
          "id": {
            "type": "string",
            "example": "satjob_a1b2c3d4e5"
          },
          "type": {
            "type": "string",
            "enum": [
              "preview",
              "backfill",
              "import"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "failed",
              "cancelled"
            ]
          },
          "params": {
            "type": "object",
            "properties": {
              "startDate": {
                "type": "string",
                "format": "date"
              },
              "endDate": {
                "type": "string",
                "format": "date"
              },
              "directions": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "issued",
                    "received"
                  ]
                }
              }
            }
          },
          "progress": {
            "type": "object",
            "properties": {
              "totalWindows": {
                "type": "integer",
                "description": "One per month per direction"
              },
              "doneWindows": {
                "type": "integer"
              },
              "invoicesFound": {
                "type": "integer"
              },
              "invoicesSaved": {
                "type": "integer"
              },
              "alreadyInGigstack": {
                "type": "integer",
                "description": "Issued CFDIs gigstack already holds, so nothing to buy"
              }
            }
          },
          "aggregates": {
            "type": "object",
            "properties": {
              "byMonth": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "month": {
                      "type": "string",
                      "example": "2026-05"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "totalAmount": {
                      "type": "number"
                    },
                    "nominaCount": {
                      "type": "integer"
                    },
                    "billableCount": {
                      "type": "integer"
                    }
                  }
                }
              },
              "billableCount": {
                "type": "integer",
                "description": "Excludes nómina and anything already held"
              },
              "estimatedCostMxn": {
                "type": "number",
                "description": "billableCount x $0.20 MXN"
              }
            }
          },
          "created_at": {
            "type": "integer"
          },
          "updated_at": {
            "type": "integer"
          },
          "completed_at": {
            "type": "integer",
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "NotFoundError": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StandardErrorResponse"
          }
        ],
        "example": {
          "success": false,
          "error": {
            "code": "resource_not_found",
            "message": "Resource not found"
          },
          "timestamp": 1767225600000
        }
      },
      "InternalServerError": {
        "allOf": [
          {
            "$ref": "#/components/schemas/StandardErrorResponse"
          }
        ],
        "example": {
          "success": false,
          "error": {
            "code": "internal_server_error",
            "message": "An internal server error occurred"
          },
          "timestamp": 1767225600000
        }
      },
      "LegacyErrorResponse": {
        "type": "object",
        "description": "Raw error body returned by handlers that do not use the standardized helpers.\nNote the absence of `success` and `timestamp`.\n",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string",
            "example": "Invalid body"
          },
          "error": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object"
              }
            ],
            "description": "Present on most, but not all, legacy error paths."
          },
          "errors": {
            "type": "array",
            "description": "Validation errors, when the failure came from body validation. Schema validation gives\nfield-level objects; some later checks (for example a Colombian debit note's rules on\n`POST /invoices/income`) give a single string reason.\n",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "path": {
                      "type": "string",
                      "example": "client_id"
                    },
                    "code": {
                      "type": "string",
                      "example": "unexpected_key"
                    },
                    "message": {
                      "type": "string",
                      "example": "Unexpected field"
                    }
                  }
                },
                {
                  "type": "string",
                  "example": "A debit note needs a motive: 1 (interest), 2 (collection_expenses), 3 (value_change) or 4 (other)"
                }
              ]
            }
          }
        }
      },
      "SatListDefinition": {
        "type": "object",
        "description": "A SAT list tracked by gigstack, plus the metadata of its most recent sync.",
        "properties": {
          "key": {
            "type": "string",
            "description": "Stable identifier for the list.",
            "example": "art_69b_definitivos"
          },
          "label": {
            "type": "string",
            "description": "Human-readable name, as published by the SAT.",
            "example": "Definitivos 69-B"
          },
          "source": {
            "type": "string",
            "description": "Which SAT article the list is published under.",
            "enum": [
              "art_69",
              "art_69b",
              "art_69b_bis"
            ],
            "example": "art_69b"
          },
          "is_risky": {
            "type": "boolean",
            "description": "Whether appearing on this list marks the RFC as risky to invoice.",
            "example": true
          },
          "filename": {
            "type": "string",
            "description": "Name of the source CSV published by the SAT.",
            "example": "Listado_Definitivos.csv"
          },
          "sync": {
            "type": "object",
            "nullable": true,
            "description": "Metadata from the most recent sync. `null` if the list has never completed a sync.",
            "properties": {
              "last_sync_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "last_status": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "ok",
                  "error",
                  null
                ],
                "example": "ok"
              },
              "row_count": {
                "type": "integer",
                "nullable": true,
                "description": "Number of RFCs on the list after the latest sync.",
                "example": 12843
              },
              "previous_row_count": {
                "type": "integer",
                "nullable": true,
                "description": "Row count before the latest sync.",
                "example": 12790
              },
              "net_new": {
                "type": "integer",
                "nullable": true,
                "description": "`row_count` minus `previous_row_count`. Negative when the SAT removed more RFCs than it added.",
                "example": 53
              },
              "removed": {
                "type": "integer",
                "nullable": true,
                "description": "RFCs dropped from the list in the latest sync.",
                "example": 4
              },
              "duration_ms": {
                "type": "integer",
                "nullable": true,
                "example": 8421
              }
            }
          }
        }
      },
      "SatListRfcCheck": {
        "type": "object",
        "description": "Result of checking a single RFC against every SAT list.",
        "properties": {
          "rfc": {
            "type": "string",
            "description": "The RFC that was checked, normalized to uppercase.",
            "example": "XAXX010101000"
          },
          "found": {
            "type": "boolean",
            "description": "Whether the RFC appears on at least one list.",
            "example": true
          },
          "is_risky": {
            "type": "boolean",
            "description": "Whether the RFC appears on at least one list flagged as risky.",
            "example": true
          },
          "risky_lists": {
            "type": "array",
            "description": "Keys of the risky lists the RFC appears on.",
            "items": {
              "type": "string"
            },
            "example": [
              "art_69b_definitivos"
            ]
          },
          "entries": {
            "type": "array",
            "description": "Every matching list entry, risky or not.",
            "items": {
              "type": "object",
              "properties": {
                "list_key": {
                  "type": "string",
                  "example": "art_69b_definitivos"
                },
                "list_label": {
                  "type": "string",
                  "example": "Definitivos 69-B"
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "art_69",
                    "art_69b",
                    "art_69b_bis"
                  ],
                  "example": "art_69b"
                },
                "is_risky": {
                  "type": "boolean",
                  "example": true
                },
                "detail": {
                  "type": "object",
                  "nullable": true,
                  "description": "Extra columns from the SAT CSV for this RFC, when the list publishes them."
                },
                "last_seen_at": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true,
                  "description": "When the RFC was last seen on this list during a sync."
                }
              }
            }
          }
        }
      },
      "SatOpinion32dCheck": {
        "type": "object",
        "description": "Result of consulting the SAT's public \"Opinión del Cumplimiento\" (32-D) service for a single RFC.\n\nRead `status` carefully: the SAT's public service only ever publishes **positive** opinions, and only\nfor taxpayers who explicitly authorized public disclosure. `no_autorizado` therefore means the result\nis **unknown** — it is not a negative opinion and must never be presented as non-compliance.\n",
        "properties": {
          "rfc": {
            "type": "string",
            "description": "The RFC that was consulted, normalized to uppercase.",
            "example": "EKU9003173C9"
          },
          "status": {
            "type": "string",
            "enum": [
              "positiva",
              "no_autorizado"
            ],
            "description": "- `positiva`: the SAT publishes a positive opinion for this RFC.\n- `no_autorizado`: the SAT publishes nothing for this RFC — either the taxpayer never opted in\n  to public disclosure, or no opinion is published. **Unknown, not negative.**\n",
            "example": "positiva"
          },
          "found": {
            "type": "boolean",
            "description": "Convenience flag — `true` exactly when `status` is `positiva`.",
            "example": true
          },
          "message": {
            "type": "string",
            "nullable": true,
            "description": "The SAT's own informational message, with HTML stripped. Only present when `status` is\n`no_autorizado`; it typically explains that the taxpayer has not authorized publication.\n",
            "example": "El contribuyente no ha autorizado la publicación de su opinión del cumplimiento."
          },
          "pdf_url": {
            "type": "string",
            "nullable": true,
            "description": "URL to download the constancia PDF issued by the SAT. Only present when `status` is\n`positiva`; `null` otherwise. The document is stored per RFC and per day and the link\nis valid for 7 days.\n",
            "example": "https://storage.googleapis.com/gigstackpro.appspot.com/sat-32d/EKU9003173C9/2026-08-06.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Expires=604800&X-Goog-Signature=2f8c1a..."
          },
          "checked_at": {
            "type": "integer",
            "format": "int64",
            "description": "Unix timestamp (ms) of when the SAT was consulted.",
            "example": 1770000000000
          }
        }
      },
      "PaymentFormEnum": {
        "type": "string",
        "enum": [
          "01",
          "02",
          "03",
          "04",
          "05",
          "06",
          "08",
          "12",
          "13",
          "14",
          "15",
          "17",
          "23",
          "24",
          "25",
          "26",
          "27",
          "28",
          "29",
          "30",
          "31",
          "99"
        ],
        "description": "SAT payment form codes (c_FormaPago) according to Mexican tax regulations.\nMost common forms:\n- `01`: Cash (Efectivo)\n- `03`: Electronic funds transfer (Transferencia electrónica)\n- `04`: Credit card (Tarjeta de crédito)\n- `28`: Debit card (Tarjeta de débito)\n",
        "example": "03"
      },
      "ItemSchema": {
        "description": "A line item on an invoice, receipt or payment. Only `quantity` is required; everything\nelse is optional, or resolved from the referenced service when `id`/`search` is used.\n`id` and `search` are mutually exclusive — supplying both is a `400`.\n\nUnknown keys are rejected. Note there is no per-item `metadata` field.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "quantity"
        ],
        "properties": {
          "id": {
            "description": "Service/product ID reference. The line inherits the service's catalog fields;\non Mexican invoices that includes its cuenta predial, stamped as the\nconcepto's `CuentaPredial` node (one per account) for arrendamiento.\n",
            "example": "service_1234567890",
            "type": "string",
            "nullable": true
          },
          "search": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "on_key",
              "on_value"
            ],
            "properties": {
              "on_key": {
                "description": "Field to search on (sku, name, etc.)",
                "example": "sku",
                "type": "string"
              },
              "on_value": {
                "description": "Value to search for",
                "example": "CONS-001",
                "type": "string"
              },
              "auto_create": {
                "description": "Create service if not found",
                "example": true,
                "type": "boolean",
                "nullable": true
              },
              "safety_check": {
                "description": "When true, prevents using multiple matching results (returns error). When false, uses the first result found. Default: false",
                "example": false,
                "type": "boolean",
                "nullable": true
              },
              "update": {
                "type": "boolean",
                "nullable": true
              }
            },
            "nullable": true
          },
          "quantity": {
            "description": "Item quantity",
            "example": 1,
            "type": "number"
          },
          "description": {
            "description": "Item description",
            "example": "Consulting services",
            "type": "string",
            "nullable": true
          },
          "sku": {
            "description": "Stock keeping unit",
            "example": "CONS-001",
            "type": "string",
            "nullable": true
          },
          "product_key": {
            "description": "SAT product key (c_ClaveProdServ)",
            "example": "80141503",
            "type": "string",
            "nullable": true
          },
          "unit_key": {
            "description": "SAT unit key (c_ClaveUnidad)",
            "example": "E48",
            "type": "string",
            "nullable": true
          },
          "unit_name": {
            "description": "Unit name",
            "example": "Servicio",
            "type": "string",
            "nullable": true
          },
          "unit_price": {
            "description": "Unit price",
            "example": 1000,
            "type": "number",
            "nullable": true
          },
          "discount": {
            "description": "Discount amount (absolute value in the item currency, not a percentage)",
            "example": 0,
            "type": "number",
            "nullable": true
          },
          "taxability": {
            "description": "SAT `c_ObjetoImp` — whether the item is subject to tax.",
            "example": "02",
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "07",
              "08",
              null
            ],
            "nullable": true
          },
          "taxes": {
            "description": "Tax elements applied to this item",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "base": {
                  "description": "Taxable base amount. Accepts number or numeric string. If null, calculated automatically from item price.",
                  "example": 100,
                  "oneOf": [
                    {
                      "type": "number",
                      "nullable": true
                    },
                    {
                      "type": "string",
                      "description": "Numeric string accepted by the request validator."
                    }
                  ]
                },
                "factor": {
                  "description": "SAT tax factor (Tasa, Cuota, Exento)",
                  "example": "Tasa",
                  "type": "string",
                  "nullable": true
                },
                "inclusive": {
                  "description": "Whether the tax is included in the unit price",
                  "example": false,
                  "type": "boolean",
                  "nullable": true
                },
                "rate": {
                  "description": "Tax rate (e.g., 0.16 for 16% IVA)",
                  "example": 0.16,
                  "type": "number",
                  "nullable": true
                },
                "type": {
                  "description": "Type of tax",
                  "example": "IVA",
                  "type": "string",
                  "enum": [
                    "IVA",
                    "ISR",
                    "IEPS",
                    null
                  ],
                  "nullable": true
                },
                "withholding": {
                  "description": "Whether this is a withholding tax",
                  "example": false,
                  "type": "boolean",
                  "nullable": true
                }
              },
              "nullable": true
            }
          },
          "third_party": {
            "description": "Third party information for items provided by external parties",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "legal_name": {
                "description": "Third party legal name",
                "example": "Third Party SA",
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "description": "Third party RFC (tax ID)",
                "example": "TPR800101ABC",
                "type": "string",
                "nullable": true
              },
              "tax_system": {
                "description": "Third party tax system",
                "example": "601",
                "type": "string",
                "nullable": true
              },
              "zip": {
                "description": "Third party ZIP code",
                "example": "03100",
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "item_complement": {
            "description": "CFDI item-level complement.",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "hydrocarbons": {
                "description": "Complemento de hidrocarburos. All four fields are required when this object is present.",
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "permit_type",
                  "permit_number",
                  "fuel_code",
                  "fuel_sub_product"
                ],
                "properties": {
                  "permit_type": {
                    "example": "PL/12345/EXP/ES/2020",
                    "type": "string"
                  },
                  "permit_number": {
                    "example": "12345",
                    "type": "string"
                  },
                  "fuel_code": {
                    "example": "PR03",
                    "type": "string"
                  },
                  "fuel_sub_product": {
                    "example": "10",
                    "type": "string"
                  }
                },
                "nullable": true
              }
            },
            "nullable": true
          }
        }
      },
      "InvoiceItemInput": {
        "description": "A line item on an income or egress invoice, or on a payment: the same fields as `ItemSchema`, plus `note`.\nOnly `quantity` is required; everything else is optional, or resolved from the referenced\nservice when `id`/`search` is used. `id` and `search` are mutually exclusive — supplying both\nis a `400`.\n\nUnknown keys are rejected. Note there is no per-item `metadata` field.\n",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "quantity"
        ],
        "properties": {
          "id": {
            "description": "Service/product ID reference. The line inherits the service's catalog fields;\non Mexican invoices that includes its cuenta predial, stamped as the\nconcepto's `CuentaPredial` node (one per account) for arrendamiento.\n",
            "example": "service_1234567890",
            "type": "string",
            "nullable": true
          },
          "search": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "on_key",
              "on_value"
            ],
            "properties": {
              "on_key": {
                "description": "Field to search on (sku, name, etc.)",
                "example": "sku",
                "type": "string"
              },
              "on_value": {
                "description": "Value to search for",
                "example": "CONS-001",
                "type": "string"
              },
              "auto_create": {
                "description": "Create service if not found",
                "example": true,
                "type": "boolean",
                "nullable": true
              },
              "safety_check": {
                "description": "When true, prevents using multiple matching results (returns error). When false, uses the first result found. Default: false",
                "example": false,
                "type": "boolean",
                "nullable": true
              },
              "update": {
                "type": "boolean",
                "nullable": true
              }
            },
            "nullable": true
          },
          "quantity": {
            "description": "Item quantity",
            "example": 1,
            "type": "number"
          },
          "description": {
            "description": "Item description",
            "example": "Consulting services",
            "type": "string",
            "nullable": true
          },
          "sku": {
            "description": "Stock keeping unit",
            "example": "CONS-001",
            "type": "string",
            "nullable": true
          },
          "product_key": {
            "description": "SAT product key (c_ClaveProdServ)",
            "example": "80141503",
            "type": "string",
            "nullable": true
          },
          "unit_key": {
            "description": "SAT unit key (c_ClaveUnidad)",
            "example": "E48",
            "type": "string",
            "nullable": true
          },
          "unit_name": {
            "description": "Unit name",
            "example": "Servicio",
            "type": "string",
            "nullable": true
          },
          "unit_price": {
            "description": "Unit price",
            "example": 1000,
            "type": "number",
            "nullable": true
          },
          "discount": {
            "description": "Discount amount (absolute value in the item currency, not a percentage)",
            "example": 0,
            "type": "number",
            "nullable": true
          },
          "taxability": {
            "description": "SAT `c_ObjetoImp` — whether the item is subject to tax.",
            "example": "02",
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "07",
              "08",
              null
            ],
            "nullable": true
          },
          "taxes": {
            "description": "Tax elements applied to this item",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "base": {
                  "description": "Taxable base amount. Accepts number or numeric string. If null, calculated automatically from item price.",
                  "example": 100,
                  "oneOf": [
                    {
                      "type": "number",
                      "nullable": true
                    },
                    {
                      "type": "string",
                      "description": "Numeric string accepted by the request validator."
                    }
                  ]
                },
                "factor": {
                  "description": "SAT tax factor (Tasa, Cuota, Exento)",
                  "example": "Tasa",
                  "type": "string",
                  "nullable": true
                },
                "inclusive": {
                  "description": "Whether the tax is included in the unit price",
                  "example": false,
                  "type": "boolean",
                  "nullable": true
                },
                "rate": {
                  "description": "Tax rate (e.g., 0.16 for 16% IVA)",
                  "example": 0.16,
                  "type": "number",
                  "nullable": true
                },
                "type": {
                  "description": "Type of tax",
                  "example": "IVA",
                  "type": "string",
                  "enum": [
                    "IVA",
                    "ISR",
                    "IEPS",
                    null
                  ],
                  "nullable": true
                },
                "withholding": {
                  "description": "Whether this is a withholding tax",
                  "example": false,
                  "type": "boolean",
                  "nullable": true
                }
              },
              "nullable": true
            }
          },
          "third_party": {
            "description": "Third party information for items provided by external parties",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "legal_name": {
                "description": "Third party legal name",
                "example": "Third Party SA",
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "description": "Third party RFC (tax ID)",
                "example": "TPR800101ABC",
                "type": "string",
                "nullable": true
              },
              "tax_system": {
                "description": "Third party tax system",
                "example": "601",
                "type": "string",
                "nullable": true
              },
              "zip": {
                "description": "Third party ZIP code",
                "example": "03100",
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "item_complement": {
            "description": "CFDI item-level complement.",
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "hydrocarbons": {
                "description": "Complemento de hidrocarburos. All four fields are required when this object is present.",
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "permit_type",
                  "permit_number",
                  "fuel_code",
                  "fuel_sub_product"
                ],
                "properties": {
                  "permit_type": {
                    "example": "PL/12345/EXP/ES/2020",
                    "type": "string"
                  },
                  "permit_number": {
                    "example": "12345",
                    "type": "string"
                  },
                  "fuel_code": {
                    "example": "PR03",
                    "type": "string"
                  },
                  "fuel_sub_product": {
                    "example": "10",
                    "type": "string"
                  }
                },
                "nullable": true
              }
            },
            "nullable": true
          },
          "note": {
            "description": "**Colombia (DIAN) only.** Free text printed under this item on the PDF gigstack draws\nfor teams that use their own Colombian PDF. It is printed only: it is not sent to Factus\nand is not part of the DIAN XML. Belongs to this invoice only: it is never saved on the\nreferenced service. On a payment, it is carried to the invoice the payment stamps. Ignored in Mexico.\n",
            "example": "Licencias para 7 colaboradores, vigencia 12 meses desde la activación",
            "type": "string",
            "maxLength": 1000,
            "nullable": true
          }
        }
      },
      "SATDocument": {
        "type": "object",
        "required": [
          "id",
          "document_type",
          "name",
          "file_url",
          "file_name",
          "file_size",
          "mime_type",
          "compliance_status",
          "created_at",
          "linked_entities"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "doc_abc123xyz",
            "description": "Unique document identifier"
          },
          "document_type": {
            "type": "string",
            "enum": [
              "contract",
              "delivery_proof",
              "payment_proof",
              "communication",
              "payment_confirmation",
              "subscription_info",
              "cronograma"
            ],
            "description": "Type of supporting document"
          },
          "name": {
            "type": "string",
            "example": "Service Contract.pdf",
            "description": "Document name"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "example": "Main service contract for consulting services",
            "description": "Optional document description"
          },
          "file_url": {
            "type": "string",
            "format": "uri",
            "example": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_1234567890%2Fdocuments%2Fcontrato-2026.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
            "description": "Download URL for the stored file. A Firebase download-token URL, not a public storage link: it does not expire, but treat it as opaque and re-read the resource instead of parsing it."
          },
          "file_name": {
            "type": "string",
            "example": "contract.pdf",
            "description": "Original filename"
          },
          "file_size": {
            "type": "integer",
            "example": 245680,
            "description": "File size in bytes"
          },
          "mime_type": {
            "type": "string",
            "example": "application/pdf",
            "description": "MIME type of the file"
          },
          "compliance_status": {
            "type": "string",
            "enum": [
              "pending_review",
              "valid",
              "requires_update",
              "expired",
              "rejected"
            ],
            "description": "SAT compliance status"
          },
          "compliance_notes": {
            "type": "string",
            "nullable": true,
            "description": "Notes about compliance status"
          },
          "valid_from": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Validity start timestamp (milliseconds)"
          },
          "valid_until": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Validity end timestamp (milliseconds)"
          },
          "ai_extraction": {
            "type": "object",
            "nullable": true,
            "properties": {
              "extracted_at": {
                "type": "integer",
                "format": "int64",
                "description": "Extraction timestamp (milliseconds)"
              },
              "extracted_by": {
                "type": "string",
                "example": "ai",
                "description": "Source of extraction"
              },
              "model": {
                "type": "string",
                "example": "gemini-3-flash",
                "description": "AI model used"
              },
              "confidence": {
                "type": "number",
                "format": "float",
                "example": 0.95,
                "description": "Confidence score (0-1)"
              },
              "extracted_data": {
                "type": "object",
                "additionalProperties": true,
                "description": "Extracted structured data"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Extraction warnings"
              }
            },
            "description": "AI extraction results if analyzed"
          },
          "audits": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "context_type": {
                  "type": "string",
                  "enum": [
                    "invoice",
                    "payment",
                    "receipt"
                  ],
                  "description": "Type of entity audited against"
                },
                "context_id": {
                  "type": "string",
                  "description": "ID of entity audited against"
                },
                "audited_at": {
                  "type": "integer",
                  "format": "int64",
                  "description": "Audit timestamp (milliseconds)"
                },
                "result": {
                  "type": "string",
                  "enum": [
                    "valid",
                    "warning",
                    "mismatch"
                  ],
                  "description": "Audit result"
                },
                "summary": {
                  "type": "string",
                  "description": "Audit summary"
                },
                "details": {
                  "type": "object",
                  "additionalProperties": true,
                  "description": "Detailed audit results"
                }
              }
            },
            "description": "Context-specific audit results"
          },
          "created_at": {
            "type": "integer",
            "format": "int64",
            "example": 1677651234000,
            "description": "Creation timestamp (milliseconds)"
          },
          "created_by": {
            "type": "string",
            "example": "user_abc123",
            "description": "User who created the document"
          },
          "updated_at": {
            "type": "integer",
            "format": "int64",
            "example": 1677651234000,
            "description": "Last update timestamp (milliseconds)"
          },
          "linked_entities": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "entity_type": {
                  "type": "string",
                  "enum": [
                    "invoice",
                    "payment",
                    "receipt",
                    "client"
                  ],
                  "description": "Type of linked entity"
                },
                "entity_id": {
                  "type": "string",
                  "description": "ID of linked entity"
                },
                "linked_at": {
                  "type": "integer",
                  "format": "int64",
                  "description": "Link timestamp (milliseconds)"
                }
              }
            },
            "description": "Entities this document is linked to"
          }
        }
      },
      "UploadSupportDocumentInput": {
        "type": "object",
        "required": [
          "file",
          "documentType"
        ],
        "properties": {
          "file": {
            "type": "string",
            "format": "binary",
            "description": "The file to upload (PDF or image, max 10MB)"
          },
          "documentType": {
            "type": "string",
            "enum": [
              "contract",
              "delivery_proof",
              "payment_proof",
              "communication",
              "payment_confirmation",
              "subscription_info"
            ],
            "description": "Type of supporting document"
          },
          "name": {
            "type": "string",
            "example": "Service Contract",
            "description": "Optional custom name for the document"
          },
          "description": {
            "type": "string",
            "example": "Master services agreement for 2026",
            "description": "Optional description of the document"
          }
        }
      },
      "PlatformPayoutRunStatusEnum": {
        "type": "string",
        "description": "Where a platform payouts run is in its lifecycle.\n\n- `planning` - the files are being read and the plan computed. Normally only seen by a retry\n  that arrives while the first request is still working.\n- `plan_ready` - the plan is computed and waiting for `POST /platform-payouts/{id}/confirm`.\n- `plan_failed` - the plan could not be computed (see `error`). Terminal: upload corrected files\n  under a **new** `Idempotency-Key`.\n- `stamping` - confirmed; the background worker is issuing the CFDIs.\n- `completed` - the worker has nothing left to try. This says nothing about how much was issued:\n  read the run's `result` (`completed`, `partially_completed` or `failed`) to know how it went.\n- `failed` - the worker stopped the whole run (see `error`), for example because the master team\n  no longer has seals (CSD) or the run made no progress after repeated attempts.\n",
        "enum": [
          "planning",
          "plan_ready",
          "plan_failed",
          "stamping",
          "completed",
          "failed"
        ],
        "example": "plan_ready"
      },
      "PlatformPayoutRunResultEnum": {
        "type": "string",
        "nullable": true,
        "description": "How a finished run turned out. `null` while the run is not finished (`planning`, `plan_ready`,\n`plan_failed`, `stamping`). Read this, not `status`, to know how a run went:\n\n- `completed` - no document failed: everything planned was issued.\n- `partially_completed` - some documents failed and at least one was issued.\n- `failed` - the run itself failed (`status: failed`), or it finished having issued nothing while\n  something failed.\n\nCounted as: failures = `progress.failed_count` (movements with at least one failed document) +\n`progress.commission_failed_count`; issued = `income_invoices_count` + `certificates_count` +\n`commission_invoices_count`.\n",
        "enum": [
          "completed",
          "partially_completed",
          "failed",
          null
        ],
        "example": "partially_completed"
      },
      "PlatformPayoutExclusionCode": {
        "type": "string",
        "description": "Stable code for why a document is not planned, sent next to the Spanish sentence. Codes are never\nrenamed; the sentences may be reworded at any time, so branch on the code. New codes may be added.\n\n- `invalid_row` - the row itself is malformed (bad date, amount or month).\n- `provider_not_found` - no gigstack team of the billing account matches the provider.\n- `missing_tax_id` - no RFC (on the team or in the file; for the commission invoice, in the file).\n- `missing_legal_name` - the provider's team has no legal name (certificate: neither team nor file).\n- `missing_zip` - the provider's team has no fiscal zip code.\n- `missing_fiscal_data` - commission invoice: no provider team, or it lacks legal name or fiscal zip.\n- `csd_expired` - the provider's CSD (sellos) in gigstack expired.\n- `missing_csd` - the provider's team has no CSD in gigstack.\n- `tax_system_not_allowed` - the provider's tax regime is not allowed by the account's tax policy.\n- `duplicate_tax_id` - the RFC matches more than one team of the billing account.\n- `name_mismatch` - `Nombre del proveedor` differs from the team's legal name (SAT registry check).\n- `missing_series` - the issuing team has no invoice series (the provider's for income, the master's\n  for commissions).\n- `public_general_not_allowed` - the certificate would need the generic RFC and the policy forbids\n  issuing to the general public.\n- `certificate_month_reserved` - an earlier run already certified this provider-month.\n- `missing_commission` - no commission for the month, so the certificate would be rejected (SPT147).\n- `zero_commission` - the month's commission in the commissions file is zero.\n",
        "enum": [
          "invalid_row",
          "provider_not_found",
          "missing_tax_id",
          "missing_legal_name",
          "missing_zip",
          "missing_fiscal_data",
          "csd_expired",
          "missing_csd",
          "tax_system_not_allowed",
          "duplicate_tax_id",
          "name_mismatch",
          "missing_series",
          "public_general_not_allowed",
          "certificate_month_reserved",
          "missing_commission",
          "zero_commission"
        ],
        "example": "missing_csd"
      },
      "PlatformPayoutRunCreateInput": {
        "type": "object",
        "description": "The two files a run is built from. Each is read by its **extension** (the MIME type is ignored):\n`.csv` / `.txt` as comma-separated text, `.xlsx` / `.xls` / `.xlsm` as a workbook, of which only\nthe first sheet is read. The first row is the header. Headers are matched ignoring case, accents\nand repeated spaces; extra columns are ignored.\n",
        "required": [
          "movements_file",
          "commissions_file"
        ],
        "properties": {
          "movements_file": {
            "type": "string",
            "format": "binary",
            "description": "One row per payout to a provider. Max 5 MB, max 50,000 rows. Required columns:\n`ID del proveedor`, `Nombre del proveedor`, `Correo electrónico`, `RFC`, `Fecha del movimiento`\n(`YYYY-MM-DD` or `DD/MM/YYYY`), `Tipo de movimiento` (free text such as `Pago semanal` or\n`Servicio`), `Subtotal` (MXN, at least `0.01`). Also accepted: `Provider ID` or `Driver ID` for\nthe id; `Nombre del conductor`, `Razón social` or `Nombre` for the name (the more specific one\nwins when several are present); `Correo` or `Email` for the e-mail.\n"
          },
          "commissions_file": {
            "type": "string",
            "format": "binary",
            "description": "One row per provider per month with the platform commission. Max 5 MB, max 50,000 rows.\nRequired columns: the same provider columns as the movements file (`ID del proveedor`,\n`Nombre del proveedor`, `Correo electrónico`, `RFC`, with the same alternatives), `Mes`\n(`YYYY-MM`) and `Comisión` (MXN). `Comisión Total` and a few legacy export spellings are also\naccepted for the amount.\n"
          }
        }
      },
      "ApiPublicPlatformPayoutRun": {
        "type": "object",
        "description": "A platform payouts run: the files it was planned from, the plan totals, and the stamping progress.\nAmounts are MXN in pesos (not cents). Timestamps are epoch milliseconds.\n",
        "required": [
          "id",
          "status",
          "result",
          "livemode",
          "team",
          "created_at",
          "plan_ready_at",
          "confirmed_at",
          "completed_at",
          "files",
          "months",
          "total_movements",
          "included_count",
          "excluded_count",
          "planned_documents",
          "exclusion_summary",
          "exclusion_code_summary",
          "progress",
          "error"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Run id. Derived from your team, the key's mode and the `Idempotency-Key` you sent, so the\nsame key always names the same run.\n",
            "pattern": "^batchrun_[A-Za-z0-9]{6,40}$",
            "example": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c"
          },
          "status": {
            "$ref": "#/components/schemas/PlatformPayoutRunStatusEnum"
          },
          "result": {
            "$ref": "#/components/schemas/PlatformPayoutRunResultEnum"
          },
          "livemode": {
            "type": "boolean",
            "description": "Mode of the credential that created the run. A test key only ever sees test runs.",
            "example": true
          },
          "team": {
            "type": "string",
            "description": "The master team the run issues from.",
            "example": "team_1234567890"
          },
          "created_at": {
            "type": "integer",
            "format": "int64",
            "description": "When the run was created (epoch ms).",
            "example": 1788220800000
          },
          "plan_ready_at": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "When planning ended, successfully (`plan_ready`) or not (`plan_failed`). `null` while `planning`.",
            "example": 1788220804120
          },
          "confirmed_at": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "When the run was confirmed for stamping. `null` until then.",
            "example": null
          },
          "completed_at": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "When the worker finished (`completed`) or stopped the run (`failed`). `null` otherwise.",
            "example": null
          },
          "files": {
            "type": "object",
            "description": "Names of the uploaded files, as sent.",
            "required": [
              "movements",
              "commissions"
            ],
            "properties": {
              "movements": {
                "type": "string",
                "example": "movimientos-agosto-2026.csv"
              },
              "commissions": {
                "type": "string",
                "example": "comisiones-agosto-2026.xlsx"
              }
            }
          },
          "months": {
            "type": "array",
            "description": "The `YYYY-MM` months present in the movements file, ascending.",
            "items": {
              "type": "string",
              "example": "2026-08"
            }
          },
          "total_movements": {
            "type": "integer",
            "description": "Rows read from the movements file.",
            "example": 412
          },
          "included_count": {
            "type": "integer",
            "description": "Movements with at least one document to issue.",
            "example": 398
          },
          "excluded_count": {
            "type": "integer",
            "description": "Movements with nothing to issue (see `exclusion_summary`).",
            "example": 14
          },
          "planned_documents": {
            "type": "object",
            "description": "CFDIs the plan will issue, by kind. `income`: one invoice per movement, issued by the\nprovider's team to the master team. `certificate`: one retention certificate\n(Constancia de Retenciones, key 26) per movement, issued by the master team to the provider.\n`commission`: one invoice per provider-month from the commissions file, issued by the\nmaster team to the provider.\n",
            "required": [
              "income",
              "certificate",
              "commission"
            ],
            "properties": {
              "income": {
                "type": "integer",
                "example": 398
              },
              "certificate": {
                "type": "integer",
                "example": 398
              },
              "commission": {
                "type": "integer",
                "example": 57
              }
            }
          },
          "exclusion_summary": {
            "type": "object",
            "description": "Excluded movements, counted by reason, for people. Keys are the Spanish reason sentences\nshown to users (free text that may be reworded); a movement excluded for two reasons has them\njoined with ` · `. Programs should read `exclusion_code_summary` instead.\n",
            "additionalProperties": {
              "type": "integer"
            },
            "example": {
              "Sin sellos (CSD) en Gigstack": 9,
              "El proveedor no tiene cuenta en Gigstack": 5
            }
          },
          "exclusion_code_summary": {
            "type": "object",
            "description": "Excluded movements, counted by exclusion code (see `PlatformPayoutExclusionCode`), for programs. Keys\nare exclusion codes; only codes that occur are present. A movement excluded for two different\nreasons counts once under **each** of its codes, so the values can add up to more than\n`excluded_count`. `{}` on runs planned before codes existed.\n",
            "properties": {
              "invalid_row": {
                "type": "integer"
              },
              "provider_not_found": {
                "type": "integer"
              },
              "missing_tax_id": {
                "type": "integer"
              },
              "missing_legal_name": {
                "type": "integer"
              },
              "missing_zip": {
                "type": "integer"
              },
              "missing_fiscal_data": {
                "type": "integer"
              },
              "csd_expired": {
                "type": "integer"
              },
              "missing_csd": {
                "type": "integer"
              },
              "tax_system_not_allowed": {
                "type": "integer"
              },
              "duplicate_tax_id": {
                "type": "integer"
              },
              "name_mismatch": {
                "type": "integer"
              },
              "missing_series": {
                "type": "integer"
              },
              "public_general_not_allowed": {
                "type": "integer"
              },
              "certificate_month_reserved": {
                "type": "integer"
              },
              "missing_commission": {
                "type": "integer"
              },
              "zero_commission": {
                "type": "integer"
              }
            },
            "additionalProperties": {
              "type": "integer"
            },
            "example": {
              "missing_csd": 9,
              "provider_not_found": 5
            }
          },
          "progress": {
            "type": "object",
            "description": "What the worker has done so far. All zero until the run is confirmed. `stamped_count` and\n`failed_count` count **movements**; the three `*_count` document counters count comprobantes.\n",
            "required": [
              "stamped_count",
              "failed_count",
              "income_invoices_count",
              "certificates_count",
              "commission_invoices_count",
              "commission_failed_count",
              "income_invoices_amount"
            ],
            "properties": {
              "stamped_count": {
                "type": "integer",
                "description": "Movements whose planned documents were all stamped.",
                "example": 0
              },
              "failed_count": {
                "type": "integer",
                "description": "Movements with at least one document that failed for good. Does not include\ncommission invoices (see `commission_failed_count`).\n",
                "example": 0
              },
              "income_invoices_count": {
                "type": "integer",
                "description": "Income invoices stamped.",
                "example": 0
              },
              "certificates_count": {
                "type": "integer",
                "description": "Retention certificates stamped.",
                "example": 0
              },
              "commission_invoices_count": {
                "type": "integer",
                "description": "Commission invoices stamped.",
                "example": 0
              },
              "commission_failed_count": {
                "type": "integer",
                "description": "Commission invoices that failed for good. `0` on runs counted before it existed.",
                "example": 0
              },
              "income_invoices_amount": {
                "type": "number",
                "description": "Sum of the totals of the stamped income invoices, MXN.",
                "example": 0
              }
            }
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Why the plan (`plan_failed`) or the run (`failed`) failed, as a Spanish sentence for end users. `null` otherwise.",
            "example": null
          }
        }
      },
      "ApiPublicPlatformPayoutDocument": {
        "type": "object",
        "description": "The state of one comprobante a movement may produce.",
        "required": [
          "planned",
          "status",
          "reason",
          "reason_code",
          "invoice_id",
          "uuid",
          "total",
          "error",
          "error_code"
        ],
        "properties": {
          "planned": {
            "type": "boolean",
            "description": "Whether the plan issues this document.",
            "example": true
          },
          "status": {
            "type": "string",
            "description": "`planned` - waiting for (or being retried by) the worker. `skipped` - not issued (see `reason`).\n`stamped` - issued. `failed` - given up on (see `error`).\n",
            "enum": [
              "planned",
              "skipped",
              "stamped",
              "failed"
            ],
            "example": "stamped"
          },
          "reason": {
            "type": "string",
            "nullable": true,
            "description": "Why the document is not planned, in Spanish, for people. May be reworded; branch on\n`reason_code`. `null` when it is planned.\n",
            "example": null
          },
          "reason_code": {
            "type": "string",
            "nullable": true,
            "description": "Why the document is not planned, as a stable code (see `PlatformPayoutExclusionCode`). `null` when it is\nplanned, and on documents planned before codes existed.\n",
            "enum": [
              "invalid_row",
              "provider_not_found",
              "missing_tax_id",
              "missing_legal_name",
              "missing_zip",
              "missing_fiscal_data",
              "csd_expired",
              "missing_csd",
              "tax_system_not_allowed",
              "duplicate_tax_id",
              "name_mismatch",
              "missing_series",
              "public_general_not_allowed",
              "certificate_month_reserved",
              "missing_commission",
              "zero_commission",
              null
            ],
            "example": null
          },
          "invoice_id": {
            "type": "string",
            "nullable": true,
            "description": "Id of the stamped document. For `income` it is an invoice of the **provider's** team\n(`provider.team`); for `certificate` it is a retention of the master team (its UUID).\n",
            "example": "7C2E4B1A-9D3F-4E8A-B6C5-1F2A3B4C5D6E"
          },
          "uuid": {
            "type": "string",
            "nullable": true,
            "description": "SAT folio fiscal (UUID) of the stamped document.",
            "example": "7C2E4B1A-9D3F-4E8A-B6C5-1F2A3B4C5D6E"
          },
          "total": {
            "type": "number",
            "nullable": true,
            "description": "Total of the stamped income invoice, MXN. Not set for certificates.",
            "example": 1323.75
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Last stamping error, in Spanish. Can be set while `status` is still `planned` (a transient\nfailure that will be retried).\n",
            "example": null
          },
          "error_code": {
            "type": "string",
            "nullable": true,
            "description": "The stamping or PAC error code behind `error`: `interrupted_stamp` (sent to the PAC but never\nrecorded; not retried), `NETWORK_ERROR` or `HTTP_<status>` (e.g. `HTTP_503`, transient),\n`team_out_of_scope` (the provider's team is no longer one this run may issue for), or a CFDI\nerror code such as `STAMPING_ERROR` or `PAC_UNAVAILABLE`. `null` when there is no error.\n",
            "example": null
          }
        }
      },
      "ApiPublicPlatformPayoutMovement": {
        "type": "object",
        "description": "One row of the movements file and the documents it produces.",
        "required": [
          "id",
          "line",
          "status",
          "provider",
          "movement_type",
          "date",
          "month",
          "subtotal",
          "commission",
          "exclusion_reason",
          "exclusion_codes",
          "error",
          "income",
          "certificate"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Movement id, unique within the run and stable across re-uploads of the same row. Treat it as opaque.",
            "example": "P10482_2026-08-04_125000_0"
          },
          "line": {
            "type": "integer",
            "description": "Row number in the movements file, counting the header as line 1.",
            "example": 2
          },
          "status": {
            "type": "string",
            "description": "`planned` - has documents still to issue. `excluded` - nothing to issue (see `exclusion_reason`).\n`stamped` - every planned document was issued. `failed` - at least one planned document failed.\n",
            "enum": [
              "planned",
              "excluded",
              "stamped",
              "failed"
            ],
            "example": "stamped"
          },
          "provider": {
            "type": "object",
            "description": "The provider (for example a driver, courier, host or seller) the payout goes to.",
            "required": [
              "id",
              "name",
              "email",
              "tax_id",
              "team"
            ],
            "properties": {
              "id": {
                "type": "string",
                "description": "`ID del proveedor` from the file (or its alternative `Provider ID` / `Driver ID`).",
                "example": "P10482"
              },
              "name": {
                "type": "string",
                "description": "Legal name of the matched gigstack team, or the file's name when no team matched.",
                "example": "ESCUELA KEMPER URGATE"
              },
              "email": {
                "type": "string",
                "description": "E-mail from the file, lowercased.",
                "example": "proveedor@example.com"
              },
              "tax_id": {
                "type": "string",
                "description": "RFC of the matched gigstack team, or the file's RFC when no team matched.",
                "example": "EKU9003173C9"
              },
              "team": {
                "type": "string",
                "nullable": true,
                "description": "The provider's gigstack team in your billing account, matched by `ID del proveedor`\n(team `metadata.driverId`), then RFC, then e-mail. `null` when no team matched.\n",
                "example": "team_0987654321"
              }
            }
          },
          "movement_type": {
            "type": "string",
            "description": "`Tipo de movimiento` from the file.",
            "example": "Pago semanal"
          },
          "date": {
            "type": "string",
            "description": "Movement date, `YYYY-MM-DD`. Empty when the file's date could not be read.",
            "example": "2026-08-04"
          },
          "month": {
            "type": "string",
            "description": "`YYYY-MM` of `date`.",
            "example": "2026-08"
          },
          "subtotal": {
            "type": "number",
            "description": "Subtotal from the file, rounded to the cent for display (MXN).",
            "example": 1250
          },
          "commission": {
            "type": "number",
            "description": "This movement's share of the provider's monthly commission, prorated by subtotal across the provider's movements of the month (MXN).",
            "example": 96.15
          },
          "exclusion_reason": {
            "type": "string",
            "nullable": true,
            "description": "Why nothing is issued for this movement, in Spanish, for people (two reasons are joined with\n` · `). `null` unless `status` is `excluded`. Branch on `exclusion_codes` instead.\n",
            "example": null
          },
          "exclusion_codes": {
            "type": "array",
            "description": "The distinct codes behind `exclusion_reason`, one per distinct reason (at most one for the\nincome invoice and one for the certificate). Empty when the movement is not excluded, and on\nmovements planned before codes existed.\n",
            "items": {
              "$ref": "#/components/schemas/PlatformPayoutExclusionCode"
            },
            "example": []
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Last stamping error on this movement, in Spanish.",
            "example": null
          },
          "income": {
            "$ref": "#/components/schemas/ApiPublicPlatformPayoutDocument"
          },
          "certificate": {
            "$ref": "#/components/schemas/ApiPublicPlatformPayoutDocument"
          }
        }
      },
      "ApiPublicPlatformPayoutMovementsPage": {
        "type": "object",
        "required": [
          "data",
          "next",
          "has_more"
        ],
        "properties": {
          "data": {
            "type": "array",
            "description": "Movements in file order (ascending `line`).",
            "items": {
              "$ref": "#/components/schemas/ApiPublicPlatformPayoutMovement"
            }
          },
          "next": {
            "type": "string",
            "nullable": true,
            "description": "Opaque cursor; send it back as `next` to get the following page. `null` on the last page.",
            "example": "51"
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether another page follows.",
            "example": true
          }
        }
      },
      "ApiPublicPlatformPayoutRunConfirmation": {
        "type": "object",
        "required": [
          "id",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c"
          },
          "status": {
            "type": "string",
            "description": "`stamping` after a successful confirm; a repeated confirm returns the current status (`stamping` or `completed`).",
            "enum": [
              "stamping",
              "completed"
            ],
            "example": "stamping"
          }
        }
      },
      "InvoiceBatchCreateInput": {
        "type": "object",
        "description": "Up to 1,000 income invoices. Each item is **exactly** the body of `POST /invoices/income`, and must carry\nits own `idempotency_key`, unique within the batch.\n\nItems are validated one by one: an invalid item is listed in the batch's `rejected` and the others go\nahead. Only a body without a non-empty `invoices` array (`invalid_body`) or with more than 1,000 items\n(`too_many_items`) refuses the whole request.\n\n`livemode`, `team` and `owner` in an item are ignored (they come from the credential), and so is\n`return_files`: a batch does not return files. Keep the whole JSON body under 10 MB.\n",
        "required": [
          "invoices"
        ],
        "properties": {
          "invoices": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "description": "The invoices, in the order you want them reported. An item's `index` is its position here (from 0).",
            "items": {
              "$ref": "#/components/schemas/InvoiceBatchItemInput"
            }
          }
        }
      },
      "InvoiceBatchItemInput": {
        "description": "One invoice of a batch. The body of `POST /invoices/income`, with `idempotency_key` required.",
        "allOf": [
          {
            "$ref": "#/components/schemas/InvoiceIncomeInput"
          },
          {
            "type": "object",
            "required": [
              "idempotency_key"
            ],
            "properties": {
              "idempotency_key": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Your identifier for this invoice (for example your order id), unique within the batch.\nSurrounding spaces are trimmed. It is the same key as on `POST /invoices/income`, so an\ninvoice already issued under it, by an earlier batch or a single call, is not issued\nagain: the item ends `duplicate`.\n",
                "example": "order-2026-09-000123"
              }
            }
          }
        ]
      },
      "InvoiceBatchStatusEnum": {
        "type": "string",
        "description": "- `processing`: some accepted items are still queued.\n- `completed`: every accepted item has a final status. Read `result` to know how it went.\n",
        "enum": [
          "processing",
          "completed"
        ],
        "example": "processing"
      },
      "InvoiceBatchResultEnum": {
        "type": "string",
        "nullable": true,
        "description": "How a finished batch turned out. `null` while `status` is `processing`.\n\n- `completed`: every item was issued (`stamped`, or `duplicate` because it had been issued before), and\n  nothing was rejected.\n- `partially_completed`: at least one item was issued, and at least one was not (`failed`,\n  `needs_review` or rejected up front).\n- `failed`: no item was issued.\n",
        "enum": [
          "completed",
          "partially_completed",
          "failed",
          null
        ],
        "example": "partially_completed"
      },
      "InvoiceBatchCounts": {
        "type": "object",
        "description": "Accepted items by status. `queued` is what is still in flight, so it reaches `0` when the batch completes.\nThe five counts add up to `accepted`; rejected items are not counted here.\n",
        "required": [
          "queued",
          "stamped",
          "failed",
          "duplicate",
          "needs_review"
        ],
        "properties": {
          "queued": {
            "type": "integer",
            "description": "Waiting for, or in, a stamping attempt.",
            "example": 0
          },
          "stamped": {
            "type": "integer",
            "description": "Stamped by this batch.",
            "example": 245
          },
          "failed": {
            "type": "integer",
            "description": "Ended without an invoice. See each item's `error`.",
            "example": 2
          },
          "duplicate": {
            "type": "integer",
            "description": "Already issued under the same `idempotency_key` before; not issued again.",
            "example": 1
          },
          "needs_review": {
            "type": "integer",
            "description": "The PAC could not confirm whether the invoice was stamped. gigstack support resolves these.",
            "example": 0
          }
        }
      },
      "InvoiceBatchError": {
        "type": "object",
        "description": "Why an item was rejected or did not produce an invoice.",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Machine-readable reason. See the operation descriptions for the possible values.",
            "example": "CFDI40147"
          },
          "message": {
            "type": "string",
            "description": "Human-readable reason, at most 500 characters. Stamping errors are in Spanish, as on `POST /invoices/income`.",
            "example": "Error al timbrar la factura: El campo UsoCFDI no es válido"
          }
        }
      },
      "InvoiceBatchRejectedItem": {
        "type": "object",
        "description": "An item refused by validation when the batch was created. Nothing was stamped or charged for it.",
        "required": [
          "index",
          "idempotency_key",
          "error"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "description": "Position of the item in `invoices` (from 0).",
            "example": 17
          },
          "idempotency_key": {
            "type": "string",
            "nullable": true,
            "description": "The item's key, trimmed. `null` when the item was not an object or had no key.",
            "example": "order-2026-09-000140"
          },
          "error": {
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceBatchError"
              }
            ],
            "description": "`code` is one of:\n\n- `invalid_item`: the item is not a JSON object.\n- `idempotency_key_required`: no `idempotency_key`, or an empty one.\n- `invalid_idempotency_key`: the key is longer than 256 characters.\n- `duplicate_idempotency_key`: an earlier item of this batch has the same key (the message names its index).\n- `invalid_body`: the item fails the `POST /invoices/income` body validation; the message lists\n  each `path: message`.\n"
          }
        }
      },
      "ApiPublicInvoiceBatch": {
        "type": "object",
        "description": "An income invoice batch: how many invoices it received, which were rejected up front, and the progress of\nthe rest. Timestamps are epoch milliseconds.\n",
        "required": [
          "id",
          "object",
          "type",
          "livemode",
          "status",
          "result",
          "total",
          "accepted",
          "rejected",
          "counts",
          "created_at",
          "completed_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Batch id. Derived from your team, the credential's mode and the `Idempotency-Key` you sent, so the\nsame key always names the same batch.\n",
            "pattern": "^ibatch_[0-9a-f]{32}$",
            "example": "ibatch_5d41402abc4b2a76b9719d911017c592"
          },
          "object": {
            "type": "string",
            "enum": [
              "invoice_batch"
            ],
            "example": "invoice_batch"
          },
          "type": {
            "type": "string",
            "description": "Kind of document the batch issues. Only `income` exists.",
            "enum": [
              "income"
            ],
            "example": "income"
          },
          "livemode": {
            "type": "boolean",
            "description": "Mode of the credential that created the batch. A test key only ever sees test batches.",
            "example": true
          },
          "status": {
            "$ref": "#/components/schemas/InvoiceBatchStatusEnum"
          },
          "result": {
            "$ref": "#/components/schemas/InvoiceBatchResultEnum"
          },
          "total": {
            "type": "integer",
            "description": "Invoices in the request.",
            "example": 250
          },
          "accepted": {
            "type": "integer",
            "description": "Invoices that passed validation and are processed.",
            "example": 248
          },
          "rejected": {
            "type": "array",
            "description": "Invoices refused by validation, in request order. Empty when every item was accepted.",
            "items": {
              "$ref": "#/components/schemas/InvoiceBatchRejectedItem"
            }
          },
          "counts": {
            "$ref": "#/components/schemas/InvoiceBatchCounts"
          },
          "created_at": {
            "type": "integer",
            "format": "int64",
            "description": "When the batch was created (epoch ms).",
            "example": 1790780400000
          },
          "completed_at": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "When the last item reached a final status (epoch ms). `null` while `processing`.",
            "example": 1790784000000
          }
        }
      },
      "InvoiceBatchItemStatusEnum": {
        "type": "string",
        "description": "- `queued`: waiting for, or in, a stamping attempt. An attempt that failed for a temporary reason (PAC\n  unavailable, its answer lost) keeps the item `queued` and is retried, up to 6 attempts.\n- `stamped`: the invoice was issued by this batch. `uuid` and `invoice_id` are set.\n- `failed`: no invoice was issued. `error` says why.\n- `duplicate`: an invoice already existed under this `idempotency_key` (an earlier batch, a single\n  `POST /invoices/income`, or a redelivery of this item). `uuid` names it; nothing was issued or charged again.\n- `needs_review`: the PAC could not confirm whether the invoice was stamped. It is never retried\n  automatically, so it cannot be issued twice; contact support with the batch id and `index`.\n",
        "enum": [
          "queued",
          "stamped",
          "failed",
          "duplicate",
          "needs_review"
        ],
        "example": "stamped"
      },
      "ApiPublicInvoiceBatchItem": {
        "type": "object",
        "description": "One accepted invoice of a batch. Rejected items are not listed here; they are in the batch's `rejected`.",
        "required": [
          "index",
          "idempotency_key",
          "status",
          "invoice_id",
          "uuid",
          "error",
          "attempts"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "description": "Position of the item in the request's `invoices` (from 0).",
            "example": 0
          },
          "idempotency_key": {
            "type": "string",
            "description": "The item's `idempotency_key`, trimmed.",
            "example": "order-2026-09-000123"
          },
          "status": {
            "$ref": "#/components/schemas/InvoiceBatchItemStatusEnum"
          },
          "invoice_id": {
            "type": "string",
            "nullable": true,
            "description": "Id of the invoice, for `GET /invoices/income/{id}`. Set for `stamped` and `duplicate`.",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          },
          "uuid": {
            "type": "string",
            "nullable": true,
            "description": "Folio fiscal (UUID) of the CFDI. Set for `stamped` and `duplicate`.",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          },
          "error": {
            "anyOf": [
              {
                "description": "Why the item has no invoice. Set only for `failed` and `needs_review`; `null` otherwise, including\nwhile a `queued` item waits to retry. `code` is either what `POST /invoices/income` would have\nanswered for the same body (a SAT/PAC code such as `CFDI40147`, `SAT_NOT_CONNECTED`,\n`CSD_VALIDATION_ERROR`, `PAC_UNAVAILABLE`, `PAC_OUTCOME_UNKNOWN`, `STAMP_NEEDS_REVIEW`, …), or one\nof the batch's own:\n\n- `credential_revoked`: the API key that created the batch was revoked or disabled before this\n  item ran. Remaining items fail the same way.\n- `credential_expired`: the API key that created the batch reached its expiry before this item\n  ran. Remaining items fail the same way.\n- `credential_scope_changed`: the API key that created the batch no longer covers its team,\n  account, mode or action. Remaining items fail the same way.\n- `credit_limit_reached`: the team's credit limit was reached.\n- `http_<status>`: the invoice endpoint answered that status without a code (for example\n  `http_404` for a client or service id that does not exist).\n- `auth_unavailable`, `internal_error`, `idempotency_in_progress`: a temporary failure that\n  persisted through every attempt.\n",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/InvoiceBatchError"
                  }
                ]
              },
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ]
          },
          "attempts": {
            "type": "integer",
            "description": "Stamping attempts made for this item so far.",
            "example": 1
          }
        }
      },
      "ApiPublicInvoiceBatchItemsPage": {
        "type": "object",
        "required": [
          "data",
          "next",
          "has_more"
        ],
        "properties": {
          "data": {
            "type": "array",
            "description": "Items in request order (ascending `index`).",
            "items": {
              "$ref": "#/components/schemas/ApiPublicInvoiceBatchItem"
            }
          },
          "next": {
            "type": "string",
            "nullable": true,
            "description": "Cursor; send it back as `next` to get the following page. `null` on the last page.",
            "example": "99"
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether another page follows.",
            "example": true
          }
        }
      },
      "PaymentBatchCreateInput": {
        "type": "object",
        "description": "Up to 10,000 payments to register. Each item is **exactly** the body of `POST /payments/register`, and\nmust carry its own `idempotency_key`, unique within the batch.\n\nItems are validated one by one: an invalid item is listed in the batch's `rejected` and the others go\nahead. Only a body without a non-empty `payments` array (`invalid_body`) or with more than 10,000 items\n(`too_many_items`) refuses the whole request.\n\n`livemode`, `team` and `owner` in an item are ignored (they come from the credential). `transfer_data`\n(a split payment) is not accepted in a batch: the item is rejected with `transfer_data_not_supported`.\nKeep the whole JSON body under 20 MB.\n",
        "required": [
          "payments"
        ],
        "properties": {
          "payments": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10000,
            "description": "The payments, in the order you want them reported. An item's `index` is its position here (from 0).",
            "items": {
              "$ref": "#/components/schemas/PaymentBatchItemInput"
            }
          }
        }
      },
      "PaymentBatchItemInput": {
        "description": "One payment of a batch. The body of `POST /payments/register`, with `idempotency_key` required.",
        "allOf": [
          {
            "$ref": "#/components/schemas/RegisterPaymentInput"
          },
          {
            "type": "object",
            "required": [
              "idempotency_key"
            ],
            "properties": {
              "idempotency_key": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Your identifier for this payment (for example your order or transaction id), unique\nwithin the batch. Surrounding spaces are trimmed. It is the same key as on\n`POST /payments/register`, so a payment already registered under it, by an earlier batch\nor a single call, is not registered again: the item ends `duplicate`.\n",
                "example": "txn-2026-10-000123"
              }
            }
          }
        ]
      },
      "PaymentBatchCounts": {
        "type": "object",
        "description": "Accepted items by status. `queued` is what is still in flight, so it reaches `0` when the batch completes.\nThe four counts add up to `accepted`; rejected items are not counted here.\n",
        "required": [
          "queued",
          "registered",
          "failed",
          "duplicate"
        ],
        "properties": {
          "queued": {
            "type": "integer",
            "description": "Waiting for, or in, a registration attempt.",
            "example": 0
          },
          "registered": {
            "type": "integer",
            "description": "Registered by this batch.",
            "example": 117
          },
          "failed": {
            "type": "integer",
            "description": "Ended without a payment. See each item's `error`.",
            "example": 1
          },
          "duplicate": {
            "type": "integer",
            "description": "Already registered under the same `idempotency_key` before; not registered again.",
            "example": 1
          }
        }
      },
      "ApiPublicPaymentBatch": {
        "type": "object",
        "description": "A payment batch: how many payments it received, which were rejected up front, and the progress of the\nrest. Timestamps are epoch milliseconds.\n",
        "required": [
          "id",
          "object",
          "livemode",
          "status",
          "result",
          "total",
          "accepted",
          "rejected",
          "counts",
          "created_at",
          "completed_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Batch id. Derived from your team, the credential's mode and the `Idempotency-Key` you sent, so the\nsame key always names the same batch. An invoice batch created under the same key has a\ndifferent id (`ibatch_…`).\n",
            "pattern": "^pbatch_[0-9a-f]{32}$",
            "example": "pbatch_7f3a9c1e5b2d4f6a8c0e2a4b6d8f0a1c"
          },
          "object": {
            "type": "string",
            "enum": [
              "payment_batch"
            ],
            "example": "payment_batch"
          },
          "livemode": {
            "type": "boolean",
            "description": "Mode of the credential that created the batch. A test key only ever sees test batches.",
            "example": true
          },
          "status": {
            "$ref": "#/components/schemas/InvoiceBatchStatusEnum"
          },
          "result": {
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceBatchResultEnum"
              }
            ],
            "description": "How a finished batch turned out. `null` while `status` is `processing`. `completed`: every item\nwas registered (`registered`, or `duplicate` because it had been registered before) and nothing\nwas rejected. `partially_completed`: at least one item was registered and at least one was not.\n`failed`: no item was registered.\n"
          },
          "total": {
            "type": "integer",
            "description": "Payments in the request.",
            "example": 120
          },
          "accepted": {
            "type": "integer",
            "description": "Payments that passed validation and are processed.",
            "example": 119
          },
          "rejected": {
            "type": "array",
            "description": "Payments refused by validation, in request order. Empty when every item was accepted. `error.code`\nis one of the invoice batch's (`invalid_item`, `idempotency_key_required`,\n`invalid_idempotency_key`, `duplicate_idempotency_key`, `invalid_body`, the last against the\n`POST /payments/register` body) or `transfer_data_not_supported`.\n",
            "items": {
              "$ref": "#/components/schemas/InvoiceBatchRejectedItem"
            }
          },
          "counts": {
            "$ref": "#/components/schemas/PaymentBatchCounts"
          },
          "created_at": {
            "type": "integer",
            "format": "int64",
            "description": "When the batch was created (epoch ms).",
            "example": 1790780400000
          },
          "completed_at": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "When the last item reached a final status (epoch ms). `null` while `processing`.",
            "example": 1790784000000
          }
        }
      },
      "PaymentBatchItemStatusEnum": {
        "type": "string",
        "description": "- `queued`: waiting for, or in, a registration attempt. An attempt that failed for a temporary reason\n  (another request holding the client, an internal error) keeps the item `queued` and is retried, up\n  to 6 attempts.\n- `registered`: the payment was registered by this batch. `payment_id` is set.\n- `failed`: no payment was registered. `error` says why.\n- `duplicate`: a payment already existed under this `idempotency_key` (an earlier batch, a single\n  `POST /payments/register`, or a redelivery of this item). `payment_id` names it; nothing was\n  registered again.\n",
        "enum": [
          "queued",
          "registered",
          "failed",
          "duplicate"
        ],
        "example": "registered"
      },
      "ApiPublicPaymentBatchItem": {
        "type": "object",
        "description": "One accepted payment of a batch. Rejected items are not listed here; they are in the batch's `rejected`.",
        "required": [
          "index",
          "idempotency_key",
          "status",
          "payment_id",
          "error",
          "attempts"
        ],
        "properties": {
          "index": {
            "type": "integer",
            "description": "Position of the item in the request's `payments` (from 0).",
            "example": 0
          },
          "idempotency_key": {
            "type": "string",
            "description": "The item's `idempotency_key`, trimmed.",
            "example": "txn-2026-10-000123"
          },
          "status": {
            "$ref": "#/components/schemas/PaymentBatchItemStatusEnum"
          },
          "payment_id": {
            "type": "string",
            "nullable": true,
            "description": "Id of the payment, for `GET /payments/{id}`. Set for `registered` and `duplicate`.",
            "example": "payment_a1b2c3d4e5"
          },
          "error": {
            "anyOf": [
              {
                "description": "Why the item has no payment. Set only for `failed`; `null` otherwise, including while a\n`queued` item waits to retry. `code` is either what `POST /payments/register` would have\nanswered for the same body (`invalid_request_body`, `validation_failed` for a client or\nservice that does not resolve, …), or one of the batch's own:\n\n- `credential_revoked`, `credential_expired`, `credential_scope_changed`: the API key that\n  created the batch is no longer valid for it. Remaining items fail the same way.\n- `http_<status>`: the payment endpoint answered that status without a code.\n- `auth_unavailable`, `internal_error`, `resource_conflict`: a temporary failure that\n  persisted through every attempt.\n",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/InvoiceBatchError"
                  }
                ]
              },
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ]
          },
          "attempts": {
            "type": "integer",
            "description": "Registration attempts made for this item so far.",
            "example": 1
          }
        }
      },
      "ApiPublicPaymentBatchItemsPage": {
        "type": "object",
        "required": [
          "data",
          "next",
          "has_more"
        ],
        "properties": {
          "data": {
            "type": "array",
            "description": "Items in request order (ascending `index`).",
            "items": {
              "$ref": "#/components/schemas/ApiPublicPaymentBatchItem"
            }
          },
          "next": {
            "type": "string",
            "nullable": true,
            "description": "Cursor; send it back as `next` to get the following page. `null` on the last page.",
            "example": "99"
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether another page follows.",
            "example": true
          }
        }
      },
      "IdempotencyInProgressResponse": {
        "type": "object",
        "description": "Raw `409` body of `POST /invoices/income` when another request with the same `idempotency_key` is being\nprocessed. Not the standardized envelope. Retry later with the same key.\n",
        "required": [
          "message",
          "error",
          "retryable"
        ],
        "properties": {
          "message": {
            "type": "string",
            "example": "An invoice with this idempotency_key is already being created"
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "idempotency_in_progress"
                ],
                "example": "idempotency_in_progress"
              },
              "message": {
                "type": "string",
                "example": "An invoice with this idempotency_key is already being created; retry later"
              }
            }
          },
          "retryable": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true
          }
        }
      },
      "EmbeddedClientInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "search": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "on_key",
              "on_value"
            ],
            "properties": {
              "on_key": {
                "type": "string"
              },
              "on_value": {
                "type": "string"
              },
              "auto_create": {
                "type": "boolean",
                "nullable": true
              },
              "safety_check": {
                "type": "boolean",
                "nullable": true
              },
              "update": {
                "type": "boolean",
                "nullable": true
              }
            },
            "nullable": true
          },
          "address": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "country": {
                "type": "string",
                "nullable": true,
                "maxLength": 3
              },
              "street": {
                "type": "string",
                "nullable": true
              },
              "zip": {
                "type": "string",
                "nullable": true
              },
              "city": {
                "type": "string",
                "nullable": true
              },
              "state": {
                "type": "string",
                "nullable": true
              },
              "exterior": {
                "type": "string",
                "nullable": true
              },
              "interior": {
                "type": "string",
                "nullable": true
              },
              "municipality": {
                "type": "string",
                "nullable": true
              },
              "neighborhood": {
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "company": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "properties": {}
          },
          "legal_name": {
            "type": "string",
            "nullable": true
          },
          "tax_id": {
            "type": "string",
            "nullable": true
          },
          "use": {
            "type": "string",
            "nullable": true
          },
          "tax_system": {
            "type": "string",
            "nullable": true
          },
          "document_type": {
            "description": "DIAN identification document code",
            "type": "string",
            "enum": [
              "",
              "11",
              "12",
              "13",
              "21",
              "22",
              "31",
              "41",
              "42",
              "47",
              "48",
              "50",
              "91",
              null
            ],
            "nullable": true
          },
          "organization_type": {
            "description": "1 = persona jurídica, 2 = persona natural",
            "oneOf": [
              {
                "type": "string",
                "enum": [
                  "",
                  "1",
                  "2",
                  null
                ],
                "nullable": true
              },
              {
                "type": "number",
                "enum": [
                  1,
                  2
                ]
              }
            ]
          },
          "tribute_code": {
            "description": "'01' = responsable de IVA, 'ZZ' = no aplica",
            "type": "string",
            "enum": [
              "",
              "01",
              "ZZ",
              null
            ],
            "nullable": true
          },
          "fiscal_responsibilities": {
            "description": "DIAN responsabilidades fiscales (lista 53). Omitted means 'R-99-PN' (no responsable)",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "O-13",
                "O-15",
                "O-23",
                "O-47",
                "R-99-PN"
              ]
            },
            "nullable": true
          },
          "dv": {
            "description": "NIT verification digit",
            "type": "string",
            "nullable": true,
            "pattern": "^[0-9]?$"
          },
          "municipality_code": {
            "description": "DANE municipality code, only for clients domiciled in Colombia",
            "type": "string",
            "nullable": true,
            "pattern": "^([0-9]{5})?$"
          }
        }
      },
      "ClientUpdateInput": {
        "description": "Update body for `PUT /v2/clients/{id}`. An omitted `name` is preserved from the\nexisting client before validation. Send only the profile fields you intend\nto change; creation uses the separate `ClientInput` schema.\n\nUnknown top-level keys are rejected (`400 validation_failed` / `unexpected_key`);\n`metadata` is the one object that accepts arbitrary keys. `team`, `livemode` and\n`owner` are reserved and injected by the auth middleware.\n\nThe `document_type`, `organization_type`, `tribute_code`, `fiscal_responsibilities`,\n`dv` and `municipality_code`\nfields are the Colombian DIAN identification set. They are accepted for every team\nregardless of country; each also accepts the empty string, which means \"not set\" and is\ndropped before the client is stored.\n",
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "search": {
            "description": "Search for an existing client before creating. If a match is found, the existing client is returned (or updated if `update: true`).\nThis enables upsert-like behavior to avoid duplicate clients.\n",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "on_key",
              "on_value"
            ],
            "properties": {
              "on_key": {
                "description": "The field to search on (e.g., 'tax_id', 'email', 'name')",
                "example": "tax_id",
                "type": "string"
              },
              "on_value": {
                "description": "The value to match against the specified field",
                "example": "PEGJ800101ABC",
                "type": "string"
              },
              "auto_create": {
                "type": "boolean",
                "nullable": true
              },
              "safety_check": {
                "type": "boolean",
                "nullable": true
              },
              "update": {
                "description": "If true and a match is found, update the existing client with the provided data. If false, return the existing client without modifications.",
                "example": false,
                "type": "boolean",
                "nullable": true
              }
            },
            "nullable": true
          },
          "address": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "country": {
                "example": "MEX",
                "type": "string",
                "nullable": true,
                "maxLength": 3
              },
              "street": {
                "example": "Av. Insurgentes Sur",
                "type": "string",
                "nullable": true
              },
              "zip": {
                "example": "03100",
                "type": "string",
                "nullable": true
              },
              "city": {
                "example": "Ciudad de México",
                "type": "string",
                "nullable": true
              },
              "state": {
                "example": "CDMX",
                "type": "string",
                "nullable": true
              },
              "exterior": {
                "example": "123",
                "type": "string",
                "nullable": true
              },
              "interior": {
                "example": "4B",
                "type": "string",
                "nullable": true
              },
              "municipality": {
                "example": "Benito Juárez",
                "type": "string",
                "nullable": true
              },
              "neighborhood": {
                "example": "Del Valle",
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "name": {
            "example": "Juan Pérez García",
            "type": "string"
          },
          "company": {
            "example": "Empresa SA de CV",
            "type": "string",
            "nullable": true
          },
          "phone": {
            "example": "+52 55 1234 5678",
            "type": "string",
            "nullable": true
          },
          "email": {
            "example": "juan.perez@ejemplo.com",
            "type": "string",
            "nullable": true,
            "format": "email"
          },
          "bcc": {
            "example": [
              "admin@empresa.com"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "metadata": {
            "example": {
              "custom_field": "value"
            },
            "type": "object",
            "additionalProperties": true,
            "properties": {}
          },
          "legal_name": {
            "example": "Juan Pérez García",
            "type": "string",
            "nullable": true
          },
          "tax_id": {
            "example": "PEGJ800101ABC",
            "type": "string",
            "nullable": true
          },
          "use": {
            "example": "G03",
            "type": "string",
            "nullable": true
          },
          "tax_system": {
            "example": "601",
            "type": "string",
            "nullable": true
          },
          "defaults": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "keep_full_legal_name": {
                "example": false,
                "type": "boolean"
              },
              "issue_automatic_invoices": {
                "example": false,
                "type": "boolean"
              },
              "issue_invoiceable_receipts": {
                "example": true,
                "type": "boolean"
              }
            }
          },
          "document_type": {
            "description": "**Colombia (DIAN).** Identification document code.\n`11` registro civil, `12` tarjeta de identidad, `13` cédula de ciudadanía,\n`21` tarjeta de extranjería, `22` cédula de extranjería, `31` NIT,\n`41` pasaporte, `42` documento de identificación extranjero,\n`47` PEP, `48` PPT, `50` NIT de otro país, `91` NUIP.\nThe empty string means \"not set\" and is dropped before the client is stored.\n",
            "example": "31",
            "type": "string",
            "enum": [
              "",
              "11",
              "12",
              "13",
              "21",
              "22",
              "31",
              "41",
              "42",
              "47",
              "48",
              "50",
              "91",
              null
            ],
            "nullable": true
          },
          "organization_type": {
            "description": "**Colombia (DIAN).** `1` = persona jurídica, `2` = persona natural.\nAccepted as either a number (`1`, `2`) or a string (`\"1\"`, `\"2\"`).\nThe empty string means \"not set\".\n",
            "example": "2",
            "oneOf": [
              {
                "type": "string",
                "enum": [
                  "",
                  "1",
                  "2",
                  null
                ],
                "nullable": true
              },
              {
                "type": "number",
                "enum": [
                  1,
                  2
                ]
              }
            ]
          },
          "tribute_code": {
            "description": "**Colombia (DIAN).** `01` = responsable de IVA, `ZZ` = no aplica.\nThe empty string means \"not set\".\n",
            "example": "01",
            "type": "string",
            "enum": [
              "",
              "01",
              "ZZ",
              null
            ],
            "nullable": true
          },
          "fiscal_responsibilities": {
            "description": "**Colombia (DIAN).** Responsabilidades fiscales del cliente (lista 53).\n`O-13` gran contribuyente, `O-15` autorretenedor,\n`O-23` agente de retención de IVA, `O-47` régimen simple de tributación,\n`R-99-PN` no responsable.\nOmit the field (or send an empty array) to leave it unset — the client is\nthen reported as `R-99-PN`, which is also the value that applies when the\narray carries only that code. `R-99-PN` excludes every `O-*` code: if both\nare sent, only the `O-*` ones are reported.\n",
            "example": [
              "O-15",
              "O-23"
            ],
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "O-13",
                "O-15",
                "O-23",
                "O-47",
                "R-99-PN"
              ]
            },
            "nullable": true
          },
          "dv": {
            "description": "**Colombia (DIAN).** NIT verification digit — a single digit, or the empty\nstring for \"not set\".\n",
            "example": "7",
            "type": "string",
            "nullable": true,
            "pattern": "^[0-9]?$"
          },
          "municipality_code": {
            "description": "**Colombia (DIAN).** DANE municipality code — exactly five digits, or the empty\nstring for \"not set\". Only meaningful for clients domiciled in Colombia.\n",
            "example": "05001",
            "type": "string",
            "nullable": true,
            "pattern": "^([0-9]{5})?$"
          },
          "check_pending_receipts": {
            "description": "Only applies to `PUT /clients/{id}`. When `true` (default) and the updated client passes fiscal validation, all of the client's pending receipts are automatically invoiced using the new client data. Set to `false` to skip this behavior.\n",
            "example": true,
            "default": true,
            "type": "boolean"
          }
        }
      },
      "JourneyInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 1000
          },
          "graph": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "nodes",
              "edges"
            ],
            "properties": {
              "nodes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "type",
                    "position",
                    "data"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "type": {
                      "type": "string",
                      "minLength": 1
                    },
                    "position": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "x",
                        "y"
                      ],
                      "properties": {
                        "x": {
                          "type": "number"
                        },
                        "y": {
                          "type": "number"
                        }
                      }
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "config": {
                          "type": "object",
                          "additionalProperties": true,
                          "properties": {},
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              },
              "edges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "source",
                    "target"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "source": {
                      "type": "string",
                      "minLength": 1
                    },
                    "target": {
                      "type": "string",
                      "minLength": 1
                    },
                    "sourceHandle": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              },
              "viewport": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "x",
                  "y",
                  "zoom"
                ],
                "properties": {
                  "x": {
                    "type": "number"
                  },
                  "y": {
                    "type": "number"
                  },
                  "zoom": {
                    "type": "number"
                  }
                },
                "nullable": true
              }
            },
            "nullable": true
          },
          "triggerType": {
            "type": "string",
            "nullable": true
          },
          "replacesDefaults": {
            "type": "boolean",
            "nullable": true
          }
        }
      },
      "JourneyUpdateInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 1000
          },
          "graph": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "nodes",
              "edges"
            ],
            "properties": {
              "nodes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "type",
                    "position",
                    "data"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "type": {
                      "type": "string",
                      "minLength": 1
                    },
                    "position": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "x",
                        "y"
                      ],
                      "properties": {
                        "x": {
                          "type": "number"
                        },
                        "y": {
                          "type": "number"
                        }
                      }
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "config": {
                          "type": "object",
                          "additionalProperties": true,
                          "properties": {},
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              },
              "edges": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "source",
                    "target"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "source": {
                      "type": "string",
                      "minLength": 1
                    },
                    "target": {
                      "type": "string",
                      "minLength": 1
                    },
                    "sourceHandle": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              },
              "viewport": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "x",
                  "y",
                  "zoom"
                ],
                "properties": {
                  "x": {
                    "type": "number"
                  },
                  "y": {
                    "type": "number"
                  },
                  "zoom": {
                    "type": "number"
                  }
                },
                "nullable": true
              }
            },
            "nullable": true
          },
          "triggerType": {
            "type": "string",
            "nullable": true
          },
          "replacesDefaults": {
            "type": "boolean",
            "nullable": true
          }
        }
      },
      "JourneyGraph": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "nodes",
          "edges"
        ],
        "properties": {
          "nodes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "type",
                "position",
                "data"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "type": {
                  "type": "string",
                  "minLength": 1
                },
                "position": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "x",
                    "y"
                  ],
                  "properties": {
                    "x": {
                      "type": "number"
                    },
                    "y": {
                      "type": "number"
                    }
                  }
                },
                "data": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "config": {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {},
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "edges": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "source",
                "target"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "source": {
                  "type": "string",
                  "minLength": 1
                },
                "target": {
                  "type": "string",
                  "minLength": 1
                },
                "sourceHandle": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "viewport": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "x",
              "y",
              "zoom"
            ],
            "properties": {
              "x": {
                "type": "number"
              },
              "y": {
                "type": "number"
              },
              "zoom": {
                "type": "number"
              }
            },
            "nullable": true
          }
        }
      },
      "JourneyCloneInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "targetLivemode": {
            "type": "boolean",
            "nullable": true,
            "description": "Mode of the copy; defaults to the source mode. Clones are drafts. The source must belong to the authenticated team and request mode."
          },
          "name": {
            "type": "string",
            "nullable": true,
            "minLength": 1,
            "maxLength": 150
          }
        }
      },
      "JourneyTestInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source_collection"
        ],
        "properties": {
          "source_collection": {
            "type": "string",
            "enum": [
              "payments",
              "invoices",
              "receipts",
              "clients",
              "teams"
            ]
          },
          "source_id": {
            "type": "string",
            "minLength": 1
          },
          "source_snapshot": {
            "type": "object",
            "additionalProperties": true,
            "properties": {}
          }
        },
        "description": "Exactly one of source_id or source_snapshot is required. The handler queues a dry-run; read the resulting run to learn the outcome."
      },
      "JourneyGroupInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "journeys"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 1000
          },
          "sourcePrompt": {
            "type": "string",
            "nullable": true,
            "maxLength": 5000
          },
          "builderSessionId": {
            "type": "string",
            "nullable": true,
            "maxLength": 80
          },
          "createdFrom": {
            "type": "string",
            "enum": [
              "ai",
              "manual",
              null
            ],
            "nullable": true
          },
          "journeys": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "name",
                "graph"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 150
                },
                "description": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 1000
                },
                "graph": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "nodes",
                    "edges"
                  ],
                  "properties": {
                    "nodes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "id",
                          "type",
                          "position",
                          "data"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1
                          },
                          "type": {
                            "type": "string",
                            "minLength": 1
                          },
                          "position": {
                            "type": "object",
                            "additionalProperties": false,
                            "required": [
                              "x",
                              "y"
                            ],
                            "properties": {
                              "x": {
                                "type": "number"
                              },
                              "y": {
                                "type": "number"
                              }
                            }
                          },
                          "data": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "config": {
                                "type": "object",
                                "additionalProperties": true,
                                "properties": {},
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    },
                    "edges": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "id",
                          "source",
                          "target"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1
                          },
                          "source": {
                            "type": "string",
                            "minLength": 1
                          },
                          "target": {
                            "type": "string",
                            "minLength": 1
                          },
                          "sourceHandle": {
                            "type": "string",
                            "nullable": true
                          }
                        }
                      }
                    },
                    "viewport": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "x",
                        "y",
                        "zoom"
                      ],
                      "properties": {
                        "x": {
                          "type": "number"
                        },
                        "y": {
                          "type": "number"
                        },
                        "zoom": {
                          "type": "number"
                        }
                      },
                      "nullable": true
                    }
                  }
                }
              }
            },
            "minItems": 1,
            "maxItems": 10
          }
        }
      },
      "JourneyGroupUpdateInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "journeys"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 1000
          },
          "editPrompt": {
            "type": "string",
            "nullable": true,
            "maxLength": 5000
          },
          "builderSessionId": {
            "type": "string",
            "nullable": true,
            "maxLength": 80
          },
          "editedFrom": {
            "type": "string",
            "enum": [
              "ai",
              "manual",
              null
            ],
            "nullable": true
          },
          "expectedLastUpdated": {
            "type": "number",
            "nullable": true,
            "description": "Copy last_updated from a fresh GET of the group. Required unless the group has no journeys; a stale token returns 409 group_changed."
          },
          "journeys": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "name",
                "graph"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "nullable": true,
                  "minLength": 1,
                  "maxLength": 60
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 150
                },
                "description": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 1000
                },
                "graph": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "nodes",
                    "edges"
                  ],
                  "properties": {
                    "nodes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "id",
                          "type",
                          "position",
                          "data"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1
                          },
                          "type": {
                            "type": "string",
                            "minLength": 1
                          },
                          "position": {
                            "type": "object",
                            "additionalProperties": false,
                            "required": [
                              "x",
                              "y"
                            ],
                            "properties": {
                              "x": {
                                "type": "number"
                              },
                              "y": {
                                "type": "number"
                              }
                            }
                          },
                          "data": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "config": {
                                "type": "object",
                                "additionalProperties": true,
                                "properties": {},
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    },
                    "edges": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "id",
                          "source",
                          "target"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1
                          },
                          "source": {
                            "type": "string",
                            "minLength": 1
                          },
                          "target": {
                            "type": "string",
                            "minLength": 1
                          },
                          "sourceHandle": {
                            "type": "string",
                            "nullable": true
                          }
                        }
                      }
                    },
                    "viewport": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "x",
                        "y",
                        "zoom"
                      ],
                      "properties": {
                        "x": {
                          "type": "number"
                        },
                        "y": {
                          "type": "number"
                        },
                        "zoom": {
                          "type": "number"
                        }
                      },
                      "nullable": true
                    }
                  }
                }
              }
            },
            "minItems": 0,
            "maxItems": 10,
            "description": "The entire final group membership. Omitted existing journeys are archived; an empty array archives all of them."
          }
        }
      },
      "JourneyGroupRevertInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "expectedLastUpdated": {
            "type": "number",
            "nullable": true,
            "description": "Copy last_updated from a fresh GET of the group. Required unless the group has no journeys; a stale token returns 409 group_changed."
          }
        }
      },
      "JourneyClonedFrom": {
        "type": "object",
        "properties": {
          "journeyId": {
            "type": "string"
          },
          "groupId": {
            "type": "string"
          },
          "livemode": {
            "type": "boolean"
          },
          "clonedAt": {
            "type": "number"
          }
        },
        "required": [
          "livemode",
          "clonedAt"
        ]
      },
      "ApiPublicJourney": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "livemode": {
            "type": "boolean"
          },
          "owner": {
            "type": "string",
            "nullable": true
          },
          "team": {
            "type": "string",
            "nullable": true
          },
          "clonedFrom": {
            "type": "object",
            "properties": {
              "journeyId": {
                "type": "string"
              },
              "groupId": {
                "type": "string"
              },
              "livemode": {
                "type": "boolean"
              },
              "clonedAt": {
                "type": "number"
              }
            },
            "required": [
              "livemode",
              "clonedAt"
            ],
            "nullable": true
          },
          "created_at": {
            "type": "number",
            "nullable": true
          },
          "last_updated": {
            "type": "number",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "published",
              "paused",
              "archived"
            ]
          },
          "version": {
            "type": "number"
          },
          "triggerType": {
            "type": "string"
          },
          "graph": {
            "$ref": "#/components/schemas/JourneyGraph"
          },
          "replacesDefaults": {
            "type": "boolean"
          },
          "stats": {
            "type": "object",
            "properties": {
              "runs": {
                "type": "number"
              },
              "errors": {
                "type": "number"
              },
              "lastRunAt": {
                "type": "number",
                "nullable": true
              }
            },
            "required": [
              "runs",
              "errors",
              "lastRunAt"
            ]
          },
          "from": {
            "type": "string",
            "enum": [
              "dashboard",
              "api",
              "ai-builder",
              "clone"
            ]
          },
          "pausedReason": {
            "type": "string",
            "enum": [
              "circuit_breaker",
              "user",
              null
            ],
            "nullable": true
          },
          "pausedDetail": {
            "type": "string",
            "nullable": true
          },
          "pausedAt": {
            "type": "number",
            "nullable": true
          },
          "groupId": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "livemode",
          "owner",
          "team",
          "clonedFrom",
          "created_at",
          "last_updated",
          "status",
          "version",
          "triggerType",
          "graph",
          "replacesDefaults",
          "stats",
          "from",
          "pausedReason",
          "pausedDetail",
          "pausedAt",
          "groupId"
        ]
      },
      "ApiPublicJourneyGroup": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "livemode": {
            "type": "boolean"
          },
          "owner": {
            "type": "string",
            "nullable": true
          },
          "team": {
            "type": "string",
            "nullable": true
          },
          "clonedFrom": {
            "type": "object",
            "properties": {
              "journeyId": {
                "type": "string"
              },
              "groupId": {
                "type": "string"
              },
              "livemode": {
                "type": "boolean"
              },
              "clonedAt": {
                "type": "number"
              }
            },
            "required": [
              "livemode",
              "clonedAt"
            ],
            "nullable": true
          },
          "created_at": {
            "type": "number",
            "nullable": true
          },
          "last_updated": {
            "type": "number",
            "nullable": true
          },
          "sourcePrompt": {
            "type": "string",
            "nullable": true
          },
          "createdFrom": {
            "type": "string",
            "enum": [
              "ai",
              "manual",
              "clone"
            ]
          },
          "lastRevisionId": {
            "type": "string",
            "nullable": true
          },
          "lastEditPrompt": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "livemode",
          "owner",
          "team",
          "clonedFrom",
          "created_at",
          "last_updated",
          "sourcePrompt",
          "createdFrom",
          "lastRevisionId",
          "lastEditPrompt"
        ]
      },
      "ApiPublicJourneyRun": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "journeyId": {
            "type": "string"
          },
          "journeyVersion": {
            "type": "number"
          },
          "journeyName": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "failed",
              "partial"
            ]
          },
          "trigger": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "sourceCollection": {
                "type": "string",
                "enum": [
                  "payments",
                  "invoices",
                  "receipts",
                  "clients",
                  "teams"
                ]
              },
              "sourceId": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "sourceCollection",
              "sourceId"
            ],
            "nullable": true
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "nodeId": {
                  "type": "string"
                },
                "nodeType": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "success",
                    "skipped",
                    "failed",
                    "pending"
                  ]
                },
                "startedAt": {
                  "type": "number"
                },
                "finishedAt": {
                  "type": "number",
                  "nullable": true
                },
                "output": {
                  "type": "object",
                  "additionalProperties": true,
                  "nullable": true
                },
                "automationId": {
                  "type": "string",
                  "nullable": true
                },
                "error": {
                  "type": "string",
                  "nullable": true
                }
              },
              "required": [
                "nodeId",
                "nodeType",
                "status",
                "startedAt",
                "finishedAt",
                "output",
                "automationId",
                "error"
              ]
            }
          },
          "binnacle": {
            "type": "string"
          },
          "livemode": {
            "type": "boolean"
          },
          "team": {
            "type": "string",
            "nullable": true
          },
          "dryRun": {
            "type": "boolean"
          },
          "created_at": {
            "type": "number",
            "nullable": true
          },
          "finished_at": {
            "type": "number",
            "nullable": true
          }
        },
        "required": [
          "id",
          "journeyId",
          "journeyVersion",
          "journeyName",
          "status",
          "trigger",
          "steps",
          "binnacle",
          "livemode",
          "team",
          "dryRun",
          "created_at",
          "finished_at"
        ]
      },
      "JourneyGroupOutcome": {
        "type": "object",
        "properties": {
          "journeyId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "version": {
            "type": "number"
          },
          "reason": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {}
          }
        },
        "required": [
          "journeyId",
          "name",
          "status"
        ]
      },
      "JourneyCatalog": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "nodes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "trigger",
                    "condition",
                    "action"
                  ]
                },
                "category": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "configSchema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": true
                  }
                },
                "contextRequires": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "contextProduces": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "outputs": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "label": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "id"
                    ]
                  }
                },
                "sourceCollection": {
                  "type": "string"
                },
                "producesCollection": {
                  "type": "string"
                },
                "allowedSourceCollections": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "execution": {
                  "type": "string",
                  "enum": [
                    "bridge",
                    "direct"
                  ]
                },
                "deprecated": {
                  "type": "boolean"
                }
              },
              "required": [
                "key",
                "kind",
                "category",
                "title",
                "description",
                "configSchema",
                "contextRequires",
                "contextProduces",
                "outputs"
              ]
            }
          },
          "graphRules": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "richOperators": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "requiresValue": {
                  "type": "boolean"
                }
              },
              "required": [
                "value",
                "label",
                "requiresValue"
              ]
            }
          },
          "clauseEntities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "templateVariables": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "limits": {
            "type": "object",
            "properties": {
              "maxNodes": {
                "type": "number"
              },
              "maxAdvancedClauses": {
                "type": "number"
              }
            },
            "required": [
              "maxNodes",
              "maxAdvancedClauses"
            ]
          }
        },
        "required": [
          "version",
          "nodes",
          "graphRules",
          "richOperators",
          "clauseEntities",
          "templateVariables",
          "limits"
        ]
      },
      "SheetsMapping": {
        "type": "object",
        "properties": {
          "target": {
            "type": "string",
            "enum": [
              "payment",
              "invoice"
            ]
          },
          "fields": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "column": {
                  "type": "string",
                  "nullable": true
                },
                "value": {}
              }
            }
          }
        },
        "required": [
          "target",
          "fields"
        ]
      },
      "SheetsConnection": {
        "type": "object",
        "properties": {
          "spreadsheet_id": {
            "type": "string"
          },
          "spreadsheet_name": {
            "type": "string"
          },
          "spreadsheet_url": {
            "type": "string",
            "format": "uri"
          },
          "sheet_name": {
            "type": "string"
          },
          "header_row": {
            "type": "number"
          },
          "headers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "livemode": {
            "type": "boolean"
          },
          "mapping": {
            "type": "object",
            "properties": {
              "target": {
                "type": "string",
                "enum": [
                  "payment",
                  "invoice"
                ]
              },
              "fields": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "column": {
                      "type": "string",
                      "nullable": true
                    },
                    "value": {}
                  }
                }
              }
            },
            "required": [
              "target",
              "fields"
            ],
            "nullable": true
          },
          "enabled": {
            "type": "boolean"
          },
          "poll_interval_minutes": {
            "type": "number"
          },
          "connected_by_email": {
            "type": "string"
          },
          "connected_at": {
            "type": "number"
          },
          "last_sync_at": {
            "type": "number",
            "nullable": true
          },
          "last_polled_at": {
            "type": "number",
            "nullable": true
          },
          "last_sync_summary": {
            "type": "object",
            "properties": {
              "read": {
                "type": "number"
              },
              "claimed": {
                "type": "number"
              },
              "imported": {
                "type": "number"
              },
              "adopted": {
                "type": "number"
              },
              "failed": {
                "type": "number"
              },
              "review": {
                "type": "number"
              },
              "skipped": {
                "type": "number"
              },
              "remaining": {
                "type": "number"
              }
            },
            "required": [
              "read",
              "claimed",
              "imported",
              "adopted",
              "failed",
              "review",
              "skipped",
              "remaining"
            ],
            "nullable": true
          },
          "last_activity_at": {
            "type": "number",
            "nullable": true
          },
          "last_activity_summary": {
            "type": "object",
            "properties": {
              "read": {
                "type": "number"
              },
              "claimed": {
                "type": "number"
              },
              "imported": {
                "type": "number"
              },
              "adopted": {
                "type": "number"
              },
              "failed": {
                "type": "number"
              },
              "review": {
                "type": "number"
              },
              "skipped": {
                "type": "number"
              },
              "remaining": {
                "type": "number"
              }
            },
            "required": [
              "read",
              "claimed",
              "imported",
              "adopted",
              "failed",
              "review",
              "skipped",
              "remaining"
            ],
            "nullable": true
          },
          "totals": {
            "type": "object",
            "properties": {
              "imported": {
                "type": "number"
              },
              "adopted": {
                "type": "number"
              },
              "failed": {
                "type": "number"
              },
              "review": {
                "type": "number"
              }
            },
            "required": [
              "imported",
              "adopted",
              "failed",
              "review"
            ]
          },
          "sync_error": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "spreadsheet_id",
          "spreadsheet_name",
          "spreadsheet_url",
          "sheet_name",
          "header_row",
          "headers",
          "livemode",
          "mapping",
          "enabled",
          "poll_interval_minutes",
          "connected_by_email",
          "connected_at",
          "last_sync_at",
          "last_polled_at",
          "last_sync_summary",
          "last_activity_at",
          "last_activity_summary",
          "totals",
          "sync_error"
        ]
      },
      "SheetsConnectInput": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Google spreadsheet URL. Share the sheet with the service_account_email returned by GET /sheets as Editor first."
          },
          "sheet_name": {
            "type": "string"
          },
          "header_row": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50,
            "default": 1
          },
          "copy_from_other": {
            "type": "boolean"
          }
        },
        "required": [
          "url"
        ],
        "additionalProperties": false
      },
      "SheetsMappingInput": {
        "type": "object",
        "properties": {
          "target": {
            "type": "string",
            "enum": [
              "payment",
              "invoice"
            ]
          },
          "fields": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "column": {
                  "type": "string",
                  "nullable": true
                },
                "value": {}
              }
            }
          },
          "poll_interval_minutes": {
            "type": "integer",
            "enum": [
              2,
              5
            ]
          }
        },
        "required": [
          "target",
          "fields"
        ],
        "additionalProperties": false
      },
      "SheetsPreviewInput": {
        "type": "object",
        "properties": {
          "target": {
            "type": "string",
            "enum": [
              "payment",
              "invoice"
            ]
          },
          "fields": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "column": {
                  "type": "string",
                  "nullable": true
                },
                "value": {}
              }
            }
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "default": 5
          }
        },
        "additionalProperties": false,
        "description": "Omit fields to use the saved mapping. If fields is supplied, also supply target."
      },
      "SelfProfileInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "first_name": {
            "type": "string",
            "nullable": true,
            "maxLength": 100
          },
          "last_name": {
            "type": "string",
            "nullable": true,
            "maxLength": 100
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "maxLength": 31,
            "pattern": "^\\+?[0-9]{1,30}$"
          },
          "country": {
            "type": "string",
            "nullable": true,
            "maxLength": 100,
            "pattern": "^[A-Z]{3}$"
          },
          "company_role": {
            "type": "string",
            "nullable": true,
            "maxLength": 100
          }
        },
        "description": "Supply at least one field. Omitted fields remain unchanged; null clears the supplied field. Email is read-only from Firebase Auth."
      },
      "SelfPreferencesInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "testmode": {
            "type": "boolean",
            "nullable": true
          },
          "search_collection": {
            "type": "string",
            "enum": [
              "payments",
              "invoices",
              "receipts",
              null
            ],
            "nullable": true
          },
          "invoices_order_by": {
            "type": "string",
            "enum": [
              "timestamp",
              "folio_number",
              null
            ],
            "nullable": true
          }
        },
        "description": "Supply at least one preference. Null resets that preference, preserving other settings and teams."
      },
      "SelfContextInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "team_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "billing_account_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9_-]+$"
          }
        },
        "description": "Supply team_id, billing_account_id, or both. The server verifies current membership/account authority; it never trusts profile membership mirrors alone."
      },
      "SelfMcpTokenInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "team_id",
          "livemode",
          "terms_accepted"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "team_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9_-]+$"
          },
          "livemode": {
            "type": "boolean"
          },
          "terms_accepted": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "description": "Requires the actual user to explicitly accept the current MCP terms. Name must contain non-whitespace text. Credential creation is limited to ten active personal MCP tokens."
      },
      "SelfProfile": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "email_verified": {
            "type": "boolean"
          },
          "first_name": {
            "type": "string",
            "nullable": true
          },
          "last_name": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "company_role": {
            "type": "string",
            "nullable": true
          },
          "photo_url": {
            "type": "string",
            "nullable": true
          },
          "providers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "uid": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "uid"
              ]
            }
          },
          "created_at": {
            "type": "string",
            "description": "Firebase Auth creation metadata date string.",
            "nullable": true
          },
          "last_sign_in_at": {
            "type": "string",
            "description": "Firebase Auth sign-in metadata date string.",
            "nullable": true
          },
          "active_team_id": {
            "type": "string",
            "nullable": true
          },
          "active_billing_account_id": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "id",
          "email",
          "email_verified",
          "first_name",
          "last_name",
          "phone",
          "country",
          "company_role",
          "photo_url",
          "providers",
          "created_at",
          "last_sign_in_at",
          "active_team_id",
          "active_billing_account_id"
        ]
      },
      "SelfPreferences": {
        "type": "object",
        "properties": {
          "team_id": {
            "type": "string"
          },
          "testmode": {
            "type": "boolean",
            "nullable": true
          },
          "search_collection": {
            "type": "string",
            "nullable": true
          },
          "invoices_order_by": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "team_id",
          "testmode",
          "search_collection",
          "invoices_order_by"
        ]
      },
      "SelfNotification": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "notification_id": {
            "type": "string",
            "nullable": true
          },
          "team_id": {
            "type": "string",
            "nullable": true
          },
          "delivered_at": {
            "type": "number",
            "nullable": true
          },
          "read_at": {
            "type": "number",
            "nullable": true
          },
          "dismissed_at": {
            "type": "number",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "priority": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "body": {
            "type": "string",
            "nullable": true
          },
          "cta": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "nullable": true
              },
              "link": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "text",
              "link"
            ],
            "nullable": true
          },
          "expires_at": {
            "type": "number",
            "nullable": true
          }
        },
        "required": [
          "id",
          "notification_id",
          "team_id",
          "delivered_at",
          "read_at",
          "dismissed_at",
          "type",
          "priority",
          "title",
          "body",
          "cta",
          "expires_at"
        ]
      },
      "SelfMcpToken": {
        "type": "object",
        "properties": {
          "keyid": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "team": {
            "type": "string"
          },
          "livemode": {
            "type": "boolean"
          },
          "valid": {
            "type": "boolean"
          },
          "timestamp": {
            "type": "number"
          },
          "lastUsedAt": {
            "type": "number",
            "nullable": true
          },
          "termsAcceptedAt": {
            "type": "number",
            "nullable": true
          }
        },
        "required": [
          "keyid",
          "name",
          "team",
          "livemode",
          "valid",
          "timestamp",
          "lastUsedAt",
          "termsAcceptedAt"
        ]
      },
      "ApiCredentialMetadata": {
        "type": "object",
        "properties": {
          "keyid": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "api"
            ]
          },
          "team": {
            "type": "string"
          },
          "livemode": {
            "type": "boolean"
          },
          "valid": {
            "type": "boolean"
          },
          "timestamp": {
            "type": "number",
            "nullable": true
          },
          "invalidTimestamp": {
            "type": "number",
            "nullable": true
          },
          "lastUsedAt": {
            "type": "number",
            "nullable": true
          }
        },
        "required": [
          "keyid",
          "type",
          "team",
          "livemode",
          "valid",
          "timestamp",
          "invalidTimestamp",
          "lastUsedAt"
        ]
      },
      "ApiCredentialPair": {
        "type": "object",
        "properties": {
          "live": {
            "type": "object",
            "properties": {
              "key": {
                "$ref": "#/components/schemas/ApiCredentialMetadata"
              },
              "apikey": {
                "type": "string",
                "description": "One-time credential. Store securely; never log it."
              }
            },
            "required": [
              "key",
              "apikey"
            ]
          },
          "test": {
            "type": "object",
            "properties": {
              "key": {
                "$ref": "#/components/schemas/ApiCredentialMetadata"
              },
              "apikey": {
                "type": "string",
                "description": "One-time credential. Store securely; never log it."
              }
            },
            "required": [
              "key",
              "apikey"
            ]
          },
          "revoked_count": {
            "type": "number"
          }
        },
        "required": [
          "live",
          "test",
          "revoked_count"
        ]
      },
      "IntegrationStripeSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          },
          "test_only": {
            "type": "boolean"
          },
          "automatic_refunds": {
            "type": "boolean"
          },
          "ppd_flow": {
            "type": "boolean"
          },
          "use_provider_exchange_rate": {
            "type": "boolean"
          },
          "convert_payments_to_currency": {
            "type": "string",
            "nullable": true,
            "pattern": "^[A-Z]{3}$"
          },
          "default_payment_method": {
            "type": "string",
            "nullable": true,
            "maxLength": 2,
            "pattern": "^\\d{2}$"
          },
          "customer_balance_payment_method": {
            "type": "string",
            "nullable": true,
            "maxLength": 2,
            "pattern": "^\\d{2}$"
          },
          "stripe_payment_method": {
            "type": "string",
            "nullable": true,
            "maxLength": 2,
            "pattern": "^\\d{2}$"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=stripe. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationAdyenSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          },
          "test_only": {
            "type": "boolean"
          },
          "ppd_flow": {
            "type": "boolean"
          },
          "use_provider_exchange_rate": {
            "type": "boolean"
          },
          "convert_payments_to_currency": {
            "type": "string",
            "nullable": true,
            "pattern": "^[A-Z]{3}$"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=adyen. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationPaypalSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          },
          "test_only": {
            "type": "boolean"
          },
          "service_description": {
            "type": "string",
            "nullable": true,
            "maxLength": 1000
          },
          "payment_form": {
            "type": "string",
            "nullable": true,
            "maxLength": 2,
            "pattern": "^\\d{2}$"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=paypal. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationConektaSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=conekta. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationOpenpaySettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=openpay. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationClipSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=clip. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationClockpmsSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=clockpms. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationPagoraliaSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=pagoralia. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationDlocalSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=dlocal. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationWoocommerceSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=woocommerce. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationMercadopagoSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=mercadopago. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationShopifySettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "automatic_invoicing": {
            "type": "boolean"
          },
          "default_payment_form": {
            "type": "string",
            "nullable": true,
            "maxLength": 2,
            "pattern": "^\\d{2}$"
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=shopify. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "IntegrationBankSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "bic": {
            "type": "string",
            "nullable": true,
            "maxLength": 20
          },
          "clabe": {
            "type": "string",
            "nullable": true,
            "pattern": "^\\d{18}$"
          },
          "country": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "holder_name": {
            "type": "string",
            "nullable": true,
            "maxLength": 200
          },
          "iban": {
            "type": "string",
            "nullable": true,
            "maxLength": 34
          },
          "help": {
            "type": "string",
            "nullable": true,
            "maxLength": 2000
          },
          "swift": {
            "type": "string",
            "nullable": true,
            "maxLength": 20
          },
          "voucher_required": {
            "type": "boolean"
          },
          "account_number": {
            "type": "string",
            "nullable": true,
            "maxLength": 64
          },
          "routing_number": {
            "type": "string",
            "nullable": true,
            "maxLength": 32
          }
        },
        "minProperties": 1,
        "description": "Settings accepted only for provider=bank. Fields omitted from the request remain unchanged. Read the provider state after a write. Nullable text clears; boolean null is rejected."
      },
      "AccountIntegrationState": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "stripe",
              "adyen",
              "paypal",
              "zettle",
              "conekta",
              "openpay",
              "clip",
              "clockpms",
              "pagoralia",
              "dlocal",
              "woocommerce",
              "mercadopago",
              "mercadolibre",
              "airtable",
              "shopify",
              "bank",
              "sheets",
              "netsuite",
              "whatsapp",
              "zapier",
              "whmcs",
              "hilos",
              "sat",
              "sat_download",
              "factus"
            ]
          },
          "label": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "payments",
              "commerce",
              "automation",
              "erp",
              "messaging",
              "fiscal"
            ]
          },
          "mode_scope": {
            "type": "string",
            "enum": [
              "team_shared",
              "connection_mode",
              "live_test"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "stored_configuration"
            ]
          },
          "completed": {
            "type": "boolean"
          },
          "region_available": {
            "type": "boolean"
          },
          "regions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "installation": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "allowed": {
                "type": "boolean"
              },
              "reason": {
                "type": "string",
                "nullable": true
              },
              "limit": {
                "type": "number",
                "nullable": true
              },
              "used": {
                "type": "number"
              }
            },
            "required": [
              "allowed",
              "reason",
              "limit",
              "used"
            ]
          },
          "settings": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "automatic_invoicing": {
                "type": "boolean",
                "nullable": true
              },
              "test_only": {
                "type": "boolean",
                "nullable": true
              },
              "automatic_refunds": {
                "type": "boolean",
                "nullable": true
              },
              "ppd_flow": {
                "type": "boolean",
                "nullable": true
              },
              "use_provider_exchange_rate": {
                "type": "boolean",
                "nullable": true
              },
              "convert_payments_to_currency": {
                "type": "string",
                "nullable": true,
                "pattern": "^[A-Z]{3}$"
              },
              "default_payment_method": {
                "type": "string",
                "nullable": true,
                "maxLength": 2,
                "pattern": "^\\d{2}$"
              },
              "customer_balance_payment_method": {
                "type": "string",
                "nullable": true,
                "maxLength": 2,
                "pattern": "^\\d{2}$"
              },
              "stripe_payment_method": {
                "type": "string",
                "nullable": true,
                "maxLength": 2,
                "pattern": "^\\d{2}$"
              },
              "service_description": {
                "type": "string",
                "nullable": true,
                "maxLength": 1000
              },
              "payment_form": {
                "type": "string",
                "nullable": true,
                "maxLength": 2,
                "pattern": "^\\d{2}$"
              },
              "default_payment_form": {
                "type": "string",
                "nullable": true,
                "maxLength": 2,
                "pattern": "^\\d{2}$"
              },
              "bic": {
                "type": "string",
                "nullable": true,
                "maxLength": 20
              },
              "clabe": {
                "type": "string",
                "nullable": true,
                "pattern": "^\\d{18}$"
              },
              "country": {
                "type": "string",
                "pattern": "^[A-Z]{3}$",
                "nullable": true
              },
              "holder_name": {
                "type": "string",
                "nullable": true,
                "maxLength": 200
              },
              "iban": {
                "type": "string",
                "nullable": true,
                "maxLength": 34
              },
              "help": {
                "type": "string",
                "nullable": true,
                "maxLength": 2000
              },
              "swift": {
                "type": "string",
                "nullable": true,
                "maxLength": 20
              },
              "voucher_required": {
                "type": "boolean",
                "nullable": true
              },
              "account_number": {
                "type": "string",
                "nullable": true,
                "maxLength": 64
              },
              "routing_number": {
                "type": "string",
                "nullable": true,
                "maxLength": 32
              }
            },
            "description": "Only the fields supported by this provider are present. Unset stored values are null, including booleans."
          },
          "connected_at": {
            "type": "number",
            "nullable": true
          },
          "last_sync_at": {
            "type": "number",
            "nullable": true
          },
          "web_actions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "api_actions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "team_id": {
            "type": "string",
            "description": "Present on a single-provider response; omitted on catalog entries."
          }
        },
        "required": [
          "provider",
          "label",
          "category",
          "mode_scope",
          "source",
          "completed",
          "region_available",
          "regions",
          "installation",
          "settings",
          "connected_at",
          "last_sync_at",
          "web_actions",
          "api_actions"
        ]
      },
      "AccountIntegrationDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AccountIntegrationState"
          },
          {
            "type": "object",
            "required": [
              "team_id"
            ],
            "properties": {
              "team_id": {
                "type": "string"
              }
            }
          }
        ]
      },
      "FiscalAccountStatus": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "team_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared"
            ]
          },
          "blocking_session_id": {
            "type": "string",
            "nullable": true
          },
          "csd": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "configured": {
                "type": "boolean"
              },
              "expires_at": {
                "type": "number",
                "nullable": true
              },
              "serial_number": {
                "type": "string",
                "nullable": true
              },
              "provider": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "configured",
              "expires_at",
              "serial_number",
              "provider"
            ]
          },
          "fiel": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "configured": {
                "type": "boolean"
              },
              "expires_at": {
                "type": "number",
                "nullable": true
              },
              "serial_number": {
                "type": "string",
                "nullable": true
              },
              "rfc": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "configured",
              "expires_at",
              "serial_number",
              "rfc"
            ]
          },
          "sat_download": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "registered": {
                "type": "boolean"
              },
              "registered_at": {
                "type": "number",
                "nullable": true
              },
              "sync_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "sync_start_date": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "registered",
              "registered_at",
              "sync_enabled",
              "sync_start_date"
            ]
          },
          "manifest": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "completed": {
                "type": "boolean"
              },
              "signed_at": {
                "type": "number",
                "nullable": true
              },
              "provider_status": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "completed",
              "signed_at",
              "provider_status"
            ]
          }
        },
        "required": [
          "team_id",
          "effect_scope",
          "blocking_session_id",
          "csd",
          "fiel",
          "sat_download",
          "manifest"
        ]
      },
      "FiscalUploadSession": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "team_id": {
            "type": "string"
          },
          "team": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "legal_name": {
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "legal_name",
              "tax_id"
            ]
          },
          "can_submit": {
            "type": "boolean"
          },
          "recovery_available_at": {
            "type": "number",
            "nullable": true
          },
          "purpose": {
            "type": "string",
            "enum": [
              "csd",
              "fiel",
              "pfx",
              "manifest"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "completed",
              "failed",
              "outcome_unknown",
              "cancelled",
              "expired"
            ]
          },
          "credential_livemode": {
            "type": "boolean"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "production",
              "sandbox"
            ]
          },
          "created_at": {
            "type": "number"
          },
          "expires_at": {
            "type": "number"
          },
          "completed_at": {
            "type": "number",
            "nullable": true
          },
          "upload_url": {
            "type": "string",
            "format": "uri"
          },
          "completion_url": {
            "type": "string",
            "format": "uri"
          },
          "manifest_consent": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "text": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "text",
              "version"
            ],
            "nullable": true
          },
          "resolution": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "released_for_new_upload"
                ]
              },
              "resolved_at": {
                "type": "number"
              }
            },
            "required": [
              "action",
              "resolved_at"
            ],
            "nullable": true
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "team_id": {
                "type": "string"
              },
              "effect_scope": {
                "type": "string",
                "enum": [
                  "team_shared"
                ]
              },
              "blocking_session_id": {
                "type": "string",
                "nullable": true
              },
              "csd": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "configured": {
                    "type": "boolean"
                  },
                  "expires_at": {
                    "type": "number",
                    "nullable": true
                  },
                  "serial_number": {
                    "type": "string",
                    "nullable": true
                  },
                  "provider": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "configured",
                  "expires_at",
                  "serial_number",
                  "provider"
                ]
              },
              "fiel": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "configured": {
                    "type": "boolean"
                  },
                  "expires_at": {
                    "type": "number",
                    "nullable": true
                  },
                  "serial_number": {
                    "type": "string",
                    "nullable": true
                  },
                  "rfc": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "configured",
                  "expires_at",
                  "serial_number",
                  "rfc"
                ]
              },
              "sat_download": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "registered": {
                    "type": "boolean"
                  },
                  "registered_at": {
                    "type": "number",
                    "nullable": true
                  },
                  "sync_enabled": {
                    "type": "boolean",
                    "nullable": true
                  },
                  "sync_start_date": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "registered",
                  "registered_at",
                  "sync_enabled",
                  "sync_start_date"
                ]
              },
              "manifest": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "completed": {
                    "type": "boolean"
                  },
                  "signed_at": {
                    "type": "number",
                    "nullable": true
                  },
                  "provider_status": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "completed",
                  "signed_at",
                  "provider_status"
                ]
              }
            },
            "required": [
              "team_id",
              "effect_scope",
              "blocking_session_id",
              "csd",
              "fiel",
              "sat_download",
              "manifest"
            ],
            "nullable": true
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              }
            },
            "required": [
              "code",
              "message",
              "retryable"
            ],
            "nullable": true
          }
        },
        "required": [
          "id",
          "team_id",
          "team",
          "can_submit",
          "recovery_available_at",
          "purpose",
          "status",
          "credential_livemode",
          "effect_scope",
          "provider_environment",
          "created_at",
          "expires_at",
          "completed_at",
          "upload_url",
          "completion_url",
          "manifest_consent",
          "resolution",
          "result",
          "error"
        ]
      },
      "FiscalUploadSessionInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "purpose": {
            "type": "string",
            "enum": [
              "csd",
              "fiel",
              "pfx",
              "manifest"
            ]
          }
        },
        "required": [
          "purpose"
        ]
      },
      "FiscalUploadResolutionInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "acknowledge_unconfirmed_effects": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "acknowledge_unconfirmed_effects"
        ]
      },
      "AccountZettleStatusResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "connection",
          "reviews",
          "reviews_limit"
        ],
        "properties": {
          "connection": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "completed",
              "livemode",
              "automaticInvoicing",
              "cardPaymentForm",
              "syncing",
              "connectedAt",
              "lastSync",
              "sync_error_present"
            ],
            "properties": {
              "completed": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "livemode": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "automaticInvoicing": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "cardPaymentForm": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "syncing": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "connectedAt": {
                "type": "number",
                "nullable": true
              },
              "lastSync": {
                "type": "number",
                "nullable": true
              },
              "sync_error_present": {
                "type": "boolean"
              }
            },
            "nullable": true
          },
          "reviews": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "purchaseId",
                "amount",
                "currency",
                "timestamp",
                "status",
                "reason",
                "updatedAt"
              ],
              "properties": {
                "purchaseId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "amount": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "currency": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "timestamp": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "status": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "reason": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "updatedAt": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                }
              }
            }
          },
          "reviews_limit": {
            "type": "integer",
            "enum": [
              20
            ]
          }
        }
      },
      "AccountZettleSettingsResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "completed"
        ],
        "properties": {
          "completed": {
            "type": "boolean"
          }
        }
      },
      "AccountZettleSettingsInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "automaticInvoicing",
          "cardPaymentForm"
        ],
        "properties": {
          "automaticInvoicing": {
            "type": "boolean"
          },
          "cardPaymentForm": {
            "type": "string",
            "enum": [
              "04",
              "28"
            ]
          }
        }
      },
      "AccountZettleSyncResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "queued"
        ],
        "properties": {
          "queued": {
            "type": "boolean"
          }
        }
      },
      "AccountZettleSyncInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      },
      "AccountZettleDisconnectResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "completed",
          "remote_removed",
          "partial_cleanup"
        ],
        "properties": {
          "completed": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "remote_removed": {
            "type": "boolean",
            "nullable": true
          },
          "partial_cleanup": {
            "type": "boolean"
          }
        }
      },
      "AccountZettleDisconnectInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      },
      "AccountNetsuiteStatusResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "live",
          "test",
          "recentSyncs",
          "recent_syncs_limit",
          "failedCount"
        ],
        "properties": {
          "live": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "completed",
              "accountId",
              "connectedAt"
            ],
            "properties": {
              "completed": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "accountId": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "connectedAt": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              }
            }
          },
          "test": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "completed",
              "accountId",
              "connectedAt"
            ],
            "properties": {
              "completed": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "accountId": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "connectedAt": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              }
            }
          },
          "recentSyncs": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "invoiceId",
                "status",
                "attempts",
                "environment",
                "shadow",
                "skipReason",
                "updatedAt",
                "syncedAt",
                "lastError",
                "steps",
                "attention",
                "diagnosis"
              ],
              "properties": {
                "id": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "invoiceId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "status": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "attempts": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "environment": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "shadow": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "skipReason": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "updatedAt": {
                  "type": "number",
                  "nullable": true
                },
                "syncedAt": {
                  "type": "number",
                  "nullable": true
                },
                "lastError": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "step",
                    "permanent",
                    "at",
                    "message_redacted"
                  ],
                  "properties": {
                    "step": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "permanent": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "at": {
                      "type": "number",
                      "nullable": true
                    },
                    "message_redacted": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "nullable": true
                },
                "steps": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "record",
                    "payment",
                    "files"
                  ],
                  "properties": {
                    "record": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "netsuiteId",
                        "recordType"
                      ],
                      "properties": {
                        "netsuiteId": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        },
                        "recordType": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        }
                      },
                      "nullable": true
                    },
                    "payment": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "netsuitePaymentId"
                      ],
                      "properties": {
                        "netsuitePaymentId": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        }
                      },
                      "nullable": true
                    },
                    "files": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "pdfAttached",
                        "xmlAttached"
                      ],
                      "properties": {
                        "pdfAttached": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        },
                        "xmlAttached": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        }
                      },
                      "nullable": true
                    }
                  }
                },
                "attention": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "code",
                    "at"
                  ],
                  "properties": {
                    "code": {
                      "type": "string",
                      "nullable": true
                    },
                    "at": {
                      "type": "number",
                      "nullable": true
                    }
                  },
                  "nullable": true
                },
                "diagnosis": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "code",
                    "actor",
                    "severity",
                    "title",
                    "detail",
                    "actions",
                    "context"
                  ],
                  "properties": {
                    "code": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "actor": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "severity": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "title": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "detail": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "actions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "context": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "description",
                        "tercero",
                        "relatedInvoiceId"
                      ],
                      "properties": {
                        "description": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        },
                        "tercero": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        },
                        "relatedInvoiceId": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        }
                      }
                    }
                  },
                  "nullable": true
                }
              }
            }
          },
          "recent_syncs_limit": {
            "type": "integer",
            "enum": [
              20
            ]
          },
          "failedCount": {
            "type": "number",
            "nullable": true
          }
        }
      },
      "AccountNetsuitePingResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "ok",
          "environment",
          "accountId",
          "ms"
        ],
        "properties": {
          "ok": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "environment": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "accountId": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "ms": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          }
        }
      },
      "AccountNetsuitePingInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      },
      "AccountNetsuiteDisconnectResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "ok",
          "environment",
          "credentials_retained"
        ],
        "properties": {
          "ok": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "environment": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "credentials_retained": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "AccountNetsuiteDisconnectInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      },
      "AccountNetsuiteSyncResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "enqueued"
        ],
        "properties": {
          "enqueued": {
            "type": "boolean"
          }
        }
      },
      "AccountNetsuiteSyncInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      },
      "AccountNetsuiteResyncResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "enqueued"
        ],
        "properties": {
          "enqueued": {
            "type": "boolean"
          }
        }
      },
      "AccountNetsuiteResyncInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      },
      "AccountNetsuiteSyncStatusResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "exists",
          "id",
          "invoiceId",
          "status",
          "attempts",
          "environment",
          "shadow",
          "skipReason",
          "updatedAt",
          "syncedAt",
          "lastError",
          "steps",
          "attention",
          "diagnosis"
        ],
        "properties": {
          "exists": {
            "type": "boolean"
          },
          "id": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "invoiceId": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "attempts": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "environment": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "shadow": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "skipReason": {
            "anyOf": [
              {
                "type": "string",
                "nullable": true
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "updatedAt": {
            "type": "number",
            "nullable": true
          },
          "syncedAt": {
            "type": "number",
            "nullable": true
          },
          "lastError": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "step",
              "permanent",
              "at",
              "message_redacted"
            ],
            "properties": {
              "step": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "permanent": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "at": {
                "type": "number",
                "nullable": true
              },
              "message_redacted": {
                "type": "boolean",
                "enum": [
                  true
                ]
              }
            },
            "nullable": true
          },
          "steps": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "record",
              "payment",
              "files"
            ],
            "properties": {
              "record": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "netsuiteId",
                  "recordType"
                ],
                "properties": {
                  "netsuiteId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "nullable": true
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "recordType": {
                    "anyOf": [
                      {
                        "type": "string",
                        "nullable": true
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  }
                },
                "nullable": true
              },
              "payment": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "netsuitePaymentId"
                ],
                "properties": {
                  "netsuitePaymentId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "nullable": true
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  }
                },
                "nullable": true
              },
              "files": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "pdfAttached",
                  "xmlAttached"
                ],
                "properties": {
                  "pdfAttached": {
                    "anyOf": [
                      {
                        "type": "string",
                        "nullable": true
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "xmlAttached": {
                    "anyOf": [
                      {
                        "type": "string",
                        "nullable": true
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  }
                },
                "nullable": true
              }
            }
          },
          "attention": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "at"
            ],
            "properties": {
              "code": {
                "type": "string",
                "nullable": true
              },
              "at": {
                "type": "number",
                "nullable": true
              }
            },
            "nullable": true
          },
          "diagnosis": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "actor",
              "severity",
              "title",
              "detail",
              "actions",
              "context"
            ],
            "properties": {
              "code": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "actor": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "severity": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "title": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "detail": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "actions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "context": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "description",
                  "tercero",
                  "relatedInvoiceId"
                ],
                "properties": {
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "nullable": true
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "tercero": {
                    "anyOf": [
                      {
                        "type": "string",
                        "nullable": true
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "relatedInvoiceId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "nullable": true
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  }
                }
              }
            },
            "nullable": true
          }
        }
      },
      "AccountNetsuiteSyncsResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items",
          "summary",
          "byCode",
          "total",
          "nextBefore",
          "truncated"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "invoiceId",
                "status",
                "updatedAt",
                "diagnosis",
                "invoice"
              ],
              "properties": {
                "invoiceId": {
                  "type": "string",
                  "nullable": true
                },
                "status": {
                  "type": "string",
                  "nullable": true
                },
                "updatedAt": {
                  "type": "number",
                  "nullable": true
                },
                "diagnosis": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "code",
                    "actor",
                    "severity",
                    "title",
                    "detail",
                    "actions",
                    "context"
                  ],
                  "properties": {
                    "code": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "actor": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "severity": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "title": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "detail": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "actions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "context": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "description",
                        "tercero",
                        "relatedInvoiceId"
                      ],
                      "properties": {
                        "description": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        },
                        "tercero": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        },
                        "relatedInvoiceId": {
                          "anyOf": [
                            {
                              "type": "string",
                              "nullable": true
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        }
                      }
                    }
                  },
                  "nullable": true
                },
                "invoice": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "series",
                    "folio",
                    "number",
                    "uuid",
                    "type",
                    "total",
                    "currency",
                    "date",
                    "client",
                    "clientId"
                  ],
                  "properties": {
                    "series": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "folio": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "number": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "uuid": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "total": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "date": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "client": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "clientId": {
                      "anyOf": [
                        {
                          "type": "string",
                          "nullable": true
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    }
                  },
                  "nullable": true
                }
              }
            }
          },
          "summary": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "customer",
              "support",
              "retrying"
            ],
            "properties": {
              "customer": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "support": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "retrying": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              }
            }
          },
          "byCode": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "total": {
            "type": "number",
            "nullable": true
          },
          "nextBefore": {
            "type": "string",
            "nullable": true
          },
          "truncated": {
            "type": "boolean"
          }
        }
      },
      "AccountNetsuiteItemsConfigResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "ok",
          "strategy",
          "mappingTable",
          "defaultItemId",
          "ruleRequires",
          "canEdit"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "strategy": {
            "type": "string",
            "nullable": true
          },
          "mappingTable": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "match",
                "matchType",
                "itemId",
                "refundItemId",
                "scope"
              ],
              "properties": {
                "match": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "matchType": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "itemId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "refundItemId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "scope": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                }
              }
            }
          },
          "defaultItemId": {
            "type": "string",
            "nullable": true
          },
          "ruleRequires": {
            "type": "object",
            "additionalProperties": false,
            "description": "What a new rule must carry for this team. When `refundItemId` is true, preview and add-rule reject a rule without one.",
            "required": [
              "refundItemId"
            ],
            "properties": {
              "refundItemId": {
                "type": "boolean"
              }
            }
          },
          "canEdit": {
            "type": "boolean"
          }
        }
      },
      "AccountNetsuiteItemsPreviewResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "ok",
          "days",
          "itemName",
          "refundItemName",
          "invoicesScanned",
          "rule",
          "totals",
          "rows",
          "previewToken",
          "requiresConfirmation"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "days": {
            "type": "number",
            "nullable": true
          },
          "itemName": {
            "type": "string",
            "nullable": true
          },
          "refundItemName": {
            "type": "string",
            "nullable": true,
            "description": "NetSuite name of the rule's refund item; null when the rule has none."
          },
          "invoicesScanned": {
            "type": "number",
            "nullable": true
          },
          "rule": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "match",
              "matchType",
              "itemId",
              "refundItemId",
              "scope"
            ],
            "properties": {
              "match": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "matchType": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "itemId": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "refundItemId": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "scope": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              }
            }
          },
          "totals": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "unchanged",
              "newlyResolved",
              "changed",
              "stillUnresolved",
              "newlyUnresolved"
            ],
            "properties": {
              "unchanged": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "newlyResolved": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "changed": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "stillUnresolved": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "newlyUnresolved": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              }
            }
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "description",
                "scope",
                "lines",
                "currentItemId",
                "proposedItemId",
                "outcome"
              ],
              "properties": {
                "description": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "scope": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "lines": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "currentItemId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "proposedItemId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                },
                "outcome": {
                  "anyOf": [
                    {
                      "type": "string",
                      "nullable": true
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                }
              }
            }
          },
          "previewToken": {
            "type": "string",
            "nullable": true
          },
          "requiresConfirmation": {
            "type": "boolean"
          }
        }
      },
      "AccountNetsuiteItemsPreviewInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "rule"
        ],
        "properties": {
          "rule": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "match",
              "matchType",
              "itemId"
            ],
            "properties": {
              "match": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1000
              },
              "matchType": {
                "type": "string",
                "enum": [
                  "exact",
                  "contains"
                ]
              },
              "itemId": {
                "type": "string",
                "pattern": "^\\d+$"
              },
              "refundItemId": {
                "type": "string",
                "pattern": "^\\d+$"
              },
              "scope": {
                "type": "string",
                "enum": [
                  "domestic",
                  "foreign"
                ]
              }
            }
          },
          "days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 180
          }
        }
      },
      "AccountNetsuiteItemsRuleResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "ok",
          "rule",
          "totals"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "rule": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "match",
              "matchType",
              "itemId",
              "refundItemId",
              "scope"
            ],
            "properties": {
              "match": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "matchType": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "itemId": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "refundItemId": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "scope": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              }
            }
          },
          "totals": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "unchanged",
              "newlyResolved",
              "changed",
              "stillUnresolved",
              "newlyUnresolved"
            ],
            "properties": {
              "unchanged": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "newlyResolved": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "changed": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "stillUnresolved": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              },
              "newlyUnresolved": {
                "anyOf": [
                  {
                    "type": "string",
                    "nullable": true
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  }
                ]
              }
            }
          }
        }
      },
      "AccountNetsuiteItemsRuleInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "rule",
          "previewToken"
        ],
        "properties": {
          "rule": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "match",
              "matchType",
              "itemId"
            ],
            "properties": {
              "match": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1000
              },
              "matchType": {
                "type": "string",
                "enum": [
                  "exact",
                  "contains"
                ]
              },
              "itemId": {
                "type": "string",
                "pattern": "^\\d+$"
              },
              "refundItemId": {
                "type": "string",
                "pattern": "^\\d+$"
              },
              "scope": {
                "type": "string",
                "enum": [
                  "domestic",
                  "foreign"
                ]
              }
            }
          },
          "days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 180
          },
          "previewToken": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "confirmChanges": {
            "type": "boolean"
          }
        }
      },
      "AccountBillingSubscription": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "status",
          "plan_id",
          "billing_cycle",
          "currency",
          "current_period_start",
          "current_period_end",
          "cancel_at",
          "trial_end",
          "cancel_at_period_end",
          "items"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "plan_id": {
            "type": "string",
            "nullable": true
          },
          "billing_cycle": {
            "type": "string",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "current_period_start": {
            "type": "number",
            "nullable": true
          },
          "current_period_end": {
            "type": "number",
            "nullable": true
          },
          "cancel_at": {
            "type": "number",
            "nullable": true
          },
          "trial_end": {
            "type": "number",
            "nullable": true
          },
          "cancel_at_period_end": {
            "type": "boolean"
          },
          "items": {
            "type": "array",
            "description": "What the subscription charges. Pricing v3 accounts carry the fixed RFC fee (lookup key v3_mx_taxpayer_fee) and the metered credits (v3_mx_credit). Amounts are minor units before tax; a metered item has no quantity.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "price_id",
                "lookup_key",
                "unit_amount",
                "quantity",
                "interval",
                "usage_type",
                "current_period_end"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "price_id": {
                  "type": "string",
                  "nullable": true
                },
                "lookup_key": {
                  "type": "string",
                  "nullable": true
                },
                "unit_amount": {
                  "type": "number",
                  "nullable": true
                },
                "quantity": {
                  "type": "number",
                  "nullable": true
                },
                "interval": {
                  "type": "string",
                  "nullable": true
                },
                "usage_type": {
                  "type": "string",
                  "nullable": true
                },
                "current_period_end": {
                  "type": "number",
                  "nullable": true
                }
              }
            }
          }
        }
      },
      "AccountBillingInvoice": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "number",
          "status",
          "currency",
          "hosted_invoice_url",
          "invoice_pdf",
          "created_at",
          "amount_due",
          "amount_paid",
          "amount_remaining",
          "period_start",
          "period_end"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "number": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "hosted_invoice_url": {
            "type": "string",
            "nullable": true
          },
          "invoice_pdf": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "number",
            "nullable": true
          },
          "amount_due": {
            "type": "number",
            "nullable": true
          },
          "amount_paid": {
            "type": "number",
            "nullable": true
          },
          "amount_remaining": {
            "type": "number",
            "nullable": true
          },
          "period_start": {
            "type": "number",
            "nullable": true
          },
          "period_end": {
            "type": "number",
            "nullable": true
          }
        }
      },
      "AccountBillingPrice": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "currency",
          "interval",
          "amount",
          "included_documents",
          "additional_document_amount"
        ],
        "properties": {
          "currency": {
            "type": "string",
            "nullable": true
          },
          "interval": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "number",
            "nullable": true
          },
          "included_documents": {
            "type": "number",
            "nullable": true
          },
          "additional_document_amount": {
            "type": "number",
            "nullable": true
          }
        }
      },
      "AccountBillingFiscal": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "billing_account_id",
          "effect_scope",
          "provider_environment",
          "exists",
          "editable",
          "source",
          "customer_id",
          "fiscal",
          "warnings",
          "stripe_synced"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "billing_account_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "billing_account_shared"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "production"
            ]
          },
          "exists": {
            "type": "boolean"
          },
          "editable": {
            "type": "boolean"
          },
          "source": {
            "type": "string",
            "enum": [
              "client",
              "seed"
            ]
          },
          "customer_id": {
            "type": "string",
            "nullable": true
          },
          "fiscal": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "legal_name",
              "rfc",
              "tax_system",
              "use",
              "email",
              "phone",
              "address"
            ],
            "properties": {
              "legal_name": {
                "type": "string",
                "nullable": true
              },
              "rfc": {
                "type": "string",
                "nullable": true
              },
              "tax_system": {
                "type": "string",
                "nullable": true
              },
              "use": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "address": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "zip",
                  "street",
                  "exterior",
                  "interior",
                  "neighborhood",
                  "municipality",
                  "city",
                  "state",
                  "country"
                ],
                "properties": {
                  "zip": {
                    "type": "string",
                    "nullable": true
                  },
                  "street": {
                    "type": "string",
                    "nullable": true
                  },
                  "exterior": {
                    "type": "string",
                    "nullable": true
                  },
                  "interior": {
                    "type": "string",
                    "nullable": true
                  },
                  "neighborhood": {
                    "type": "string",
                    "nullable": true
                  },
                  "municipality": {
                    "type": "string",
                    "nullable": true
                  },
                  "city": {
                    "type": "string",
                    "nullable": true
                  },
                  "state": {
                    "type": "string",
                    "nullable": true
                  },
                  "country": {
                    "type": "string",
                    "nullable": true
                  }
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "stripe_synced": {
            "type": "boolean",
            "nullable": true
          }
        }
      },
      "AccountBillingOperation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "team_id",
          "billing_account_id",
          "effect_scope",
          "provider_environment",
          "action",
          "status",
          "created_at",
          "updated_at",
          "recovery_available_at",
          "result",
          "error",
          "resolution"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "team_id": {
            "type": "string"
          },
          "billing_account_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "billing_account_shared"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "production"
            ]
          },
          "action": {
            "type": "string",
            "enum": [
              "checkout",
              "checkout.cancel",
              "upgrade",
              "portal",
              "fiscal.update"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "processing",
              "handoff_ready",
              "completed",
              "failed",
              "outcome_unknown",
              "cancelled"
            ]
          },
          "created_at": {
            "type": "number"
          },
          "updated_at": {
            "type": "number"
          },
          "recovery_available_at": {
            "type": "number"
          },
          "result": {
            "oneOf": [
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "checkout_operation_id",
                  "session_id",
                  "status"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "checkout_cancellation"
                    ]
                  },
                  "checkout_operation_id": {
                    "type": "string"
                  },
                  "session_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "expired",
                      "complete"
                    ]
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "plan_id"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "free_plan"
                    ]
                  },
                  "plan_id": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "session_id",
                  "url",
                  "expires_at"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "checkout"
                    ]
                  },
                  "session_id": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string",
                    "nullable": true
                  },
                  "expires_at": {
                    "type": "number",
                    "nullable": true
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "intent",
                  "url",
                  "expires_at"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "portal"
                    ]
                  },
                  "intent": {
                    "type": "string",
                    "enum": [
                      "manage",
                      "cancel_subscription",
                      "update_payment_method"
                    ]
                  },
                  "url": {
                    "type": "string"
                  },
                  "expires_at": {
                    "type": "number",
                    "nullable": true,
                    "enum": [
                      null
                    ]
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "subscription"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "subscription"
                    ]
                  },
                  "subscription": {
                    "$ref": "#/components/schemas/AccountBillingSubscription"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "fiscal"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "fiscal"
                    ]
                  },
                  "fiscal": {
                    "$ref": "#/components/schemas/AccountBillingFiscal"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "description": "A feature turned on (`POST /teams/{id}/billing/features`).",
                "required": [
                  "kind",
                  "scope",
                  "team_id",
                  "feature",
                  "subscription_id",
                  "subscription_item_id",
                  "quantity",
                  "free_until",
                  "prorated",
                  "charged"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "feature"
                    ]
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "team",
                      "billing_account"
                    ],
                    "description": "`billing_account`: gigstack Connect, on for the whole account."
                  },
                  "team_id": {
                    "type": "string"
                  },
                  "feature": {
                    "type": "string"
                  },
                  "subscription_id": {
                    "type": "string"
                  },
                  "subscription_item_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "quantity": {
                    "type": "integer"
                  },
                  "free_until": {
                    "type": "number",
                    "nullable": true,
                    "description": "First charged at this cut (ms). Always null for Connect."
                  },
                  "prorated": {
                    "type": "boolean"
                  },
                  "charged": {
                    "type": "boolean"
                  },
                  "connect": {
                    "$ref": "#/components/schemas/AccountBillingConnect"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "description": "A feature turned off (`POST /teams/{id}/billing/features/deactivate`).",
                "required": [
                  "kind",
                  "scope",
                  "team_id",
                  "feature",
                  "ends_at"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "feature_off"
                    ]
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "team",
                      "billing_account"
                    ]
                  },
                  "team_id": {
                    "type": "string"
                  },
                  "feature": {
                    "type": "string"
                  },
                  "ends_at": {
                    "type": "number",
                    "nullable": true,
                    "description": "Still on until this cut (ms); null when it is off already."
                  },
                  "connect": {
                    "$ref": "#/components/schemas/AccountBillingConnect"
                  }
                }
              }
            ]
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message",
              "retryable"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              }
            },
            "nullable": true
          },
          "resolution": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "action",
              "resolved_at"
            ],
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "released_for_new_operation"
                ]
              },
              "resolved_at": {
                "type": "number"
              }
            },
            "nullable": true
          }
        }
      },
      "AccountBillingConnect": {
        "type": "object",
        "additionalProperties": false,
        "description": "Pricing v3 gigstack Connect of the billing account (only on `feature: connect` results).",
        "required": [
          "state",
          "ends_at",
          "staff_managed",
          "free",
          "subscription_item_id"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "off",
              "on",
              "ending"
            ]
          },
          "ends_at": {
            "type": "integer",
            "nullable": true
          },
          "staff_managed": {
            "type": "boolean"
          },
          "free": {
            "type": "boolean"
          },
          "subscription_item_id": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "AccountBillingSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "billing_account_id",
          "effect_scope",
          "provider_environment",
          "can_manage",
          "customer_id",
          "plan",
          "usage",
          "subscriptions",
          "subscriptions_has_more"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "billing_account_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "billing_account_shared"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "production"
            ]
          },
          "can_manage": {
            "type": "boolean"
          },
          "customer_id": {
            "type": "string",
            "nullable": true
          },
          "plan": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "pricing_version",
              "subscription_id",
              "status",
              "billing_cycle",
              "cancellation_date",
              "features"
            ],
            "properties": {
              "id": {
                "type": "string",
                "nullable": true
              },
              "name": {
                "type": "string",
                "nullable": true
              },
              "pricing_version": {
                "type": "string",
                "nullable": true
              },
              "subscription_id": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string",
                "nullable": true
              },
              "billing_cycle": {
                "type": "string",
                "nullable": true
              },
              "cancellation_date": {
                "type": "integer",
                "nullable": true,
                "description": "While the subscription is past due, when its grace ends (ms). Paid features pause after it unless the invoice is paid."
              },
              "features": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "includedDocuments": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "seats": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "maxClients": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "selfBillingPortal": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "maxIntegrations": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "customerPortal": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "technicalSupport": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "apiAndWebhooks": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "customDomain": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "multipleIssuerAccounts": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "analyticsAndReports": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "dedicatedSupportChannel": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "supplierMode": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  },
                  "erps": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "boolean"
                      }
                    ]
                  }
                }
              }
            }
          },
          "usage": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "used_documents",
              "included_documents",
              "credits",
              "current_period_start",
              "current_period_end"
            ],
            "properties": {
              "used_documents": {
                "type": "number",
                "nullable": true
              },
              "included_documents": {
                "type": "number",
                "nullable": true
              },
              "credits": {
                "type": "number",
                "nullable": true
              },
              "current_period_start": {
                "type": "number",
                "nullable": true
              },
              "current_period_end": {
                "type": "number",
                "nullable": true
              }
            }
          },
          "retention_offer": {
            "type": "object",
            "additionalProperties": false,
            "description": "Pricing v3 cancel flow: whether the app may offer one free month of the fixed fees before a cancel. Decided by fixed rules (active, live 30 days, once per account).",
            "required": [
              "eligible",
              "reason",
              "used_at"
            ],
            "properties": {
              "eligible": {
                "type": "boolean"
              },
              "reason": {
                "type": "string",
                "nullable": true,
                "enum": [
                  "not_v3",
                  "no_subscription",
                  "not_active",
                  "cancel_scheduled",
                  "already_used",
                  "too_new",
                  null
                ],
                "description": "Why it is not offered; null when it is."
              },
              "used_at": {
                "type": "integer",
                "nullable": true,
                "description": "When the account took its free month (ms), if ever."
              }
            }
          },
          "cancellation": {
            "type": "object",
            "nullable": true,
            "additionalProperties": false,
            "description": "The cancel the account asked for from the app, if any.",
            "required": [
              "requested_at",
              "reason",
              "cancel_at",
              "resumed_at"
            ],
            "properties": {
              "requested_at": {
                "type": "integer",
                "nullable": true
              },
              "reason": {
                "type": "string",
                "nullable": true
              },
              "cancel_at": {
                "type": "integer",
                "nullable": true,
                "description": "When the subscription ends (ms)."
              },
              "resumed_at": {
                "type": "integer",
                "nullable": true,
                "description": "When the cancel was undone (ms), if it was."
              }
            }
          },
          "connect": {
            "type": "object",
            "nullable": true,
            "additionalProperties": false,
            "description": "Pricing v3: the billing account's gigstack Connect, turned on and off with `POST /teams/{id}/billing/features` (`feature: connect`). Null on legacy plans, whose Connect is `plan.features.multipleIssuerAccounts`.",
            "required": [
              "state",
              "ends_at",
              "staff_managed",
              "free",
              "subscription_item_id"
            ],
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "off",
                  "on",
                  "ending"
                ],
                "description": "`ending`: turned off from the app, still on until `ends_at`."
              },
              "ends_at": {
                "type": "integer",
                "nullable": true,
                "description": "When an `ending` Connect turns off (ms, the next cut)."
              },
              "staff_managed": {
                "type": "boolean",
                "description": "Turned on by gigstack staff; it cannot be turned off from the app."
              },
              "free": {
                "type": "boolean",
                "description": "On at no charge because the price list does not charge Connect."
              },
              "subscription_item_id": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "credits": {
            "type": "object",
            "nullable": true,
            "additionalProperties": false,
            "description": "Pricing v3 only (absent for other accounts; null when it cannot be read). The credits and usage of the current calendar month in Mexico City, from the same rating the usage meter bills. Credits are numbers of credits, amounts are MXN before IVA, dates are ms.",
            "required": [
              "period",
              "period_start",
              "period_end",
              "credit_value_mxn",
              "given",
              "used",
              "left",
              "welcome",
              "gifts",
              "free_units",
              "free_documents",
              "usage_credits",
              "charge_mxn",
              "reported_mxn",
              "threshold"
            ],
            "properties": {
              "period": {
                "type": "string",
                "description": "The month rated, YYYY-MM."
              },
              "period_start": {
                "type": "integer"
              },
              "period_end": {
                "type": "integer",
                "description": "First instant after the month (ms)."
              },
              "credit_value_mxn": {
                "type": "number",
                "description": "MXN per credit."
              },
              "given": {
                "type": "number",
                "description": "Welcome credits and gifts that cover this month."
              },
              "used": {
                "type": "number",
                "description": "Credits taken off this month's usage."
              },
              "left": {
                "type": "number",
                "description": "Credits left after this month's usage. A welcome or gift also used in earlier months has less left than given minus used."
              },
              "welcome": {
                "type": "object",
                "nullable": true,
                "additionalProperties": false,
                "description": "The one-time credits given at go-live. They cover the go-live month and the next; what is left after that lapses. Null when the account has none.",
                "required": [
                  "given",
                  "used",
                  "left",
                  "expires_at",
                  "lapsed"
                ],
                "properties": {
                  "given": {
                    "type": "number"
                  },
                  "used": {
                    "type": "number"
                  },
                  "left": {
                    "type": "number"
                  },
                  "expires_at": {
                    "type": "integer",
                    "description": "End of the welcome's last month (ms)."
                  },
                  "lapsed": {
                    "type": "boolean"
                  }
                }
              },
              "gifts": {
                "type": "object",
                "additionalProperties": false,
                "description": "Credit gifts covering this month, used oldest first after the welcome.",
                "required": [
                  "given",
                  "used",
                  "left",
                  "items"
                ],
                "properties": {
                  "given": {
                    "type": "number"
                  },
                  "used": {
                    "type": "number"
                  },
                  "left": {
                    "type": "number"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "given",
                        "used",
                        "left",
                        "until_period"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "given": {
                          "type": "number"
                        },
                        "used": {
                          "type": "number"
                        },
                        "left": {
                          "type": "number"
                        },
                        "until_period": {
                          "type": "string",
                          "description": "Last month the gift covers, YYYY-MM."
                        }
                      }
                    }
                  }
                }
              },
              "free_units": {
                "type": "array",
                "description": "Documents without charge this month, per unit, summed over the account's teams. They are used before any credit. Units in `free_documents` are not listed here.",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "unit",
                    "included",
                    "used"
                  ],
                  "properties": {
                    "unit": {
                      "type": "string"
                    },
                    "included": {
                      "type": "integer"
                    },
                    "used": {
                      "type": "integer"
                    }
                  }
                }
              },
              "free_documents": {
                "type": "object",
                "nullable": true,
                "additionalProperties": false,
                "description": "Documents without charge this month shared by several units (the catalog's per-team allowance across income, payment complement, credit note, transfer and retention; the current catalog sets it to 0, so every document is charged from the first), summed over the account's live teams, and how many were used. Null when every unit has its own free units (`free_units`).",
                "required": [
                  "included",
                  "used",
                  "units"
                ],
                "properties": {
                  "included": {
                    "type": "integer"
                  },
                  "used": {
                    "type": "integer"
                  },
                  "units": {
                    "type": "array",
                    "description": "The units that draw on it, in the order they draw on it.",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "usage_credits": {
                "type": "number",
                "description": "This month's usage in credits, before welcome credits and gifts."
              },
              "charge_mxn": {
                "type": "number",
                "description": "This month's usage beyond the credits, in MXN before IVA."
              },
              "reported_mxn": {
                "type": "number",
                "nullable": true,
                "description": "What the usage meter has sent for this month so far, in MXN before IVA."
              },
              "threshold": {
                "type": "object",
                "additionalProperties": false,
                "description": "Early billing: the subscription is invoiced as soon as its usage reaches this amount (MXN before IVA). `remaining_mxn` compares it with this month's charge; Stripe counts its own billing period, so it is an estimate.",
                "required": [
                  "amount_mxn",
                  "source",
                  "remaining_mxn"
                ],
                "properties": {
                  "amount_mxn": {
                    "type": "number",
                    "nullable": true
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "account",
                      "catalog",
                      "default"
                    ]
                  },
                  "remaining_mxn": {
                    "type": "number",
                    "nullable": true
                  }
                }
              }
            }
          },
          "subscriptions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountBillingSubscription"
            }
          },
          "subscriptions_has_more": {
            "type": "boolean"
          }
        }
      },
      "PriceTier": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "up_to",
          "unit_price"
        ],
        "properties": {
          "up_to": {
            "type": "integer",
            "nullable": true,
            "description": "Last position (inclusive) this price applies to; null for the open last step.",
            "example": 50
          },
          "unit_price": {
            "type": "number",
            "description": "MXN before IVA.",
            "example": 2.1
          }
        }
      },
      "PriceList": {
        "type": "object",
        "description": "Pricing v3 price list, from the billing catalog (the admin panel edits it). Amounts are MXN before IVA (16% is added on top): catalog credits × the country's credit value. A price the catalog does not have is left out, never guessed, so hide what is missing instead of showing a remembered number. One rule for `charged`: false means free, and the item is listed at 0 (`monthly_price` and every `unit_price`). An add-on (`add_on: true`) with `charged: false` is turned on at no cost. The only exception is the first RFC while it is a fixed item of the subscription: its `monthly_price` stays, since going live charges it. `listed` says whether the item is on the public list; `GET /pricing` leaves out the ones that are not, the account's own list keeps them.",
        "additionalProperties": false,
        "required": [
          "country",
          "currency",
          "taxes_included",
          "available",
          "units",
          "features",
          "signup_credits",
          "free_documents",
          "billing_threshold",
          "billing_threshold_source"
        ],
        "properties": {
          "country": {
            "type": "string",
            "enum": [
              "MEX",
              "COL"
            ]
          },
          "currency": {
            "type": "string",
            "example": "MXN"
          },
          "taxes_included": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "available": {
            "type": "boolean",
            "description": "False while the country has no credit value; every map is then empty."
          },
          "units": {
            "type": "object",
            "description": "Per document or event, keyed by usage unit (invoice_income, invoice_egress, invoice_payment_complement, invoice_transfer, retention, receipt, sat_xml, payment_paid…).",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "label",
                "charged",
                "listed",
                "free_units",
                "tiers",
                "automatic_multiplier"
              ],
              "properties": {
                "label": {
                  "type": "string"
                },
                "charged": {
                  "type": "boolean",
                  "description": "False means free; every `unit_price` is then 0."
                },
                "listed": {
                  "type": "boolean",
                  "description": "On the public price list. Always true in GET /pricing."
                },
                "free_units": {
                  "type": "integer",
                  "description": "Free units per team per month before the scale applies. 0 for a unit in `free_documents`, whose shared allowance replaces it."
                },
                "tiers": {
                  "type": "array",
                  "description": "Graduated; each step charges only the units inside it.",
                  "items": {
                    "$ref": "#/components/schemas/PriceTier"
                  }
                },
                "automatic_multiplier": {
                  "type": "number",
                  "nullable": true,
                  "description": "Share of the step price automatic documents pay."
                }
              }
            }
          },
          "features": {
            "type": "object",
            "description": "Monthly fees keyed by feature (taxpayer, self_invoice_portal, connect, support…).",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "label",
                "charged",
                "listed",
                "scope",
                "monthly_price",
                "included",
                "add_on",
                "per_account_with_connect",
                "charge_only_when_active"
              ],
              "properties": {
                "label": {
                  "type": "string"
                },
                "charged": {
                  "type": "boolean",
                  "description": "False means free: `monthly_price` is 0 and turning the add-on on adds nothing to the bill. Exception: the first RFC while it is a fixed item of the subscription."
                },
                "listed": {
                  "type": "boolean",
                  "description": "On the public price list. Always true in GET /pricing."
                },
                "scope": {
                  "type": "string",
                  "enum": [
                    "team",
                    "billingAccount"
                  ]
                },
                "monthly_price": {
                  "type": "number",
                  "description": "MXN before IVA, 0 when not charged. For taxpayer, the first taxpayer."
                },
                "included": {
                  "type": "boolean",
                  "description": "Included at no charge by decision."
                },
                "add_on": {
                  "type": "boolean",
                  "description": "A billing admin turns it on from the app (POST /teams/{id}/billing/features)."
                },
                "per_account_with_connect": {
                  "type": "boolean"
                },
                "charge_only_when_active": {
                  "type": "boolean"
                },
                "extra_tiers": {
                  "type": "array",
                  "description": "Taxpayer only. Each additional taxpayer, by its position (2 onwards).",
                  "items": {
                    "$ref": "#/components/schemas/PriceTier"
                  }
                }
              }
            }
          },
          "signup_credits": {
            "type": "object",
            "nullable": true,
            "description": "One-time credits a new account gets when it goes live.",
            "additionalProperties": false,
            "required": [
              "credits",
              "value",
              "expires_in_days"
            ],
            "properties": {
              "credits": {
                "type": "number"
              },
              "value": {
                "type": "number",
                "description": "MXN before IVA."
              },
              "expires_in_days": {
                "type": "integer",
                "nullable": true
              }
            }
          },
          "free_documents": {
            "type": "object",
            "nullable": true,
            "description": "The catalog's allowance of free documents per team per month, in total across `units` (the units' own `free_units` are then 0). The current catalog sets `included` to 0: every document is charged from the first. Null when every unit has its own free units.",
            "additionalProperties": false,
            "required": [
              "included",
              "units"
            ],
            "properties": {
              "included": {
                "type": "integer"
              },
              "units": {
                "type": "array",
                "description": "The units that draw on it, in the order they draw on it.",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "billing_threshold": {
            "type": "number",
            "nullable": true,
            "description": "Early billing: usage is invoiced before the monthly cut once it reaches this (MXN before IVA). Null: monthly only. An account can have its own (see the billing summary credits)."
          },
          "billing_threshold_source": {
            "type": "string",
            "enum": [
              "catalog",
              "default"
            ],
            "description": "`default`: the catalog has none and the built-in default applies."
          }
        },
        "example": {
          "country": "MEX",
          "currency": "MXN",
          "taxes_included": false,
          "available": true,
          "units": {
            "invoice_income": {
              "label": "Factura de ingreso",
              "charged": true,
              "listed": true,
              "free_units": 0,
              "tiers": [
                {
                  "up_to": 50,
                  "unit_price": 2.1
                },
                {
                  "up_to": null,
                  "unit_price": 0.4
                }
              ],
              "automatic_multiplier": 0.5
            }
          },
          "features": {
            "recurring_invoicing": {
              "label": "Facturas y pagos recurrentes",
              "charged": true,
              "listed": true,
              "scope": "team",
              "monthly_price": 99,
              "included": false,
              "add_on": true,
              "per_account_with_connect": true,
              "charge_only_when_active": false
            }
          },
          "signup_credits": null,
          "free_documents": {
            "included": 0,
            "units": [
              "invoice_income",
              "invoice_payment_complement",
              "invoice_egress",
              "invoice_transfer",
              "retention"
            ]
          },
          "billing_threshold": 500,
          "billing_threshold_source": "catalog"
        }
      },
      "AccountBillingPlans": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "billing_account_id",
          "effect_scope",
          "provider_environment",
          "data"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "billing_account_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "billing_account_shared"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "production"
            ]
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "version",
                "name",
                "description",
                "features",
                "monthly",
                "annual"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "version": {
                  "type": "string",
                  "nullable": true
                },
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "features": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "includedDocuments": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "seats": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "maxClients": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "selfBillingPortal": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "maxIntegrations": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "customerPortal": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "technicalSupport": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "apiAndWebhooks": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "customDomain": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "multipleIssuerAccounts": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "analyticsAndReports": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "dedicatedSupportChannel": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "supplierMode": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "erps": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    }
                  }
                },
                "monthly": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "currency",
                    "interval",
                    "amount",
                    "included_documents",
                    "additional_document_amount"
                  ],
                  "properties": {
                    "currency": {
                      "type": "string",
                      "nullable": true
                    },
                    "interval": {
                      "type": "string",
                      "nullable": true
                    },
                    "amount": {
                      "type": "number",
                      "nullable": true
                    },
                    "included_documents": {
                      "type": "number",
                      "nullable": true
                    },
                    "additional_document_amount": {
                      "type": "number",
                      "nullable": true
                    }
                  },
                  "nullable": true
                },
                "annual": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "currency",
                    "interval",
                    "amount",
                    "included_documents",
                    "additional_document_amount"
                  ],
                  "properties": {
                    "currency": {
                      "type": "string",
                      "nullable": true
                    },
                    "interval": {
                      "type": "string",
                      "nullable": true
                    },
                    "amount": {
                      "type": "number",
                      "nullable": true
                    },
                    "included_documents": {
                      "type": "number",
                      "nullable": true
                    },
                    "additional_document_amount": {
                      "type": "number",
                      "nullable": true
                    }
                  },
                  "nullable": true
                }
              }
            }
          }
        }
      },
      "AccountBillingHistory": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "billing_account_id",
          "effect_scope",
          "provider_environment",
          "data",
          "has_more",
          "cursor"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "billing_account_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "billing_account_shared"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "production"
            ]
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountBillingInvoice"
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "cursor": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "AccountBillingCheckoutInput": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
          },
          "plan_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$"
          },
          "billing_cycle": {
            "type": "string",
            "enum": [
              "monthly",
              "annual"
            ]
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10000
          },
          "plan_version": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$"
          },
          "intro": {
            "type": "boolean"
          },
          "trial_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$"
          },
          "partner_ref": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "coupon": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          }
        },
        "required": [
          "operation_id",
          "plan_id",
          "billing_cycle"
        ],
        "additionalProperties": false,
        "not": {
          "required": [
            "intro",
            "trial_id"
          ],
          "properties": {
            "intro": {
              "enum": [
                true
              ]
            }
          }
        }
      },
      "AccountBillingUpgradeInput": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
          },
          "plan_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$"
          },
          "billing_cycle": {
            "type": "string",
            "enum": [
              "monthly",
              "annual"
            ]
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10000
          }
        },
        "required": [
          "operation_id",
          "plan_id",
          "billing_cycle"
        ],
        "additionalProperties": false
      },
      "AccountBillingPortalInput": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
          },
          "intent": {
            "type": "string",
            "enum": [
              "manage",
              "cancel_subscription",
              "update_payment_method"
            ]
          }
        },
        "required": [
          "operation_id",
          "intent"
        ],
        "additionalProperties": false
      },
      "AccountBillingGoLiveInput": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
          }
        },
        "required": [
          "operation_id"
        ],
        "additionalProperties": false
      },
      "AccountBillingFeatureActivateInput": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
          },
          "feature": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$",
            "example": "self_invoice_portal",
            "description": "Catalog key of a paid team feature, e.g. `self_invoice_portal`, or `connect` for gigstack Connect on the whole billing account."
          }
        },
        "required": [
          "operation_id",
          "feature"
        ],
        "additionalProperties": false
      },
      "AccountBillingFiscalInput": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
          },
          "fiscal": {
            "type": "object",
            "properties": {
              "legal_name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "rfc": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "tax_system": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "use": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "email": {
                "type": "string",
                "minLength": 1,
                "maxLength": 320,
                "nullable": true
              },
              "phone": {
                "type": "string",
                "minLength": 1,
                "maxLength": 320,
                "nullable": true
              },
              "address": {
                "type": "object",
                "properties": {
                  "zip": {
                    "type": "string",
                    "pattern": "^\\d{5}$"
                  },
                  "street": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "nullable": true
                  },
                  "exterior": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "nullable": true
                  },
                  "interior": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "nullable": true
                  },
                  "neighborhood": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "nullable": true
                  },
                  "municipality": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "nullable": true
                  },
                  "city": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "nullable": true
                  },
                  "state": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "nullable": true
                  },
                  "country": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "nullable": true
                  }
                },
                "required": [
                  "zip"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "legal_name",
              "rfc",
              "tax_system",
              "use",
              "address"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "operation_id",
          "fiscal"
        ],
        "additionalProperties": false
      },
      "AccountBillingCancelInput": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
          }
        },
        "required": [
          "operation_id"
        ],
        "additionalProperties": false
      },
      "AccountBillingReconcileInput": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "AccountBillingResolveInput": {
        "type": "object",
        "properties": {
          "acknowledge_unconfirmed_effects": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "acknowledge_unconfirmed_effects"
        ],
        "additionalProperties": false
      },
      "AccountBrand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "effect_scope",
          "brand"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared"
            ]
          },
          "brand": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "alias",
              "primary_color",
              "secondary_color",
              "logo",
              "voice"
            ],
            "properties": {
              "alias": {
                "type": "string",
                "nullable": true
              },
              "primary_color": {
                "type": "string",
                "nullable": true
              },
              "secondary_color": {
                "type": "string",
                "nullable": true
              },
              "logo": {
                "type": "string",
                "nullable": true
              },
              "voice": {
                "type": "string",
                "nullable": true
              }
            }
          }
        }
      },
      "AccountPortal": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "effect_scope",
          "slug",
          "url",
          "can_register",
          "can_rename"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared"
            ]
          },
          "slug": {
            "type": "string",
            "nullable": true
          },
          "url": {
            "type": "string",
            "nullable": true
          },
          "can_register": {
            "type": "boolean"
          },
          "can_rename": {
            "type": "boolean"
          }
        }
      },
      "AccountBrandAnalysis": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "effect_scope",
          "analysis"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared"
            ]
          },
          "analysis": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "brandVoice",
              "analyzedUrl",
              "pagesAnalyzed",
              "saved"
            ],
            "properties": {
              "brandVoice": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "tone",
                  "style",
                  "targetAudience",
                  "summary",
                  "personality",
                  "vocabulary",
                  "avoidWords",
                  "values",
                  "examplePhrases"
                ],
                "properties": {
                  "tone": {
                    "type": "string"
                  },
                  "style": {
                    "type": "string"
                  },
                  "targetAudience": {
                    "type": "string"
                  },
                  "summary": {
                    "type": "string"
                  },
                  "personality": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "vocabulary": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "avoidWords": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "values": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "examplePhrases": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "analyzedUrl": {
                "type": "string"
              },
              "pagesAnalyzed": {
                "type": "integer"
              },
              "saved": {
                "type": "boolean",
                "enum": [
                  false
                ]
              }
            }
          }
        }
      },
      "AccountBrandLogoResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "team_id",
          "effect_scope",
          "brand",
          "storage_cleanup"
        ],
        "properties": {
          "team_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared"
            ]
          },
          "brand": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "alias",
              "primary_color",
              "secondary_color",
              "logo",
              "voice"
            ],
            "properties": {
              "alias": {
                "type": "string",
                "nullable": true
              },
              "primary_color": {
                "type": "string",
                "nullable": true
              },
              "secondary_color": {
                "type": "string",
                "nullable": true
              },
              "logo": {
                "type": "string",
                "nullable": true
              },
              "voice": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "storage_cleanup": {
            "type": "string",
            "enum": [
              "not_needed",
              "removed",
              "retained"
            ]
          }
        }
      },
      "AccountPortalInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "slug"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9]+$"
          },
          "expected_slug": {
            "type": "string",
            "nullable": true,
            "maxLength": 128
          },
          "confirm_existing_links_change": {
            "type": "boolean"
          }
        }
      },
      "AccountBrandInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "alias": {
            "type": "string",
            "nullable": true,
            "maxLength": 200
          },
          "primary_color": {
            "type": "string",
            "nullable": true,
            "maxLength": 40
          },
          "secondary_color": {
            "type": "string",
            "nullable": true,
            "maxLength": 40
          },
          "voice": {
            "type": "string",
            "nullable": true,
            "maxLength": 20000
          }
        }
      },
      "AccountBrandAnalysisInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2048,
            "format": "uri"
          }
        }
      },
      "IntegrationSetupCreateInput": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "airtable",
              "mercadolibre",
              "netsuite",
              "zettle"
            ]
          },
          "expected_livemode": {
            "type": "boolean"
          },
          "recovery_operation_id": {
            "type": "string",
            "minLength": 36,
            "maxLength": 36,
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
          },
          "acknowledge_unconfirmed_effects": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "provider"
        ],
        "additionalProperties": false,
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "provider": {
                "type": "string",
                "enum": [
                  "airtable"
                ]
              },
              "expected_livemode": {
                "type": "boolean"
              }
            },
            "required": [
              "provider",
              "expected_livemode"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "provider": {
                "type": "string",
                "enum": [
                  "airtable"
                ]
              },
              "expected_livemode": {
                "type": "boolean"
              },
              "recovery_operation_id": {
                "type": "string",
                "minLength": 36,
                "maxLength": 36,
                "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
              },
              "acknowledge_unconfirmed_effects": {
                "type": "boolean",
                "enum": [
                  true
                ]
              }
            },
            "required": [
              "provider",
              "expected_livemode",
              "recovery_operation_id",
              "acknowledge_unconfirmed_effects"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "provider": {
                "type": "string",
                "enum": [
                  "mercadolibre",
                  "netsuite",
                  "zettle"
                ]
              },
              "expected_livemode": {
                "type": "boolean"
              }
            },
            "required": [
              "provider"
            ],
            "additionalProperties": false
          }
        ]
      },
      "IntegrationSetupEmptyInput": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "IntegrationSetupResolveInput": {
        "type": "object",
        "properties": {
          "acknowledge_unconfirmed_effects": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "acknowledge_unconfirmed_effects"
        ],
        "additionalProperties": false
      },
      "IntegrationSetupSubmitInput": {
        "type": "object",
        "properties": {
          "consent": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "credentials": {
            "anyOf": [
              {
                "type": "object",
                "properties": {},
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "accountId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "consumerKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 16000
                  },
                  "consumerSecret": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 16000
                  },
                  "tokenId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 16000
                  },
                  "tokenSecret": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 16000
                  }
                },
                "required": [
                  "accountId",
                  "consumerKey",
                  "consumerSecret",
                  "tokenId",
                  "tokenSecret"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "clientId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "apiKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 16000
                  },
                  "cardPaymentForm": {
                    "type": "string",
                    "enum": [
                      "04",
                      "28"
                    ]
                  }
                },
                "required": [
                  "clientId",
                  "apiKey",
                  "cardPaymentForm"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "required": [
          "consent"
        ],
        "additionalProperties": false
      },
      "IntegrationSetupSession": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "team_id": {
            "type": "string"
          },
          "team": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "id",
              "name"
            ]
          },
          "provider": {
            "type": "string",
            "enum": [
              "airtable",
              "mercadolibre",
              "netsuite",
              "zettle"
            ]
          },
          "method": {
            "type": "string",
            "enum": [
              "oauth",
              "credentials"
            ]
          },
          "credential_livemode": {
            "type": "boolean"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared_credentials",
              "credential_mode",
              "connection_import_mode"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "awaiting_oauth",
              "completed",
              "failed",
              "outcome_unknown",
              "cancelled",
              "expired"
            ]
          },
          "created_at": {
            "type": "number"
          },
          "expires_at": {
            "type": "number"
          },
          "updated_at": {
            "type": "number"
          },
          "completion_url": {
            "type": "string"
          },
          "can_submit": {
            "type": "boolean"
          },
          "recovery_available_at": {
            "type": "number",
            "nullable": true
          },
          "disclosures": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "credential_schema": {
            "type": "object",
            "additionalProperties": true,
            "description": "Exact public browser form schema; contains no stored credential values."
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "connected": {
                "type": "boolean"
              },
              "credentials_may_be_stored": {
                "type": "boolean"
              }
            },
            "required": [
              "connected",
              "credentials_may_be_stored"
            ],
            "nullable": true
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "nullable": true
          },
          "resolution": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "released_for_new_session"
                ]
              },
              "resolved_at": {
                "type": "number"
              }
            },
            "required": [
              "action",
              "resolved_at"
            ],
            "nullable": true
          },
          "recovery": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "operation_id": {
                "type": "string"
              },
              "action": {
                "type": "string",
                "enum": [
                  "register",
                  "unregister",
                  "disconnect"
                ]
              },
              "original_status": {
                "type": "string",
                "enum": [
                  "outcome_unknown"
                ]
              },
              "effect_scope": {
                "type": "string",
                "enum": [
                  "shared_connection"
                ]
              },
              "livemode": {
                "type": "boolean"
              },
              "local_disabled_count": {
                "type": "integer",
                "minimum": 0
              },
              "snapshot_complete": {
                "type": "boolean"
              },
              "identity_verification": {
                "type": "string",
                "enum": [
                  "pending",
                  "same",
                  "different",
                  "unverified"
                ]
              },
              "imports_disabled": {
                "type": "boolean",
                "enum": [
                  true
                ]
              },
              "prior_outcome_preserved": {
                "type": "boolean",
                "enum": [
                  true
                ]
              }
            },
            "required": [
              "operation_id",
              "action",
              "original_status",
              "effect_scope",
              "livemode",
              "local_disabled_count",
              "snapshot_complete",
              "identity_verification",
              "imports_disabled",
              "prior_outcome_preserved"
            ],
            "nullable": true
          }
        },
        "required": [
          "id",
          "team_id",
          "team",
          "provider",
          "method",
          "credential_livemode",
          "effect_scope",
          "status",
          "created_at",
          "expires_at",
          "updated_at",
          "completion_url",
          "can_submit",
          "recovery_available_at",
          "disclosures",
          "credential_schema",
          "result",
          "error",
          "resolution"
        ]
      },
      "IntegrationSetupBrowserSession": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "team_id": {
            "type": "string"
          },
          "team": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "id",
              "name"
            ]
          },
          "provider": {
            "type": "string",
            "enum": [
              "airtable",
              "mercadolibre",
              "netsuite",
              "zettle"
            ]
          },
          "method": {
            "type": "string",
            "enum": [
              "oauth",
              "credentials"
            ]
          },
          "credential_livemode": {
            "type": "boolean"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared_credentials",
              "credential_mode",
              "connection_import_mode"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "awaiting_oauth",
              "completed",
              "failed",
              "outcome_unknown",
              "cancelled",
              "expired"
            ]
          },
          "created_at": {
            "type": "number"
          },
          "expires_at": {
            "type": "number"
          },
          "updated_at": {
            "type": "number"
          },
          "completion_url": {
            "type": "string"
          },
          "can_submit": {
            "type": "boolean"
          },
          "recovery_available_at": {
            "type": "number",
            "nullable": true
          },
          "disclosures": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "credential_schema": {
            "type": "object",
            "additionalProperties": true,
            "description": "Exact public browser form schema; contains no stored credential values."
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "connected": {
                "type": "boolean"
              },
              "credentials_may_be_stored": {
                "type": "boolean"
              }
            },
            "required": [
              "connected",
              "credentials_may_be_stored"
            ],
            "nullable": true
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "nullable": true
          },
          "resolution": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "released_for_new_session"
                ]
              },
              "resolved_at": {
                "type": "number"
              }
            },
            "required": [
              "action",
              "resolved_at"
            ],
            "nullable": true
          },
          "authorize_url": {
            "type": "string",
            "description": "OAuth authorization URL returned only to the submitting signed-in browser. Never stored or returned by agent readback."
          }
        },
        "required": [
          "id",
          "team_id",
          "team",
          "provider",
          "method",
          "credential_livemode",
          "effect_scope",
          "status",
          "created_at",
          "expires_at",
          "updated_at",
          "completion_url",
          "can_submit",
          "recovery_available_at",
          "disclosures",
          "credential_schema",
          "result",
          "error",
          "resolution"
        ]
      },
      "AccountEmailDomain": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "domain": {
            "type": "string",
            "nullable": true
          },
          "subdomain": {
            "type": "string",
            "nullable": true
          },
          "full_domain": {
            "type": "string",
            "nullable": true
          },
          "valid": {
            "type": "boolean"
          },
          "dns_setup": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "host": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "data": {
                  "type": "string"
                },
                "valid": {
                  "type": "boolean"
                }
              },
              "required": [
                "host",
                "type",
                "data",
                "valid"
              ]
            }
          },
          "configured": {
            "type": "boolean"
          }
        },
        "required": [
          "domain",
          "subdomain",
          "full_domain",
          "valid",
          "dns_setup",
          "configured"
        ]
      },
      "AccountEmailDomainOperation": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "set",
              "validate",
              "remove"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "completed",
              "failed",
              "outcome_unknown"
            ]
          },
          "created_at": {
            "type": "number"
          },
          "started_at": {
            "type": "number",
            "nullable": true
          },
          "completed_at": {
            "type": "number",
            "nullable": true
          },
          "recovery_available_at": {
            "type": "number",
            "nullable": true
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "domain": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "domain": {
                    "type": "string",
                    "nullable": true
                  },
                  "subdomain": {
                    "type": "string",
                    "nullable": true
                  },
                  "full_domain": {
                    "type": "string",
                    "nullable": true
                  },
                  "valid": {
                    "type": "boolean"
                  },
                  "dns_setup": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "host": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "data": {
                          "type": "string"
                        },
                        "valid": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "host",
                        "type",
                        "data",
                        "valid"
                      ]
                    }
                  },
                  "configured": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "domain",
                  "subdomain",
                  "full_domain",
                  "valid",
                  "dns_setup",
                  "configured"
                ]
              },
              "previous_provider_domain_retained": {
                "type": "boolean"
              }
            },
            "required": [
              "domain",
              "previous_provider_domain_retained"
            ],
            "nullable": true
          },
          "error_code": {
            "type": "string",
            "nullable": true
          },
          "resolution": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "released_for_new_operation"
                ]
              },
              "resolved_at": {
                "type": "number"
              }
            },
            "required": [
              "action",
              "resolved_at"
            ],
            "nullable": true
          }
        },
        "required": [
          "id",
          "action",
          "status",
          "created_at",
          "started_at",
          "completed_at",
          "recovery_available_at",
          "result",
          "error_code",
          "resolution"
        ]
      },
      "AccountEmailDomainReconciled": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "set",
              "validate",
              "remove"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "completed",
              "failed",
              "outcome_unknown"
            ]
          },
          "created_at": {
            "type": "number"
          },
          "started_at": {
            "type": "number",
            "nullable": true
          },
          "completed_at": {
            "type": "number",
            "nullable": true
          },
          "recovery_available_at": {
            "type": "number",
            "nullable": true
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "domain": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "domain": {
                    "type": "string",
                    "nullable": true
                  },
                  "subdomain": {
                    "type": "string",
                    "nullable": true
                  },
                  "full_domain": {
                    "type": "string",
                    "nullable": true
                  },
                  "valid": {
                    "type": "boolean"
                  },
                  "dns_setup": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "host": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "data": {
                          "type": "string"
                        },
                        "valid": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "host",
                        "type",
                        "data",
                        "valid"
                      ]
                    }
                  },
                  "configured": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "domain",
                  "subdomain",
                  "full_domain",
                  "valid",
                  "dns_setup",
                  "configured"
                ]
              },
              "previous_provider_domain_retained": {
                "type": "boolean"
              }
            },
            "required": [
              "domain",
              "previous_provider_domain_retained"
            ],
            "nullable": true
          },
          "error_code": {
            "type": "string",
            "nullable": true
          },
          "resolution": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "released_for_new_operation"
                ]
              },
              "resolved_at": {
                "type": "number"
              }
            },
            "required": [
              "action",
              "resolved_at"
            ],
            "nullable": true
          },
          "observation": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "domain": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "domain": {
                    "type": "string",
                    "nullable": true
                  },
                  "subdomain": {
                    "type": "string",
                    "nullable": true
                  },
                  "full_domain": {
                    "type": "string",
                    "nullable": true
                  },
                  "valid": {
                    "type": "boolean"
                  },
                  "dns_setup": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "host": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "data": {
                          "type": "string"
                        },
                        "valid": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "host",
                        "type",
                        "data",
                        "valid"
                      ]
                    }
                  },
                  "configured": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "domain",
                  "subdomain",
                  "full_domain",
                  "valid",
                  "dns_setup",
                  "configured"
                ]
              },
              "attempt_confirmed": {
                "type": "boolean",
                "enum": [
                  false
                ]
              }
            },
            "required": [
              "domain",
              "attempt_confirmed"
            ]
          }
        },
        "required": [
          "id",
          "action",
          "status",
          "created_at",
          "started_at",
          "completed_at",
          "recovery_available_at",
          "result",
          "error_code",
          "resolution"
        ]
      },
      "AccountEmailDomainState": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "team_id": {
            "type": "string"
          },
          "billing_account_id": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_shared"
            ]
          },
          "provider_environment": {
            "type": "string",
            "enum": [
              "configured_sendgrid_account"
            ]
          },
          "testmode_isolates_provider": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "can_manage": {
            "type": "boolean",
            "description": "False when existing domain ownership requires operator verification."
          },
          "ownership_status": {
            "type": "string",
            "enum": [
              "verified",
              "migration_required"
            ],
            "description": "Provider ownership is established server-side; legacy unverified records require operator migration."
          },
          "domain": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "domain": {
                "type": "string",
                "nullable": true
              },
              "subdomain": {
                "type": "string",
                "nullable": true
              },
              "full_domain": {
                "type": "string",
                "nullable": true
              },
              "valid": {
                "type": "boolean"
              },
              "dns_setup": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "host": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "data": {
                      "type": "string"
                    },
                    "valid": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "host",
                    "type",
                    "data",
                    "valid"
                  ]
                }
              },
              "configured": {
                "type": "boolean"
              }
            },
            "required": [
              "domain",
              "subdomain",
              "full_domain",
              "valid",
              "dns_setup",
              "configured"
            ]
          },
          "active_operation": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "action": {
                "type": "string",
                "enum": [
                  "set",
                  "validate",
                  "remove"
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "processing",
                  "completed",
                  "failed",
                  "outcome_unknown"
                ]
              },
              "created_at": {
                "type": "number"
              },
              "started_at": {
                "type": "number",
                "nullable": true
              },
              "completed_at": {
                "type": "number",
                "nullable": true
              },
              "recovery_available_at": {
                "type": "number",
                "nullable": true
              },
              "result": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "domain": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "domain": {
                        "type": "string",
                        "nullable": true
                      },
                      "subdomain": {
                        "type": "string",
                        "nullable": true
                      },
                      "full_domain": {
                        "type": "string",
                        "nullable": true
                      },
                      "valid": {
                        "type": "boolean"
                      },
                      "dns_setup": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "host": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string"
                            },
                            "data": {
                              "type": "string"
                            },
                            "valid": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "host",
                            "type",
                            "data",
                            "valid"
                          ]
                        }
                      },
                      "configured": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "domain",
                      "subdomain",
                      "full_domain",
                      "valid",
                      "dns_setup",
                      "configured"
                    ]
                  },
                  "previous_provider_domain_retained": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "domain",
                  "previous_provider_domain_retained"
                ],
                "nullable": true
              },
              "error_code": {
                "type": "string",
                "nullable": true
              },
              "resolution": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "released_for_new_operation"
                    ]
                  },
                  "resolved_at": {
                    "type": "number"
                  }
                },
                "required": [
                  "action",
                  "resolved_at"
                ],
                "nullable": true
              }
            },
            "required": [
              "id",
              "action",
              "status",
              "created_at",
              "started_at",
              "completed_at",
              "recovery_available_at",
              "result",
              "error_code",
              "resolution"
            ],
            "nullable": true
          }
        },
        "required": [
          "team_id",
          "billing_account_id",
          "effect_scope",
          "provider_environment",
          "testmode_isolates_provider",
          "can_manage",
          "ownership_status",
          "domain",
          "active_operation"
        ]
      },
      "AccountEmailDomainSetInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "domain",
          "subdomain"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
          },
          "domain": {
            "type": "string",
            "minLength": 1,
            "maxLength": 253
          },
          "subdomain": {
            "type": "string",
            "minLength": 1,
            "maxLength": 253
          }
        }
      },
      "AccountEmailDomainOperationInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
          }
        }
      },
      "AccountEmailDomainEmptyInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      },
      "AccountEmailDomainResolveInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "acknowledge_unconfirmed_effects"
        ],
        "properties": {
          "acknowledge_unconfirmed_effects": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "AccountApprovalInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "action",
          "payload"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "action": {
            "type": "string",
            "enum": [
              "api_keys.create_scoped",
              "api_keys.rotate_scoped",
              "api_keys.generate",
              "api_keys.rotate",
              "mcp_tokens.create",
              "team.ownership.transfer",
              "team.members.promote_admin",
              "team.members.add_admin",
              "team.invitations.create_admin",
              "billing_account.invitations.create_admin",
              "managed_users.create_admin",
              "managed_users.issue_session",
              "managed_users.revoke_sessions"
            ]
          },
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "billing_account_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "payload": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "first_name": {
                "type": "string",
                "nullable": true,
                "maxLength": 100
              },
              "last_name": {
                "type": "string",
                "nullable": true,
                "maxLength": 100
              },
              "phone": {
                "type": "string",
                "nullable": true,
                "pattern": "^\\+[1-9]\\d{7,14}$"
              },
              "company_role": {
                "type": "string",
                "nullable": true,
                "maxLength": 100
              },
              "address": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "country": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "street": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "zip": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "city": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "state": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "exterior": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "municipality": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "neighborhood": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  }
                },
                "nullable": true
              },
              "email": {
                "type": "string",
                "maxLength": 320,
                "format": "email"
              },
              "send_email": {
                "type": "boolean"
              },
              "existing_invitation_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "billing_account_id": {
                "type": "string"
              },
              "team_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "maxItems": 100
              },
              "action_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "maxItems": 200
              },
              "manager_user_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "maxItems": 100
              },
              "expires_at": {
                "type": "integer",
                "nullable": true
              },
              "key_id": {
                "type": "string"
              },
              "overlap_seconds": {
                "type": "integer",
                "minimum": 0,
                "maximum": 86400
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "livemode": {
                "type": "boolean"
              },
              "environments": {
                "type": "string",
                "enum": [
                  "both"
                ]
              },
              "new_owner_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "user_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "member_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              }
            }
          }
        }
      },
      "AccountApprovalReceipt": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "key_id": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "api",
                    "mcp"
                  ]
                },
                "livemode": {
                  "type": "boolean"
                }
              },
              "required": [
                "key_id",
                "type",
                "livemode"
              ]
            }
          },
          "revoked_count": {
            "type": "integer",
            "minimum": 0
          },
          "membership": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "team.ownership.transfer",
                  "team.members.promote_admin",
                  "team.members.add_admin"
                ]
              },
              "member_id": {
                "type": "string"
              },
              "owner_id": {
                "type": "string"
              },
              "previous_owner_id": {
                "type": "string"
              },
              "role": {
                "type": "string",
                "enum": [
                  "admin"
                ]
              },
              "is_owner": {
                "type": "boolean"
              },
              "added": {
                "type": "boolean"
              }
            },
            "required": [
              "action",
              "member_id",
              "owner_id",
              "previous_owner_id",
              "role",
              "is_owner",
              "added"
            ],
            "nullable": true
          },
          "invitation": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "team",
                  "billingAccount"
                ]
              },
              "team_id": {
                "type": "string",
                "nullable": true
              },
              "billing_account_id": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "role": {
                "type": "string",
                "enum": [
                  "admin"
                ]
              },
              "expires_at": {
                "type": "number"
              },
              "approval_id": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "type",
              "team_id",
              "billing_account_id",
              "email",
              "role",
              "expires_at",
              "approval_id"
            ],
            "nullable": true
          },
          "managed_identity": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "user_id": {
                "type": "string"
              },
              "team_id": {
                "type": "string"
              },
              "billing_account_id": {
                "type": "string"
              },
              "role": {
                "type": "string",
                "enum": [
                  "admin"
                ]
              },
              "auth_state": {
                "type": "string",
                "enum": [
                  "enabled"
                ]
              },
              "membership_granted": {
                "type": "boolean",
                "enum": [
                  true
                ]
              }
            },
            "required": [
              "user_id",
              "team_id",
              "billing_account_id",
              "role",
              "auth_state",
              "membership_granted"
            ],
            "nullable": true
          },
          "managed_session": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "user_id": {
                "type": "string"
              },
              "approval_id": {
                "type": "string"
              },
              "action": {
                "type": "string",
                "enum": [
                  "managed_users.issue_session",
                  "managed_users.revoke_sessions"
                ]
              },
              "custom_token_expires_at": {
                "type": "number",
                "nullable": true,
                "description": "Custom-token exchange deadline in epoch milliseconds, not the expiry of a redeemed Firebase session. Null for revocation."
              },
              "session_expiration": {
                "type": "string",
                "enum": [
                  "not_bounded_by_custom_token"
                ]
              },
              "revocation_scope": {
                "type": "string",
                "enum": [
                  "refresh_tokens_only",
                  null
                ],
                "nullable": true
              }
            },
            "required": [
              "user_id",
              "approval_id",
              "action",
              "custom_token_expires_at",
              "session_expiration",
              "revocation_scope"
            ],
            "nullable": true
          },
          "scoped_api_key": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "key_id",
              "previous_key_id",
              "overlap_seconds",
              "previous_revoke_at",
              "metadata"
            ],
            "properties": {
              "key_id": {
                "type": "string"
              },
              "previous_key_id": {
                "type": "string",
                "nullable": true
              },
              "overlap_seconds": {
                "type": "integer",
                "minimum": 0,
                "maximum": 86400
              },
              "previous_revoke_at": {
                "type": "integer",
                "minimum": 0,
                "nullable": true
              },
              "metadata": {
                "$ref": "#/components/schemas/ScopedApiKeyMetadata"
              }
            },
            "nullable": true
          }
        },
        "required": [
          "keys",
          "revoked_count",
          "membership",
          "invitation",
          "managed_identity",
          "managed_session"
        ]
      },
      "AccountApproval": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "action": {
            "type": "string",
            "enum": [
              "api_keys.generate",
              "api_keys.rotate",
              "mcp_tokens.create",
              "team.ownership.transfer",
              "team.members.promote_admin",
              "team.members.add_admin",
              "team.invitations.create_admin",
              "billing_account.invitations.create_admin",
              "managed_users.create_admin",
              "managed_users.issue_session",
              "managed_users.revoke_sessions",
              "api_keys.create_scoped",
              "api_keys.rotate_scoped"
            ]
          },
          "team": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "legal_name": {
                "type": "string",
                "nullable": true
              },
              "tax_id": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "id",
              "legal_name",
              "tax_id"
            ],
            "nullable": true
          },
          "billing_account_id": {
            "type": "string"
          },
          "payload": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "livemode": {
                "type": "boolean"
              },
              "new_owner_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "member_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "email": {
                "type": "string"
              },
              "send_email": {
                "type": "boolean"
              },
              "existing_invitation_id": {
                "type": "string"
              },
              "first_name": {
                "type": "string",
                "nullable": true,
                "maxLength": 100
              },
              "last_name": {
                "type": "string",
                "nullable": true,
                "maxLength": 100
              },
              "phone": {
                "type": "string",
                "nullable": true,
                "pattern": "^\\+[1-9]\\d{7,14}$"
              },
              "company_role": {
                "type": "string",
                "nullable": true,
                "maxLength": 100
              },
              "address": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "country": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "street": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "zip": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "city": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "state": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "exterior": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "municipality": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  },
                  "neighborhood": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 250
                  }
                },
                "nullable": true
              },
              "user_id": {
                "type": "string"
              },
              "billing_account_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "team_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                },
                "minItems": 1,
                "maxItems": 100
              },
              "action_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 128
                },
                "minItems": 1,
                "maxItems": 200
              },
              "expires_at": {
                "type": "integer"
              },
              "manager_user_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                },
                "maxItems": 100
              },
              "key_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "overlap_seconds": {
                "type": "integer",
                "minimum": 0,
                "maximum": 86400
              }
            }
          },
          "requested_modes": {
            "type": "array",
            "items": {
              "type": "boolean"
            }
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_credentials",
              "user_access",
              "team_membership",
              "billing_account_membership",
              "managed_identity",
              "managed_session",
              "scoped_api_key"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "completed",
              "cancelled",
              "expired",
              "invalidated",
              "processing",
              "unknown",
              "failed",
              "activation_required"
            ]
          },
          "created_at": {
            "type": "number"
          },
          "expires_at": {
            "type": "number"
          },
          "completed_at": {
            "type": "number",
            "nullable": true
          },
          "review_url": {
            "type": "string",
            "format": "uri"
          },
          "can_cancel": {
            "type": "boolean"
          },
          "disclosure_version": {
            "type": "string",
            "enum": [
              "credential-approval-v1",
              "membership-approval-v1",
              "invitation-approval-v1",
              "managed-identity-v1",
              "managed-session-v1"
            ]
          },
          "existing_key_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "terms": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "acceptance_required": {
                "type": "boolean",
                "enum": [
                  true
                ]
              }
            },
            "required": [
              "url",
              "acceptance_required"
            ],
            "nullable": true
          },
          "receipt": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "keys": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "key_id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "api",
                        "mcp"
                      ]
                    },
                    "livemode": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "key_id",
                    "type",
                    "livemode"
                  ]
                }
              },
              "revoked_count": {
                "type": "integer",
                "minimum": 0
              },
              "membership": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "team.ownership.transfer",
                      "team.members.promote_admin",
                      "team.members.add_admin"
                    ]
                  },
                  "member_id": {
                    "type": "string"
                  },
                  "owner_id": {
                    "type": "string"
                  },
                  "previous_owner_id": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin"
                    ]
                  },
                  "is_owner": {
                    "type": "boolean"
                  },
                  "added": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "action",
                  "member_id",
                  "owner_id",
                  "previous_owner_id",
                  "role",
                  "is_owner",
                  "added"
                ],
                "nullable": true
              },
              "invitation": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "team",
                      "billingAccount"
                    ]
                  },
                  "team_id": {
                    "type": "string",
                    "nullable": true
                  },
                  "billing_account_id": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin"
                    ]
                  },
                  "expires_at": {
                    "type": "number"
                  },
                  "approval_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "type",
                  "team_id",
                  "billing_account_id",
                  "email",
                  "role",
                  "expires_at",
                  "approval_id"
                ],
                "nullable": true
              },
              "managed_identity": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "user_id": {
                    "type": "string"
                  },
                  "team_id": {
                    "type": "string"
                  },
                  "billing_account_id": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin"
                    ]
                  },
                  "auth_state": {
                    "type": "string",
                    "enum": [
                      "enabled"
                    ]
                  },
                  "membership_granted": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                },
                "required": [
                  "user_id",
                  "team_id",
                  "billing_account_id",
                  "role",
                  "auth_state",
                  "membership_granted"
                ],
                "nullable": true
              },
              "managed_session": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "user_id": {
                    "type": "string"
                  },
                  "approval_id": {
                    "type": "string"
                  },
                  "action": {
                    "type": "string",
                    "enum": [
                      "managed_users.issue_session",
                      "managed_users.revoke_sessions"
                    ]
                  },
                  "custom_token_expires_at": {
                    "type": "number",
                    "nullable": true,
                    "description": "Custom-token exchange deadline in epoch milliseconds, not the expiry of a redeemed Firebase session. Null for revocation."
                  },
                  "session_expiration": {
                    "type": "string",
                    "enum": [
                      "not_bounded_by_custom_token"
                    ]
                  },
                  "revocation_scope": {
                    "type": "string",
                    "enum": [
                      "refresh_tokens_only",
                      null
                    ],
                    "nullable": true
                  }
                },
                "required": [
                  "user_id",
                  "approval_id",
                  "action",
                  "custom_token_expires_at",
                  "session_expiration",
                  "revocation_scope"
                ],
                "nullable": true
              }
            },
            "required": [
              "keys",
              "revoked_count",
              "membership",
              "invitation",
              "managed_identity",
              "managed_session"
            ],
            "nullable": true
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean",
                "enum": [
                  false
                ]
              }
            },
            "required": [
              "code",
              "message",
              "retryable"
            ],
            "nullable": true
          },
          "membership_change": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "target": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "nullable": true
                  },
                  "display_name": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "id",
                  "email",
                  "display_name"
                ]
              },
              "previous_owner_id": {
                "type": "string"
              },
              "previous_role": {
                "type": "string",
                "enum": [
                  "admin",
                  "editor",
                  "viewer",
                  "blocked",
                  null
                ],
                "nullable": true
              },
              "new_role": {
                "type": "string",
                "enum": [
                  "admin"
                ]
              },
              "transfers_ownership": {
                "type": "boolean"
              },
              "billing_ownership_changes": {
                "type": "boolean",
                "enum": [
                  false
                ]
              },
              "hidden_member": {
                "type": "boolean",
                "enum": [
                  false
                ]
              }
            },
            "required": [
              "target",
              "previous_owner_id",
              "previous_role",
              "new_role",
              "transfers_ownership",
              "billing_ownership_changes",
              "hidden_member"
            ],
            "nullable": true
          },
          "invitation_change": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "team",
                  "billingAccount"
                ]
              },
              "email": {
                "type": "string"
              },
              "role": {
                "type": "string",
                "enum": [
                  "admin"
                ]
              },
              "team_id": {
                "type": "string",
                "nullable": true
              },
              "billing_account_id": {
                "type": "string"
              },
              "billing_account_name": {
                "type": "string",
                "nullable": true
              },
              "inviter": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "nullable": true
                  },
                  "display_name": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "id",
                  "email",
                  "display_name"
                ]
              },
              "send_email": {
                "type": "boolean"
              },
              "expires_at": {
                "type": "number"
              },
              "existing_invitation": {
                "type": "boolean"
              },
              "prior_delivery_status": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "id",
              "type",
              "email",
              "role",
              "team_id",
              "billing_account_id",
              "billing_account_name",
              "inviter",
              "send_email",
              "expires_at",
              "existing_invitation",
              "prior_delivery_status"
            ],
            "nullable": true
          },
          "managed_identity_change": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "user_id": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "profile": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "first_name": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 100
                  },
                  "last_name": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 100
                  },
                  "phone": {
                    "type": "string",
                    "nullable": true,
                    "pattern": "^\\+[1-9]\\d{7,14}$"
                  },
                  "company_role": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 100
                  },
                  "address": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "country": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 250
                      },
                      "street": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 250
                      },
                      "zip": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 250
                      },
                      "city": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 250
                      },
                      "state": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 250
                      },
                      "exterior": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 250
                      },
                      "municipality": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 250
                      },
                      "neighborhood": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 250
                      }
                    },
                    "nullable": true
                  }
                }
              },
              "team_id": {
                "type": "string"
              },
              "billing_account_id": {
                "type": "string"
              },
              "role": {
                "type": "string",
                "enum": [
                  "admin"
                ]
              },
              "auto_join": {
                "type": "boolean",
                "enum": [
                  true
                ]
              },
              "credential_delivery": {
                "type": "string",
                "enum": [
                  "none"
                ]
              },
              "initial_auth_state": {
                "type": "string",
                "enum": [
                  "disabled"
                ]
              },
              "bootstrap_effects": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "profile_initialization",
                    "membership_usage_initialization",
                    "support_identity_claims"
                  ]
                },
                "minItems": 3,
                "maxItems": 3
              }
            },
            "required": [
              "user_id",
              "email",
              "profile",
              "team_id",
              "billing_account_id",
              "role",
              "auto_join",
              "credential_delivery",
              "initial_auth_state",
              "bootstrap_effects"
            ],
            "nullable": true
          },
          "managed_identity_execution": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "phase": {
                "type": "string",
                "enum": [
                  "creating",
                  "activation_required",
                  "activating",
                  "complete",
                  "failed"
                ]
              },
              "auth_state": {
                "type": "string",
                "enum": [
                  "unknown",
                  "disabled",
                  "enabled"
                ]
              },
              "membership_granted": {
                "type": "boolean"
              },
              "started_at": {
                "type": "number"
              },
              "updated_at": {
                "type": "number"
              },
              "error_code": {
                "type": "string",
                "nullable": true
              }
            },
            "required": [
              "phase",
              "auth_state",
              "membership_granted",
              "started_at",
              "updated_at",
              "error_code"
            ],
            "nullable": true
          },
          "managed_session_change": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "user_id": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "auth_creation_time": {
                "type": "string"
              },
              "billing_account_id": {
                "type": "string"
              },
              "teams": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string",
                      "description": "Current access, including inherited billing_account_admin and master_team_billing_access."
                    }
                  },
                  "required": [
                    "id",
                    "role"
                  ]
                }
              },
              "billing_accounts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "role"
                  ]
                }
              },
              "delivery": {
                "type": "string",
                "enum": [
                  "browser_once",
                  "none"
                ]
              },
              "session_scope": {
                "type": "string",
                "enum": [
                  "firebase_identity"
                ]
              },
              "prior_attempts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "approval_id": {
                      "type": "string"
                    },
                    "action": {
                      "type": "string",
                      "enum": [
                        "managed_users.issue_session",
                        "managed_users.revoke_sessions"
                      ]
                    },
                    "phase": {
                      "type": "string",
                      "enum": [
                        "attempting",
                        "issued",
                        "revoked",
                        "unknown"
                      ]
                    },
                    "attempted_at": {
                      "type": "number"
                    },
                    "custom_token_expires_at": {
                      "type": "number",
                      "nullable": true,
                      "description": "Custom-token exchange deadline in epoch milliseconds, not the expiry of a redeemed Firebase session. Null for revocation."
                    }
                  },
                  "required": [
                    "approval_id",
                    "action",
                    "phase",
                    "attempted_at",
                    "custom_token_expires_at"
                  ]
                }
              }
            },
            "required": [
              "user_id",
              "email",
              "auth_creation_time",
              "billing_account_id",
              "teams",
              "billing_accounts",
              "delivery",
              "session_scope",
              "prior_attempts"
            ],
            "nullable": true
          },
          "managed_session_execution": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "phase": {
                "type": "string",
                "enum": [
                  "attempting",
                  "issued",
                  "revoked",
                  "unknown"
                ]
              },
              "attempted_at": {
                "type": "number"
              },
              "custom_token_expires_at": {
                "type": "number",
                "nullable": true,
                "description": "Custom-token exchange deadline in epoch milliseconds, not the expiry of a redeemed Firebase session. Null for revocation."
              },
              "delivery": {
                "type": "string",
                "enum": [
                  "not_observable",
                  "none"
                ]
              }
            },
            "required": [
              "phase",
              "attempted_at",
              "custom_token_expires_at",
              "delivery"
            ],
            "nullable": true
          },
          "scoped_key_change": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "name",
              "livemode",
              "billing_account_id",
              "team_ids",
              "action_ids",
              "expires_at",
              "manager_user_ids",
              "action",
              "previous_key_id",
              "overlap_seconds",
              "previous_revoke_at",
              "unrelated_keys_affected",
              "secret_disclosure"
            ],
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "livemode": {
                "type": "boolean"
              },
              "billing_account_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,128}$"
              },
              "team_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                },
                "minItems": 1,
                "maxItems": 100
              },
              "action_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 128
                },
                "minItems": 1,
                "maxItems": 200
              },
              "expires_at": {
                "type": "integer"
              },
              "manager_user_ids": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,128}$"
                },
                "maxItems": 100
              },
              "action": {
                "type": "string",
                "enum": [
                  "create",
                  "rotate"
                ]
              },
              "previous_key_id": {
                "type": "string",
                "nullable": true
              },
              "overlap_seconds": {
                "type": "integer",
                "minimum": 0,
                "maximum": 86400
              },
              "previous_revoke_at": {
                "type": "integer",
                "minimum": 0,
                "nullable": true
              },
              "unrelated_keys_affected": {
                "type": "boolean",
                "enum": [
                  false
                ]
              },
              "secret_disclosure": {
                "type": "string",
                "enum": [
                  "once"
                ]
              }
            },
            "nullable": true
          }
        },
        "required": [
          "id",
          "operation_id",
          "action",
          "team",
          "billing_account_id",
          "payload",
          "requested_modes",
          "effect_scope",
          "status",
          "created_at",
          "expires_at",
          "completed_at",
          "review_url",
          "can_cancel",
          "disclosure_version",
          "existing_key_ids",
          "terms",
          "receipt",
          "error",
          "membership_change",
          "invitation_change",
          "managed_identity_change",
          "managed_identity_execution",
          "managed_session_change",
          "managed_session_execution"
        ]
      },
      "AccountInvitation": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "admin",
              "editor",
              "viewer"
            ]
          },
          "team_id": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "enum": [
              "team",
              "billingAccount"
            ]
          },
          "billing_account_id": {
            "type": "string",
            "nullable": true
          },
          "approval_required": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "accepted",
              "declined",
              "revoked",
              "expired"
            ]
          },
          "created_at": {
            "type": "number",
            "nullable": true
          },
          "expires_at": {
            "type": "number",
            "nullable": true
          },
          "created_by": {
            "type": "string",
            "nullable": true
          },
          "delivery": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "not_requested",
                  "pending",
                  "sent",
                  "failed",
                  "unknown"
                ]
              },
              "attempted_at": {
                "type": "number",
                "nullable": true
              }
            },
            "required": [
              "status",
              "attempted_at"
            ]
          }
        },
        "required": [
          "id",
          "email",
          "role",
          "team_id",
          "type",
          "billing_account_id",
          "approval_required",
          "status",
          "created_at",
          "expires_at",
          "created_by",
          "delivery"
        ]
      },
      "AccountApprovalRequired": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "error": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "account_approval_required"
                ]
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          },
          "timestamp": {
            "type": "number"
          }
        },
        "required": [
          "success",
          "error",
          "timestamp"
        ]
      },
      "AccountApiPayloadMarker": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "$redacted": {
            "type": "string",
            "enum": [
              "sensitive_field",
              "unstructured_field",
              "value_not_allowlisted",
              "unstructured_body"
            ]
          },
          "$truncated": {
            "type": "string",
            "enum": [
              "depth_or_node_limit",
              "encoded_body_limit"
            ]
          },
          "$redacted_keys": {
            "type": "integer",
            "minimum": 0
          },
          "$omitted_keys": {
            "type": "integer",
            "minimum": 0
          }
        },
        "minProperties": 1
      },
      "AccountApiPayloadField_data": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_data"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_data"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_items": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_items"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_items"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_services": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_services"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_services"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_client": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_client"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_client"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_address": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_address"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_address"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_defaults": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_defaults"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_defaults"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_global": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_global"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_global"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_taxes": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_taxes"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_taxes"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_third_party": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_third_party"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_third_party"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_item_complement": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_item_complement"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_item_complement"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_hydrocarbons": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_hydrocarbons"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_hydrocarbons"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_invoice": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_invoice"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_invoice"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_receipt": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_receipt"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_receipt"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_payment": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_payment"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_payment"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_invoice_configuration": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_invoice_configuration"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_invoice_configuration"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_pagination": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_pagination"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_pagination"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_error": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_error"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_error"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_errors": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_errors"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_errors"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_related_documents": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_related_documents"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_related_documents"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_complements": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_complements"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_complements"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_fiscal_responsibilities": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "O-13",
              "O-15",
              "O-23",
              "O-47",
              "R-99-PN"
            ]
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_fiscal_responsibilities"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_fiscal_responsibilities"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_amount": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_amount"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_amount"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_total": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_total"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_total"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_subtotal": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_subtotal"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_subtotal"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_quantity": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_quantity"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_quantity"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_unit_price": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_unit_price"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_unit_price"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_discount": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_discount"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_discount"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_rate": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_rate"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_rate"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_base": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_base"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_base"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_exchange_rate": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_exchange_rate"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_exchange_rate"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_exchange": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_exchange"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_exchange"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_date": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_date"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_date"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_timestamp": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_timestamp"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_timestamp"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_year": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_year"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_year"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_folio_number": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_folio_number"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_folio_number"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_paid_amount": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_paid_amount"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_paid_amount"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_pending_amount": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_pending_amount"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_pending_amount"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_balance": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_balance"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_balance"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_previous_balance": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_previous_balance"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_previous_balance"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_remaining_balance": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_remaining_balance"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_remaining_balance"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_payment_number": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_payment_number"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_payment_number"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_limit": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_limit"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_limit"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_scanned_count": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_scanned_count"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_scanned_count"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_status_code": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_status_code"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_status_code"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_statusCode": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_statusCode"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_statusCode"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_count": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "number"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_count"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_count"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_success": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_success"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_success"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_livemode": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_livemode"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_livemode"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_has_more": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_has_more"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_has_more"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_inclusive": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_inclusive"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_inclusive"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_withholding": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_withholding"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_withholding"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_send_email": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_ignore_emails": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_return_files": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_return_files"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_return_files"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_keep_full_legal_name": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_keep_full_legal_name"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_keep_full_legal_name"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_issue_automatic_invoices": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_issue_automatic_invoices"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_issue_automatic_invoices"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_issue_invoiceable_receipts": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_issue_invoiceable_receipts"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_issue_invoiceable_receipts"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_check_pending_receipts": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_check_pending_receipts"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_check_pending_receipts"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_stamp": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_stamp"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_stamp"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_is_paid": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_is_paid"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_is_paid"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_is_invoiceable": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_is_invoiceable"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_is_invoiceable"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_is_canceled": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "boolean"
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_is_canceled"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_is_canceled"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_payment_method": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "PPD",
              "PUE"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_payment_method"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_payment_method"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_payment_form": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "08",
              "12",
              "13",
              "14",
              "15",
              "17",
              "23",
              "24",
              "25",
              "26",
              "27",
              "28",
              "29",
              "30",
              "31",
              "99"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_payment_form"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_payment_form"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_exports": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_exports"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_exports"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_taxability": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "07",
              "08"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_taxability"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_taxability"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_type": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "IVA",
              "ISR",
              "IEPS",
              "income",
              "egress",
              "payment",
              "transfer",
              "invoice",
              "receipt",
              "service"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_type"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_type"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_factor": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "Tasa",
              "Cuota",
              "Exento"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_factor"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_factor"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_currency": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "AED",
              "AFN",
              "ALL",
              "AMD",
              "ANG",
              "AOA",
              "ARS",
              "AUD",
              "AWG",
              "AZN",
              "BAM",
              "BBD",
              "BDT",
              "BGN",
              "BHD",
              "BIF",
              "BMD",
              "BND",
              "BOB",
              "BRL",
              "BSD",
              "BTN",
              "BWP",
              "BYN",
              "BZD",
              "CAD",
              "CDF",
              "CHF",
              "CKD",
              "CLP",
              "CNY",
              "COP",
              "CRC",
              "CUC",
              "CUP",
              "CVE",
              "CZK",
              "DJF",
              "DKK",
              "DOP",
              "DZD",
              "EGP",
              "EHP",
              "ERN",
              "ETB",
              "EUR",
              "FJD",
              "FKP",
              "FOK",
              "GBP",
              "GEL",
              "GGP",
              "GHS",
              "GIP",
              "GMD",
              "GNF",
              "GTQ",
              "GYD",
              "HKD",
              "HNL",
              "HRK",
              "HTG",
              "HUF",
              "IDR",
              "ILS",
              "IMP",
              "INR",
              "IQD",
              "IRR",
              "ISK",
              "JEP",
              "JMD",
              "JOD",
              "JPY",
              "KES",
              "KGS",
              "KHR",
              "KID",
              "KMF",
              "KPW",
              "KRW",
              "KWD",
              "KYD",
              "KZT",
              "LAK",
              "LBP",
              "LKR",
              "LRD",
              "LSL",
              "LYD",
              "MAD",
              "MDL",
              "MGA",
              "MKD",
              "MMK",
              "MNT",
              "MOP",
              "MRU",
              "MUR",
              "MVR",
              "MWK",
              "MXN",
              "MYR",
              "MZN",
              "NAD",
              "NGN",
              "NIO",
              "NOK",
              "NPR",
              "NZD",
              "OMR",
              "PAB",
              "PEN",
              "PGK",
              "PHP",
              "PKR",
              "PLN",
              "PND",
              "PRB",
              "PYG",
              "QAR",
              "RON",
              "RSD",
              "RUB",
              "RWF",
              "SAR",
              "SBD",
              "SCR",
              "SDG",
              "SEK",
              "SGD",
              "SHP",
              "SLL",
              "SLS",
              "SOS",
              "SRD",
              "SSP",
              "STN",
              "SVC",
              "SYP",
              "SZL",
              "THB",
              "TJS",
              "TMT",
              "TND",
              "TOP",
              "TRY",
              "TTD",
              "TVD",
              "TWD",
              "TZS",
              "UAH",
              "UGX",
              "USD",
              "UYU",
              "UZS",
              "VED",
              "VES",
              "VND",
              "VUV",
              "WST",
              "XAF",
              "XCD",
              "XOF",
              "XPF",
              "YER",
              "ZAR",
              "ZMW",
              "ZWB",
              "ZWL",
              "Abkhazia",
              "Artsakh"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_currency"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_currency"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_country": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "AFG",
              "AF",
              "ALA",
              "AX",
              "ALB",
              "AL",
              "DZA",
              "DZ",
              "ASM",
              "AS",
              "AND",
              "AD",
              "AGO",
              "AO",
              "AIA",
              "AI",
              "ATA",
              "AQ",
              "ATG",
              "AG",
              "ARG",
              "AR",
              "ARM",
              "AM",
              "ABW",
              "AW",
              "AUS",
              "AU",
              "AUT",
              "AT",
              "AZE",
              "AZ",
              "BHS",
              "BS",
              "BHR",
              "BH",
              "BGD",
              "BD",
              "BRB",
              "BB",
              "BLR",
              "BY",
              "BEL",
              "BE",
              "BLZ",
              "BZ",
              "BEN",
              "BJ",
              "BMU",
              "BM",
              "BTN",
              "BT",
              "BOL",
              "BO",
              "BES",
              "BQ",
              "BIH",
              "BA",
              "BWA",
              "BW",
              "BVT",
              "BV",
              "BRA",
              "BR",
              "IOT",
              "IO",
              "BRN",
              "BN",
              "BGR",
              "BG",
              "BFA",
              "BF",
              "BDI",
              "BI",
              "KHM",
              "KH",
              "CMR",
              "CM",
              "CAN",
              "CA",
              "CPV",
              "CV",
              "CYM",
              "KY",
              "CAF",
              "CF",
              "TCD",
              "TD",
              "CHL",
              "CL",
              "CHN",
              "CN",
              "CXR",
              "CX",
              "CCK",
              "CC",
              "COL",
              "CO",
              "COM",
              "KM",
              "COG",
              "CG",
              "COD",
              "CD",
              "COK",
              "CK",
              "CRI",
              "CR",
              "CIV",
              "CI",
              "HRV",
              "HR",
              "CUB",
              "CU",
              "CUW",
              "CW",
              "CYP",
              "CY",
              "CZE",
              "CZ",
              "DNK",
              "DK",
              "DJI",
              "DJ",
              "DMA",
              "DM",
              "DOM",
              "DO",
              "ECU",
              "EC",
              "EGY",
              "EG",
              "SLV",
              "SV",
              "GNQ",
              "GQ",
              "ERI",
              "ER",
              "EST",
              "EE",
              "ETH",
              "ET",
              "FLK",
              "FK",
              "FRO",
              "FO",
              "FJI",
              "FJ",
              "FIN",
              "FI",
              "FRA",
              "FR",
              "GUF",
              "GF",
              "PYF",
              "PF",
              "ATF",
              "TF",
              "GAB",
              "GA",
              "GMB",
              "GM",
              "GEO",
              "GE",
              "DEU",
              "DE",
              "GHA",
              "GH",
              "GIB",
              "GI",
              "GRC",
              "GR",
              "GRL",
              "GL",
              "GRD",
              "GD",
              "GLP",
              "GP",
              "GUM",
              "GU",
              "GTM",
              "GT",
              "GGY",
              "GG",
              "GIN",
              "GN",
              "GNB",
              "GW",
              "GUY",
              "GY",
              "HTI",
              "HT",
              "HMD",
              "HM",
              "VAT",
              "VA",
              "HND",
              "HN",
              "HKG",
              "HK",
              "HUN",
              "HU",
              "ISL",
              "IS",
              "IND",
              "IN",
              "IDN",
              "ID",
              "IRN",
              "IR",
              "IRQ",
              "IQ",
              "IRL",
              "IE",
              "IMN",
              "IM",
              "ISR",
              "IL",
              "ITA",
              "IT",
              "JAM",
              "JM",
              "JPN",
              "JP",
              "JEY",
              "JE",
              "JOR",
              "JO",
              "KAZ",
              "KZ",
              "KEN",
              "KE",
              "KIR",
              "KI",
              "PRK",
              "KP",
              "KOR",
              "KR",
              "KWT",
              "KW",
              "KGZ",
              "KG",
              "LAO",
              "LA",
              "LVA",
              "LV",
              "LBN",
              "LB",
              "LSO",
              "LS",
              "LBR",
              "LR",
              "LBY",
              "LY",
              "LIE",
              "LI",
              "LTU",
              "LT",
              "LUX",
              "LU",
              "MAC",
              "MO",
              "MKD",
              "MK",
              "MDG",
              "MG",
              "MWI",
              "MW",
              "MYS",
              "MY",
              "MDV",
              "MV",
              "MLI",
              "ML",
              "MLT",
              "MT",
              "MHL",
              "MH",
              "MTQ",
              "MQ",
              "MRT",
              "MR",
              "MUS",
              "MU",
              "MYT",
              "YT",
              "MEX",
              "MX",
              "FSM",
              "FM",
              "MDA",
              "MD",
              "MCO",
              "MC",
              "MNG",
              "MN",
              "MNE",
              "ME",
              "MSR",
              "MS",
              "MAR",
              "MA",
              "MOZ",
              "MZ",
              "MMR",
              "MM",
              "NAM",
              "NA",
              "NRU",
              "NR",
              "NPL",
              "NP",
              "NLD",
              "NL",
              "NCL",
              "NC",
              "NZL",
              "NZ",
              "NIC",
              "NI",
              "NER",
              "NE",
              "NGA",
              "NG",
              "NIU",
              "NU",
              "NFK",
              "NF",
              "MNP",
              "MP",
              "NOR",
              "NO",
              "OMN",
              "OM",
              "PAK",
              "PK",
              "PLW",
              "PW",
              "PSE",
              "PS",
              "PAN",
              "PA",
              "PNG",
              "PG",
              "PRY",
              "PY",
              "PER",
              "PE",
              "PHL",
              "PH",
              "PCN",
              "PN",
              "POL",
              "PL",
              "PRT",
              "PT",
              "PRI",
              "PR",
              "QAT",
              "QA",
              "REU",
              "RE",
              "ROU",
              "RO",
              "RUS",
              "RU",
              "RWA",
              "RW",
              "BLM",
              "BL",
              "SHN",
              "SH",
              "KNA",
              "KN",
              "LCA",
              "LC",
              "MAF",
              "MF",
              "SPM",
              "PM",
              "VCT",
              "VC",
              "WSM",
              "WS",
              "SMR",
              "SM",
              "STP",
              "ST",
              "SAU",
              "SA",
              "SEN",
              "SN",
              "SRB",
              "RS",
              "SYC",
              "SC",
              "SLE",
              "SL",
              "SGP",
              "SG",
              "SXM",
              "SX",
              "SVK",
              "SK",
              "SVN",
              "SI",
              "SLB",
              "SB",
              "SOM",
              "SO",
              "ZAF",
              "ZA",
              "SGS",
              "GS",
              "SSD",
              "SS",
              "ESP",
              "ES",
              "LKA",
              "LK",
              "SDN",
              "SD",
              "SUR",
              "SR",
              "SJM",
              "SJ",
              "SWZ",
              "SZ",
              "SWE",
              "SE",
              "CHE",
              "CH",
              "SYR",
              "SY",
              "TWN",
              "TW",
              "TJK",
              "TJ",
              "TZA",
              "TZ",
              "THA",
              "TH",
              "TLS",
              "TL",
              "TGO",
              "TG",
              "TKL",
              "TK",
              "TON",
              "TO",
              "TTO",
              "TT",
              "TUN",
              "TN",
              "TUR",
              "TR",
              "TKM",
              "TM",
              "TCA",
              "TC",
              "TUV",
              "TV",
              "UGA",
              "UG",
              "UKR",
              "UA",
              "ARE",
              "AE",
              "GBR",
              "GB",
              "USA",
              "US",
              "UMI",
              "UM",
              "URY",
              "UY",
              "UZB",
              "UZ",
              "VUT",
              "VU",
              "VEN",
              "VE",
              "VNM",
              "VN",
              "VGB",
              "VG",
              "VIR",
              "VI",
              "WLF",
              "WF",
              "ESH",
              "EH",
              "YEM",
              "YE",
              "ZMB",
              "ZM",
              "ZWE",
              "ZW"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_country"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_country"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_document_type": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "",
              "11",
              "12",
              "13",
              "21",
              "22",
              "31",
              "41",
              "42",
              "47",
              "48",
              "50",
              "91"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_document_type"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_document_type"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_organization_type": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "",
              "1",
              "2"
            ]
          },
          {
            "type": "number",
            "enum": [
              1,
              2
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_organization_type"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_organization_type"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_tribute_code": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "",
              "01",
              "ZZ"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_tribute_code"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_tribute_code"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_automation_type": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "payment",
              "none"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_automation_type"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_automation_type"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_status": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "valid",
              "canceled",
              "pending",
              "paid",
              "unpaid",
              "active",
              "draft",
              "completed",
              "failed"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_status"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_status"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_use": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "G01",
              "G02",
              "G03",
              "I01",
              "I02",
              "I03",
              "I04",
              "I05",
              "I06",
              "I07",
              "I08",
              "D01",
              "D02",
              "D03",
              "D04",
              "D05",
              "D06",
              "D07",
              "D08",
              "D09",
              "D10",
              "S01",
              "CP01",
              "CN01"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_use"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_use"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_tax_system": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "601",
              "603",
              "605",
              "606",
              "608",
              "609",
              "610",
              "611",
              "612",
              "614",
              "616",
              "620",
              "621",
              "622",
              "623",
              "624",
              "628",
              "607",
              "629",
              "630",
              "615",
              "625",
              "626"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_tax_system"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_tax_system"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_relationship": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "07",
              "08",
              "09"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_relationship"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_relationship"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_months": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05",
              "06",
              "07",
              "08",
              "09",
              "10",
              "11",
              "12",
              "13",
              "14",
              "15",
              "16",
              "17",
              "18"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_months"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_months"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_periodicity": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "01",
              "02",
              "03",
              "04",
              "05"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_periodicity"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_periodicity"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_dv": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "string",
            "enum": [
              "",
              "0",
              "1",
              "2",
              "3",
              "4",
              "5",
              "6",
              "7",
              "8",
              "9"
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_dv"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_dv"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_id": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_id"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_id"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_team": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_team"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_team"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_team_id": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_team_id"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_team_id"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_resource_id": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_resource_id"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_resource_id"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_keyId": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_userId": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_userId"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_userId"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_tax_id": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_legal_name": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_legal_name"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_legal_name"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_name": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_name"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_name"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_company": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_company"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_company"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_email": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_emails": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_bcc": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_bcc"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_bcc"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_phone": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_metadata": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_metadata"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_metadata"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_description": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_description"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_description"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_message": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_message"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_message"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_code": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_code"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_code"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_zip": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_zip"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_zip"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_street": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_street"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_street"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_city": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_city"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_city"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_state": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_state"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_state"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_municipality": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_municipality"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_municipality"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_municipality_code": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_municipality_code"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_municipality_code"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_neighborhood": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_neighborhood"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_neighborhood"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_interior": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_interior"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_interior"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_exterior": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_exterior"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_exterior"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_sku": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_sku"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_sku"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_product_key": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_unit_key": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_unit_name": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_unit_name"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_unit_name"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_series": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_series"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_series"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_folio": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_folio"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_folio"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_documents": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_documents"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_documents"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_invoice_pdf_notes": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_addenda": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_addenda"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_addenda"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_idempotency_key": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_request": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_request"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_request"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_response": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_response"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_response"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_body": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_body"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_body"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_headers": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_token": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_password": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_credentials": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_certificate": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_secret": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_files": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_files"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_files"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_pdf": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_xml": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          }
        ]
      },
      "AccountApiPayloadField_permit_type": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_permit_type"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_permit_type"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_permit_number": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_permit_number"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_permit_number"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_fuel_code": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_fuel_code"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_fuel_code"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadField_fuel_sub_product": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayloadField_fuel_sub_product"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayloadField_fuel_sub_product"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiPayloadObject": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/AccountApiPayloadField_data"
          },
          "items": {
            "$ref": "#/components/schemas/AccountApiPayloadField_items"
          },
          "services": {
            "$ref": "#/components/schemas/AccountApiPayloadField_services"
          },
          "client": {
            "$ref": "#/components/schemas/AccountApiPayloadField_client"
          },
          "address": {
            "$ref": "#/components/schemas/AccountApiPayloadField_address"
          },
          "defaults": {
            "$ref": "#/components/schemas/AccountApiPayloadField_defaults"
          },
          "global": {
            "$ref": "#/components/schemas/AccountApiPayloadField_global"
          },
          "taxes": {
            "$ref": "#/components/schemas/AccountApiPayloadField_taxes"
          },
          "third_party": {
            "$ref": "#/components/schemas/AccountApiPayloadField_third_party"
          },
          "item_complement": {
            "$ref": "#/components/schemas/AccountApiPayloadField_item_complement"
          },
          "hydrocarbons": {
            "$ref": "#/components/schemas/AccountApiPayloadField_hydrocarbons"
          },
          "invoice": {
            "$ref": "#/components/schemas/AccountApiPayloadField_invoice"
          },
          "receipt": {
            "$ref": "#/components/schemas/AccountApiPayloadField_receipt"
          },
          "payment": {
            "$ref": "#/components/schemas/AccountApiPayloadField_payment"
          },
          "invoice_configuration": {
            "$ref": "#/components/schemas/AccountApiPayloadField_invoice_configuration"
          },
          "pagination": {
            "$ref": "#/components/schemas/AccountApiPayloadField_pagination"
          },
          "error": {
            "$ref": "#/components/schemas/AccountApiPayloadField_error"
          },
          "errors": {
            "$ref": "#/components/schemas/AccountApiPayloadField_errors"
          },
          "related_documents": {
            "$ref": "#/components/schemas/AccountApiPayloadField_related_documents"
          },
          "complements": {
            "$ref": "#/components/schemas/AccountApiPayloadField_complements"
          },
          "fiscal_responsibilities": {
            "$ref": "#/components/schemas/AccountApiPayloadField_fiscal_responsibilities"
          },
          "amount": {
            "$ref": "#/components/schemas/AccountApiPayloadField_amount"
          },
          "total": {
            "$ref": "#/components/schemas/AccountApiPayloadField_total"
          },
          "subtotal": {
            "$ref": "#/components/schemas/AccountApiPayloadField_subtotal"
          },
          "quantity": {
            "$ref": "#/components/schemas/AccountApiPayloadField_quantity"
          },
          "unit_price": {
            "$ref": "#/components/schemas/AccountApiPayloadField_unit_price"
          },
          "discount": {
            "$ref": "#/components/schemas/AccountApiPayloadField_discount"
          },
          "rate": {
            "$ref": "#/components/schemas/AccountApiPayloadField_rate"
          },
          "base": {
            "$ref": "#/components/schemas/AccountApiPayloadField_base"
          },
          "exchange_rate": {
            "$ref": "#/components/schemas/AccountApiPayloadField_exchange_rate"
          },
          "exchange": {
            "$ref": "#/components/schemas/AccountApiPayloadField_exchange"
          },
          "date": {
            "$ref": "#/components/schemas/AccountApiPayloadField_date"
          },
          "timestamp": {
            "$ref": "#/components/schemas/AccountApiPayloadField_timestamp"
          },
          "year": {
            "$ref": "#/components/schemas/AccountApiPayloadField_year"
          },
          "folio_number": {
            "$ref": "#/components/schemas/AccountApiPayloadField_folio_number"
          },
          "paid_amount": {
            "$ref": "#/components/schemas/AccountApiPayloadField_paid_amount"
          },
          "pending_amount": {
            "$ref": "#/components/schemas/AccountApiPayloadField_pending_amount"
          },
          "balance": {
            "$ref": "#/components/schemas/AccountApiPayloadField_balance"
          },
          "previous_balance": {
            "$ref": "#/components/schemas/AccountApiPayloadField_previous_balance"
          },
          "remaining_balance": {
            "$ref": "#/components/schemas/AccountApiPayloadField_remaining_balance"
          },
          "payment_number": {
            "$ref": "#/components/schemas/AccountApiPayloadField_payment_number"
          },
          "limit": {
            "$ref": "#/components/schemas/AccountApiPayloadField_limit"
          },
          "scanned_count": {
            "$ref": "#/components/schemas/AccountApiPayloadField_scanned_count"
          },
          "status_code": {
            "$ref": "#/components/schemas/AccountApiPayloadField_status_code"
          },
          "statusCode": {
            "$ref": "#/components/schemas/AccountApiPayloadField_statusCode"
          },
          "count": {
            "$ref": "#/components/schemas/AccountApiPayloadField_count"
          },
          "success": {
            "$ref": "#/components/schemas/AccountApiPayloadField_success"
          },
          "livemode": {
            "$ref": "#/components/schemas/AccountApiPayloadField_livemode"
          },
          "has_more": {
            "$ref": "#/components/schemas/AccountApiPayloadField_has_more"
          },
          "inclusive": {
            "$ref": "#/components/schemas/AccountApiPayloadField_inclusive"
          },
          "withholding": {
            "$ref": "#/components/schemas/AccountApiPayloadField_withholding"
          },
          "send_email": {
            "$ref": "#/components/schemas/AccountApiPayloadField_send_email"
          },
          "ignore_emails": {
            "$ref": "#/components/schemas/AccountApiPayloadField_ignore_emails"
          },
          "return_files": {
            "$ref": "#/components/schemas/AccountApiPayloadField_return_files"
          },
          "keep_full_legal_name": {
            "$ref": "#/components/schemas/AccountApiPayloadField_keep_full_legal_name"
          },
          "issue_automatic_invoices": {
            "$ref": "#/components/schemas/AccountApiPayloadField_issue_automatic_invoices"
          },
          "issue_invoiceable_receipts": {
            "$ref": "#/components/schemas/AccountApiPayloadField_issue_invoiceable_receipts"
          },
          "check_pending_receipts": {
            "$ref": "#/components/schemas/AccountApiPayloadField_check_pending_receipts"
          },
          "stamp": {
            "$ref": "#/components/schemas/AccountApiPayloadField_stamp"
          },
          "is_paid": {
            "$ref": "#/components/schemas/AccountApiPayloadField_is_paid"
          },
          "is_invoiceable": {
            "$ref": "#/components/schemas/AccountApiPayloadField_is_invoiceable"
          },
          "is_canceled": {
            "$ref": "#/components/schemas/AccountApiPayloadField_is_canceled"
          },
          "payment_method": {
            "$ref": "#/components/schemas/AccountApiPayloadField_payment_method"
          },
          "payment_form": {
            "$ref": "#/components/schemas/AccountApiPayloadField_payment_form"
          },
          "exports": {
            "$ref": "#/components/schemas/AccountApiPayloadField_exports"
          },
          "taxability": {
            "$ref": "#/components/schemas/AccountApiPayloadField_taxability"
          },
          "type": {
            "$ref": "#/components/schemas/AccountApiPayloadField_type"
          },
          "factor": {
            "$ref": "#/components/schemas/AccountApiPayloadField_factor"
          },
          "currency": {
            "$ref": "#/components/schemas/AccountApiPayloadField_currency"
          },
          "country": {
            "$ref": "#/components/schemas/AccountApiPayloadField_country"
          },
          "document_type": {
            "$ref": "#/components/schemas/AccountApiPayloadField_document_type"
          },
          "organization_type": {
            "$ref": "#/components/schemas/AccountApiPayloadField_organization_type"
          },
          "tribute_code": {
            "$ref": "#/components/schemas/AccountApiPayloadField_tribute_code"
          },
          "automation_type": {
            "$ref": "#/components/schemas/AccountApiPayloadField_automation_type"
          },
          "status": {
            "$ref": "#/components/schemas/AccountApiPayloadField_status"
          },
          "use": {
            "$ref": "#/components/schemas/AccountApiPayloadField_use"
          },
          "tax_system": {
            "$ref": "#/components/schemas/AccountApiPayloadField_tax_system"
          },
          "relationship": {
            "$ref": "#/components/schemas/AccountApiPayloadField_relationship"
          },
          "months": {
            "$ref": "#/components/schemas/AccountApiPayloadField_months"
          },
          "periodicity": {
            "$ref": "#/components/schemas/AccountApiPayloadField_periodicity"
          },
          "dv": {
            "$ref": "#/components/schemas/AccountApiPayloadField_dv"
          },
          "id": {
            "$ref": "#/components/schemas/AccountApiPayloadField_id"
          },
          "team": {
            "$ref": "#/components/schemas/AccountApiPayloadField_team"
          },
          "team_id": {
            "$ref": "#/components/schemas/AccountApiPayloadField_team_id"
          },
          "resource_id": {
            "$ref": "#/components/schemas/AccountApiPayloadField_resource_id"
          },
          "keyId": {
            "$ref": "#/components/schemas/AccountApiPayloadField_keyId"
          },
          "userId": {
            "$ref": "#/components/schemas/AccountApiPayloadField_userId"
          },
          "tax_id": {
            "$ref": "#/components/schemas/AccountApiPayloadField_tax_id"
          },
          "legal_name": {
            "$ref": "#/components/schemas/AccountApiPayloadField_legal_name"
          },
          "name": {
            "$ref": "#/components/schemas/AccountApiPayloadField_name"
          },
          "company": {
            "$ref": "#/components/schemas/AccountApiPayloadField_company"
          },
          "email": {
            "$ref": "#/components/schemas/AccountApiPayloadField_email"
          },
          "emails": {
            "$ref": "#/components/schemas/AccountApiPayloadField_emails"
          },
          "bcc": {
            "$ref": "#/components/schemas/AccountApiPayloadField_bcc"
          },
          "phone": {
            "$ref": "#/components/schemas/AccountApiPayloadField_phone"
          },
          "metadata": {
            "$ref": "#/components/schemas/AccountApiPayloadField_metadata"
          },
          "description": {
            "$ref": "#/components/schemas/AccountApiPayloadField_description"
          },
          "message": {
            "$ref": "#/components/schemas/AccountApiPayloadField_message"
          },
          "code": {
            "$ref": "#/components/schemas/AccountApiPayloadField_code"
          },
          "zip": {
            "$ref": "#/components/schemas/AccountApiPayloadField_zip"
          },
          "street": {
            "$ref": "#/components/schemas/AccountApiPayloadField_street"
          },
          "city": {
            "$ref": "#/components/schemas/AccountApiPayloadField_city"
          },
          "state": {
            "$ref": "#/components/schemas/AccountApiPayloadField_state"
          },
          "municipality": {
            "$ref": "#/components/schemas/AccountApiPayloadField_municipality"
          },
          "municipality_code": {
            "$ref": "#/components/schemas/AccountApiPayloadField_municipality_code"
          },
          "neighborhood": {
            "$ref": "#/components/schemas/AccountApiPayloadField_neighborhood"
          },
          "interior": {
            "$ref": "#/components/schemas/AccountApiPayloadField_interior"
          },
          "exterior": {
            "$ref": "#/components/schemas/AccountApiPayloadField_exterior"
          },
          "sku": {
            "$ref": "#/components/schemas/AccountApiPayloadField_sku"
          },
          "product_key": {
            "$ref": "#/components/schemas/AccountApiPayloadField_product_key"
          },
          "unit_key": {
            "$ref": "#/components/schemas/AccountApiPayloadField_unit_key"
          },
          "unit_name": {
            "$ref": "#/components/schemas/AccountApiPayloadField_unit_name"
          },
          "series": {
            "$ref": "#/components/schemas/AccountApiPayloadField_series"
          },
          "folio": {
            "$ref": "#/components/schemas/AccountApiPayloadField_folio"
          },
          "documents": {
            "$ref": "#/components/schemas/AccountApiPayloadField_documents"
          },
          "invoice_pdf_notes": {
            "$ref": "#/components/schemas/AccountApiPayloadField_invoice_pdf_notes"
          },
          "addenda": {
            "$ref": "#/components/schemas/AccountApiPayloadField_addenda"
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/AccountApiPayloadField_idempotency_key"
          },
          "request": {
            "$ref": "#/components/schemas/AccountApiPayloadField_request"
          },
          "response": {
            "$ref": "#/components/schemas/AccountApiPayloadField_response"
          },
          "body": {
            "$ref": "#/components/schemas/AccountApiPayloadField_body"
          },
          "headers": {
            "$ref": "#/components/schemas/AccountApiPayloadField_headers"
          },
          "token": {
            "$ref": "#/components/schemas/AccountApiPayloadField_token"
          },
          "password": {
            "$ref": "#/components/schemas/AccountApiPayloadField_password"
          },
          "credentials": {
            "$ref": "#/components/schemas/AccountApiPayloadField_credentials"
          },
          "certificate": {
            "$ref": "#/components/schemas/AccountApiPayloadField_certificate"
          },
          "secret": {
            "$ref": "#/components/schemas/AccountApiPayloadField_secret"
          },
          "files": {
            "$ref": "#/components/schemas/AccountApiPayloadField_files"
          },
          "pdf": {
            "$ref": "#/components/schemas/AccountApiPayloadField_pdf"
          },
          "xml": {
            "$ref": "#/components/schemas/AccountApiPayloadField_xml"
          },
          "permit_type": {
            "$ref": "#/components/schemas/AccountApiPayloadField_permit_type"
          },
          "permit_number": {
            "$ref": "#/components/schemas/AccountApiPayloadField_permit_number"
          },
          "fuel_code": {
            "$ref": "#/components/schemas/AccountApiPayloadField_fuel_code"
          },
          "fuel_sub_product": {
            "$ref": "#/components/schemas/AccountApiPayloadField_fuel_sub_product"
          },
          "$redacted_keys": {
            "type": "integer",
            "minimum": 0
          },
          "$omitted_keys": {
            "type": "integer",
            "minimum": 0
          }
        },
        "maxProperties": 102
      },
      "AccountApiPayload": {
        "description": "Version 1 allowlisted structured values. Maximum depth 8, 1500 nodes, 50 array items, 100 object keys and 262144 characters for encoded JSON. Other values are explicitly redacted; omitted keys/items and bounded truncation are marked. IDs, names, metadata, free text, URLs, files and historical credentials never confer access and remain hidden.",
        "anyOf": [
          {
            "$ref": "#/components/schemas/AccountApiPayloadObject"
          },
          {
            "$ref": "#/components/schemas/AccountApiPayloadMarker"
          },
          {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ]
          },
          {
            "type": "array",
            "maxItems": 50,
            "items": {
              "$ref": "#/components/schemas/AccountApiPayload"
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "$items",
              "$omitted_items"
            ],
            "properties": {
              "$items": {
                "type": "array",
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/AccountApiPayload"
                }
              },
              "$omitted_items": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        ]
      },
      "AccountApiLog": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "timestamp": {
            "type": "number",
            "nullable": true
          },
          "method": {
            "type": "string",
            "nullable": true,
            "enum": [
              "GET",
              "POST",
              "PUT",
              "PATCH",
              "DELETE",
              "OPTIONS",
              "HEAD",
              null
            ]
          },
          "endpoint": {
            "type": "string",
            "nullable": true
          },
          "status_code": {
            "type": "number",
            "nullable": true
          },
          "livemode": {
            "type": "boolean"
          },
          "redaction": {
            "type": "string",
            "enum": [
              "metadata_and_body_shape"
            ]
          },
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$"
          }
        },
        "required": [
          "id",
          "timestamp",
          "method",
          "endpoint",
          "status_code",
          "livemode",
          "redaction",
          "team_id"
        ]
      },
      "AccountApiLogDetail": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "timestamp": {
            "type": "number",
            "nullable": true
          },
          "method": {
            "type": "string",
            "nullable": true,
            "enum": [
              "GET",
              "POST",
              "PUT",
              "PATCH",
              "DELETE",
              "OPTIONS",
              "HEAD",
              null
            ]
          },
          "endpoint": {
            "type": "string",
            "nullable": true
          },
          "status_code": {
            "type": "number",
            "nullable": true
          },
          "livemode": {
            "type": "boolean"
          },
          "redaction": {
            "type": "string",
            "enum": [
              "metadata_and_body_shape"
            ]
          },
          "request_shape": {
            "description": "Redacted structure only: recognized field names and primitive type markers, bounded nested objects and array sample shapes. Never the original payload values."
          },
          "query_shape": {
            "description": "Redacted structure only: recognized field names and primitive type markers, bounded nested objects and array sample shapes. Never the original payload values."
          },
          "response_shape": {
            "description": "Redacted structure only: recognized field names and primitive type markers, bounded nested objects and array sample shapes. Never the original payload values."
          },
          "team_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$"
          },
          "payload_redaction": {
            "type": "string",
            "enum": [
              "allowlisted_structured_values_v1"
            ]
          },
          "request_payload": {
            "$ref": "#/components/schemas/AccountApiPayload"
          },
          "query_payload": {
            "$ref": "#/components/schemas/AccountApiPayload"
          },
          "response_payload": {
            "$ref": "#/components/schemas/AccountApiPayload"
          }
        },
        "required": [
          "id",
          "timestamp",
          "method",
          "endpoint",
          "status_code",
          "livemode",
          "redaction",
          "request_shape",
          "query_shape",
          "response_shape",
          "team_id",
          "payload_redaction",
          "request_payload",
          "query_payload",
          "response_payload"
        ]
      },
      "AccountWebhookDeliveryLog": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "timestamp": {
            "type": "number",
            "nullable": true
          },
          "updated_at": {
            "type": "number",
            "nullable": true
          },
          "webhook_id": {
            "type": "string",
            "nullable": true
          },
          "event": {
            "type": "string",
            "nullable": true,
            "enum": [
              "payment.created",
              "payment.updated",
              "payment.succeeded",
              "payment.canceled",
              "payment.deleted",
              "payment.upcoming_due_date",
              "invoice.created",
              "invoice.canceled",
              "invoice.failed",
              "invoice_batch.completed",
              "payment_batch.completed",
              "receipt.created",
              "receipt.updated",
              "receipt.completed",
              "receipt.deleted",
              "customer.created",
              "customer.updated",
              "customer.deleted",
              "service.created",
              "service.updated",
              "service.deleted",
              "sat.invoice.synced",
              "teams.created",
              "teams.sat.completed",
              "teams.stripe.completed",
              "teams.openpay.completed",
              "teams.sat.manifest.signed",
              null
            ]
          },
          "livemode": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "retrying",
              "succeeded",
              "failed",
              "unknown"
            ]
          },
          "response_code": {
            "type": "number",
            "nullable": true
          },
          "retry_requested": {
            "type": "boolean"
          },
          "redaction": {
            "type": "string",
            "enum": [
              "metadata_and_body_shape"
            ]
          },
          "resource_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$",
            "maxLength": 160,
            "nullable": true,
            "description": "Historical selection hint only. Does not prove current resource existence or access; each action reauthorizes the resource."
          },
          "attempts": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "latency_ms": {
            "type": "number",
            "minimum": 0,
            "nullable": true
          },
          "error_category": {
            "type": "string",
            "enum": [
              "http_response",
              "network_or_timeout",
              "manual_authority_changed",
              "resource_scope_changed",
              "malformed",
              "protocol",
              "userinfo",
              "private_host",
              "dns",
              "redirect",
              "endpoint_unavailable",
              "credentials_unavailable",
              null
            ],
            "nullable": true
          }
        },
        "required": [
          "id",
          "timestamp",
          "updated_at",
          "webhook_id",
          "event",
          "livemode",
          "status",
          "response_code",
          "retry_requested",
          "redaction",
          "resource_id",
          "attempts",
          "latency_ms",
          "error_category"
        ]
      },
      "AccountWebhookDeliveryLogDetail": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "timestamp": {
            "type": "number",
            "nullable": true
          },
          "updated_at": {
            "type": "number",
            "nullable": true
          },
          "webhook_id": {
            "type": "string",
            "nullable": true
          },
          "event": {
            "type": "string",
            "nullable": true,
            "enum": [
              "payment.created",
              "payment.updated",
              "payment.succeeded",
              "payment.canceled",
              "payment.deleted",
              "payment.upcoming_due_date",
              "invoice.created",
              "invoice.canceled",
              "invoice.failed",
              "invoice_batch.completed",
              "payment_batch.completed",
              "receipt.created",
              "receipt.updated",
              "receipt.completed",
              "receipt.deleted",
              "customer.created",
              "customer.updated",
              "customer.deleted",
              "service.created",
              "service.updated",
              "service.deleted",
              "sat.invoice.synced",
              "teams.created",
              "teams.sat.completed",
              "teams.stripe.completed",
              "teams.openpay.completed",
              "teams.sat.manifest.signed",
              null
            ]
          },
          "livemode": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "retrying",
              "succeeded",
              "failed",
              "unknown"
            ]
          },
          "response_code": {
            "type": "number",
            "nullable": true
          },
          "retry_requested": {
            "type": "boolean"
          },
          "redaction": {
            "type": "string",
            "enum": [
              "metadata_and_body_shape"
            ]
          },
          "payload_shape": {
            "description": "Redacted structure only: recognized field names and primitive type markers, bounded nested objects and array sample shapes. Never the original payload values."
          },
          "response_shape": {
            "description": "Redacted structure only: recognized field names and primitive type markers, bounded nested objects and array sample shapes. Never the original payload values."
          },
          "resource_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$",
            "maxLength": 160,
            "nullable": true,
            "description": "Historical selection hint only. Does not prove current resource existence or access; each action reauthorizes the resource."
          },
          "attempts": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "latency_ms": {
            "type": "number",
            "minimum": 0,
            "nullable": true
          },
          "error_category": {
            "type": "string",
            "enum": [
              "http_response",
              "network_or_timeout",
              "manual_authority_changed",
              "resource_scope_changed",
              "malformed",
              "protocol",
              "userinfo",
              "private_host",
              "dns",
              "redirect",
              "endpoint_unavailable",
              "credentials_unavailable",
              null
            ],
            "nullable": true
          }
        },
        "required": [
          "id",
          "timestamp",
          "updated_at",
          "webhook_id",
          "event",
          "livemode",
          "status",
          "response_code",
          "retry_requested",
          "redaction",
          "payload_shape",
          "response_shape",
          "resource_id",
          "attempts",
          "latency_ms",
          "error_category"
        ]
      },
      "PaymentLinkCreateInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_livemode",
          "items",
          "currency"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "expected_livemode": {
            "type": "boolean"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "total"
              ],
              "properties": {
                "total": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1000000000000
                },
                "quantity": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0.000001,
                  "maximum": 1000000000
                },
                "hours": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0,
                  "maximum": 1000000000000
                },
                "discount": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0,
                  "maximum": 1000000000000
                },
                "feeAdded": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0,
                  "maximum": 1000000000000
                },
                "paymentType": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "value"
                  ],
                  "properties": {
                    "value": {
                      "type": "string",
                      "enum": [
                        "fixed",
                        "hour"
                      ]
                    },
                    "label": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 100
                    }
                  },
                  "nullable": true
                },
                "taxes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "rate",
                      "type"
                    ],
                    "properties": {
                      "rate": {
                        "oneOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "string",
                            "description": "Numeric string accepted by the request validator."
                          }
                        ],
                        "minimum": 0,
                        "maximum": 100
                      },
                      "type": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "factor": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 30
                      },
                      "withholding": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "inclusive": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "id": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 160
                      },
                      "ieps_mode": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 30
                      },
                      "base": {
                        "type": "number",
                        "nullable": true,
                        "minimum": 0,
                        "maximum": 1000000000000
                      }
                    }
                  },
                  "nullable": true,
                  "maxItems": 30
                },
                "localTaxes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "rate",
                      "type"
                    ],
                    "properties": {
                      "rate": {
                        "oneOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "string",
                            "description": "Numeric string accepted by the request validator."
                          }
                        ],
                        "minimum": 0,
                        "maximum": 100
                      },
                      "type": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "factor": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 30
                      },
                      "withholding": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "inclusive": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "id": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 160
                      },
                      "ieps_mode": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 30
                      },
                      "base": {
                        "type": "number",
                        "nullable": true,
                        "minimum": 0,
                        "maximum": 1000000000000
                      }
                    }
                  },
                  "nullable": true,
                  "maxItems": 30
                },
                "description": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 10000
                },
                "name": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 1000
                },
                "product_key": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 100
                },
                "unit_key": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 100
                },
                "unit_name": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 100
                },
                "id": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "fid": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "localId": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "from": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 100
                },
                "owner": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "team": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "billingAccount": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "timestamp": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0,
                  "maximum": 100000000000000
                },
                "tax_included": {
                  "type": "boolean",
                  "nullable": true
                },
                "localChanges": {
                  "type": "boolean",
                  "nullable": true
                },
                "livemode": {
                  "type": "boolean",
                  "nullable": true
                },
                "disabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "sku": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 1000
                },
                "property_tax_account": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 1000
                },
                "customs_keys": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "nullable": true,
                  "maxItems": 100
                },
                "amounts": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "taxes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "rate",
                          "type"
                        ],
                        "properties": {
                          "rate": {
                            "oneOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string",
                                "description": "Numeric string accepted by the request validator."
                              }
                            ],
                            "minimum": 0,
                            "maximum": 100
                          },
                          "type": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "factor": {
                            "type": "string",
                            "nullable": true,
                            "maxLength": 30
                          },
                          "withholding": {
                            "type": "boolean",
                            "nullable": true
                          },
                          "inclusive": {
                            "type": "boolean",
                            "nullable": true
                          },
                          "id": {
                            "type": "string",
                            "nullable": true,
                            "maxLength": 160
                          },
                          "ieps_mode": {
                            "type": "string",
                            "nullable": true,
                            "maxLength": 30
                          },
                          "base": {
                            "type": "number",
                            "nullable": true,
                            "minimum": 0,
                            "maximum": 1000000000000
                          }
                        }
                      },
                      "nullable": true,
                      "maxItems": 30
                    },
                    "subtotal": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    },
                    "total": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    },
                    "includedTaxes": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    },
                    "excludedTaxes": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    },
                    "withholdedTaxes": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    }
                  },
                  "nullable": true
                },
                "third_party": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "legal_name": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 1000
                    },
                    "tax_id": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 100
                    },
                    "tax_system": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 100
                    },
                    "zip": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 30
                    }
                  },
                  "nullable": true
                }
              }
            },
            "minItems": 1,
            "maxItems": 200
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "exchange": {
            "type": "number",
            "nullable": true,
            "minimum": 1e-8,
            "maximum": 1000000000
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 10000
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "properties": {},
            "nullable": true
          },
          "limitDaysToPay": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "maximum": 3650
          },
          "automations": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "type",
                "from",
                "ref",
                "action"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "invoice"
                  ]
                },
                "from": {
                  "type": "string",
                  "enum": [
                    "payments"
                  ]
                },
                "ref": {
                  "type": "string",
                  "enum": [
                    "payments"
                  ]
                },
                "action": {
                  "type": "string",
                  "enum": [
                    "create"
                  ]
                }
              }
            },
            "maxItems": 1
          },
          "custom_method_types": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "enum": [
                    "card",
                    "oxxo",
                    "bank",
                    "customer_balance",
                    "bank_account",
                    "store",
                    "hosted"
                  ]
                }
              }
            },
            "maxItems": 7
          }
        }
      },
      "PaymentLinkUpdateInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_livemode",
          "expected_revision"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "expected_livemode": {
            "type": "boolean"
          },
          "expected_revision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "total"
              ],
              "properties": {
                "total": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1000000000000
                },
                "quantity": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0.000001,
                  "maximum": 1000000000
                },
                "hours": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0,
                  "maximum": 1000000000000
                },
                "discount": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0,
                  "maximum": 1000000000000
                },
                "feeAdded": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0,
                  "maximum": 1000000000000
                },
                "paymentType": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "value"
                  ],
                  "properties": {
                    "value": {
                      "type": "string",
                      "enum": [
                        "fixed",
                        "hour"
                      ]
                    },
                    "label": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 100
                    }
                  },
                  "nullable": true
                },
                "taxes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "rate",
                      "type"
                    ],
                    "properties": {
                      "rate": {
                        "oneOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "string",
                            "description": "Numeric string accepted by the request validator."
                          }
                        ],
                        "minimum": 0,
                        "maximum": 100
                      },
                      "type": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "factor": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 30
                      },
                      "withholding": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "inclusive": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "id": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 160
                      },
                      "ieps_mode": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 30
                      },
                      "base": {
                        "type": "number",
                        "nullable": true,
                        "minimum": 0,
                        "maximum": 1000000000000
                      }
                    }
                  },
                  "nullable": true,
                  "maxItems": 30
                },
                "localTaxes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "rate",
                      "type"
                    ],
                    "properties": {
                      "rate": {
                        "oneOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "string",
                            "description": "Numeric string accepted by the request validator."
                          }
                        ],
                        "minimum": 0,
                        "maximum": 100
                      },
                      "type": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "factor": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 30
                      },
                      "withholding": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "inclusive": {
                        "type": "boolean",
                        "nullable": true
                      },
                      "id": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 160
                      },
                      "ieps_mode": {
                        "type": "string",
                        "nullable": true,
                        "maxLength": 30
                      },
                      "base": {
                        "type": "number",
                        "nullable": true,
                        "minimum": 0,
                        "maximum": 1000000000000
                      }
                    }
                  },
                  "nullable": true,
                  "maxItems": 30
                },
                "description": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 10000
                },
                "name": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 1000
                },
                "product_key": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 100
                },
                "unit_key": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 100
                },
                "unit_name": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 100
                },
                "id": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "fid": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "localId": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "from": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 100
                },
                "owner": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "team": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "billingAccount": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 160
                },
                "timestamp": {
                  "type": "number",
                  "nullable": true,
                  "minimum": 0,
                  "maximum": 100000000000000
                },
                "tax_included": {
                  "type": "boolean",
                  "nullable": true
                },
                "localChanges": {
                  "type": "boolean",
                  "nullable": true
                },
                "livemode": {
                  "type": "boolean",
                  "nullable": true
                },
                "disabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "sku": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 1000
                },
                "property_tax_account": {
                  "type": "string",
                  "nullable": true,
                  "maxLength": 1000
                },
                "customs_keys": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "nullable": true,
                  "maxItems": 100
                },
                "amounts": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "taxes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "rate",
                          "type"
                        ],
                        "properties": {
                          "rate": {
                            "oneOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string",
                                "description": "Numeric string accepted by the request validator."
                              }
                            ],
                            "minimum": 0,
                            "maximum": 100
                          },
                          "type": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "factor": {
                            "type": "string",
                            "nullable": true,
                            "maxLength": 30
                          },
                          "withholding": {
                            "type": "boolean",
                            "nullable": true
                          },
                          "inclusive": {
                            "type": "boolean",
                            "nullable": true
                          },
                          "id": {
                            "type": "string",
                            "nullable": true,
                            "maxLength": 160
                          },
                          "ieps_mode": {
                            "type": "string",
                            "nullable": true,
                            "maxLength": 30
                          },
                          "base": {
                            "type": "number",
                            "nullable": true,
                            "minimum": 0,
                            "maximum": 1000000000000
                          }
                        }
                      },
                      "nullable": true,
                      "maxItems": 30
                    },
                    "subtotal": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    },
                    "total": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    },
                    "includedTaxes": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    },
                    "excludedTaxes": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    },
                    "withholdedTaxes": {
                      "type": "number",
                      "nullable": true,
                      "minimum": 0,
                      "maximum": 1000000000000
                    }
                  },
                  "nullable": true
                },
                "third_party": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "legal_name": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 1000
                    },
                    "tax_id": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 100
                    },
                    "tax_system": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 100
                    },
                    "zip": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 30
                    }
                  },
                  "nullable": true
                }
              }
            },
            "minItems": 1,
            "maxItems": 200
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "exchange": {
            "type": "number",
            "nullable": true,
            "minimum": 1e-8,
            "maximum": 1000000000
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 10000
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "properties": {},
            "nullable": true
          },
          "limitDaysToPay": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "maximum": 3650
          },
          "automations": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "type",
                "from",
                "ref",
                "action"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "invoice"
                  ]
                },
                "from": {
                  "type": "string",
                  "enum": [
                    "payments"
                  ]
                },
                "ref": {
                  "type": "string",
                  "enum": [
                    "payments"
                  ]
                },
                "action": {
                  "type": "string",
                  "enum": [
                    "create"
                  ]
                }
              }
            },
            "maxItems": 1
          },
          "custom_method_types": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "enum": [
                    "card",
                    "oxxo",
                    "bank",
                    "customer_balance",
                    "bank_account",
                    "store",
                    "hosted"
                  ]
                }
              }
            },
            "maxItems": 7
          }
        }
      },
      "PaymentLinkDeleteInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_livemode",
          "expected_revision"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "expected_livemode": {
            "type": "boolean"
          },
          "expected_revision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        }
      },
      "PaymentLink": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "team_id",
          "livemode",
          "status",
          "amount",
          "total",
          "url",
          "short_url",
          "owner",
          "created_at",
          "updated_at",
          "deleted_at",
          "revision",
          "effect_scope",
          "views",
          "historical_references"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "Stored selected-service snapshots. New writes use the complete typed item input contract."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "exchange": {
            "type": "number",
            "nullable": true,
            "minimum": 1e-8,
            "maximum": 1000000000
          },
          "description": {
            "type": "string",
            "nullable": true,
            "maxLength": 10000
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "properties": {},
            "nullable": true
          },
          "limitDaysToPay": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "maximum": 3650
          },
          "automations": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "type",
                "from",
                "ref",
                "action"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "invoice"
                  ]
                },
                "from": {
                  "type": "string",
                  "enum": [
                    "payments"
                  ]
                },
                "ref": {
                  "type": "string",
                  "enum": [
                    "payments"
                  ]
                },
                "action": {
                  "type": "string",
                  "enum": [
                    "create"
                  ]
                }
              }
            },
            "maxItems": 1
          },
          "custom_method_types": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "enum": [
                    "card",
                    "oxxo",
                    "bank",
                    "customer_balance",
                    "bank_account",
                    "store",
                    "hosted"
                  ]
                }
              }
            },
            "maxItems": 7
          },
          "id": {
            "type": "string",
            "pattern": "^plink[A-Za-z0-9_-]{1,155}$"
          },
          "team_id": {
            "type": "string"
          },
          "livemode": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "active links may accept new payers; deleted links refuse new payer requests."
          },
          "amount": {
            "type": "number",
            "nullable": true
          },
          "total": {
            "type": "number",
            "nullable": true
          },
          "url": {
            "type": "string",
            "nullable": true
          },
          "short_url": {
            "type": "string",
            "nullable": true,
            "description": "Null for newly created staging links; use url."
          },
          "owner": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "number",
            "nullable": true
          },
          "updated_at": {
            "type": "number",
            "nullable": true
          },
          "deleted_at": {
            "type": "number",
            "nullable": true
          },
          "revision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_mode_payment_link"
            ]
          },
          "views": {
            "type": "integer",
            "minimum": 0,
            "nullable": true,
            "description": "Saved historical view count; null means absent or unrecognized, not zero."
          },
          "historical_references": {
            "type": "object",
            "required": [
              "invoices",
              "receipts",
              "unresolved_count",
              "authorization"
            ],
            "additionalProperties": false,
            "properties": {
              "invoices": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,160}$"
                }
              },
              "receipts": {
                "type": "array",
                "nullable": true,
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,160}$"
                }
              },
              "unresolved_count": {
                "type": "integer",
                "minimum": 0
              },
              "authorization": {
                "type": "string",
                "enum": [
                  "resolve_each_resource"
                ]
              }
            },
            "description": "Saved ID hints, not current document existence or access. Null arrays are absent/unrecognized; unresolved_count covers rejected entries. Read each target through its current scoped resource API before opening or acting. Does not enumerate all payments generated from the link."
          }
        }
      },
      "PaymentLinkOperation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "team_id",
          "livemode",
          "action",
          "payment_link_id",
          "status",
          "completed_at",
          "revision",
          "effect_scope"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid"
          },
          "team_id": {
            "type": "string"
          },
          "livemode": {
            "type": "boolean"
          },
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update",
              "delete"
            ]
          },
          "payment_link_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "completed"
            ]
          },
          "completed_at": {
            "type": "number"
          },
          "revision": {
            "type": "string"
          },
          "effect_scope": {
            "type": "string",
            "enum": [
              "team_mode_payment_link"
            ]
          }
        }
      },
      "PaymentLinkMutationResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "data",
          "operation"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "data": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PaymentLink"
              },
              {
                "type": "object",
                "nullable": true,
                "enum": [
                  null
                ]
              }
            ],
            "description": "Current resource; null can coexist with a historical completed receipt."
          },
          "operation": {
            "$ref": "#/components/schemas/PaymentLinkOperation"
          }
        }
      },
      "PaymentReminderInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "when",
          "duration",
          "periodicity"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,160}$"
          },
          "type": {
            "type": "string",
            "enum": [
              "default",
              "daily",
              "weekly",
              "monthly",
              "yearly",
              "custom"
            ]
          },
          "when": {
            "type": "string",
            "enum": [
              "before",
              "after"
            ]
          },
          "duration": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3650
          },
          "periodicity": {
            "type": "string",
            "enum": [
              "day",
              "week",
              "month",
              "year"
            ]
          },
          "custom_subject": {
            "type": "string",
            "nullable": true,
            "maxLength": 300
          },
          "custom_template": {
            "type": "string",
            "nullable": true,
            "maxLength": 10000
          }
        }
      },
      "PaymentReminderConfigurationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_livemode",
          "expected_revision",
          "reminders"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "expected_livemode": {
            "type": "boolean"
          },
          "expected_revision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "reminders": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/PaymentReminderInput"
            }
          },
          "limitDaysToPay": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3650
          }
        }
      },
      "PaymentReminderRecoveryRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "expected_livemode",
          "expected_revision",
          "reminders",
          "supersedes_operation_id",
          "affected_generations"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "expected_livemode": {
            "type": "boolean"
          },
          "expected_revision": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "reminders": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/PaymentReminderInput"
            }
          },
          "limitDaysToPay": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3650
          },
          "supersedes_operation_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "affected_generations": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "reminder_id",
                "generation"
              ],
              "properties": {
                "reminder_id": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_-]{1,160}$"
                },
                "generation": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                }
              }
            }
          }
        }
      },
      "PaymentReminderRecoveryExecuteRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "review_version",
          "review_challenge",
          "acknowledge_duplicate_email"
        ],
        "properties": {
          "review_version": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "review_challenge": {
            "type": "string",
            "minLength": 32,
            "maxLength": 256
          },
          "acknowledge_duplicate_email": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "PaymentReminderEmptyRequest": {
        "type": "object",
        "additionalProperties": false
      },
      "ScopedApiKeyCreateInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "livemode",
          "billing_account_id",
          "team_ids",
          "action_ids",
          "manager_user_ids"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "livemode": {
            "type": "boolean"
          },
          "billing_account_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "team_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            },
            "minItems": 1,
            "maxItems": 100
          },
          "action_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 128
            },
            "minItems": 1,
            "maxItems": 200
          },
          "expires_at": {
            "type": "integer",
            "nullable": true
          },
          "manager_user_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            },
            "maxItems": 100
          }
        }
      },
      "ScopedApiKeyRotateInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "key_id",
          "overlap_seconds"
        ],
        "properties": {
          "key_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "overlap_seconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400
          }
        }
      },
      "ScopedApiKeyRevokeInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          }
        }
      },
      "ScopedApiKeyMetadata": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "scope_version",
          "scope_kind",
          "billing_account_id",
          "team",
          "livemode",
          "team_ids",
          "action_ids",
          "expires_at",
          "manager_user_ids",
          "status",
          "created_at",
          "revoked_at",
          "revoke_at",
          "replacement_key_id",
          "last_used_at",
          "can_manage",
          "can_rotate",
          "can_revoke"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "scope_version": {
            "type": "integer",
            "enum": [
              2
            ],
            "nullable": true
          },
          "scope_kind": {
            "type": "string",
            "enum": [
              "scoped",
              "legacy_unrestricted"
            ]
          },
          "billing_account_id": {
            "type": "string"
          },
          "team": {
            "type": "string",
            "nullable": true
          },
          "livemode": {
            "type": "boolean",
            "nullable": true
          },
          "team_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "action_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "expires_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "manager_user_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "expired",
              "revoked",
              "scheduled_revocation",
              "policy_invalid"
            ]
          },
          "created_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "revoked_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "revoke_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "replacement_key_id": {
            "type": "string",
            "nullable": true
          },
          "last_used_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "can_manage": {
            "type": "boolean"
          },
          "can_rotate": {
            "type": "boolean"
          },
          "can_revoke": {
            "type": "boolean"
          }
        }
      },
      "ScopedApiKeyCapabilities": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "can_create_scoped",
          "can_emergency_revoke",
          "is_billing_owner"
        ],
        "properties": {
          "can_create_scoped": {
            "type": "boolean"
          },
          "can_emergency_revoke": {
            "type": "boolean"
          },
          "is_billing_owner": {
            "type": "boolean"
          }
        }
      },
      "ScopedApiKeyList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor",
          "capabilities"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScopedApiKeyMetadata"
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "capabilities": {
            "$ref": "#/components/schemas/ScopedApiKeyCapabilities"
          }
        }
      },
      "ScopedApiKeyPolicy": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "billing_account_id",
          "eligible_teams",
          "actions",
          "eligible_managers",
          "max_expiry_days",
          "max_overlap_seconds",
          "can_create_scoped",
          "can_emergency_revoke",
          "is_billing_owner"
        ],
        "properties": {
          "billing_account_id": {
            "type": "string"
          },
          "eligible_teams": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "name"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "label",
                "group"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "group": {
                  "type": "string"
                }
              }
            }
          },
          "eligible_managers": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "uid",
                "display_name"
              ],
              "properties": {
                "uid": {
                  "type": "string"
                },
                "display_name": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "max_expiry_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365
          },
          "max_overlap_seconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400
          },
          "can_create_scoped": {
            "type": "boolean"
          },
          "can_emergency_revoke": {
            "type": "boolean"
          },
          "is_billing_owner": {
            "type": "boolean"
          }
        }
      },
      "ScopedApiKeyAudit": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items",
          "next_cursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "action",
                "timestamp",
                "actor_user_id",
                "key_id",
                "operation_id"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "action": {
                  "type": "string"
                },
                "timestamp": {
                  "type": "integer",
                  "minimum": 0
                },
                "actor_user_id": {
                  "type": "string"
                },
                "key_id": {
                  "type": "string"
                },
                "operation_id": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "ScopedApiKeyRevokeReceipt": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "key_id",
          "revoked",
          "operation_id"
        ],
        "properties": {
          "key_id": {
            "type": "string"
          },
          "revoked": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          }
        }
      },
      "ScopedApiKeyChange": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "livemode",
          "billing_account_id",
          "team_ids",
          "action_ids",
          "expires_at",
          "manager_user_ids",
          "action",
          "previous_key_id",
          "overlap_seconds",
          "previous_revoke_at",
          "unrelated_keys_affected",
          "secret_disclosure"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "livemode": {
            "type": "boolean"
          },
          "billing_account_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{1,128}$"
          },
          "team_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            },
            "minItems": 1,
            "maxItems": 100
          },
          "action_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 128
            },
            "minItems": 1,
            "maxItems": 200
          },
          "expires_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "manager_user_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            },
            "maxItems": 100
          },
          "action": {
            "type": "string",
            "enum": [
              "create",
              "rotate"
            ]
          },
          "previous_key_id": {
            "type": "string",
            "nullable": true
          },
          "overlap_seconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400
          },
          "previous_revoke_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "unrelated_keys_affected": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "secret_disclosure": {
            "type": "string",
            "enum": [
              "once"
            ]
          }
        }
      },
      "ScopedApiKeyReceipt": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "key_id",
          "previous_key_id",
          "overlap_seconds",
          "previous_revoke_at",
          "metadata"
        ],
        "properties": {
          "key_id": {
            "type": "string"
          },
          "previous_key_id": {
            "type": "string",
            "nullable": true
          },
          "overlap_seconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400
          },
          "previous_revoke_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          },
          "metadata": {
            "$ref": "#/components/schemas/ScopedApiKeyMetadata"
          }
        }
      },
      "ScopedApiKeyEmergencyInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          }
        }
      },
      "ScopedApiKeyEmergencyReceipt": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "operation_id",
          "billing_account_id",
          "status",
          "revoked_count",
          "scope",
          "legacy_keys_affected",
          "mcp_revoked",
          "oauth_revoked",
          "created_at",
          "completed_at"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
          },
          "billing_account_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "processing",
              "completed"
            ]
          },
          "revoked_count": {
            "type": "integer",
            "minimum": 0
          },
          "scope": {
            "type": "string",
            "enum": [
              "billing_account_scoped_keys"
            ]
          },
          "legacy_keys_affected": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "mcp_revoked": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "oauth_revoked": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "created_at": {
            "type": "integer",
            "minimum": 0
          },
          "completed_at": {
            "type": "integer",
            "minimum": 0,
            "nullable": true
          }
        }
      }
    }
  },
  "paths": {
    "/teams/{id}/integrations/stripe/disconnect": {
      "post": {
        "operationId": "disconnectStripeLocalV2",
        "tags": [
          "Teams"
        ],
        "summary": "Remove local Stripe credentials",
        "description": "Current original team machine grant or current personal editor. Save operation UUID before transport; unknown results require read-only reconciliation. API-key creator history is not impersonated. A session started by a team API key (requester credential_kind api, person_id null) expires 24 hours after creation so a person can open browser_handoff_url later; a session started by a person expires after ten minutes. Browser steps still require an independently signed-in, authorized member, and an OAuth state expires ten minutes after authorize. An operation that expired before any provider effect (pending, or awaiting_oauth with an unused state) is superseded atomically by the next session and is no longer reported as active; a live operation, or one in_progress or outcome_unknown, still answers 409 stripe_operation_pending. Local disconnect removes shared live/test credential custody but does not revoke provider authorization or remove remote webhooks; in-flight authorized calls are not cancelled.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current safe metadata or explicitly private ephemeral browser result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/StripeLocalDisconnectReceipt"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Unknown result: read saved UUID; never replay a provider effect.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StripeLocalDisconnectInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/stripe/connection-sessions/{operationId}/cancel": {
      "post": {
        "operationId": "cancelStripeConnectionV2",
        "tags": [
          "Teams"
        ],
        "summary": "Cancel untouched Stripe setup",
        "description": "Current original team machine grant or current personal editor. Save operation UUID before transport; unknown results require read-only reconciliation. API-key creator history is not impersonated. A session started by a team API key (requester credential_kind api, person_id null) expires 24 hours after creation so a person can open browser_handoff_url later; a session started by a person expires after ten minutes. Browser steps still require an independently signed-in, authorized member, and an OAuth state expires ten minutes after authorize. An operation that expired before any provider effect (pending, or awaiting_oauth with an unused state) is superseded atomically by the next session and is no longer reported as active; a live operation, or one in_progress or outcome_unknown, still answers 409 stripe_operation_pending. Local disconnect removes shared live/test credential custody but does not revoke provider authorization or remove remote webhooks; in-flight authorized calls are not cancelled.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current safe metadata or explicitly private ephemeral browser result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/StripeConnectionSession"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Unknown result: read saved UUID; never replay a provider effect.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StripeConnectionTerminalInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/stripe/operations/{operationId}": {
      "get": {
        "operationId": "getStripeConnectionOperationV2",
        "tags": [
          "Teams"
        ],
        "summary": "Read saved Stripe operation",
        "description": "Current original team machine grant or current personal editor. Save operation UUID before transport; unknown results require read-only reconciliation. API-key creator history is not impersonated. A session started by a team API key (requester credential_kind api, person_id null) expires 24 hours after creation so a person can open browser_handoff_url later; a session started by a person expires after ten minutes. Browser steps still require an independently signed-in, authorized member, and an OAuth state expires ten minutes after authorize. An operation that expired before any provider effect (pending, or awaiting_oauth with an unused state) is superseded atomically by the next session and is no longer reported as active; a live operation, or one in_progress or outcome_unknown, still answers 409 stripe_operation_pending. Local disconnect removes shared live/test credential custody but does not revoke provider authorization or remove remote webhooks; in-flight authorized calls are not cancelled.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          },
          {
            "name": "livemode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "boolean"
            },
            "description": "Explicit selected mode; must match machine credential mode."
          }
        ],
        "responses": {
          "200": {
            "description": "Current safe metadata or explicitly private ephemeral browser result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/StripeConnectionSession"
                        },
                        {
                          "$ref": "#/components/schemas/StripeLocalDisconnectReceipt"
                        },
                        {
                          "$ref": "#/components/schemas/StripeUnconfirmedClosureReceipt"
                        }
                      ]
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Unknown result: read saved UUID; never replay a provider effect.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/stripe/connection-sessions": {
      "post": {
        "operationId": "prepareStripeConnectionV2",
        "tags": [
          "Teams"
        ],
        "summary": "Prepare Stripe connection",
        "description": "Current original team machine grant or current personal editor. Save operation UUID before transport; unknown results require read-only reconciliation. API-key creator history is not impersonated. A session started by a team API key (requester credential_kind api, person_id null) expires 24 hours after creation so a person can open browser_handoff_url later; a session started by a person expires after ten minutes. Browser steps still require an independently signed-in, authorized member, and an OAuth state expires ten minutes after authorize. An operation that expired before any provider effect (pending, or awaiting_oauth with an unused state) is superseded atomically by the next session and is no longer reported as active; a live operation, or one in_progress or outcome_unknown, still answers 409 stripe_operation_pending. Local disconnect removes shared live/test credential custody but does not revoke provider authorization or remove remote webhooks; in-flight authorized calls are not cancelled.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current safe metadata or explicitly private ephemeral browser result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "operation_id",
                        "team_id",
                        "billing_account_id",
                        "requester",
                        "method",
                        "livemode",
                        "expected_generation",
                        "generation",
                        "status",
                        "created_at",
                        "expires_at",
                        "updated_at",
                        "steps",
                        "provider_revocation",
                        "provider_webhook_removal",
                        "browser_handoff_url"
                      ],
                      "properties": {
                        "operation_id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                        },
                        "team_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "billing_account_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "requester": {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "credential_kind",
                            "source_team_id",
                            "credential_id",
                            "person_id"
                          ],
                          "properties": {
                            "credential_kind": {
                              "type": "string",
                              "enum": [
                                "firebase",
                                "mcp",
                                "api",
                                "oauth"
                              ]
                            },
                            "source_team_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "credential_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$",
                              "nullable": true
                            },
                            "person_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$",
                              "nullable": true
                            }
                          }
                        },
                        "method": {
                          "type": "string",
                          "enum": [
                            "oauth",
                            "manual_key",
                            "connect_webhooks",
                            "account_onboarding",
                            "platform_account_create"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "expected_generation": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "generation": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991,
                          "nullable": true
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending",
                            "expired",
                            "awaiting_oauth",
                            "in_progress",
                            "completed",
                            "outcome_unknown",
                            "cancelled"
                          ]
                        },
                        "created_at": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "expires_at": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "updated_at": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "steps": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "oauth_exchange": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "account_verification": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "manual_webhook": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "connect_webhook": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "transfer_webhook": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "credential_commit": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "account_onboarding_link": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "platform_account_create": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            }
                          }
                        },
                        "provider_revocation": {
                          "type": "string",
                          "enum": [
                            "not_performed"
                          ]
                        },
                        "provider_webhook_removal": {
                          "type": "string",
                          "enum": [
                            "not_performed"
                          ]
                        },
                        "browser_handoff_url": {
                          "type": "string",
                          "format": "uri"
                        },
                        "provider_account_id": {
                          "type": "string",
                          "pattern": "^acct_[A-Za-z0-9]+$"
                        }
                      }
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Unknown result: read saved UUID; never replay a provider effect.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StripeConnectionCreateInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/stripe/connection": {
      "get": {
        "operationId": "getStripeConnectionV2",
        "tags": [
          "Teams"
        ],
        "summary": "Read Stripe connection",
        "description": "Current original team machine grant or current personal editor. Save operation UUID before transport; unknown results require read-only reconciliation. API-key creator history is not impersonated. A session started by a team API key (requester credential_kind api, person_id null) expires 24 hours after creation so a person can open browser_handoff_url later; a session started by a person expires after ten minutes. Browser steps still require an independently signed-in, authorized member, and an OAuth state expires ten minutes after authorize. An operation that expired before any provider effect (pending, or awaiting_oauth with an unused state) is superseded atomically by the next session and is no longer reported as active; a live operation, or one in_progress or outcome_unknown, still answers 409 stripe_operation_pending. Local disconnect removes shared live/test credential custody but does not revoke provider authorization or remove remote webhooks; in-flight authorized calls are not cancelled.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "livemode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "boolean"
            },
            "description": "Explicit selected mode; must match machine credential mode."
          }
        ],
        "responses": {
          "200": {
            "description": "Current safe metadata or explicitly private ephemeral browser result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/StripeConnectionStatus"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Unknown result: read saved UUID; never replay a provider effect.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/users/{id}/password-reset-recoveries/{operationId}": {
      "get": {
        "operationId": "getPasswordResetRecovery",
        "summary": "Read safe reset recovery status",
        "description": "Save a UUIDv4 before preparing. Current original credential, admin authority, target membership and exact team/mode are independently checked. Preparation sends no email. Execute consumes the confirmed intent before providers; no automatic retry. On an uncertain response read the same UUID. Recovery uses a different UUID and requires a current person in the private browser, never an agent challenge. The earlier code may remain valid and another email may arrive. Provider acceptance is neither delivery nor password change. Reset affects the global login even in test mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped receipt; contains no recipient, reset URL or reviewer proof.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "oneOf": [
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "operation_id",
                            "supersedes_operation_id",
                            "team_id",
                            "user_id",
                            "livemode",
                            "password_change",
                            "prior_reset_code_revocation",
                            "status",
                            "browser_handoff"
                          ],
                          "properties": {
                            "operation_id": {
                              "type": "string",
                              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                            },
                            "supersedes_operation_id": {
                              "type": "string",
                              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                            },
                            "team_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "user_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "password_change": {
                              "type": "string",
                              "enum": [
                                "not_verified"
                              ]
                            },
                            "prior_reset_code_revocation": {
                              "type": "string",
                              "enum": [
                                "not_performed"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "private_review_required",
                                "review_stale"
                              ]
                            },
                            "browser_handoff": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "url",
                                "effect",
                                "contains_reset_credential"
                              ],
                              "properties": {
                                "url": {
                                  "type": "string",
                                  "format": "uri"
                                },
                                "effect": {
                                  "type": "string",
                                  "enum": [
                                    "private_review_required"
                                  ]
                                },
                                "contains_reset_credential": {
                                  "type": "boolean",
                                  "enum": [
                                    false
                                  ]
                                }
                              }
                            },
                            "target_changed": {
                              "type": "boolean"
                            },
                            "prior_email_delivery": {
                              "type": "string",
                              "enum": [
                                "unknown",
                                "not_attempted"
                              ]
                            },
                            "acknowledge_duplicate_email_required": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "operation_id",
                            "supersedes_operation_id",
                            "team_id",
                            "user_id",
                            "livemode",
                            "password_change",
                            "prior_reset_code_revocation",
                            "status",
                            "attempt_in_progress",
                            "claim_expires_at",
                            "email_delivery",
                            "started_at",
                            "updated_at",
                            "browser_handoff"
                          ],
                          "properties": {
                            "operation_id": {
                              "type": "string",
                              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                            },
                            "supersedes_operation_id": {
                              "type": "string",
                              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                            },
                            "team_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "user_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "password_change": {
                              "type": "string",
                              "enum": [
                                "not_verified"
                              ]
                            },
                            "prior_reset_code_revocation": {
                              "type": "string",
                              "enum": [
                                "not_performed"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "prepared",
                                "outcome_unknown",
                                "generation_unknown",
                                "generated_unsent",
                                "email_unknown",
                                "provider_accepted",
                                "canceled"
                              ]
                            },
                            "attempt_in_progress": {
                              "type": "boolean"
                            },
                            "claim_expires_at": {
                              "type": "integer",
                              "minimum": 0,
                              "nullable": true
                            },
                            "email_delivery": {
                              "type": "string",
                              "enum": [
                                "not_attempted",
                                "unknown",
                                "provider_accepted"
                              ]
                            },
                            "started_at": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "updated_at": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "browser_handoff": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "url",
                                "effect",
                                "contains_reset_credential"
                              ],
                              "properties": {
                                "url": {
                                  "type": "string",
                                  "format": "uri"
                                },
                                "effect": {
                                  "type": "string",
                                  "enum": [
                                    "private_review_required"
                                  ]
                                },
                                "contains_reset_credential": {
                                  "type": "boolean",
                                  "enum": [
                                    false
                                  ]
                                }
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Refusal or unconfirmed outcome. Retain the UUID and read status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "error"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Users"
        ]
      }
    },
    "/users/{id}/password-reset-recoveries": {
      "post": {
        "operationId": "preparePasswordResetRecovery",
        "summary": "Prepare privately reviewed reset recovery",
        "description": "Save a UUIDv4 before preparing. Current original credential, admin authority, target membership and exact team/mode are independently checked. Preparation sends no email. Execute consumes the confirmed intent before providers; no automatic retry. On an uncertain response read the same UUID. Recovery uses a different UUID and requires a current person in the private browser, never an agent challenge. The earlier code may remain valid and another email may arrive. Provider acceptance is neither delivery nor password change. Reset affects the global login even in test mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped receipt; contains no recipient, reset URL or reviewer proof.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "oneOf": [
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "operation_id",
                            "supersedes_operation_id",
                            "team_id",
                            "user_id",
                            "livemode",
                            "password_change",
                            "prior_reset_code_revocation",
                            "status",
                            "browser_handoff"
                          ],
                          "properties": {
                            "operation_id": {
                              "type": "string",
                              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                            },
                            "supersedes_operation_id": {
                              "type": "string",
                              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                            },
                            "team_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "user_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "password_change": {
                              "type": "string",
                              "enum": [
                                "not_verified"
                              ]
                            },
                            "prior_reset_code_revocation": {
                              "type": "string",
                              "enum": [
                                "not_performed"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "private_review_required",
                                "review_stale"
                              ]
                            },
                            "browser_handoff": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "url",
                                "effect",
                                "contains_reset_credential"
                              ],
                              "properties": {
                                "url": {
                                  "type": "string",
                                  "format": "uri"
                                },
                                "effect": {
                                  "type": "string",
                                  "enum": [
                                    "private_review_required"
                                  ]
                                },
                                "contains_reset_credential": {
                                  "type": "boolean",
                                  "enum": [
                                    false
                                  ]
                                }
                              }
                            },
                            "target_changed": {
                              "type": "boolean"
                            },
                            "prior_email_delivery": {
                              "type": "string",
                              "enum": [
                                "unknown",
                                "not_attempted"
                              ]
                            },
                            "acknowledge_duplicate_email_required": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "operation_id",
                            "supersedes_operation_id",
                            "team_id",
                            "user_id",
                            "livemode",
                            "password_change",
                            "prior_reset_code_revocation",
                            "status",
                            "attempt_in_progress",
                            "claim_expires_at",
                            "email_delivery",
                            "started_at",
                            "updated_at",
                            "browser_handoff"
                          ],
                          "properties": {
                            "operation_id": {
                              "type": "string",
                              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                            },
                            "supersedes_operation_id": {
                              "type": "string",
                              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                            },
                            "team_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "user_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "password_change": {
                              "type": "string",
                              "enum": [
                                "not_verified"
                              ]
                            },
                            "prior_reset_code_revocation": {
                              "type": "string",
                              "enum": [
                                "not_performed"
                              ]
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "prepared",
                                "outcome_unknown",
                                "generation_unknown",
                                "generated_unsent",
                                "email_unknown",
                                "provider_accepted",
                                "canceled"
                              ]
                            },
                            "attempt_in_progress": {
                              "type": "boolean"
                            },
                            "claim_expires_at": {
                              "type": "integer",
                              "minimum": 0,
                              "nullable": true
                            },
                            "email_delivery": {
                              "type": "string",
                              "enum": [
                                "not_attempted",
                                "unknown",
                                "provider_accepted"
                              ]
                            },
                            "started_at": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "updated_at": {
                              "type": "integer",
                              "minimum": 0
                            },
                            "browser_handoff": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "url",
                                "effect",
                                "contains_reset_credential"
                              ],
                              "properties": {
                                "url": {
                                  "type": "string",
                                  "format": "uri"
                                },
                                "effect": {
                                  "type": "string",
                                  "enum": [
                                    "private_review_required"
                                  ]
                                },
                                "contains_reset_credential": {
                                  "type": "boolean",
                                  "enum": [
                                    false
                                  ]
                                }
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Refusal or unconfirmed outcome. Retain the UUID and read status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "error"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Users"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "operation_id",
                  "expected_livemode",
                  "confirm_reset_email",
                  "supersedes_operation_id"
                ],
                "properties": {
                  "operation_id": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                  },
                  "expected_livemode": {
                    "type": "boolean"
                  },
                  "confirm_reset_email": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  },
                  "supersedes_operation_id": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/users/{id}/password-reset-operations/{operationId}/execute": {
      "post": {
        "operationId": "executePasswordResetOperation",
        "summary": "Request the prepared reset email",
        "description": "Save a UUIDv4 before preparing. Current original credential, admin authority, target membership and exact team/mode are independently checked. Preparation sends no email. Execute consumes the confirmed intent before providers; no automatic retry. On an uncertain response read the same UUID. Recovery uses a different UUID and requires a current person in the private browser, never an agent challenge. The earlier code may remain valid and another email may arrive. Provider acceptance is neither delivery nor password change. Reset affects the global login even in test mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped receipt; contains no recipient, reset URL or reviewer proof.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "operation_id",
                        "team_id",
                        "user_id",
                        "livemode",
                        "password_change",
                        "status",
                        "attempt_in_progress",
                        "claim_expires_at",
                        "email_delivery",
                        "started_at",
                        "updated_at"
                      ],
                      "properties": {
                        "operation_id": {
                          "type": "string",
                          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                        },
                        "team_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "user_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "password_change": {
                          "type": "string",
                          "enum": [
                            "not_verified"
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "prepared",
                            "outcome_unknown",
                            "generation_unknown",
                            "generated_unsent",
                            "email_unknown",
                            "provider_accepted",
                            "canceled"
                          ]
                        },
                        "attempt_in_progress": {
                          "type": "boolean"
                        },
                        "claim_expires_at": {
                          "type": "integer",
                          "minimum": 0,
                          "nullable": true
                        },
                        "email_delivery": {
                          "type": "string",
                          "enum": [
                            "not_attempted",
                            "unknown",
                            "provider_accepted"
                          ]
                        },
                        "started_at": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "updated_at": {
                          "type": "integer",
                          "minimum": 0
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Refusal or unconfirmed outcome. Retain the UUID and read status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "error"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Users"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {}
              }
            }
          }
        }
      }
    },
    "/users/{id}/password-reset-operations/{operationId}": {
      "get": {
        "operationId": "getPasswordResetOperation",
        "summary": "Read saved reset email status",
        "description": "Save a UUIDv4 before preparing. Current original credential, admin authority, target membership and exact team/mode are independently checked. Preparation sends no email. Execute consumes the confirmed intent before providers; no automatic retry. On an uncertain response read the same UUID. Recovery uses a different UUID and requires a current person in the private browser, never an agent challenge. The earlier code may remain valid and another email may arrive. Provider acceptance is neither delivery nor password change. Reset affects the global login even in test mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped receipt; contains no recipient, reset URL or reviewer proof.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "operation_id",
                        "team_id",
                        "user_id",
                        "livemode",
                        "password_change",
                        "status",
                        "attempt_in_progress",
                        "claim_expires_at",
                        "email_delivery",
                        "started_at",
                        "updated_at"
                      ],
                      "properties": {
                        "operation_id": {
                          "type": "string",
                          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                        },
                        "team_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "user_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "password_change": {
                          "type": "string",
                          "enum": [
                            "not_verified"
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "prepared",
                            "outcome_unknown",
                            "generation_unknown",
                            "generated_unsent",
                            "email_unknown",
                            "provider_accepted",
                            "canceled"
                          ]
                        },
                        "attempt_in_progress": {
                          "type": "boolean"
                        },
                        "claim_expires_at": {
                          "type": "integer",
                          "minimum": 0,
                          "nullable": true
                        },
                        "email_delivery": {
                          "type": "string",
                          "enum": [
                            "not_attempted",
                            "unknown",
                            "provider_accepted"
                          ]
                        },
                        "started_at": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "updated_at": {
                          "type": "integer",
                          "minimum": 0
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Refusal or unconfirmed outcome. Retain the UUID and read status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "error"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Users"
        ]
      },
      "delete": {
        "operationId": "cancelPasswordResetOperation",
        "summary": "Cancel an untouched reset preparation",
        "description": "Save a UUIDv4 before preparing. Current original credential, admin authority, target membership and exact team/mode are independently checked. Preparation sends no email. Execute consumes the confirmed intent before providers; no automatic retry. On an uncertain response read the same UUID. Recovery uses a different UUID and requires a current person in the private browser, never an agent challenge. The earlier code may remain valid and another email may arrive. Provider acceptance is neither delivery nor password change. Reset affects the global login even in test mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped receipt; contains no recipient, reset URL or reviewer proof.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "operation_id",
                        "team_id",
                        "user_id",
                        "livemode",
                        "password_change",
                        "status",
                        "attempt_in_progress",
                        "claim_expires_at",
                        "email_delivery",
                        "started_at",
                        "updated_at"
                      ],
                      "properties": {
                        "operation_id": {
                          "type": "string",
                          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                        },
                        "team_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "user_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "password_change": {
                          "type": "string",
                          "enum": [
                            "not_verified"
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "prepared",
                            "outcome_unknown",
                            "generation_unknown",
                            "generated_unsent",
                            "email_unknown",
                            "provider_accepted",
                            "canceled"
                          ]
                        },
                        "attempt_in_progress": {
                          "type": "boolean"
                        },
                        "claim_expires_at": {
                          "type": "integer",
                          "minimum": 0,
                          "nullable": true
                        },
                        "email_delivery": {
                          "type": "string",
                          "enum": [
                            "not_attempted",
                            "unknown",
                            "provider_accepted"
                          ]
                        },
                        "started_at": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "updated_at": {
                          "type": "integer",
                          "minimum": 0
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Refusal or unconfirmed outcome. Retain the UUID and read status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "error"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Users"
        ]
      }
    },
    "/users/{id}/password-reset-operations": {
      "post": {
        "operationId": "preparePasswordResetOperation",
        "summary": "Prepare one reset email",
        "description": "Save a UUIDv4 before preparing. Current original credential, admin authority, target membership and exact team/mode are independently checked. Preparation sends no email. Execute consumes the confirmed intent before providers; no automatic retry. On an uncertain response read the same UUID. Recovery uses a different UUID and requires a current person in the private browser, never an agent challenge. The earlier code may remain valid and another email may arrive. Provider acceptance is neither delivery nor password change. Reset affects the global login even in test mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped receipt; contains no recipient, reset URL or reviewer proof.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "operation_id",
                        "team_id",
                        "user_id",
                        "livemode",
                        "password_change",
                        "status",
                        "attempt_in_progress",
                        "claim_expires_at",
                        "email_delivery",
                        "started_at",
                        "updated_at"
                      ],
                      "properties": {
                        "operation_id": {
                          "type": "string",
                          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                        },
                        "team_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "user_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "password_change": {
                          "type": "string",
                          "enum": [
                            "not_verified"
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "prepared",
                            "outcome_unknown",
                            "generation_unknown",
                            "generated_unsent",
                            "email_unknown",
                            "provider_accepted",
                            "canceled"
                          ]
                        },
                        "attempt_in_progress": {
                          "type": "boolean"
                        },
                        "claim_expires_at": {
                          "type": "integer",
                          "minimum": 0,
                          "nullable": true
                        },
                        "email_delivery": {
                          "type": "string",
                          "enum": [
                            "not_attempted",
                            "unknown",
                            "provider_accepted"
                          ]
                        },
                        "started_at": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "updated_at": {
                          "type": "integer",
                          "minimum": 0
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Refusal or unconfirmed outcome. Retain the UUID and read status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "error"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "error": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ],
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Users"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "operation_id",
                  "expected_livemode",
                  "confirm_reset_email"
                ],
                "properties": {
                  "operation_id": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
                  },
                  "expected_livemode": {
                    "type": "boolean"
                  },
                  "confirm_reset_email": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/teams/{id}/customer-portal-operations": {
      "post": {
        "operationId": "prepareCustomerPortalOperation",
        "tags": [
          "Teams"
        ],
        "summary": "Prepare a customer portal operation",
        "description": "Safe metadata only. Persist caller UUID before prepare; same immutable input can be reconciled with GET. Preparation emits no credential. Original verified grant and exact current target/mode authorize independently. Active access requires private reviewed revocation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "livemode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "boolean"
            },
            "description": "Assertion only; current verified credential and browser selected mode must independently agree."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "operation_id",
                  "livemode"
                ],
                "properties": {
                  "operation_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                  },
                  "livemode": {
                    "type": "boolean"
                  },
                  "replaces_operation_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                  },
                  "client_id": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 254
                  }
                },
                "oneOf": [
                  {
                    "required": [
                      "client_id"
                    ],
                    "not": {
                      "required": [
                        "email"
                      ]
                    }
                  },
                  {
                    "required": [
                      "email"
                    ],
                    "not": {
                      "required": [
                        "client_id"
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Confirmed operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PortalAccessOperation"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Current credential, personal provenance or target authority denied"
          },
          "409": {
            "description": "Frozen context changed, consumed proof or incompatible operation state"
          },
          "503": {
            "description": "Outcome unconfirmed. Read the existing UUID; never automatically repeat issuance."
          }
        }
      }
    },
    "/teams/{id}/customer-portal-operations/{operationId}": {
      "get": {
        "operationId": "getCustomerPortalOperation",
        "tags": [
          "Teams"
        ],
        "summary": "Get a customer portal operation",
        "description": "Safe metadata only. Persist caller UUID before prepare; same immutable input can be reconciled with GET. Preparation emits no credential. Original verified grant and exact current target/mode authorize independently. Active access requires private reviewed revocation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "livemode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "boolean"
            },
            "description": "Assertion only; current verified credential and browser selected mode must independently agree."
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmed operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PortalAccessOperation"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Current credential, personal provenance or target authority denied"
          },
          "409": {
            "description": "Frozen context changed, consumed proof or incompatible operation state"
          },
          "503": {
            "description": "Outcome unconfirmed. Read the existing UUID; never automatically repeat issuance."
          }
        }
      },
      "delete": {
        "operationId": "cancelCustomerPortalOperation",
        "tags": [
          "Teams"
        ],
        "summary": "Cancel a customer portal operation",
        "description": "Safe metadata only. Persist caller UUID before prepare; same immutable input can be reconciled with GET. Preparation emits no credential. Original verified grant and exact current target/mode authorize independently. Active access requires private reviewed revocation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "livemode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "boolean"
            },
            "description": "Assertion only; current verified credential and browser selected mode must independently agree."
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmed operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PortalAccessOperation"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Current credential, personal provenance or target authority denied"
          },
          "409": {
            "description": "Frozen context changed, consumed proof or incompatible operation state"
          },
          "503": {
            "description": "Outcome unconfirmed. Read the existing UUID; never automatically repeat issuance."
          }
        }
      }
    },
    "/teams/{id}/invoice-portal-operations": {
      "post": {
        "operationId": "prepareInvoicePortalOperation",
        "tags": [
          "Teams"
        ],
        "summary": "Prepare an invoice portal operation",
        "description": "Safe metadata only. Persist caller UUID before prepare; same immutable input can be reconciled with GET. Preparation emits no credential. Original verified grant and exact current target/mode authorize independently. Active access requires private reviewed revocation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "livemode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "boolean"
            },
            "description": "Assertion only; current verified credential and browser selected mode must independently agree."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "operation_id",
                  "livemode"
                ],
                "properties": {
                  "operation_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                  },
                  "livemode": {
                    "type": "boolean"
                  },
                  "replaces_operation_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                  },
                  "expiresIn": {
                    "type": "string",
                    "default": "1h",
                    "description": "Finite duration, maximum 24h"
                  },
                  "scopes": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "enum": [
                        "invoices:read"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Confirmed operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PortalAccessOperation"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Current credential, personal provenance or target authority denied"
          },
          "409": {
            "description": "Frozen context changed, consumed proof or incompatible operation state"
          },
          "503": {
            "description": "Outcome unconfirmed. Read the existing UUID; never automatically repeat issuance."
          }
        }
      }
    },
    "/teams/{id}/invoice-portal-operations/{operationId}": {
      "get": {
        "operationId": "getInvoicePortalOperation",
        "tags": [
          "Teams"
        ],
        "summary": "Get an invoice portal operation",
        "description": "Safe metadata only. Persist caller UUID before prepare; same immutable input can be reconciled with GET. Preparation emits no credential. Original verified grant and exact current target/mode authorize independently. Active access requires private reviewed revocation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "livemode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "boolean"
            },
            "description": "Assertion only; current verified credential and browser selected mode must independently agree."
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmed operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PortalAccessOperation"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Current credential, personal provenance or target authority denied"
          },
          "409": {
            "description": "Frozen context changed, consumed proof or incompatible operation state"
          },
          "503": {
            "description": "Outcome unconfirmed. Read the existing UUID; never automatically repeat issuance."
          }
        }
      },
      "delete": {
        "operationId": "cancelInvoicePortalOperation",
        "tags": [
          "Teams"
        ],
        "summary": "Cancel an invoice portal operation",
        "description": "Safe metadata only. Persist caller UUID before prepare; same immutable input can be reconciled with GET. Preparation emits no credential. Original verified grant and exact current target/mode authorize independently. Active access requires private reviewed revocation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "livemode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "boolean"
            },
            "description": "Assertion only; current verified credential and browser selected mode must independently agree."
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmed operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PortalAccessOperation"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Current credential, personal provenance or target authority denied"
          },
          "409": {
            "description": "Frozen context changed, consumed proof or incompatible operation state"
          },
          "503": {
            "description": "Outcome unconfirmed. Read the existing UUID; never automatically repeat issuance."
          }
        }
      }
    },
    "/teams/{id}/vendors": {
      "post": {
        "operationId": "createVendorV2",
        "tags": [
          "Teams"
        ],
        "summary": "Create vendor account",
        "description": "Creates an actual vendor with current master owner, owner-only membership, private capability/OTP and atomic account/profile/grants. Current editors may create unless supplierMode is false. Save UUID before sending; reconcile/retry identical input with same UUID. Returns safe metadata only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Safe vendor metadata or operation/capability status. Never returns raw onboarding URLs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "vendor_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "master_team_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "billing_account_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "owner_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "alias": {
                          "type": "string"
                        },
                        "legal_name": {
                          "type": "string"
                        },
                        "tax_id": {
                          "type": "string"
                        },
                        "is_vendor": {
                          "type": "boolean"
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "operation": {
                          "type": "object",
                          "properties": {
                            "operation_id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                            },
                            "vendor_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed"
                              ]
                            },
                            "replayed": {
                              "type": "boolean"
                            }
                          }
                        },
                        "browser_handoff": {
                          "type": "string",
                          "format": "uri",
                          "description": "Safe private browser handoff containing IDs only; no onboarding secret."
                        },
                        "capability_delivery": {
                          "type": "string",
                          "enum": [
                            "private_browser_only"
                          ]
                        },
                        "operation_id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "completed",
                            "not_found",
                            "active",
                            "expired",
                            "legacy_unmanaged"
                          ]
                        },
                        "permanent_noncompletion": {
                          "type": "boolean",
                          "enum": [
                            false
                          ]
                        },
                        "generation": {
                          "type": "integer",
                          "nullable": true
                        },
                        "expires_at": {
                          "type": "number",
                          "nullable": true
                        },
                        "created_by": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$",
                          "nullable": true
                        },
                        "purpose": {
                          "type": "string",
                          "enum": [
                            "public_csd_onboarding"
                          ]
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared"
                          ]
                        },
                        "legacy_sessions_may_remain": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid UUID or request"
          },
          "401": {
            "description": "Original credential missing, revoked or changed"
          },
          "403": {
            "description": "Current authority, mode, supplier plan or reviewed extra-admin approval required"
          },
          "409": {
            "description": "Grant drift, changed request UUID conflict or vendor superseded"
          },
          "503": {
            "description": "Outcome unknown; reconcile the same operation identifier before retrying"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "operation_id",
                  "alias"
                ],
                "properties": {
                  "operation_id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                  },
                  "alias": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 250
                  },
                  "legal_name": {
                    "type": "string",
                    "maxLength": 250
                  },
                  "tax_id": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "members": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9_-]{1,128}$"
                    },
                    "description": "Only the current master owner is permitted. Additional admins require reviewed add_admin approval before any effect."
                  },
                  "livemode": {
                    "type": "boolean",
                    "description": "Must match the original credential data mode."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/teams/{id}/vendors/operations/{operationId}": {
      "get": {
        "operationId": "getVendorCreationOperationV2",
        "tags": [
          "Teams"
        ],
        "summary": "Read vendor creation operation",
        "description": "Read safe receipt under current original actor/master authority. not_found is not permanent proof of noncompletion. No automatic new UUID or provider replay.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          },
          {
            "name": "expected_livemode",
            "in": "query",
            "description": "Optional mode binding for creation readback. Machine credentials remain bound to their issued mode.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe vendor metadata or operation/capability status. Never returns raw onboarding URLs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "vendor_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "master_team_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "billing_account_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "owner_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "alias": {
                          "type": "string"
                        },
                        "legal_name": {
                          "type": "string"
                        },
                        "tax_id": {
                          "type": "string"
                        },
                        "is_vendor": {
                          "type": "boolean"
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "operation": {
                          "type": "object",
                          "properties": {
                            "operation_id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                            },
                            "vendor_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed"
                              ]
                            },
                            "replayed": {
                              "type": "boolean"
                            }
                          }
                        },
                        "browser_handoff": {
                          "type": "string",
                          "format": "uri",
                          "description": "Safe private browser handoff containing IDs only; no onboarding secret."
                        },
                        "capability_delivery": {
                          "type": "string",
                          "enum": [
                            "private_browser_only"
                          ]
                        },
                        "operation_id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "completed",
                            "not_found",
                            "active",
                            "expired",
                            "legacy_unmanaged"
                          ]
                        },
                        "permanent_noncompletion": {
                          "type": "boolean",
                          "enum": [
                            false
                          ]
                        },
                        "generation": {
                          "type": "integer",
                          "nullable": true
                        },
                        "expires_at": {
                          "type": "number",
                          "nullable": true
                        },
                        "created_by": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$",
                          "nullable": true
                        },
                        "purpose": {
                          "type": "string",
                          "enum": [
                            "public_csd_onboarding"
                          ]
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared"
                          ]
                        },
                        "legacy_sessions_may_remain": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid UUID or request"
          },
          "401": {
            "description": "Original credential missing, revoked or changed"
          },
          "403": {
            "description": "Current authority, mode, supplier plan or reviewed extra-admin approval required"
          },
          "409": {
            "description": "Grant drift, changed request UUID conflict or vendor superseded"
          },
          "503": {
            "description": "Outcome unknown; reconcile the same operation identifier before retrying"
          }
        }
      }
    },
    "/teams/{id}/vendors/{vendorId}/onboarding-capability": {
      "get": {
        "operationId": "getVendorOnboardingCapabilityV2",
        "tags": [
          "Teams"
        ],
        "summary": "Read safe vendor capability status",
        "description": "Safe generation/status and private browser handoff only. Explicit browser review is required for reveal/rotation/sharing/secret entry. legacy_sessions_may_remain distinguishes historical unversioned sessions that rotation does not universally revoke.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "vendorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe vendor metadata or operation/capability status. Never returns raw onboarding URLs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "vendor_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "master_team_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "billing_account_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "owner_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "alias": {
                          "type": "string"
                        },
                        "legal_name": {
                          "type": "string"
                        },
                        "tax_id": {
                          "type": "string"
                        },
                        "is_vendor": {
                          "type": "boolean"
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "operation": {
                          "type": "object",
                          "properties": {
                            "operation_id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                            },
                            "vendor_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "completed"
                              ]
                            },
                            "replayed": {
                              "type": "boolean"
                            }
                          }
                        },
                        "browser_handoff": {
                          "type": "string",
                          "format": "uri",
                          "description": "Safe private browser handoff containing IDs only; no onboarding secret."
                        },
                        "capability_delivery": {
                          "type": "string",
                          "enum": [
                            "private_browser_only"
                          ]
                        },
                        "operation_id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "completed",
                            "not_found",
                            "active",
                            "expired",
                            "legacy_unmanaged"
                          ]
                        },
                        "permanent_noncompletion": {
                          "type": "boolean",
                          "enum": [
                            false
                          ]
                        },
                        "generation": {
                          "type": "integer",
                          "nullable": true
                        },
                        "expires_at": {
                          "type": "number",
                          "nullable": true
                        },
                        "created_by": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$",
                          "nullable": true
                        },
                        "purpose": {
                          "type": "string",
                          "enum": [
                            "public_csd_onboarding"
                          ]
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared"
                          ]
                        },
                        "legacy_sessions_may_remain": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid UUID or request"
          },
          "401": {
            "description": "Original credential missing, revoked or changed"
          },
          "403": {
            "description": "Current authority, mode, supplier plan or reviewed extra-admin approval required"
          },
          "409": {
            "description": "Grant drift, changed request UUID conflict or vendor superseded"
          },
          "503": {
            "description": "Outcome unknown; reconcile the same operation identifier before retrying"
          }
        }
      }
    },
    "/webhooks/configuration-operations/{operationId}": {
      "get": {
        "operationId": "getWebhookConfigurationOperation",
        "tags": [
          "Webhooks"
        ],
        "summary": "Read webhook configuration operation",
        "description": "Read the same operation after an uncertain response. Inspect operation.status: HTTP 200 does not mean installation completed. The data field is the current endpoint or null, including after later deletion. Keys are never replayed. Do not automatically submit a new operation or repeat secret entry.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe operation status and current endpoint, if it still exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookConfigurationResult"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "wh_example",
                    "url": "https://receiver.example/webhook",
                    "events": [
                      "payment.succeeded"
                    ],
                    "status": "inactive",
                    "owner": "user_example",
                    "created_at": 1709090576567,
                    "version": "v2",
                    "type": null,
                    "revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "effect_scope": "shared_team_webhooks",
                    "security": {
                      "header_names": [],
                      "configured": false,
                      "status": "not_configured"
                    },
                    "signing": {
                      "enabled": false,
                      "configured": false,
                      "status": "disabled"
                    }
                  },
                  "operation": {
                    "operation_id": "ae7388d2-79d2-4333-9eb8-33b1a1e21b58",
                    "team_id": "team_example",
                    "webhook_id": "wh_example",
                    "action": "create",
                    "status": "completed",
                    "created_at": 1709090576567,
                    "effect_scope": "shared_team_webhooks",
                    "secret_attempts": 0,
                    "error": null,
                    "credential_delivery": "not_replayed"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Current administrator authority or credential is no longer valid."
          },
          "404": {
            "description": "Operation does not exist in this team and credential scope."
          },
          "503": {
            "description": "Current credential or operation state could not be confirmed."
          }
        }
      }
    },
    "/webhooks/{id}/test": {
      "post": {
        "operationId": "testManualWebhook",
        "tags": [
          "Webhooks"
        ],
        "summary": "Send a test event",
        "description": "Requires a verified Firebase person or signed personal MCP credential with current team authority; ordinary team API keys are refused. The backend resolves the saved endpoint and resource. Confirm the selected team, current mode and effect before posting. Save operation_id before the request. HTTP 200 describes queue submission and delivery separately; it does not prove receipt. On timeout or unknown submission, read the same operation and do not automatically post again. Can test a saved inactive endpoint. Uses an existing authorized resource and the saved endpoint security configuration. It can make a real outbound request even in test data mode. See the Webhooks guide for recovery and payload semantics.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,200}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,200}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ManualWebhookTestInput"
              },
              "example": {
                "operation_id": "11111111-1111-4111-8111-111111111111",
                "expected_livemode": false,
                "confirmed": true,
                "event": "payment.created",
                "resource_id": "payment_example"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scoped operation receipt. Inspect submission and delivery separately.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ManualWebhookOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "operation_id": "11111111-1111-4111-8111-111111111111",
                    "action": "test",
                    "team_id": "team_example",
                    "livemode": false,
                    "endpoint_id": "wh_example",
                    "delivery_id": "manual-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "log_id": "manual-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "submission": "unknown",
                    "delivery": "pending",
                    "attempts": 0,
                    "duplicate_delivery_possible": true,
                    "payload_semantics": "current_resource",
                    "v2_state": "current_at_delivery"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid selection, operation UUID, mode assertion or confirmation."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current authority refused or changed."
          },
          "404": {
            "description": "Operation or resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode, resource, endpoint or operation changed; original snapshot may be unavailable."
          },
          "502": {
            "description": "Private service returned an invalid or mismatched receipt."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Submission result unknown. Read the same UUID and mode; never retry the POST automatically."
          }
        }
      }
    },
    "/webhooks/{id}/resend-current": {
      "post": {
        "operationId": "resendCurrentWebhook",
        "tags": [
          "Webhooks"
        ],
        "summary": "Send current resource state",
        "description": "Requires a verified Firebase person or signed personal MCP credential with current team authority; ordinary team API keys are refused. The backend resolves the saved endpoint and resource. Confirm the selected team, current mode and effect before posting. Save operation_id before the request. HTTP 200 describes queue submission and delivery separately; it does not prove receipt. On timeout or unknown submission, read the same operation and do not automatically post again. Explicitly sends the currently authorized resource, potentially creating duplicate delivery. An optional log_id supplies scoped context only; it never selects an old payload. See the Webhooks guide for recovery and payload semantics.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,200}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,200}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ManualWebhookResendCurrentInput"
              },
              "example": {
                "operation_id": "11111111-1111-4111-8111-111111111111",
                "expected_livemode": false,
                "confirmed": true,
                "event": "payment.created",
                "resource_id": "payment_example",
                "acknowledge_duplicate_delivery": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scoped operation receipt. Inspect submission and delivery separately.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ManualWebhookOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "operation_id": "11111111-1111-4111-8111-111111111111",
                    "action": "resend_current",
                    "team_id": "team_example",
                    "livemode": false,
                    "endpoint_id": "wh_example",
                    "delivery_id": "manual-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "log_id": "manual-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "submission": "unknown",
                    "delivery": "pending",
                    "attempts": 0,
                    "duplicate_delivery_possible": true,
                    "payload_semantics": "current_resource",
                    "v2_state": "current_at_delivery"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid selection, operation UUID, mode assertion or confirmation."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current authority refused or changed."
          },
          "404": {
            "description": "Operation or resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode, resource, endpoint or operation changed; original snapshot may be unavailable."
          },
          "502": {
            "description": "Private service returned an invalid or mismatched receipt."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Submission result unknown. Read the same UUID and mode; never retry the POST automatically."
          }
        }
      }
    },
    "/teams/{id}/webhook-deliveries/{logId}/retry": {
      "post": {
        "operationId": "retryWebhookDelivery",
        "tags": [
          "Webhooks"
        ],
        "summary": "Retry a stored webhook event",
        "description": "Requires a verified Firebase person or signed personal MCP credential with current team authority; ordinary team API keys are refused. The backend resolves the saved endpoint and resource. Confirm the selected team, current mode and effect before posting. Save operation_id before the request. HTTP 200 describes queue submission and delivery separately; it does not prove receipt. On timeout or unknown submission, read the same operation and do not automatically post again. Uses a retained authenticated event snapshot, not arbitrary client payload. Missing legacy, oversized or deleted snapshots return 409. v2 resource fields are refreshed at delivery, so this is not an exact replay of historical receiver bytes. See the Webhooks guide for recovery and payload semantics.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,200}$"
            }
          },
          {
            "name": "logId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,200}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ManualWebhookRetryInput"
              },
              "example": {
                "operation_id": "11111111-1111-4111-8111-111111111111",
                "expected_livemode": false,
                "confirmed": true,
                "acknowledge_duplicate_delivery": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scoped operation receipt. Inspect submission and delivery separately.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ManualWebhookOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "operation_id": "11111111-1111-4111-8111-111111111111",
                    "action": "retry",
                    "team_id": "team_example",
                    "livemode": false,
                    "endpoint_id": "wh_example",
                    "delivery_id": "manual-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "log_id": "manual-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "submission": "unknown",
                    "delivery": "pending",
                    "attempts": 0,
                    "duplicate_delivery_possible": true,
                    "payload_semantics": "stored_event_snapshot",
                    "v2_state": "current_at_delivery"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid selection, operation UUID, mode assertion or confirmation."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current authority refused or changed."
          },
          "404": {
            "description": "Operation or resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode, resource, endpoint or operation changed; original snapshot may be unavailable."
          },
          "502": {
            "description": "Private service returned an invalid or mismatched receipt."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Submission result unknown. Read the same UUID and mode; never retry the POST automatically."
          }
        }
      }
    },
    "/teams/{id}/webhook-operations/{operationId}": {
      "get": {
        "operationId": "getManualWebhookOperation",
        "tags": [
          "Webhooks"
        ],
        "summary": "Read a webhook operation",
        "description": "Requires a verified Firebase person or signed personal MCP credential with current team authority; ordinary team API keys are refused. The backend resolves the saved endpoint and resource. Read-only recovery: preserve the original operation UUID and mode, including after switching the account mode. No delivery is submitted. See the Webhooks guide for recovery and payload semantics.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,200}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
          },
          {
            "name": "expected_livemode",
            "in": "query",
            "required": true,
            "schema": {
              "type": "boolean"
            },
            "description": "Frozen mode of the original operation. This does not change the current account mode."
          }
        ],
        "responses": {
          "200": {
            "description": "Scoped operation receipt. Inspect submission and delivery separately.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ManualWebhookOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "operation_id": "11111111-1111-4111-8111-111111111111",
                    "action": "test",
                    "team_id": "team_example",
                    "livemode": false,
                    "endpoint_id": "wh_example",
                    "delivery_id": "manual-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "log_id": "manual-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "submission": "unknown",
                    "delivery": "pending",
                    "attempts": 0,
                    "duplicate_delivery_possible": true,
                    "payload_semantics": "current_resource",
                    "v2_state": "current_at_delivery"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid selection, operation UUID, mode assertion or confirmation."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current authority refused or changed."
          },
          "404": {
            "description": "Operation or resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode, resource, endpoint or operation changed; original snapshot may be unavailable."
          },
          "502": {
            "description": "Private service returned an invalid or mismatched receipt."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Submission result unknown. Read the same UUID and mode; never retry the POST automatically."
          }
        }
      }
    },
    "/clients": {
      "get": {
        "operationId": "listClients",
        "tags": [
          "Clients"
        ],
        "summary": "List clients",
        "description": "Retrieve a paginated list of clients with powerful filtering capabilities.\n\n**gigstack Connect:** Access other teams' clients using the `team` parameter.\n\n**Filtering Options:**\n- Filter by creation date using comparison operators\n- Filter by metadata fields using dot or underscore notation (e.g., `metadata.external_id` or `metadata_external_id`)\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGtParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLtParam"
          },
          {
            "$ref": "#/components/parameters/TaxIdFilterParam"
          },
          {
            "name": "metadata.{key}",
            "in": "query",
            "description": "Filter by any metadata field using dot notation (e.g., `metadata.external_id=EXT-123`)\nor underscore notation (e.g., `metadata_external_id=EXT-123`).\nBoth formats are supported and equivalent.\nUses Typesense search for efficient querying without requiring Firestore indexes.\n",
            "required": false,
            "schema": {
              "type": "string"
            },
            "style": "form"
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number for pagination when using metadata filters (default 1).\nOnly applies when filtering by metadata fields.\n",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Clients retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Clients retrieved successfully"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiPublicClient"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "example": false
                    },
                    "total_results": {
                      "type": "integer",
                      "example": 25
                    },
                    "next": {
                      "type": "string",
                      "nullable": true,
                      "example": "eyJjcmVhdGVkX2F0IjoxNjc3NjUxMjM0fQ=="
                    }
                  }
                },
                "example": {
                  "message": "Clients retrieved successfully",
                  "data": [
                    {
                      "id": "client_1234567890",
                      "name": "Juan Pérez García",
                      "email": "juan.perez@ejemplo.com",
                      "tax_id": "PEGJ800101ABC",
                      "tax_system": "601",
                      "legal_name": "Juan Pérez García",
                      "address": {
                        "street": "Av. Insurgentes Sur 123",
                        "zip": "03100",
                        "city": "Ciudad de México",
                        "state": "CDMX",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "livemode": true,
                      "created_at": 1677651234,
                      "team": "team_1234567890",
                      "owner": "user_1234567890",
                      "from": "api"
                    }
                  ],
                  "has_more": false,
                  "total_results": 1
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createClients",
        "tags": [
          "Clients"
        ],
        "summary": "Create client",
        "description": "[Small working example](/recipes/customer)\n\n**Integration note:** Creating a contact does not establish fiscal validity. Inspect fiscal_validation when returned; contact-only input can produce status skipped. A matching search with update false returns the existing customer with HTTP 200; a new record returns 201. Read [shared fields](/concepts/shared-fields) and the [Mexico](/countries/mexico) or [Colombia](/countries/colombia) guide for country-specific meaning. The linked fiscal recipes and staging issuance results use a Mexican issuer.\n\nCreate a new client with fiscal information for Mexican tax compliance.\n\n**Duplicate Prevention (Upsert):** Use the `search` parameter to find existing clients before creating:\n- If a match is found and `search.update` is `false` (default): Returns the existing client without modifications.\n- If a match is found and `search.update` is `true`: Updates the existing client with the provided data and returns it.\n- If no match is found: Creates a new client.\n\nThis is useful for integrations that may send the same client multiple times.\n\n**gigstack Connect:** Create clients for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientInput"
              },
              "example": {
                "name": "Juan Pérez García",
                "email": "juan.perez@ejemplo.com",
                "company": "Empresa SA de CV",
                "phone": "+52 55 1234 5678",
                "legal_name": "Juan Pérez García",
                "tax_id": "PEGJ800101ABC",
                "use": "G03",
                "tax_system": "601",
                "address": {
                  "country": "MEX",
                  "street": "Av. Insurgentes Sur",
                  "zip": "03100",
                  "city": "Ciudad de México",
                  "state": "CDMX",
                  "exterior": "123",
                  "interior": "4B",
                  "municipality": "Benito Juárez",
                  "neighborhood": "Del Valle"
                },
                "bcc": [
                  "admin@empresa.com"
                ],
                "metadata": {
                  "custom_field": "value",
                  "department": "sales"
                },
                "defaults": {
                  "keep_full_legal_name": false,
                  "issue_automatic_invoices": false,
                  "issue_invoiceable_receipts": true
                },
                "search": {
                  "on_key": "tax_id",
                  "on_value": "PEGJ800101ABC",
                  "update": false
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Existing client found (when using `search` parameter)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Existing client found"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicClient"
                    }
                  }
                },
                "examples": {
                  "existingClient": {
                    "summary": "Existing client found",
                    "value": {
                      "message": "Existing client found",
                      "data": {
                        "id": "client_1234567890",
                        "name": "Juan Pérez García",
                        "email": "juan.perez@ejemplo.com",
                        "tax_id": "PEGJ800101ABC",
                        "tax_system": "601",
                        "legal_name": "Juan Pérez García",
                        "address": {
                          "street": "Av. Insurgentes Sur 123",
                          "zip": "03100",
                          "city": "Ciudad de México",
                          "state": "CDMX",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "livemode": true,
                        "created_at": 1677651234,
                        "team": "team_1234567890",
                        "owner": "user_1234567890",
                        "from": "api"
                      }
                    }
                  },
                  "existingClientUpdated": {
                    "summary": "Existing client found and updated",
                    "value": {
                      "message": "Existing client found and updated",
                      "data": {
                        "id": "client_1234567890",
                        "name": "Juan Pérez García",
                        "email": "juan.perez@ejemplo.com",
                        "tax_id": "PEGJ800101ABC",
                        "tax_system": "601",
                        "legal_name": "Juan Pérez García",
                        "address": {
                          "street": "Av. Insurgentes Sur 123",
                          "zip": "03100",
                          "city": "Ciudad de México",
                          "state": "CDMX",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "livemode": true,
                        "created_at": 1677651234,
                        "team": "team_1234567890",
                        "owner": "user_1234567890",
                        "from": "api"
                      }
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Client created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Client created successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicClient"
                    }
                  }
                },
                "example": {
                  "message": "Client created successfully",
                  "data": {
                    "id": "client_1234567890",
                    "name": "Juan Pérez García",
                    "email": "juan.perez@ejemplo.com",
                    "tax_id": "PEGJ800101ABC",
                    "tax_system": "601",
                    "legal_name": "Juan Pérez García",
                    "address": {
                      "street": "Av. Insurgentes Sur 123",
                      "zip": "03100",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "country": "MEX"
                    },
                    "is_valid": true,
                    "livemode": true,
                    "created_at": 1677651234,
                    "team": "team_1234567890",
                    "owner": "user_1234567890",
                    "from": "api",
                    "efos": {
                      "is_valid": true
                    },
                    "fiscal_validation": {
                      "status": "valid"
                    },
                    "sat_status": {
                      "is_risky": false,
                      "efos": {
                        "is_valid": true
                      },
                      "hits": [],
                      "checked_at": 1776887458784
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - Multiple clients match the search criteria",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "resource_conflict"
                        },
                        "message": {
                          "type": "string",
                          "example": "Multiple clients found matching tax_id=\"PEGJ800101ABC\". Please use a more specific search criteria."
                        },
                        "details": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "List of matching client IDs",
                          "example": [
                            "client_1234567890",
                            "client_0987654321"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/clients/{id}": {
      "get": {
        "operationId": "getClientsById",
        "tags": [
          "Clients"
        ],
        "summary": "Get client",
        "description": "Retrieve a specific client by ID.\n\n**gigstack Connect:** Access other teams' clients using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "client_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Client retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Client retrieved successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicClient"
                    }
                  }
                },
                "example": {
                  "message": "Client retrieved successfully",
                  "data": {
                    "id": "client_1234567890",
                    "name": "Juan Pérez García",
                    "email": "juan.perez@ejemplo.com",
                    "tax_id": "PEGJ800101ABC",
                    "tax_system": "601",
                    "legal_name": "Juan Pérez García",
                    "address": {
                      "street": "Av. Insurgentes Sur 123",
                      "zip": "03100",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "country": "MEX"
                    },
                    "is_valid": true,
                    "livemode": true,
                    "created_at": 1677651234,
                    "team": "team_1234567890",
                    "owner": "user_1234567890",
                    "from": "api"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "operationId": "updateClientsById",
        "tags": [
          "Clients"
        ],
        "summary": "Update client",
        "description": "[Small working example](/guides/api-credentials)\n\n**Integration note:** Client mutation operations are not grantable to new scoped keys because mounted downstream Stripe/fiscal effects lack scope proof coverage. Existing legacy/personal behavior is unchanged. Consult the scoped policy catalog for exact business reads and service CRUD permissions.\n\n**Partial update:** send only the fields you want to change; omitted fields keep their current values.\nA partial `address` changes only the leaves sent, and an explicit empty `bcc: []` clears the list. Null\nand empty strings are ignored.\n\nUpdate an existing client.\n\n**Pending receipts:** By default, after a successful update, if the client passes fiscal validation, all of the client's pending receipts are automatically invoiced using the new client data. Set `check_pending_receipts: false` in the body to skip this behavior. When the check runs, the response includes a `pending_receipts` summary.\n\n**gigstack Connect:** Update other teams' clients using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "client_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientUpdateInput"
              },
              "example": {
                "name": "Juan Pérez García",
                "email": "juan.perez.updated@ejemplo.com",
                "company": "Empresa SA de CV - Sucursal Norte",
                "phone": "+52 55 1234 5678",
                "legal_name": "Juan Pérez García",
                "tax_id": "PEGJ800101ABC",
                "use": "G03",
                "tax_system": "601",
                "address": {
                  "country": "MEX",
                  "street": "Av. Insurgentes Sur",
                  "zip": "03100",
                  "city": "Ciudad de México",
                  "state": "CDMX",
                  "exterior": "123",
                  "interior": "4B",
                  "municipality": "Benito Juárez",
                  "neighborhood": "Del Valle"
                },
                "bcc": [
                  "admin@empresa.com",
                  "contabilidad@empresa.com"
                ],
                "metadata": {
                  "updated_reason": "Address change",
                  "priority_client": true
                },
                "defaults": {
                  "keep_full_legal_name": true,
                  "issue_automatic_invoices": true,
                  "issue_invoiceable_receipts": true
                },
                "check_pending_receipts": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Client updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Client updated successfully"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ApiPublicClient"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "pending_receipts": {
                              "$ref": "#/components/schemas/PendingReceiptsSummary"
                            }
                          }
                        }
                      ]
                    }
                  }
                },
                "example": {
                  "message": "Client updated successfully",
                  "data": {
                    "id": "client_1234567890",
                    "name": "Juan Pérez García",
                    "email": "juan.perez@ejemplo.com",
                    "tax_id": "PEGJ800101ABC",
                    "tax_system": "601",
                    "legal_name": "Juan Pérez García",
                    "address": {
                      "street": "Av. Insurgentes Sur 123",
                      "zip": "03100",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "country": "MEX"
                    },
                    "is_valid": true,
                    "livemode": true,
                    "created_at": 1677651234,
                    "team": "team_1234567890",
                    "owner": "user_1234567890",
                    "pending_receipts": {
                      "attempted": 2,
                      "succeeded": 2,
                      "failed": 0,
                      "skipped": 0,
                      "failures": []
                    },
                    "from": "api"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "deleteClientsById",
        "tags": [
          "Clients"
        ],
        "summary": "Delete client",
        "description": "Delete a specific client.\n\n**gigstack Connect:** Delete other teams' clients using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "client_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Client deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "deleted": true
                  },
                  "message": "Client deleted successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/clients/search": {
      "get": {
        "operationId": "getClientsSearch",
        "tags": [
          "Clients"
        ],
        "summary": "Search clients",
        "description": "Full-text search across clients using Typesense. Provides fast, typo-tolerant search capabilities.\n\n**gigstack Connect:** Access other teams' clients using the `team` parameter.\n\n**Search Capabilities:**\n- Search across client name, email, tax ID, legal name, and metadata\n- Typo-tolerant fuzzy matching\n- Paginated results\n\n**Requirements:**\n- Typesense must be configured for your team\n- The `q` (or `query`) parameter is required\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/SearchQueryParam"
          },
          {
            "$ref": "#/components/parameters/SearchQueryBackwardCompatParam"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/SearchPageParam"
          },
          {
            "$ref": "#/components/parameters/ClientsSearchFieldsParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Clients searched successfully",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SearchResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "message": "Clients searched successfully",
                  "data": [
                    {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    }
                  ],
                  "found": 1,
                  "page": 1,
                  "per_page": 10,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "missing_query": {
                    "summary": "Missing query parameter",
                    "value": {
                      "error": {
                        "code": "missing_query",
                        "message": "Query parameter is required"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "missing_typesense_key": {
                    "summary": "Typesense not configured",
                    "value": {
                      "error": {
                        "code": "missing_typesense_key",
                        "message": "Typesense API key not configured for this team"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_fields": {
                    "summary": "A field that cannot be searched",
                    "value": {
                      "error": {
                        "code": "invalid_fields",
                        "message": "Cannot search in id. `fields` sets the fields to search in; for clients use any of: name, ..., or metadata.<key>"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_search": {
                    "summary": "Requested fields this team's index does not have",
                    "value": {
                      "error": {
                        "code": "invalid_search",
                        "message": "The search request was rejected. Check that the `fields` exist for this team."
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/clients/validate/{id}": {
      "post": {
        "operationId": "createClientsValidateById",
        "deprecated": true,
        "tags": [
          "Clients"
        ],
        "summary": "Validate client fiscal information (deprecated path)",
        "description": "**Deprecated:** use [`POST /clients/{id}/validate`](/reference/validateClientById), which runs the same handler. The client ID now comes first, like every other `/clients/{id}/…` action.\nThis route keeps working; its responses carry `Deprecation: true` and `Link: </v2/clients/{id}/validate>; rel=\"successor-version\"`, with the\nconcrete ID in place of each path parameter.\n\nRe-runs the full SAT validation for a client on demand. Performs three independent checks in parallel\nand persists the results on the client doc (`is_valid`, `efos`, `sat_status`):\n\n1. **Fiscal validation** — attempts to stamp a test CFDI against the PAC. Detects RFC/legal_name/CP mismatches with SAT registry.\n2. **EFOS check** — Art. 69-B blacklist lookup.\n3. **SAT lists** — fan-out lookup across 20 Datos Abiertos lists (Art. 69 Cancelados/Firmes/No localizados/CSD sin efectos/..., Art. 69-B Definitivos/Presuntos/..., Art. 69-B Bis). Lists are refreshed weekly from `sat.gob.mx`.\n\n**gigstack Connect:** Validate other teams' clients using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "client_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Client validated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Client info validated successfully"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "fiscal_validation": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "valid",
                                "not_valid",
                                "skipped"
                              ]
                            },
                            "message": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        },
                        "efos": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "is_valid": {
                              "type": "boolean",
                              "nullable": true
                            }
                          }
                        },
                        "sat_status": {
                          "type": "object",
                          "nullable": true,
                          "description": "See `sat_status` on `ApiPublicClient` for full shape."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Client info validated successfully",
                  "data": {
                    "fiscal_validation": {
                      "status": "not_valid",
                      "message": "Fiscal info validation failed. El campo DomicilioFiscalReceptor del receptor..."
                    },
                    "efos": {
                      "is_valid": false
                    },
                    "sat_status": {
                      "is_risky": true,
                      "efos": {
                        "is_valid": false
                      },
                      "hits": [
                        {
                          "list": "art_69b_definitivos",
                          "label": "Definitivos 69-B",
                          "source": "art_69b",
                          "is_risky": true,
                          "detail": {
                            "nombre_del_contribuyente": "ASESORES Y ADMINISTRADORES AGRICOLAS, S. DE R.L. DE C.V.",
                            "situacion_del_contribuyente": "Definitivo",
                            "publicacion_dof_definitivos": "28/06/2018"
                          }
                        }
                      ],
                      "checked_at": 1776887458784
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/clients/{id}/validate": {
      "post": {
        "operationId": "validateClientById",
        "tags": [
          "Clients"
        ],
        "summary": "Validate client fiscal information",
        "description": "Re-runs the full SAT validation for a client on demand. Performs three independent checks in parallel\nand persists the results on the client doc (`is_valid`, `efos`, `sat_status`):\n\n1. **Fiscal validation** — attempts to stamp a test CFDI against the PAC. Detects RFC/legal_name/CP mismatches with SAT registry.\n2. **EFOS check** — Art. 69-B blacklist lookup.\n3. **SAT lists** — fan-out lookup across 20 Datos Abiertos lists (Art. 69 Cancelados/Firmes/No localizados/CSD sin efectos/..., Art. 69-B Definitivos/Presuntos/..., Art. 69-B Bis). Lists are refreshed weekly from `sat.gob.mx`.\n\n**gigstack Connect:** Validate other teams' clients using the `team` parameter.\n\nReplaces the deprecated [`POST /clients/validate/{id}`](/reference/createClientsValidateById), which runs the same handler. The client ID now comes first, like every other `/clients/{id}/…` action.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "client_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Client validated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Client info validated successfully"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "fiscal_validation": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "valid",
                                "not_valid",
                                "skipped"
                              ]
                            },
                            "message": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        },
                        "efos": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "is_valid": {
                              "type": "boolean",
                              "nullable": true
                            }
                          }
                        },
                        "sat_status": {
                          "type": "object",
                          "nullable": true,
                          "description": "See `sat_status` on `ApiPublicClient` for full shape."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Client info validated successfully",
                  "data": {
                    "fiscal_validation": {
                      "status": "not_valid",
                      "message": "Fiscal info validation failed. El campo DomicilioFiscalReceptor del receptor..."
                    },
                    "efos": {
                      "is_valid": false
                    },
                    "sat_status": {
                      "is_risky": true,
                      "efos": {
                        "is_valid": false
                      },
                      "hits": [
                        {
                          "list": "art_69b_definitivos",
                          "label": "Definitivos 69-B",
                          "source": "art_69b",
                          "is_risky": true,
                          "detail": {
                            "nombre_del_contribuyente": "ASESORES Y ADMINISTRADORES AGRICOLAS, S. DE R.L. DE C.V.",
                            "situacion_del_contribuyente": "Definitivo",
                            "publicacion_dof_definitivos": "28/06/2018"
                          }
                        }
                      ],
                      "checked_at": 1776887458784
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/clients/customerportal": {
      "post": {
        "operationId": "createClientsCustomerportal",
        "tags": [
          "Clients"
        ],
        "summary": "Get client customer portal access token",
        "description": "Deprecated, kept for one release as a compatibility window (backend PR 490). Personal sessions and unscoped API keys still receive one; scoped API keys get 410. Prepare /v2/teams/{id}/customer-portal-operations with a persisted UUID and explicit mode; review and issue only in the private personal browser. Safe metadata never replays a bearer.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Issued (compatibility window; personal sessions and unscoped API keys only)"
          },
          "410": {
            "description": "private_portal_review_required"
          }
        },
        "deprecated": true
      }
    },
    "/clients/csf": {
      "post": {
        "operationId": "createClientsCsf",
        "tags": [
          "Clients"
        ],
        "summary": "Upload CSF PDF to create or update client",
        "description": "Upload a CSF (Constancia de Situación Fiscal) PDF file from SAT to automatically extract fiscal information and create a new client or update an existing one.\n\n**How it works:**\n1. Upload the CSF PDF file as `multipart/form-data`\n2. The system extracts RFC and CIF from the PDF\n3. Validates the fiscal information against SAT\n4. Creates a new client or updates an existing one with the fiscal data\n\nExisting clients are shared team catalogue records. Updating by client_id affects the client reused by live and sandbox workflows and preserves its stored mode. New clients use the credential mode. Tenant ownership is checked before PDF/SAT processing and transactionally before saving.\n\n**Query Parameters:**\n- `client_id` (optional): If provided, updates the existing client. If omitted, creates a new client.\n\n**Extracted Information:**\n- Legal name (Razón Social)\n- RFC (Tax ID)\n- Fiscal regime (Régimen Fiscal)\n- Fiscal type (company/individual)\n- Fiscal status\n- Complete address (street, exterior/interior number, neighborhood, city, state, zip code)\n\n**gigstack Connect:** Create or update clients for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "client_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional client ID to update. If not provided, creates a new client."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "CSF PDF file from SAT"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Existing client (`client_id`) updated with the CSF data. Standardized envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicClient"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "client_1234567890",
                    "name": "ESCUELA KEMPER URGATE",
                    "legal_name": "ESCUELA KEMPER URGATE",
                    "email": "contabilidad@ejemplo.com",
                    "bcc": [],
                    "phone": "+524421234567",
                    "tax_id": "EKU9003173C9",
                    "tax_system": "601",
                    "use": "G03",
                    "address": {
                      "street": "Av. Constituyentes",
                      "exterior": "1000",
                      "neighborhood": "Centro",
                      "city": "Querétaro",
                      "state": "QRO",
                      "zip": "76000",
                      "country": "MEX"
                    },
                    "is_valid": false,
                    "efos": {
                      "is_valid": true
                    },
                    "metadata": {
                      "rfc": "EKU9003173C9",
                      "fiscal_type": "company",
                      "fiscal_status": "Activo"
                    },
                    "livemode": true,
                    "from": "api",
                    "owner": "user_1234567890",
                    "team": "team_1234567890",
                    "created_at": 1767225600000
                  },
                  "message": "Client updated with CSF data",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "201": {
            "description": "Client created from the CSF. Standardized envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicClient"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "client_1234567890",
                    "name": "ESCUELA KEMPER URGATE",
                    "legal_name": "ESCUELA KEMPER URGATE",
                    "email": "contabilidad@ejemplo.com",
                    "bcc": [],
                    "phone": "+524421234567",
                    "tax_id": "EKU9003173C9",
                    "tax_system": "601",
                    "use": "G03",
                    "address": {
                      "street": "Av. Constituyentes",
                      "exterior": "1000",
                      "neighborhood": "Centro",
                      "city": "Querétaro",
                      "state": "QRO",
                      "zip": "76000",
                      "country": "MEX"
                    },
                    "is_valid": false,
                    "efos": {
                      "is_valid": true
                    },
                    "metadata": {
                      "rfc": "EKU9003173C9",
                      "fiscal_type": "company",
                      "fiscal_status": "Activo"
                    },
                    "livemode": true,
                    "from": "api",
                    "owner": "user_1234567890",
                    "team": "team_1234567890",
                    "created_at": 1767225600000
                  },
                  "message": "Client created from CSF",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Invalid file, missing fiscal data, or malformed client_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "no_file": {
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Error processing CSF upload"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_pdf": {
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Error processing CSF upload"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "missing_data": {
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Error processing CSF upload"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Client not found or outside the selected team; identical response for both cases.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "resource_not_found",
                    "message": "Client not found"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/clients/{id}/stamp-pending-receipts": {
      "post": {
        "tags": [
          "Clients"
        ],
        "summary": "Stamp pending receipts",
        "operationId": "stampClientPendingReceipts",
        "description": "Stamp the client's pending receipts into CFDI invoices.\n\n**Batch cap:** at most **100** receipts are stamped per call. Receipts are processed\nfive at a time. If the client has more than 100 pending receipts, call the endpoint\nrepeatedly until `data.remaining` reaches `0`.\n\n`data.remaining` is re-counted from Firestore *after* stamping, so it includes both\nreceipts beyond the 100-item cap and receipts that failed in this run (they stay\n`pending`).\n\n**Fiscal prerequisites.** Before stamping anything the handler checks that the client\nhas an RFC (`rfc`, falling back to `tax_id`), a legal name (`legal_name`, falling back\nto `name`), `address.zip`, and `tax_system`. If any is missing it returns `400` with\n`error.code: client_fiscal_data_incomplete` and stamps nothing. `email` and\n`address.country` are not checked (`country` defaults to `MEX`).\n\n**gigstack Connect:** Stamp other teams' client receipts using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Client id.",
            "schema": {
              "type": "string"
            },
            "example": "client_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Batch processed. A `200` does **not** mean every receipt was stamped — inspect\n`data.failed` and `data.results`. When the client has no pending receipts the\nresponse is still `200`, with all counters at `0` and the message\n`No pending receipts found`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "description": "`Stamped N receipt(s)`, `Stamped N receipt(s), M failed`, or `No pending receipts found`.",
                          "example": "Stamped 2 receipt(s), 1 failed"
                        },
                        "data": {
                          "type": "object",
                          "required": [
                            "stamped",
                            "failed",
                            "remaining",
                            "results"
                          ],
                          "properties": {
                            "stamped": {
                              "type": "integer",
                              "description": "Receipts successfully stamped in this call.",
                              "example": 2
                            },
                            "failed": {
                              "type": "integer",
                              "description": "Receipts that failed to stamp in this call.",
                              "example": 1
                            },
                            "remaining": {
                              "type": "integer",
                              "description": "Receipts still `pending` for this client after the call.",
                              "example": 0
                            },
                            "results": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "required": [
                                  "id",
                                  "status"
                                ],
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "example": "receipt_1234567890"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "stamped",
                                      "failed"
                                    ],
                                    "example": "stamped"
                                  },
                                  "error": {
                                    "type": "string",
                                    "description": "Present only when `status` is `failed`.",
                                    "example": "CFDI40147 - El campo UsoCFDI no es válido"
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "message": "Stamped 2 receipt(s), 1 failed",
                  "timestamp": 1767225600000,
                  "data": {
                    "stamped": 2,
                    "failed": 1,
                    "remaining": 0,
                    "results": [
                      {
                        "id": "receipt_1234567890",
                        "status": "stamped"
                      },
                      {
                        "id": "receipt_2345678901",
                        "status": "stamped"
                      },
                      {
                        "id": "receipt_3456789012",
                        "status": "failed",
                        "error": "CFDI40147 - El campo UsoCFDI no es válido"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "The client is missing fiscal information required to stamp. Nothing is stamped.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "client_fiscal_data_incomplete",
                    "message": "Client is missing fiscal information required to stamp",
                    "details": "Missing field(s): rfc, tax_system"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Client not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      }
    },
    "/clients/{id}/support-documents": {
      "post": {
        "operationId": "createClientsByIdSupportDocuments",
        "tags": [
          "Clients"
        ],
        "summary": "Upload a client support document",
        "description": "Upload a supporting document (contract, proof of delivery, etc.) for a client.\n\n**SAT 2026 Compliance:** Documents uploaded to a client are automatically inherited by all\nof the client's invoices and payments, simplifying compliance management.\n\n**gigstack Connect:** Upload documents for other teams' clients using the `team` parameter.\n\n**Supported File Types:**\n- PDF files (.pdf)\n- Images (.png, .jpg, .jpeg, .webp)\n\n**File Size Limit:** 10MB\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Client ID",
            "example": "client_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/UploadSupportDocumentInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Document uploaded. Standardized envelope (`timestamp` in epoch ms).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/SATDocument"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "doc_1234567890",
                    "document_type": "contract",
                    "name": "Contrato de servicios 2026",
                    "description": null,
                    "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_1234567890%2Fdocuments%2Fcontrato-2026.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                    "file_name": "contrato-2026.pdf",
                    "file_size": 284913,
                    "mime_type": "application/pdf",
                    "compliance_status": "pending_review",
                    "created_at": 1767225600000,
                    "linked_entities": [
                      {
                        "entity_type": "client",
                        "entity_id": "client_1234567890",
                        "linked_at": 1767225600000
                      }
                    ]
                  },
                  "message": "Support document uploaded successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Client not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "getClientsByIdSupportDocuments",
        "tags": [
          "Clients"
        ],
        "summary": "List a client's support documents",
        "description": "Retrieve all supporting documents attached to a client.\n\n**gigstack Connect:** View documents for other teams' clients using the `team` parameter.\n\nDocuments are returned sorted by creation date (newest first).\n\n**Note:** Client documents are automatically inherited by all the client's invoices and payments.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Client ID",
            "example": "client_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Documents retrieved, newest first. Standardized envelope (`timestamp` in epoch ms).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SATDocument"
                      }
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": [
                    {
                      "id": "doc_1234567890",
                      "document_type": "contract",
                      "name": "Contrato de servicios 2026",
                      "description": null,
                      "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_1234567890%2Fdocuments%2Fcontrato-2026.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                      "file_name": "contrato-2026.pdf",
                      "file_size": 284913,
                      "mime_type": "application/pdf",
                      "compliance_status": "pending_review",
                      "created_at": 1767225600000,
                      "linked_entities": [
                        {
                          "entity_type": "client",
                          "entity_id": "client_1234567890",
                          "linked_at": 1767225600000
                        }
                      ]
                    }
                  ],
                  "message": "Support documents retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Client not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      }
    },
    "/services": {
      "get": {
        "operationId": "listServices",
        "tags": [
          "Services"
        ],
        "summary": "List services",
        "description": "Retrieve a paginated list of services.\n\n**gigstack Connect:** Access other teams' services using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGtParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLtParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Services retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Services retrieved successfully"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiPublicService"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "example": false
                    },
                    "total_results": {
                      "type": "integer",
                      "example": 10
                    },
                    "next": {
                      "type": "string",
                      "nullable": true,
                      "example": null
                    }
                  }
                },
                "example": {
                  "message": "Services retrieved successfully",
                  "data": [
                    {
                      "id": "service_1234567890",
                      "description": "Professional consulting services",
                      "sku": "CONS-001",
                      "product_key": "80141503",
                      "unit_key": "E48",
                      "unit_name": "Servicio",
                      "unit_price": 1000,
                      "quantity": 1,
                      "taxes": [
                        {
                          "type": "IVA",
                          "rate": 0.16,
                          "factor": "Tasa",
                          "withholding": false
                        }
                      ],
                      "team": "team_1234567890",
                      "created_at": 1677651234,
                      "from": "api"
                    }
                  ],
                  "has_more": false,
                  "total_results": 1
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createServices",
        "tags": [
          "Services"
        ],
        "summary": "Create service",
        "description": "Create a new service.\n\n**gigstack Connect:** Create services for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceInput"
              },
              "example": {
                "description": "Professional consulting services",
                "sku": "CONS-001",
                "product_key": "80141503",
                "unit_key": "ACT",
                "unit_name": "Actividad",
                "unit_price": 1500,
                "taxes": [
                  {
                    "type": "IVA",
                    "rate": 0.16,
                    "factor": "Tasa",
                    "withholding": false,
                    "inclusive": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Service created. Standardized envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Service created"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicService"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Service created",
                  "data": {
                    "id": "service_1234567890",
                    "description": "Professional consulting services",
                    "sku": "CONS-001",
                    "product_key": "80141503",
                    "unit_key": "E48",
                    "unit_name": "Servicio",
                    "unit_price": 1000,
                    "quantity": 1,
                    "taxes": [
                      {
                        "type": "IVA",
                        "rate": 0.16,
                        "factor": "Tasa",
                        "withholding": false
                      }
                    ],
                    "team": "team_1234567890",
                    "created_at": 1677651234,
                    "from": "api"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Body validation failed (`error.code: validation_failed`, message `Invalid body`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "validation_failed",
                    "message": "Invalid body",
                    "details": [
                      "unit_price: Expected number"
                    ]
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/services/{id}": {
      "get": {
        "operationId": "getServicesById",
        "tags": [
          "Services"
        ],
        "summary": "Get service",
        "description": "Retrieve a specific service by ID.\n\n**gigstack Connect:** Access other teams' services using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "service_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Service retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Service retrieved successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicService"
                    }
                  }
                },
                "example": {
                  "message": "Service retrieved successfully",
                  "data": {
                    "id": "service_1234567890",
                    "description": "Professional consulting services",
                    "sku": "CONS-001",
                    "product_key": "80141503",
                    "unit_key": "E48",
                    "unit_name": "Servicio",
                    "unit_price": 1000,
                    "quantity": 1,
                    "taxes": [
                      {
                        "type": "IVA",
                        "rate": 0.16,
                        "factor": "Tasa",
                        "withholding": false
                      }
                    ],
                    "team": "team_1234567890",
                    "created_at": 1677651234,
                    "from": "api"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "operationId": "updateServicesById",
        "tags": [
          "Services"
        ],
        "summary": "Update service",
        "description": "**Partial update:** send only the fields you want to change; omitted fields keep their current values.\n\nUpdate an existing service.\n\n**gigstack Connect:** Update other teams' services using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "service_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceInput"
              },
              "example": {
                "description": "Updated consulting services - Premium package",
                "sku": "CONS-001-PREMIUM",
                "product_key": "80141503",
                "unit_key": "ACT",
                "unit_name": "Actividad",
                "unit_price": 2500,
                "taxes": [
                  {
                    "type": "IVA",
                    "rate": 0.16,
                    "factor": "Tasa",
                    "withholding": false,
                    "inclusive": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated. Raw body (no `success`/`timestamp`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicService"
                    }
                  }
                },
                "example": {
                  "message": "Service updated successfully",
                  "data": {
                    "id": "service_1234567890",
                    "description": "Servicios de consultoría profesional",
                    "quantity": 1,
                    "unit_price": 1000,
                    "product_key": "80141503",
                    "unit_key": "E48",
                    "unit_name": "Unidad de servicio",
                    "taxes": [
                      {
                        "type": "IVA",
                        "rate": 0.16,
                        "factor": "Tasa",
                        "withholding": false
                      }
                    ],
                    "team": "team_1234567890",
                    "created_at": 1767225600000,
                    "from": "api"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Body validation failed. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string"
                          },
                          "code": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "error": "Invalid request body",
                  "errors": [
                    {
                      "path": "unit_price",
                      "code": "invalid_type",
                      "message": "Expected number"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected failure. Raw body (the message says \"client\" for services; this is the text the API returns).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "error": "Failed to update client"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteServicesById",
        "tags": [
          "Services"
        ],
        "summary": "Delete service",
        "description": "Delete a specific service.\n\n**gigstack Connect:** Delete other teams' services using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "service_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Service deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "deleted": true
                  },
                  "message": "Service deleted successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/sat": {
      "get": {
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "List SAT invoices",
        "description": "Returns invoices downloaded from SAT via Descarga Masiva. Supports filtering by direction,\nstatus, invoice type, RFC, and date range. Uses cursor-based pagination.\n\nRequires Descarga Masiva to be activated and at least one download request to have completed.\n",
        "operationId": "listSatInvoices",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "direction",
            "in": "query",
            "description": "Filter by invoice direction",
            "schema": {
              "type": "string",
              "enum": [
                "issued",
                "received"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by SAT invoice status",
            "schema": {
              "type": "string",
              "enum": [
                "Vigente",
                "Cancelado"
              ]
            }
          },
          {
            "name": "invoice_type",
            "in": "query",
            "description": "Filter by CFDI type code",
            "schema": {
              "type": "string",
              "enum": [
                "I",
                "E",
                "P",
                "N",
                "T"
              ]
            }
          },
          {
            "name": "issuer_rfc",
            "in": "query",
            "description": "Filter by issuer RFC",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "receiver_rfc",
            "in": "query",
            "description": "Filter by receiver RFC",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Issue date from (inclusive), format YYYY-MM-DD",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Issue date to (inclusive), format YYYY-MM-DD",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Number of results per page (1–100, default 20)",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "description": "UUID of the last invoice from the previous page (cursor pagination)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of SAT invoices",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SatInvoice"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next": {
                      "type": "string",
                      "nullable": true,
                      "description": "UUID to pass as starting_after for the next page"
                    },
                    "count": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": [
                    {
                      "id": "6741A863-04BE-49FE-BB76-E1657AB6B7EA",
                      "uuid": "6741A863-04BE-49FE-BB76-E1657AB6B7EA",
                      "direction": "received",
                      "issuer": {
                        "rfc": "EKU9003173C9",
                        "name": "ESCUELA KEMPER URGATE"
                      },
                      "receiver": {
                        "rfc": "MEE200101ABC",
                        "name": "MI EMPRESA EJEMPLO SA DE CV"
                      },
                      "invoice_type": "I",
                      "series": "F",
                      "folio": "1024",
                      "subtotal": 103.44,
                      "total": 120,
                      "currency": "MXN",
                      "issue_date": "2025-01-15",
                      "stamp_date": "2025-01-15T12:34:56",
                      "status": "Vigente",
                      "pac_rfc": "SAT970701NN3",
                      "version": "4.0",
                      "certificate_number": "00001000000513342038",
                      "download_request_id": "satreq_abc123",
                      "has_xml": true,
                      "created_at": 1767225600000,
                      "updated_at": 1767225600000
                    }
                  ],
                  "has_more": true,
                  "next": "6741A863-04BE-49FE-BB76-E1657AB6B7EA",
                  "count": 1
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    },
    "/invoices/sat/{uuid}": {
      "get": {
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Get a SAT invoice",
        "description": "Returns a single invoice downloaded from SAT by its UUID.",
        "operationId": "getSatInvoice",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "description": "The SAT invoice UUID",
            "schema": {
              "type": "string"
            },
            "example": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e"
          }
        ],
        "responses": {
          "200": {
            "description": "SAT invoice",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SatInvoice"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "6741A863-04BE-49FE-BB76-E1657AB6B7EA",
                    "uuid": "6741A863-04BE-49FE-BB76-E1657AB6B7EA",
                    "direction": "received",
                    "issuer": {
                      "rfc": "EKU9003173C9",
                      "name": "ESCUELA KEMPER URGATE"
                    },
                    "receiver": {
                      "rfc": "MEE200101ABC",
                      "name": "MI EMPRESA EJEMPLO SA DE CV"
                    },
                    "invoice_type": "I",
                    "series": "F",
                    "folio": "1024",
                    "subtotal": 103.44,
                    "total": 120,
                    "currency": "MXN",
                    "issue_date": "2025-01-15",
                    "stamp_date": "2025-01-15T12:34:56",
                    "status": "Vigente",
                    "pac_rfc": "SAT970701NN3",
                    "version": "4.0",
                    "certificate_number": "00001000000513342038",
                    "download_request_id": "satreq_abc123",
                    "has_xml": true,
                    "created_at": 1767225600000,
                    "updated_at": 1767225600000
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Invoice not found"
          }
        }
      }
    },
    "/invoices/import": {
      "post": {
        "operationId": "importInvoiceXml",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Import CFDI XMLs the team already holds",
        "description": "Imports up to 50 stamped CFDI XMLs and files each one by the team's RFC:\n\n- **Team is the issuer** → stored as an invoice (`GET /invoices/{id}`), with its XML.\n- **Team is the receiver** → stored with the SAT received invoices (`GET /invoices/sat`), already imported, so Descarga Masiva will not download or bill it again.\n- **Neither** → rejected; nothing is written.\n\nNothing is billed. A UUID the team already holds is reported as `already_exists`; one held by another account as `conflict`. Received nómina XMLs are rejected because they contain employee personal data. Status is assumed `Vigente`: an XML cannot show a later cancellation.\n\nSend each file as `xml` (the XML text) or `content` (base64).\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "files"
                ],
                "properties": {
                  "files": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "type": "object",
                      "properties": {
                        "filename": {
                          "type": "string",
                          "example": "factura-a12.xml"
                        },
                        "xml": {
                          "type": "string",
                          "description": "The CFDI XML as text"
                        },
                        "content": {
                          "type": "string",
                          "description": "The CFDI XML, base64-encoded. Used when `xml` is absent."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-file outcome",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "summary": {
                          "type": "object",
                          "properties": {
                            "imported": {
                              "type": "integer"
                            },
                            "issued": {
                              "type": "integer"
                            },
                            "received": {
                              "type": "integer"
                            },
                            "already_exists": {
                              "type": "integer"
                            },
                            "not_imported": {
                              "type": "integer"
                            }
                          }
                        },
                        "results": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "filename": {
                                "type": "string"
                              },
                              "success": {
                                "type": "boolean"
                              },
                              "action": {
                                "type": "string",
                                "enum": [
                                  "created",
                                  "completed",
                                  "already_exists",
                                  "conflict",
                                  "rejected"
                                ]
                              },
                              "direction": {
                                "type": "string",
                                "nullable": true,
                                "enum": [
                                  "issued",
                                  "received",
                                  null
                                ]
                              },
                              "uuid": {
                                "type": "string",
                                "nullable": true
                              },
                              "error": {
                                "type": "string",
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Imported 2 of 3 files",
                  "data": {
                    "summary": {
                      "imported": 2,
                      "issued": 1,
                      "received": 1,
                      "already_exists": 0,
                      "not_imported": 1
                    },
                    "results": [
                      {
                        "filename": "a12.xml",
                        "success": true,
                        "action": "created",
                        "direction": "issued",
                        "uuid": "6F1B2C3D-0000-4000-8000-000000000001",
                        "error": null
                      },
                      {
                        "filename": "proveedor.xml",
                        "success": true,
                        "action": "created",
                        "direction": "received",
                        "uuid": "6F1B2C3D-0000-4000-8000-000000000002",
                        "error": null
                      },
                      {
                        "filename": "otro.xml",
                        "success": false,
                        "action": "rejected",
                        "direction": null,
                        "uuid": "6F1B2C3D-0000-4000-8000-000000000003",
                        "error": "El RFC AAA010101AAA no aparece como emisor ni receptor de este CFDI"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or malformed files, more than 50 files, or no RFC on the team"
          }
        }
      }
    },
    "/invoices/sat/{uuid}/retry-xml": {
      "post": {
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Retry XML download",
        "description": "Manually retry the XML download for a received SAT invoice stuck in processing or error state.",
        "operationId": "retrySatXmlDownload",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "description": "The SAT invoice UUID",
            "schema": {
              "type": "string"
            },
            "example": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e"
          }
        ],
        "responses": {
          "200": {
            "description": "XML downloaded, or already present. When the invoice already had its XML the\nhandler short-circuits with `message: Invoice already has XML downloaded.` and\n`data.resource_status: ready` without re-fetching or charging a credit.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "XML downloaded successfully"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "resource_status": {
                          "type": "string",
                          "enum": [
                            "ready"
                          ],
                          "example": "ready"
                        },
                        "credit_charged": {
                          "type": "boolean",
                          "example": true
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "XML downloaded successfully",
                  "data": {
                    "resource_status": "ready",
                    "credit_charged": true
                  }
                }
              }
            }
          },
          "400": {
            "description": "Either the invoice is issued rather than received\n(`Issued invoices do not require XML retry — they already have their XML.`) or the\nteam has no usable FIEL\n(`FIEL credentials not found or expired. Upload FIEL first using POST /v2/invoices/download/fiel`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "FIEL credentials not found or expired. Upload FIEL first using POST /v2/invoices/download/fiel"
                }
              }
            }
          },
          "401": {
            "description": "`{ \"success\": false, \"message\": \"Unauthorized\" }`."
          },
          "403": {
            "description": "`{ \"success\": false, \"message\": \"Forbidden\" }` — the invoice belongs to another team."
          },
          "404": {
            "description": "`{ \"success\": false, \"message\": \"SAT invoice not found\" }`."
          },
          "422": {
            "description": "The XML fetch from SAT failed. The invoice is marked `resource_status: error`;\n`message` is `XML download failed` and `error` carries the upstream reason.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "XML download failed"
                    },
                    "error": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "resource_status": {
                          "type": "string",
                          "enum": [
                            "error"
                          ]
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "XML download failed",
                  "error": "SAT rejected the download request for this UUID",
                  "data": {
                    "resource_status": "error"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal error while retrying the XML download."
          }
        }
      }
    },
    "/invoices/sat/{uuid}/pdf": {
      "post": {
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Generate PDF for a received SAT invoice",
        "description": "Generates a PDF from the stored XML of a received SAT invoice.\nThe result is cached — subsequent calls return the cached PDF instantly.\nRequires the XML to have been downloaded first (`hasXml: true`).\n",
        "operationId": "generateSatPdf",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "description": "The SAT invoice UUID",
            "schema": {
              "type": "string"
            },
            "example": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e"
          }
        ],
        "responses": {
          "200": {
            "description": "PDF generated, or served from cache. The success body is **not** enveloped — it is\njust `{ \"pdf\": \"<base64>\" }`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "pdf"
                  ],
                  "properties": {
                    "pdf": {
                      "type": "string",
                      "description": "Base64-encoded PDF file",
                      "example": "JVBERi0xLjQKJcOkw..."
                    }
                  }
                },
                "example": {
                  "pdf": "JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9UeXBlIC9DYXRhbG9nPj4K..."
                }
              }
            }
          },
          "401": {
            "description": "`{ \"success\": false, \"message\": \"Unauthorized\" }`."
          },
          "403": {
            "description": "`{ \"success\": false, \"message\": \"Forbidden\" }` — the invoice belongs to another team."
          },
          "404": {
            "description": "`{ \"success\": false, \"message\": \"SAT invoice not found\" }`, or\n`{ \"success\": false, \"message\": \"XML not yet available\" }` when the XML has not been\ndownloaded yet — call `POST /v2/invoices/sat/{uuid}/retry-xml` first.\n"
          },
          "422": {
            "description": "**Too many conceptos for a PDF.** PDFs are generated for CFDIs of up to 500\nconceptos; above that the renderer is not called and nothing is cached. The XML\nstays available.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "PDF_TOO_LARGE"
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "code": "PDF_TOO_LARGE",
                  "message": "El comprobante tiene 2308 conceptos; el PDF solo se genera hasta 500. El XML está disponible."
                }
              }
            }
          },
          "500": {
            "description": "`{ \"success\": false, \"message\": \"<error>\" }` or `Internal error`."
          },
          "502": {
            "description": "**Upstream PDF renderer failure.** The CFDI-to-PDF service returned a non-OK\nresponse (`PDF generator error: <body>`) or an empty payload\n(`PDF generator returned no data`). The stored XML is intact — retry later.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "PDF generator returned no data"
                }
              }
            }
          }
        }
      }
    },
    "/invoices/errors": {
      "get": {
        "operationId": "getInvoicesErrors",
        "tags": [
          "Invoices"
        ],
        "summary": "List CFDI errors",
        "description": "Retrieve a paginated and filterable list of CFDI errors from the error matrix.\nUse this endpoint to search for error codes, understand error causes, and find solutions.\n\n**Query Options:**\n- Filter by exact error code using `code` parameter\n- Search across all fields using `q` parameter\n- Filter by error type (invoice, receiver, sender, unknown)\n- Paginate results with `limit` and `page` parameters\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "code",
            "in": "query",
            "description": "Filter by exact error code (e.g., CFDI140223). Returns single document if found.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Search query. Searches across code, description, explanation, and solution fields.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Filter by error type",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "invoice",
                "receiver",
                "sender",
                "unknown"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Number of results per page (max 100)",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number for pagination",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CFDI errors retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "total",
                    "page",
                    "limit",
                    "message",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CfdiError"
                      }
                    },
                    "total": {
                      "type": "integer",
                      "description": "Total count of matching errors",
                      "example": 150
                    },
                    "page": {
                      "type": "integer",
                      "description": "Current page number",
                      "example": 1
                    },
                    "limit": {
                      "type": "integer",
                      "description": "Items per page",
                      "example": 50
                    },
                    "message": {
                      "type": "string",
                      "example": "CFDI errors retrieved successfully"
                    },
                    "timestamp": {
                      "type": "number",
                      "format": "int64",
                      "description": "Unix timestamp in milliseconds",
                      "example": 1734605400000
                    }
                  }
                },
                "examples": {
                  "singleError": {
                    "summary": "Single error by code",
                    "value": {
                      "success": true,
                      "data": [
                        {
                          "code": "CFDI140223",
                          "description": "El campo Rfc del receptor no es valido",
                          "explanation": "The RFC (tax ID) provided for the receiver does not meet the validation requirements or format specified by SAT",
                          "solution": "Verify that the receiver's RFC is correct, properly formatted (13 characters for individuals, 12 for legal entities), and matches SAT's registered information",
                          "type": "receiver"
                        }
                      ],
                      "total": 1,
                      "page": 1,
                      "limit": 1,
                      "message": "CFDI error retrieved successfully",
                      "timestamp": 1767225600000
                    }
                  },
                  "searchResults": {
                    "summary": "Search results",
                    "value": {
                      "success": true,
                      "data": [
                        {
                          "code": "CFDI140223",
                          "description": "El campo Rfc del receptor no es valido",
                          "explanation": "The RFC (tax ID) provided for the receiver does not meet the validation requirements",
                          "solution": "Verify that the receiver's RFC is correct and properly formatted",
                          "type": "receiver"
                        },
                        {
                          "code": "CFDI140225",
                          "description": "El RFC del receptor no existe en el padron del SAT",
                          "explanation": "The receiver's RFC is not registered in SAT's taxpayer registry",
                          "solution": "Confirm the RFC is registered with SAT or contact the receiver to verify their tax information",
                          "type": "receiver"
                        }
                      ],
                      "total": 2,
                      "page": 1,
                      "limit": 10,
                      "message": "CFDI errors retrieved successfully",
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Error code not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "message": {
                      "type": "string",
                      "example": "CFDI Error not found"
                    },
                    "error": {
                      "type": "string",
                      "example": "Error code 'INVALID_CODE' not found"
                    },
                    "timestamp": {
                      "type": "number",
                      "format": "int64",
                      "description": "Unix timestamp in milliseconds",
                      "example": 1734605400000
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/income": {
      "get": {
        "operationId": "getInvoicesIncome",
        "tags": [
          "Invoices"
        ],
        "summary": "List income invoices",
        "description": "Retrieve a paginated list of income invoices with powerful filtering capabilities.\n\n**gigstack Connect:** Access other teams' invoices using the `team` parameter.\n\n**Filtering Options:**\n- Filter by creation date using comparison operators\n- Filter by `status`, `series`, `folio` and `idempotency_key` (exact match only)\n- Filter by metadata fields using dot or underscore notation (e.g., `metadata.order_id` or `metadata_order_id`)\n\n**Colombia:** DIAN debit notes are income (`I`) documents, so they are listed here alongside sales\ninvoices. Tell them apart by `document_kind: \"debit_note\"`, which only debit notes carry. There is no\nfilter on `document_kind`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "$ref": "#/components/parameters/ClientIdFilterParam"
          },
          {
            "$ref": "#/components/parameters/TaxIdFilterParam"
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by invoice status. `cancelled` is accepted as an alias of `canceled`.\n",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "valid",
                "canceled",
                "cancelled"
              ]
            }
          },
          {
            "name": "series",
            "in": "query",
            "description": "Filter by exact invoice series (no prefix matching).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "folio",
            "in": "query",
            "description": "Filter by exact folio number (no prefix matching).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idempotency_key",
            "in": "query",
            "description": "Filter by the exact idempotency key the invoice was created with.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metadata.{key}",
            "in": "query",
            "description": "Filter by any metadata field using dot notation (e.g., `metadata.order_id=ORD-123`)\nor underscore notation (e.g., `metadata_order_id=ORD-123`).\nBoth formats are supported and equivalent.\nUses Typesense search for efficient querying without requiring Firestore indexes.\n",
            "required": false,
            "schema": {
              "type": "string"
            },
            "style": "form"
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number for pagination when using metadata filters (default 1).\nOnly applies when filtering by metadata fields.\n",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invoices retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "success": true,
                  "message": "Invoices retrieved successfully",
                  "data": [
                    {
                      "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                      "idempotency_key": null,
                      "client": {
                        "id": "client_1234567890",
                        "name": "ESCUELA KEMPER URGATE",
                        "legal_name": "ESCUELA KEMPER URGATE",
                        "email": "contabilidad@ejemplo.com",
                        "bcc": [],
                        "phone": "+524421234567",
                        "tax_id": "EKU9003173C9",
                        "tax_system": "601",
                        "use": "G03",
                        "address": {
                          "street": "Av. Constituyentes",
                          "exterior": "1000",
                          "neighborhood": "Centro",
                          "city": "Querétaro",
                          "state": "QRO",
                          "zip": "76000",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "efos": {
                          "is_valid": true
                        },
                        "metadata": {},
                        "livemode": true,
                        "from": "api",
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      },
                      "created_at": 1767225600000,
                      "date": 1767225600000,
                      "currency": "MXN",
                      "exchange_rate": 1,
                      "total": 1160,
                      "subtotal": 1000,
                      "discount": 0,
                      "taxes": 160,
                      "withholding_taxes": 0,
                      "series": "A",
                      "folio_number": 123,
                      "invoice_type": "I",
                      "use": "G03",
                      "payment_form": "03",
                      "payment_method": "PUE",
                      "livemode": true,
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "from": "api",
                      "status": "valid",
                      "payments": [
                        "payment_1234567890"
                      ],
                      "invoices": [],
                      "items": [
                        {
                          "id": "service_1234567890",
                          "description": "Servicios de consultoría profesional",
                          "quantity": 1,
                          "unit_price": 1000,
                          "product_key": "80141503",
                          "unit_key": "E48"
                        }
                      ],
                      "metadata": {},
                      "emails": [
                        "contabilidad@ejemplo.com"
                      ],
                      "cancellation": null,
                      "stamp": {
                        "sello": "kQ3xZ9vR2mP7tL4wN8cB1yH6",
                        "stamp_at": 1767225600000
                      },
                      "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB&re=MEE200101ABC&rr=EKU9003173C9&tt=1160.00&fe=kQ3xZ9"
                    }
                  ],
                  "next": null,
                  "has_more": false,
                  "total_results": 1,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createInvoicesIncome",
        "tags": [
          "Invoices"
        ],
        "summary": "Create income invoice",
        "description": "[Small working example](/recipes/paid-later)\n\n**Integration note:** This endpoint stamps immediately. For a reviewable document, create a draft first. Successful issuance returns HTTP 200 and data.uuid. Fiscal validity does not establish that payment has been received. Read [shared fields](/concepts/shared-fields) and the [Mexico](/countries/mexico) or [Colombia](/countries/colombia) guide for country-specific meaning. The linked fiscal recipes and staging issuance results use a Mexican issuer.\n\nCreate a new income invoice with CFDI 4.0 compliance.\n\n**Safe retries with `idempotency_key`.** Send your own identifier for the invoice (for example your\norder id) in `idempotency_key`. gigstack claims the key before charging a credit or stamping, so\nrepeating the request cannot issue a second CFDI or charge twice:\n\n- The invoice already exists: `400` with `message.duplicate: true` and `message.uuid`.\n- Another request with the key is still being processed: `409` `idempotency_in_progress`. Retry later.\n- The PAC's answer was lost: `503` `PAC_OUTCOME_UNKNOWN` with `retryable: true`. Retry with the same\n  key: the same XML and folio are sent again, so the PAC stamps it once or returns the stamp it already made.\n- The PAC can't confirm an earlier attempt: `409` `STAMP_NEEDS_REVIEW`. Don't retry; contact support.\n- The serie and folio already belong to another CFDI of the issuer's RFC (for example, another account\n  on the same RFC): `400` `FOLIO_ALREADY_USED`. Nothing was stamped and the key is free again. With\n  your own `folio_number`, send another one; with gigstack's folios, give the team a serie of its own\n  first, since the other account keeps using that serie.\n- The SAT or PAC rejected the data: `400`, and the key is free again for a corrected request.\n\nWithout an `idempotency_key` none of this applies, and after a `503` `PAC_OUTCOME_UNKNOWN`\n(`retryable: false`) you can't tell whether the invoice exists: look it up before sending it again.\n\nTo issue many invoices at once, use `POST /invoices/income/batch`.\n\n**Colombia: debit notes (notas débito).** A team invoicing in Colombia issues a DIAN debit note\nthrough this same endpoint with `document_kind: \"debit_note\"`, a `motive`, and\n`related_documents: [{ \"relationship\": \"02\", \"documents\": [\"<invoice uuid or DIAN number>\"] }]`\nnaming the one sales invoice being debited. `items` are the additional amounts charged, not the\noriginal invoice's items. gigstack sends it to DIAN through Factus as a debit note that references\nthat invoice. It needs an active \"Nota Débito\" numbering range in the team's Factus account; without\none the request fails with `COL_NUMBERING_RANGE_ERROR`. The series and folio returned are DIAN's (for\nexample `ND3`). The response is the usual income invoice (`invoice_type: I`) plus `document_kind:\n\"debit_note\"` and `motive`, and the debit note is listed by `GET /invoices/income`.\n\nA debit note can't be cancelled: to reverse it, issue a credit note on the original invoice. A credit\nor debit note can't be the document a debit note references. Malformed debit-note requests (no\n`motive`, wrong `related_documents`, combined with `global`, or from a team not invoicing in\nColombia) are answered `400` before a credit is consumed or a folio reserved.\n\n**gigstack Connect:** Create invoices for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceIncomeInput"
              },
              "examples": {
                "mexico_invoice": {
                  "summary": "Income invoice (Mexico)",
                  "value": {
                    "automation_type": "payment",
                    "currency": "MXN",
                    "use": "G03",
                    "payment_form": "03",
                    "payment_method": "PUE",
                    "client": {
                      "id": "client_1234567890"
                    },
                    "items": [
                      {
                        "description": "Professional consulting services",
                        "sku": "CONS-001",
                        "product_key": "80141503",
                        "unit_key": "ACT",
                        "unit_name": "Actividad",
                        "unit_price": 1500,
                        "taxability": "02",
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false,
                            "inclusive": false
                          }
                        ],
                        "quantity": 1
                      }
                    ],
                    "send_email": true,
                    "emails": [
                      "cliente@empresa.com"
                    ],
                    "metadata": {
                      "project_id": "PROJ-2024-001",
                      "department": "consulting"
                    }
                  }
                },
                "colombia_debit_note": {
                  "summary": "Debit note on invoice FV69 (Colombia)",
                  "description": "Charges COP 50,000 of collection expenses plus 19% IVA on the sales invoice\n`FV69`. `use` is only the compatibility string the shared schema requires; it is\nnot sent to DIAN.\n",
                  "value": {
                    "document_kind": "debit_note",
                    "motive": "collection_expenses",
                    "related_documents": [
                      {
                        "relationship": "02",
                        "documents": [
                          "FV69"
                        ]
                      }
                    ],
                    "client": {
                      "id": "client_1234567890"
                    },
                    "currency": "COP",
                    "exchange_rate": 1,
                    "use": "G03",
                    "payment_form": "03",
                    "payment_method": "PUE",
                    "automation_type": "none",
                    "items": [
                      {
                        "description": "Gastos de cobranza factura FV69",
                        "product_key": "80101500",
                        "quantity": 1,
                        "unit_price": 50000,
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.19,
                            "factor": "Tasa",
                            "withholding": false,
                            "inclusive": false
                          }
                        ]
                      }
                    ],
                    "send_email": false,
                    "idempotency_key": "debit-note-fv69-collection-001"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invoice created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Invoice created successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicIncomeInvoice"
                    }
                  }
                },
                "examples": {
                  "mexico_invoice": {
                    "summary": "Income invoice (Mexico)",
                    "value": {
                      "message": "Invoice created successfully",
                      "data": {
                        "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                        "client": {
                          "id": "client_1234567890",
                          "name": "Juan Pérez García",
                          "email": "juan.perez@ejemplo.com",
                          "tax_id": "PEGJ800101ABC",
                          "from": "api",
                          "livemode": true,
                          "owner": "user_1234567890",
                          "team": "team_1234567890",
                          "created_at": 1767225600000
                        },
                        "status": "valid",
                        "currency": "MXN",
                        "exchange_rate": 1,
                        "total": 1160,
                        "subtotal": 1000,
                        "taxes": 160,
                        "discount": 0,
                        "series": "A",
                        "folio_number": 123,
                        "invoice_type": "I",
                        "payment_method": "PUE",
                        "items": [
                          {
                            "id": "item_1234567890",
                            "description": "Professional consulting services",
                            "quantity": 1,
                            "unit_price": 1000,
                            "product_key": "80141503",
                            "unit_key": "E48"
                          }
                        ],
                        "created_at": 1677651234,
                        "livemode": true,
                        "owner": "user_1234567890"
                      }
                    }
                  },
                  "colombia_debit_note": {
                    "summary": "Debit note ND3 on invoice FV69 (Colombia, test mode)",
                    "description": "`uuid` is the identifier DIAN gave the debit note (its CUDE); keep it as an\nopaque string. `series` and `folio_number` are DIAN's number `ND3`.\n",
                    "value": {
                      "message": "Invoice created",
                      "data": {
                        "uuid": "7c1e9a4b2d8f6e3a5b0c9d7e1f2a4b6c8d0e3f5a7b9c1d2e4f6a8b0c2d4e6f8a1b3c5d7e9f0a2b4c6d8e1f3a5b7c9d0e2f4a6",
                        "client": {
                          "id": "client_1234567890",
                          "name": "Comercializadora Andina de Prueba SAS",
                          "email": "customer@example.com",
                          "from": "api",
                          "livemode": false,
                          "owner": "user_1234567890",
                          "team": "team_1234567890",
                          "created_at": 1767225600000
                        },
                        "status": "valid",
                        "currency": "COP",
                        "exchange_rate": 1,
                        "total": 59500,
                        "subtotal": 50000,
                        "taxes": 9500,
                        "withholding_taxes": 0,
                        "discount": 0,
                        "series": "ND",
                        "folio_number": 3,
                        "invoice_type": "I",
                        "document_kind": "debit_note",
                        "motive": "collection_expenses",
                        "use": "G03",
                        "payment_form": "03",
                        "payment_method": "PUE",
                        "related_documents": [
                          {
                            "relationship": "02",
                            "documents": [
                              "FV69"
                            ]
                          }
                        ],
                        "items": [
                          {
                            "id": "item_1234567890",
                            "description": "Gastos de cobranza factura FV69",
                            "quantity": 1,
                            "unit_price": 50000,
                            "product_key": "80101500"
                          }
                        ],
                        "invoices": [],
                        "payments": [],
                        "created_at": 1767225600000,
                        "livemode": false,
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "from": "api"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request. All bodies here are **raw**, not the standardized envelope.\n- Body validation: `{ \"message\": \"Invalid body\", \"errors\": [ { \"path\": …, \"code\": …, \"message\": … } ] }`.\n  Unknown keys are rejected — there is no `client_id` field; use `client: { \"id\": … }`.\n- `{ \"message\": \"Billing account not found\", \"error\": \"Billing account is required\" }`\n- `{ \"message\": \"Invalid currency\", \"error\": … }`\n- `{ \"message\": \"Exchange rate not found\" }`\n- `{ \"message\": \"Resource resolution failed\", \"error\": … }` when the client/service\n  reference is ambiguous (both `id` and `search`, or `safety_check` matched several).\n- Generic CFDI/PAC stamping failure, nested one level under `message`:\n  `{ \"message\": { \"error\": …, \"code\": …, \"providerMessage\": …, \"retryable\": false } }`.\n  A rejection frees the `idempotency_key`: a corrected request may reuse it.\n- **Duplicate `idempotency_key`.** An invoice already exists under the key. Same CFDI shape,\n  `code: INVALID_INVOICE`, plus `duplicate: true` and the existing invoice's `uuid`. Nothing was\n  stamped or charged. Treat it as success and read the invoice with `GET /invoices/income/{id}`.\n- **Colombian debit note, request refused** (before any credit or folio is used):\n  `{ \"message\": \"Invalid body\", \"errors\": [\"<reason>\"] }`, where `errors` holds one **string**.\n  Reasons: `motive` or `billing_period` sent without `document_kind: debit_note`; `debit_note`\n  from a team that doesn't invoice in Colombia; combined with `global`; `related_documents` not\n  exactly one `02` entry with one document; `motive` missing; `billing_period` ending before it\n  starts, missing on a debit note that reverses a credit note, or sent on one that debits a\n  sales invoice.\n- **Colombian debit note, refused while issuing** (CFDI shape under `message`):\n  `COL_NUMBERING_RANGE_ERROR` (no active, or more than one, \"Nota Débito\" numbering range in the\n  team's Factus account), `COL_BILL_NOT_FOUND` (the invoice referenced by `uuid` isn't found in this\n  team, is of the other mode, has no DIAN number, or is itself a debit note; a DIAN\n  number such as `FV69` not found in the team is passed to Factus as given),\n  `COL_DEBIT_NOTE_ERROR` (an earlier debit note is still pending at DIAN; contact support), or\n  `COL_STAMP_ERROR` (Factus or DIAN rejected the document).\n",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/LegacyErrorResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "message": {
                          "$ref": "#/components/schemas/CfdiErrorResponse"
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "invalid_body": {
                    "summary": "Body validation",
                    "value": {
                      "message": "Invalid body",
                      "errors": [
                        {
                          "path": "client_id",
                          "code": "unexpected_key",
                          "message": "Unexpected field"
                        }
                      ]
                    }
                  },
                  "sat_rejection": {
                    "summary": "The SAT rejected the document's data",
                    "value": {
                      "message": {
                        "error": "Error al timbrar la factura: CFDI40147 - El campo UsoCFDI no es válido [pcs_8f2a1c]",
                        "code": "CFDI40147",
                        "providerMessage": "CFDI40147 - El campo UsoCFDI no es válido",
                        "retryable": false
                      }
                    }
                  },
                  "duplicate_idempotency_key": {
                    "summary": "An invoice already exists under this idempotency_key",
                    "value": {
                      "message": {
                        "error": "Error al timbrar la factura: Ya existe un comprobante con la misma idempotencia (uuid: 0f8fad5b-d9cb-469f-a165-70867728950e)",
                        "code": "INVALID_INVOICE",
                        "providerMessage": "Ya existe un comprobante con la misma idempotencia (uuid: 0f8fad5b-d9cb-469f-a165-70867728950e)",
                        "retryable": false,
                        "duplicate": true,
                        "uuid": "0f8fad5b-d9cb-469f-a165-70867728950e"
                      }
                    }
                  },
                  "debit_note_missing_motive": {
                    "summary": "Colombian debit note without a motive",
                    "value": {
                      "message": "Invalid body",
                      "errors": [
                        "A debit note needs a motive: 1 (interest), 2 (collection_expenses), 3 (value_change) or 4 (other)"
                      ]
                    }
                  },
                  "debit_note_wrong_reference": {
                    "summary": "Colombian debit note without exactly one 02 related document",
                    "value": {
                      "message": "Invalid body",
                      "errors": [
                        "A debit note must reference exactly one invoice: related_documents [{ relationship: '02', documents: [<invoice uuid>] }]"
                      ]
                    }
                  },
                  "debit_note_not_colombia": {
                    "summary": "Debit note from a team that doesn't invoice in Colombia",
                    "value": {
                      "message": "Invalid body",
                      "errors": [
                        "Debit notes (document_kind debit_note) are only available for teams invoicing in Colombia"
                      ]
                    }
                  },
                  "debit_note_no_numbering_range": {
                    "summary": "No active Nota Débito numbering range in Factus",
                    "value": {
                      "message": {
                        "error": "Error al timbrar la factura: El equipo no tiene un rango de numeración de notas débito activo en Factus. [pcs_5c6d7e]",
                        "code": "COL_NUMBERING_RANGE_ERROR",
                        "providerMessage": "El equipo no tiene un rango de numeración de notas débito activo en Factus.",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Raw shape with only a `message` key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The referenced client or service belongs to another team, or its `livemode` does\nnot match the API key. Raw shape `{ \"message\": \"Resource resolution failed\", \"error\": … }`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "The referenced client or service id was not found. Raw shape.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Three cases, all raw bodies:\n\n- **Client or service lock.** A concurrent create holds the lock for the same client or service\n  (`search` + `auto_create`). `{ \"message\": \"Resource resolution failed\", \"error\": … }`. Retry\n  after about a second.\n- **`idempotency_in_progress`.** Another request with the same `idempotency_key` is being\n  processed (`IdempotencyInProgressResponse`, `retryable: true`). Retry later with the same key;\n  you get the invoice's outcome (a `400` duplicate once it exists). A request that died mid-way\n  holds the key for up to 10 minutes.\n- **`STAMP_NEEDS_REVIEW`.** An earlier attempt with this `idempotency_key` reached the PAC, and\n  the PAC could not confirm whether it stamped (no UUID returned, or the SAT's 72-hour window\n  has passed), or it stamped and the invoice could not be saved. CFDI shape under `message`,\n  `retryable: false`. Retrying could issue a second CFDI, so every retry gets this answer.\n  Contact support with the key.\n",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/LegacyErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/IdempotencyInProgressResponse"
                    },
                    {
                      "type": "object",
                      "required": [
                        "message"
                      ],
                      "properties": {
                        "message": {
                          "$ref": "#/components/schemas/CfdiErrorResponse"
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "client_lock": {
                    "summary": "Concurrent create of the same client",
                    "value": {
                      "message": "Resource resolution failed",
                      "error": "Client creation in progress for tax_id=EKU9003173C9. Please retry."
                    }
                  },
                  "idempotency_in_progress": {
                    "summary": "Same idempotency_key, still being processed",
                    "value": {
                      "message": "An invoice with this idempotency_key is already being created",
                      "error": {
                        "code": "idempotency_in_progress",
                        "message": "An invoice with this idempotency_key is already being created; retry later"
                      },
                      "retryable": true
                    }
                  },
                  "stamp_needs_review": {
                    "summary": "The PAC could not confirm an earlier attempt",
                    "value": {
                      "message": {
                        "error": "El PAC indica que el comprobante A-1284 ya fue timbrado pero no devolvió su UUID: Comprobante timbrado previamente [pcs_3b7e9d]",
                        "code": "STAMP_NEEDS_REVIEW",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          },
          "412": {
            "description": "**SAT not connected.** The team has no valid CSD, or the certificate failed\nvalidation. Returned in the CFDI error shape nested under `message`, with\n`retryable: false`. Upload a CSD via `POST /v2/teams/{id}/sat-connection`\nbefore retrying — retrying as-is will fail identically.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "$ref": "#/components/schemas/CfdiErrorResponse"
                    }
                  }
                },
                "example": {
                  "message": {
                    "error": "El certificado de sello digital (CSD) no está configurado o no es válido.",
                    "code": "CSD_VALIDATION_ERROR",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "description": "**Team credit limit reached.** Raw shape carrying the limit and current usage.\nNo document is created.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditLimitResponse"
                },
                "example": {
                  "message": "Team credit limit reached",
                  "error": "Credit limit of 100 documents reached for this billing period",
                  "credit_limit": 100,
                  "used_credits": 100
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error. Raw shape — either\n`{ \"message\": \"Failed to save invoice\", \"error\": { \"code\": \"invoice_save_error\", … } }`\nor `{ \"message\": \"An error occurred while creating invoice\", \"error\": { \"code\": …, \"message\": … } }`.\nA `Failed to save invoice` after a stamp means the CFDI exists: with an `idempotency_key`, a retry\nanswers `409` `STAMP_NEEDS_REVIEW` instead of stamping again.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "The stamp did not complete. CFDI error shape nested under `message`. Read `code`:\n\n- **`PAC_UNAVAILABLE`** (`retryable: true`). The PAC could not be reached, or refused the request\n  before stamping (HTTP 4xx such as 429, maintenance). The document never reached the SAT and no\n  CFDI exists. Wait a few minutes and retry.\n- **`PAC_OUTCOME_UNKNOWN`**. The request reached the PAC and its answer was lost (timeout, reset,\n  HTTP 5xx, unreadable body), so the CFDI **may exist**. Its folio is never reused.\n  - With an `idempotency_key`, `retryable: true`: retry with the **same** key. The same XML and\n    folio are sent again, so the PAC either stamps it now or returns the stamp it already made; it\n    cannot stamp twice, and the retry is not charged again. Any other failure after the XML was\n    sent is also answered this way.\n  - Without one, `retryable: false`: a new request would take a new folio and could issue a second\n    CFDI. Check whether the invoice exists before sending it again.\n\nTimeouts and HTTP 5xx from the PAC used to be answered as `PAC_UNAVAILABLE`; they are now\n`PAC_OUTCOME_UNKNOWN`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "$ref": "#/components/schemas/CfdiErrorResponse"
                    }
                  }
                },
                "examples": {
                  "pac_unavailable": {
                    "summary": "PAC unreachable; nothing was stamped",
                    "value": {
                      "message": {
                        "error": "El servicio de timbrado no está disponible en este momento. Vuelve a intentarlo en unos minutos. No se pudo contactar al PAC: connect ECONNREFUSED [pcs_1a2b3c]",
                        "code": "PAC_UNAVAILABLE",
                        "retryable": true
                      }
                    }
                  },
                  "pac_outcome_unknown": {
                    "summary": "PAC answer lost; retry with the same idempotency_key",
                    "value": {
                      "message": {
                        "error": "No se recibió la respuesta del servicio de timbrado; el comprobante podría estar timbrado. Se perdió la respuesta del PAC: The operation was aborted due to timeout [pcs_4d5e6f]",
                        "code": "PAC_OUTCOME_UNKNOWN",
                        "retryable": true
                      }
                    }
                  },
                  "pac_outcome_unknown_no_key": {
                    "summary": "PAC answer lost on a request without idempotency_key",
                    "value": {
                      "message": {
                        "error": "No se recibió la respuesta del servicio de timbrado; el comprobante podría estar timbrado. El PAC respondió 504 Gateway Timeout [pcs_7a8b9c]",
                        "code": "PAC_OUTCOME_UNKNOWN",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/invoices/income/batch": {
      "post": {
        "operationId": "createIncomeInvoiceBatch",
        "tags": [
          "Invoices"
        ],
        "summary": "Create a batch of income invoices",
        "description": "Accepts up to **1,000** income invoices in one request and stamps them in the background. Each item is\nexactly the body of `POST /invoices/income`, and must carry its own `idempotency_key`, unique within the\nbatch. To send more than 1,000 invoices, send more batches, each with its own `Idempotency-Key`.\n\n**What happens in the request.** Every item is validated against the `POST /invoices/income` body schema,\nwith no I/O. An invalid item is listed in `rejected` with its reason and the rest go ahead; only an empty\nor missing `invoices` array, or more than 1,000 items, refuses the whole request (`400`). The answer is\n`202` with the batch in `processing`; the first items may already have started.\n\n**What happens after.** Each accepted item is stamped by the same code as `POST /invoices/income`, with\nthe credential that created the batch, so it fails for the same reasons (a client that doesn't exist, a\nSAT rejection, the credit limit) and consumes one credit when stamped. A temporary failure (PAC\nunavailable, its answer lost) is retried automatically, up to 6 attempts per item. Items run about 10 at\na time per team. Follow the batch with `GET /invoices/income/batch/{id}`, or subscribe a webhook to\n`invoice_batch.completed` (body `InvoiceBatchCompletedWebhookEvent`, signed, sent once and never\nretried; see the `webhookEvent` callback of `POST /webhooks`), then read the per-item results with\n`GET /invoices/income/batch/{id}/items`.\n\n**Two levels of idempotency.**\n- The `Idempotency-Key` header names the **batch**. The batch id is derived from your team, the\n  credential's mode and the header, so the same key with the same body returns the same batch (`200`),\n  and nothing is created again. The same key with a different body is `409` `idempotency_key_reused`.\n  Bodies are compared as sent, including key order, so resend the exact same JSON.\n- Each item's `idempotency_key` names the **invoice**. It is the same key `POST /invoices/income` uses:\n  an invoice already issued under it, by an earlier batch or a single call, is not issued again, and the\n  item ends `duplicate`. So a new batch that repeats items of a previous one is safe.\n\n**gigstack Connect:** create the batch for a connected team with the `team` parameter, and read it with the\nsame `team`.\n\n**Mode.** `livemode` comes only from the credential: a test key creates a test batch.\n\nNot supported here: file uploads (CSV/XLSX), egress invoices and payment complements. If most of your\nsales are to the general public, the monthly global invoice (*factura global*) that gigstack already\nproduces may be all you need.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Your identifier for this batch, 8-128 characters of `A-Z a-z 0-9 . _ : -`. Reusing it with the same\nbody returns the batch it first created; reusing it with a different body is `409 idempotency_key_reused`.\n",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            },
            "example": "sales-2026-09-29-part-1"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceBatchCreateInput"
              },
              "example": {
                "invoices": [
                  {
                    "idempotency_key": "order-2026-09-000123",
                    "automation_type": "none",
                    "currency": "MXN",
                    "use": "G03",
                    "payment_form": "04",
                    "payment_method": "PUE",
                    "client": {
                      "id": "client_1234567890"
                    },
                    "items": [
                      {
                        "description": "Professional consulting services",
                        "product_key": "80141503",
                        "unit_key": "E48",
                        "unit_price": 1000,
                        "quantity": 1,
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false
                          }
                        ]
                      }
                    ],
                    "send_email": true
                  },
                  {
                    "idempotency_key": "order-2026-09-000124",
                    "automation_type": "none",
                    "currency": "MXN",
                    "use": "G03",
                    "payment_form": "03",
                    "payment_method": "PUE",
                    "client": {
                      "id": "client_0987654321"
                    },
                    "items": [
                      {
                        "description": "Annual support plan",
                        "product_key": "81111811",
                        "unit_key": "E48",
                        "unit_price": 2500,
                        "quantity": 1,
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Retry of an earlier request with the same `Idempotency-Key` and the same body: the batch it created,\nas it is now. Nothing is created again. If the first request died while writing the batch, this\nrequest finishes creating it.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicInvoiceBatch"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "ibatch_5d41402abc4b2a76b9719d911017c592",
                    "object": "invoice_batch",
                    "type": "income",
                    "livemode": true,
                    "status": "processing",
                    "result": null,
                    "total": 250,
                    "accepted": 248,
                    "rejected": [
                      {
                        "index": 17,
                        "idempotency_key": "order-2026-09-000140",
                        "error": {
                          "code": "invalid_body",
                          "message": "client_id: Unexpected field"
                        }
                      },
                      {
                        "index": 42,
                        "idempotency_key": "order-2026-09-000123",
                        "error": {
                          "code": "duplicate_idempotency_key",
                          "message": "idempotency_key is already used by item 0"
                        }
                      }
                    ],
                    "counts": {
                      "queued": 131,
                      "stamped": 115,
                      "failed": 1,
                      "duplicate": 1,
                      "needs_review": 0
                    },
                    "created_at": 1790780400000,
                    "completed_at": null
                  },
                  "timestamp": 1790781000000
                }
              }
            }
          },
          "202": {
            "description": "Batch created. `status` is `processing`; the accepted items are being stamped in the background.\nItems refused by validation are in `rejected` and will not be stamped. A batch in which every item\nwas rejected has nothing to stamp and is usually already `completed`, with `result: failed`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicInvoiceBatch"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "ibatch_5d41402abc4b2a76b9719d911017c592",
                    "object": "invoice_batch",
                    "type": "income",
                    "livemode": true,
                    "status": "processing",
                    "result": null,
                    "total": 250,
                    "accepted": 248,
                    "rejected": [
                      {
                        "index": 17,
                        "idempotency_key": "order-2026-09-000140",
                        "error": {
                          "code": "invalid_body",
                          "message": "client_id: Unexpected field"
                        }
                      },
                      {
                        "index": 42,
                        "idempotency_key": "order-2026-09-000123",
                        "error": {
                          "code": "duplicate_idempotency_key",
                          "message": "idempotency_key is already used by item 0"
                        }
                      }
                    ],
                    "counts": {
                      "queued": 248,
                      "stamped": 0,
                      "failed": 0,
                      "duplicate": 0,
                      "needs_review": 0
                    },
                    "created_at": 1790780400000,
                    "completed_at": null
                  },
                  "timestamp": 1790780401250
                }
              }
            }
          },
          "400": {
            "description": "The request was refused and no batch was created. `error.code`:\n\n- `invalid_request_body`: the `Idempotency-Key` header is missing or malformed.\n- `invalid_body`: the body is not `{ \"invoices\": [ … ] }` with at least one item.\n- `too_many_items`: more than 1,000 items. Split them into several batches.\n\nProblems with a single item don't refuse the request; they are listed in the batch's `rejected`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "examples": {
                  "missing_idempotency_key": {
                    "summary": "Idempotency-Key header missing",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Idempotency-Key header is required"
                      },
                      "timestamp": 1790780400000
                    }
                  },
                  "malformed_idempotency_key": {
                    "summary": "Idempotency-Key does not match the format",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Idempotency-Key must be 8-128 chars matching [A-Za-z0-9._:-]"
                      },
                      "timestamp": 1790780400000
                    }
                  },
                  "invalid_body": {
                    "summary": "No invoices array",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_body",
                        "message": "Body must be { \"invoices\": [ ... ] } with at least one invoice"
                      },
                      "timestamp": 1790780400000
                    }
                  },
                  "too_many_items": {
                    "summary": "More than 1,000 invoices",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "too_many_items",
                        "message": "A batch holds at most 1000 invoices; send the rest in more batches"
                      },
                      "timestamp": 1790780400000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Either the authentication layer refused the credential (raw body, see `AuthForbidden`), or a\nuser-scoped token (MCP, dashboard) lacks `editor` permission on invoices (standardized envelope,\n`forbidden`). API keys and OAuth tokens act as the team and are not role-checked.\n",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/StandardErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/AuthMiddlewareError"
                    }
                  ]
                },
                "examples": {
                  "missing_invoices_permission": {
                    "summary": "User-scoped token without editor permission on invoices",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "forbidden",
                        "message": "This action requires editor access to invoices"
                      },
                      "timestamp": 1790780400000
                    }
                  },
                  "revoked_api_key": {
                    "summary": "Authentication layer - API key revoked or disabled",
                    "value": {
                      "message": "API Key inválida.",
                      "details": "Invalid API Key"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`idempotency_key_reused`: the `Idempotency-Key` was already used with a **different body**. Nothing\nwas created. Send the new body under a new key; to read the original batch, use\n`GET /invoices/income/batch/{id}`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "idempotency_key_reused",
                    "message": "This Idempotency-Key was already used with a different body. Use a new key for a different batch."
                  },
                  "timestamp": 1790780400000
                }
              }
            }
          },
          "500": {
            "description": "Unexpected failure (`internal_server_error`). Retrying with the **same** `Idempotency-Key` and body\nis safe: it returns the batch if it was created, or creates it.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "internal_server_error",
                    "message": "An internal server error occurred"
                  },
                  "timestamp": 1790780400000
                }
              }
            }
          }
        }
      }
    },
    "/invoices/income/batch/{id}": {
      "get": {
        "operationId": "getIncomeInvoiceBatch",
        "tags": [
          "Invoices"
        ],
        "summary": "Get an income invoice batch",
        "description": "Returns the batch: the items rejected up front, and the progress of the accepted ones in `counts`. Poll it\nuntil `status` is `completed`, then read `result`, not `status`, to know how it went: `completed`\n(everything issued), `partially_completed` (some items have no invoice) or `failed` (none issued).\n\nFor each invoice's outcome, page through `GET /invoices/income/batch/{id}/items`.\n\nA batch of another team, or of the other mode (a live batch read with a test key), answers `404`.\nUnder gigstack Connect, send the same `team` the batch was created with.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Batch id, as returned by `POST /invoices/income/batch`.",
            "schema": {
              "type": "string"
            },
            "example": "ibatch_5d41402abc4b2a76b9719d911017c592"
          }
        ],
        "responses": {
          "200": {
            "description": "The batch.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicInvoiceBatch"
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "processing": {
                    "summary": "Still stamping",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "ibatch_5d41402abc4b2a76b9719d911017c592",
                        "object": "invoice_batch",
                        "type": "income",
                        "livemode": true,
                        "status": "processing",
                        "result": null,
                        "total": 250,
                        "accepted": 248,
                        "rejected": [
                          {
                            "index": 17,
                            "idempotency_key": "order-2026-09-000140",
                            "error": {
                              "code": "invalid_body",
                              "message": "client_id: Unexpected field"
                            }
                          },
                          {
                            "index": 42,
                            "idempotency_key": "order-2026-09-000123",
                            "error": {
                              "code": "duplicate_idempotency_key",
                              "message": "idempotency_key is already used by item 0"
                            }
                          }
                        ],
                        "counts": {
                          "queued": 131,
                          "stamped": 115,
                          "failed": 1,
                          "duplicate": 1,
                          "needs_review": 0
                        },
                        "created_at": 1790780400000,
                        "completed_at": null
                      },
                      "timestamp": 1790781000000
                    }
                  },
                  "partially_completed": {
                    "summary": "Finished, some items have no invoice",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "ibatch_5d41402abc4b2a76b9719d911017c592",
                        "object": "invoice_batch",
                        "type": "income",
                        "livemode": true,
                        "status": "completed",
                        "result": "partially_completed",
                        "total": 250,
                        "accepted": 248,
                        "rejected": [
                          {
                            "index": 17,
                            "idempotency_key": "order-2026-09-000140",
                            "error": {
                              "code": "invalid_body",
                              "message": "client_id: Unexpected field"
                            }
                          },
                          {
                            "index": 42,
                            "idempotency_key": "order-2026-09-000123",
                            "error": {
                              "code": "duplicate_idempotency_key",
                              "message": "idempotency_key is already used by item 0"
                            }
                          }
                        ],
                        "counts": {
                          "queued": 0,
                          "stamped": 245,
                          "failed": 2,
                          "duplicate": 1,
                          "needs_review": 0
                        },
                        "created_at": 1790780400000,
                        "completed_at": 1790784000000
                      },
                      "timestamp": 1790784060000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "No batch with this id in your team and mode (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "not_found",
                    "message": "Invoice batch not found"
                  },
                  "timestamp": 1790781000000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/income/batch/{id}/items": {
      "get": {
        "operationId": "listIncomeInvoiceBatchItems",
        "tags": [
          "Invoices"
        ],
        "summary": "List the items of an income invoice batch",
        "description": "One entry per **accepted** item, in request order (ascending `index`), with its status and, once issued,\nits invoice. Items rejected up front are not listed; they are in the batch's `rejected`.\n\nCursor pagination: pass `data.next` back as `next` while `data.has_more` is `true`. The cursor is the last\n`index` of the page, so pages never overlap or skip items while statuses change. Filter with `status`,\nfor example `status=failed` to list only what needs fixing.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Batch id.",
            "schema": {
              "type": "string"
            },
            "example": "ibatch_5d41402abc4b2a76b9719d911017c592"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items per page (default **100**, 1-500). Anything else is `400 invalid_limit`.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            },
            "example": 100
          },
          {
            "name": "next",
            "in": "query",
            "required": false,
            "description": "Cursor from the previous page's `data.next`. Omit for the first page. An invalid one is `400 invalid_cursor`.",
            "schema": {
              "type": "string"
            },
            "example": "99"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only items in this status. `queued` covers every item still in flight. Any other value is\n`400 invalid_status`. Omit for all items.\n",
            "schema": {
              "$ref": "#/components/schemas/InvoiceBatchItemStatusEnum"
            },
            "example": "failed"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of items. Note the nesting: the array is at `data.data`, the cursor at `data.next`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicInvoiceBatchItemsPage"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "data": [
                      {
                        "index": 0,
                        "idempotency_key": "order-2026-09-000123",
                        "status": "stamped",
                        "invoice_id": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                        "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                        "error": null,
                        "attempts": 1
                      },
                      {
                        "index": 1,
                        "idempotency_key": "order-2026-09-000124",
                        "status": "duplicate",
                        "invoice_id": "0f8fad5b-d9cb-469f-a165-70867728950e",
                        "uuid": "0f8fad5b-d9cb-469f-a165-70867728950e",
                        "error": null,
                        "attempts": 1
                      },
                      {
                        "index": 2,
                        "idempotency_key": "order-2026-09-000125",
                        "status": "failed",
                        "invoice_id": null,
                        "uuid": null,
                        "error": {
                          "code": "CFDI40147",
                          "message": "Error al timbrar la factura: CFDI40147 - El campo UsoCFDI no es válido [pcs_8f2a1c]"
                        },
                        "attempts": 1
                      },
                      {
                        "index": 3,
                        "idempotency_key": "order-2026-09-000126",
                        "status": "queued",
                        "invoice_id": null,
                        "uuid": null,
                        "error": null,
                        "attempts": 2
                      }
                    ],
                    "next": "3",
                    "has_more": true
                  },
                  "timestamp": 1790781000000
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is invalid. `error.code`: `invalid_limit`, `invalid_status` or `invalid_cursor`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "examples": {
                  "invalid_limit": {
                    "summary": "limit out of range",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_limit",
                        "message": "limit must be an integer between 1 and 500"
                      },
                      "timestamp": 1790781000000
                    }
                  },
                  "invalid_status": {
                    "summary": "Unknown status filter",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_status",
                        "message": "status must be one of queued, stamped, failed, duplicate, needs_review"
                      },
                      "timestamp": 1790781000000
                    }
                  },
                  "invalid_cursor": {
                    "summary": "Malformed cursor",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_cursor",
                        "message": "next is not a valid cursor"
                      },
                      "timestamp": 1790781000000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "No batch with this id in your team and mode (`not_found`). Checked before the query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "not_found",
                    "message": "Invoice batch not found"
                  },
                  "timestamp": 1790781000000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/income/{id}": {
      "get": {
        "operationId": "getInvoicesIncomeById",
        "tags": [
          "Invoices"
        ],
        "summary": "Get income invoice",
        "description": "Retrieve a specific income invoice by ID.\n\n**gigstack Connect:** Access other teams' invoices using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "SAT UUID (folio fiscal)",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        ],
        "responses": {
          "200": {
            "description": "Invoice retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Invoice retrieved successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicIncomeInvoice"
                    }
                  }
                },
                "example": {
                  "message": "Invoice retrieved successfully",
                  "data": {
                    "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                    "client": {
                      "id": "client_1234567890",
                      "name": "Juan Pérez García",
                      "email": "juan.perez@ejemplo.com",
                      "tax_id": "PEGJ800101ABC",
                      "from": "api",
                      "livemode": true,
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "status": "valid",
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "total": 1160,
                    "subtotal": 1000,
                    "taxes": 160,
                    "discount": 0,
                    "series": "A",
                    "folio_number": 123,
                    "invoice_type": "I",
                    "payment_method": "PUE",
                    "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx",
                    "created_at": 1677651234,
                    "livemode": true,
                    "owner": "user_1234567890"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/egress": {
      "get": {
        "operationId": "getInvoicesEgress",
        "tags": [
          "Invoices"
        ],
        "summary": "List egress invoices",
        "description": "Retrieve a paginated list of egress invoices with powerful filtering capabilities.\n\n**gigstack Connect:** Access other teams' invoices using the `team` parameter.\n\n**Filtering Options:**\n- Filter by creation date using comparison operators\n- Filter by `status`, `series`, `folio` and `idempotency_key` (exact match only)\n- Filter by metadata fields using dot or underscore notation (e.g., `metadata.order_id` or `metadata_order_id`)\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "$ref": "#/components/parameters/ClientIdFilterParam"
          },
          {
            "$ref": "#/components/parameters/TaxIdFilterParam"
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter by invoice status. `cancelled` is accepted as an alias of `canceled`.\n",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "valid",
                "canceled",
                "cancelled"
              ]
            }
          },
          {
            "name": "series",
            "in": "query",
            "description": "Filter by exact invoice series (no prefix matching).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "folio",
            "in": "query",
            "description": "Filter by exact folio number (no prefix matching).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idempotency_key",
            "in": "query",
            "description": "Filter by the exact idempotency key the invoice was created with.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metadata.{key}",
            "in": "query",
            "description": "Filter by any metadata field using dot notation (e.g., `metadata.order_id=ORD-123`)\nor underscore notation (e.g., `metadata_order_id=ORD-123`).\nBoth formats are supported and equivalent.\nUses Typesense search for efficient querying without requiring Firestore indexes.\n",
            "required": false,
            "schema": {
              "type": "string"
            },
            "style": "form"
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number for pagination when using metadata filters (default 1).\nOnly applies when filtering by metadata fields.\n",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invoices retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "success": true,
                  "message": "Invoices retrieved successfully",
                  "data": [
                    {
                      "uuid": "C1D2E3F4-2B3C-4D5E-8F9A-1234567890BC",
                      "idempotency_key": null,
                      "client": {
                        "id": "client_1234567890",
                        "name": "ESCUELA KEMPER URGATE",
                        "legal_name": "ESCUELA KEMPER URGATE",
                        "email": "contabilidad@ejemplo.com",
                        "bcc": [],
                        "phone": "+524421234567",
                        "tax_id": "EKU9003173C9",
                        "tax_system": "601",
                        "use": "G03",
                        "address": {
                          "street": "Av. Constituyentes",
                          "exterior": "1000",
                          "neighborhood": "Centro",
                          "city": "Querétaro",
                          "state": "QRO",
                          "zip": "76000",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "efos": {
                          "is_valid": true
                        },
                        "metadata": {},
                        "livemode": true,
                        "from": "api",
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      },
                      "created_at": 1767225600000,
                      "date": 1767225600000,
                      "currency": "MXN",
                      "exchange_rate": 1,
                      "total": 580,
                      "subtotal": 500,
                      "discount": 0,
                      "taxes": 80,
                      "withholding_taxes": 0,
                      "series": "NC",
                      "folio_number": 12,
                      "invoice_type": "E",
                      "use": "G02",
                      "payment_form": "03",
                      "payment_method": "PUE",
                      "livemode": true,
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "from": "api",
                      "status": "valid",
                      "payments": [],
                      "invoices": [],
                      "items": [
                        {
                          "id": "item_nc_001",
                          "description": "Bonificación por ajuste de servicio",
                          "quantity": 1,
                          "unit_price": 500,
                          "product_key": "84111506",
                          "unit_key": "ACT"
                        }
                      ],
                      "metadata": {},
                      "emails": [
                        "contabilidad@ejemplo.com"
                      ],
                      "cancellation": null,
                      "stamp": {
                        "sello": "kQ3xZ9vR2mP7tL4wN8cB1yH6",
                        "stamp_at": 1767225600000
                      },
                      "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=C1D2E3F4-2B3C-4D5E-8F9A-1234567890BC&re=MEE200101ABC&rr=EKU9003173C9&tt=580.00&fe=kQ3xZ9",
                      "related_documents": [
                        {
                          "relationship": "01",
                          "documents": [
                            "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
                          ]
                        }
                      ]
                    }
                  ],
                  "next": null,
                  "has_more": false,
                  "total_results": 1,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createInvoicesEgress",
        "tags": [
          "Invoices"
        ],
        "summary": "Create egress invoice",
        "description": "[Small working example](/recipes/credit-note)\n\n**Integration note:** A credit note adjusts the fiscal document. It does not refund money through a payment processor. Verified staging issuance returned HTTP 200 and data.uuid. Read [shared fields](/concepts/shared-fields) and the [Mexico](/countries/mexico) or [Colombia](/countries/colombia) guide for country-specific meaning. The linked fiscal recipes and staging issuance results use a Mexican issuer.\n\nCreate a new egress invoice (expense/credit note) with CFDI 4.0 compliance.\n\n**gigstack Connect:** Create invoices for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceEgressInput"
              },
              "example": {
                "automation_type": "none",
                "currency": "MXN",
                "use": "G03",
                "payment_form": "03",
                "client": {
                  "id": "client_1234567890"
                },
                "items": [
                  {
                    "quantity": 1,
                    "description": "Purchased materials",
                    "sku": "MAT-001",
                    "product_key": "80141503",
                    "unit_key": "E48",
                    "unit_name": "Unidad",
                    "unit_price": 500,
                    "taxability": "02",
                    "taxes": [
                      {
                        "type": "IVA",
                        "rate": 0.16,
                        "factor": "Tasa",
                        "withholding": false,
                        "inclusive": false
                      }
                    ]
                  }
                ],
                "send_email": true,
                "emails": [
                  "proveedor@empresa.com"
                ],
                "metadata": {
                  "purchase_order": "PO-2024-001",
                  "department": "procurement"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invoice created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Invoice created successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicIncomeInvoice"
                    }
                  }
                },
                "example": {
                  "message": "Invoice created successfully",
                  "data": {
                    "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                    "client": {
                      "id": "client_1234567890",
                      "name": "Proveedor ABC SA",
                      "email": "proveedor@empresa.com",
                      "tax_id": "PABC800101ABC",
                      "from": "api",
                      "livemode": true,
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "status": "valid",
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "total": 580,
                    "subtotal": 500,
                    "taxes": 80,
                    "discount": 0,
                    "series": "E",
                    "folio_number": 123,
                    "invoice_type": "E",
                    "items": [
                      {
                        "id": "item_1234567890",
                        "description": "Purchased materials",
                        "quantity": 1,
                        "unit_price": 500,
                        "product_key": "80141503",
                        "unit_key": "E48"
                      }
                    ],
                    "created_at": 1677651234,
                    "livemode": true,
                    "owner": "user_1234567890"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request. All bodies here are **raw**, not the standardized envelope.\n- Body validation: `{ \"message\": \"Invalid body\", \"errors\": [ { \"path\": …, \"code\": …, \"message\": … } ] }`.\n  Unknown keys are rejected — there is no `client_id` field; use `client: { \"id\": … }`.\n- `{ \"message\": \"Billing account not found\", \"error\": \"Billing account is required\" }`\n- `{ \"message\": \"Invalid currency\", \"error\": … }`\n- `{ \"message\": \"Exchange rate not found\" }`\n- `{ \"message\": \"Resource resolution failed\", \"error\": … }` when the client/service\n  reference is ambiguous (both `id` and `search`, or `safety_check` matched several).\n- Generic CFDI/PAC stamping failure, nested one level under `message`:\n  `{ \"message\": { \"error\": …, \"code\": …, \"providerMessage\": …, \"retryable\": false } }`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/LegacyErrorResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "message": {
                          "$ref": "#/components/schemas/CfdiErrorResponse"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Raw shape with only a `message` key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The referenced client or service belongs to another team, or its `livemode` does\nnot match the API key. Raw shape `{ \"message\": \"Resource resolution failed\", \"error\": … }`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "The referenced client or service id was not found. Raw shape.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A concurrent create holds the lock for the same client or service. Retry the\nrequest. Raw shape.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "412": {
            "description": "**SAT not connected.** The team has no valid CSD, or the certificate failed\nvalidation. Returned in the CFDI error shape nested under `message`, with\n`retryable: false`. Upload a CSD via `POST /v2/teams/{id}/sat-connection`\nbefore retrying — retrying as-is will fail identically.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "$ref": "#/components/schemas/CfdiErrorResponse"
                    }
                  }
                },
                "example": {
                  "message": {
                    "error": "El certificado de sello digital (CSD) no está configurado o no es válido.",
                    "code": "csd_validation_error",
                    "retryable": false
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error. Raw shape — either\n`{ \"message\": \"Failed to save invoice\", \"error\": { \"code\": \"invoice_save_error\", … } }`\nor `{ \"message\": \"An error occurred while creating invoice\", \"error\": { \"code\": …, \"message\": … } }`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "**PAC unavailable.** The stamping provider could not be reached. Returned in the\nCFDI error shape nested under `message`, with `retryable: true` — this is the only\nCFDI failure that is safe to retry unchanged. Wait a few minutes and retry with\nthe same `idempotency_key`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "$ref": "#/components/schemas/CfdiErrorResponse"
                    }
                  }
                },
                "example": {
                  "message": {
                    "error": "El servicio de timbrado no está disponible en este momento. Vuelve a intentarlo en unos minutos.",
                    "code": "pac_unavailable",
                    "retryable": true
                  }
                }
              }
            }
          }
        }
      }
    },
    "/invoices/egress/{id}": {
      "get": {
        "operationId": "getInvoicesEgressById",
        "tags": [
          "Invoices"
        ],
        "summary": "Get egress invoice",
        "description": "Retrieve a specific egress invoice by ID.\n\n**gigstack Connect:** Access other teams' invoices using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "SAT UUID (folio fiscal)",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        ],
        "responses": {
          "200": {
            "description": "Invoice retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Invoice retrieved successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicIncomeInvoice"
                    }
                  }
                },
                "example": {
                  "message": "Invoice retrieved successfully",
                  "data": {
                    "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                    "client": {
                      "id": "client_1234567890",
                      "name": "Proveedor ABC SA",
                      "email": "proveedor@empresa.com",
                      "tax_id": "PABC800101ABC",
                      "from": "api",
                      "livemode": true,
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "status": "valid",
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "total": 580,
                    "subtotal": 500,
                    "taxes": 80,
                    "discount": 0,
                    "series": "E",
                    "folio_number": 123,
                    "invoice_type": "E",
                    "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx",
                    "created_at": 1677651234,
                    "livemode": true,
                    "owner": "user_1234567890"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/transfer": {
      "get": {
        "operationId": "getInvoicesTransfer",
        "tags": [
          "Invoices"
        ],
        "summary": "List transfer invoices",
        "description": "Retrieve a paginated list of transfer invoices (CFDI type T - Traslado with Carta Porte).\n\n**gigstack Connect:** Access other teams' invoices using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "name": "metadata.{key}",
            "in": "query",
            "description": "Filter by any metadata field using dot notation (e.g., `metadata.order_id=ORD-123`)\nor underscore notation (e.g., `metadata_order_id=ORD-123`).\nBoth formats are supported and equivalent.\nUses Typesense search for efficient querying without requiring Firestore indexes.\n",
            "required": false,
            "schema": {
              "type": "string"
            },
            "style": "form"
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number for pagination when using metadata filters (default 1).\nOnly applies when filtering by metadata fields.\n",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer invoices retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "postInvoicesTransfer",
        "tags": [
          "Invoices"
        ],
        "summary": "Create transfer invoice (Carta Porte)",
        "description": "Stamp a CFDI type T (traslado) with the Carta Porte 3.1 complement, for moving goods by road\n(autotransporte).\n\n- The comprobante is fixed by the SAT: `Moneda` XXX, `Total` 0, `UsoCFDI` S01, no `MetodoPago`.\n  `currency`, `use`, `payment_method` and `payment_form` are ignored if sent.\n- There are no `items`: the CFDI conceptos are built from `carta_porte.Mercancias.Mercancia`.\n- `carta_porte` uses the SAT attribute names from CartaPorte31.xsd. Numbers may be sent as\n  numbers or numeric strings.\n- At least one `Origen` and one `Destino`; every `Destino` needs `DistanciaRecorrida`.\n  `DistanciaRecorrida` is dropped from the `Origen`.\n- `FiguraTransporte` is required (for `TipoFigura` 01, the operator, send `NumLicencia`).\n- The series defaults to `T`.\n- Only teams stamping through gigstack's own PAC (CSD uploaded) can use this endpoint.\n\nStamping is irreversible. Use a test API key to try it without fiscal effect.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "client",
                  "carta_porte"
                ],
                "properties": {
                  "client": {
                    "description": "Client reference (receptor). Same format as income invoices.",
                    "type": "object"
                  },
                  "carta_porte": {
                    "type": "object",
                    "required": [
                      "TranspInternac",
                      "TotalDistRec",
                      "Ubicaciones",
                      "Mercancias",
                      "Autotransporte",
                      "FiguraTransporte"
                    ],
                    "properties": {
                      "TranspInternac": {
                        "type": "string",
                        "enum": [
                          "Sí",
                          "No"
                        ]
                      },
                      "EntradaSalidaMerc": {
                        "type": "string",
                        "enum": [
                          "Entrada",
                          "Salida"
                        ]
                      },
                      "PaisOrigenDestino": {
                        "type": "string"
                      },
                      "ViaEntradaSalida": {
                        "type": "string"
                      },
                      "TotalDistRec": {
                        "type": "number"
                      },
                      "Ubicaciones": {
                        "type": "array",
                        "minItems": 2,
                        "items": {
                          "type": "object"
                        }
                      },
                      "Mercancias": {
                        "type": "object"
                      },
                      "Autotransporte": {
                        "type": "object"
                      },
                      "FiguraTransporte": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                          "type": "object"
                        }
                      }
                    }
                  },
                  "series": {
                    "type": "string"
                  },
                  "folio_number": {
                    "type": "number"
                  },
                  "date": {
                    "type": "number",
                    "description": "Unix epoch milliseconds"
                  },
                  "idempotency_key": {
                    "type": "string"
                  },
                  "related_documents": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "metadata": {
                    "type": "object"
                  },
                  "send_email": {
                    "type": "boolean"
                  },
                  "emails": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "email"
                    }
                  },
                  "return_files": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "client": {
                  "id": "client_1234567890"
                },
                "carta_porte": {
                  "TranspInternac": "No",
                  "TotalDistRec": 120,
                  "Ubicaciones": [
                    {
                      "TipoUbicacion": "Origen",
                      "RFCRemitenteDestinatario": "EKU9003173C9",
                      "NombreRemitenteDestinatario": "ESCUELA KEMPER URGATE",
                      "FechaHoraSalidaLlegada": "2026-10-06T09:00:00",
                      "Domicilio": {
                        "Pais": "MEX",
                        "CodigoPostal": "42501",
                        "Estado": "HID"
                      }
                    },
                    {
                      "TipoUbicacion": "Destino",
                      "RFCRemitenteDestinatario": "EKU9003173C9",
                      "NombreRemitenteDestinatario": "ESCUELA KEMPER URGATE",
                      "FechaHoraSalidaLlegada": "2026-10-06T13:00:00",
                      "DistanciaRecorrida": 120,
                      "Domicilio": {
                        "Pais": "MEX",
                        "CodigoPostal": "03020",
                        "Estado": "CMX"
                      }
                    }
                  ],
                  "Mercancias": {
                    "PesoBrutoTotal": 12.5,
                    "UnidadPeso": "KGM",
                    "NumTotalMercancias": 1,
                    "Mercancia": [
                      {
                        "BienesTransp": "50202203",
                        "Descripcion": "Bebida embotellada",
                        "Cantidad": 10,
                        "ClaveUnidad": "XBO",
                        "PesoEnKg": 12.5
                      }
                    ]
                  },
                  "Autotransporte": {
                    "PermSCT": "TPAF01",
                    "NumPermisoSCT": "0X2XTXZ0X5X0X3X2X1X0",
                    "IdentificacionVehicular": {
                      "ConfigVehicular": "VL",
                      "PlacaVM": "ABC1234",
                      "AnioModeloVM": 2022,
                      "PesoBrutoVehicular": 3
                    },
                    "Seguros": {
                      "AseguraRespCivil": "SEGUROS SA",
                      "PolizaRespCivil": "123456"
                    }
                  },
                  "FiguraTransporte": [
                    {
                      "TipoFigura": "01",
                      "RFCFigura": "VAAM130719H60",
                      "NombreFigura": "OPERADOR",
                      "NumLicencia": "a234567890"
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transfer invoice stamped",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Transfer invoice created"
                    },
                    "data": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body or Carta Porte rule (e.g. missing DistanciaRecorrida on a Destino)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/transfer/{id}": {
      "get": {
        "operationId": "getInvoicesTransferById",
        "tags": [
          "Invoices"
        ],
        "summary": "Get transfer invoice",
        "description": "Retrieve a specific transfer invoice by ID (CFDI type T - Traslado).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer invoice retrieved successfully"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Invoice not found"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/payment": {
      "get": {
        "operationId": "getInvoicesPayment",
        "tags": [
          "Invoices"
        ],
        "summary": "List payment complement invoices",
        "description": "Retrieve a paginated list of payment complement invoices (CFDI type P - Complemento de Pago).\n\nPayment complements are used for PPD (Pago en Parcialidades o Diferido) invoices to register partial or deferred payments.\n\n**gigstack Connect:** Access other teams' invoices using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "name": "idempotency_key",
            "in": "query",
            "description": "Filter by the exact idempotency key the payment complement was created with.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "metadata.{key}",
            "in": "query",
            "description": "Filter by any metadata field using dot notation (e.g., `metadata.order_id=ORD-123`)\nor underscore notation (e.g., `metadata_order_id=ORD-123`).\nBoth formats are supported and equivalent.\nUses Typesense search for efficient querying without requiring Firestore indexes.\n",
            "required": false,
            "schema": {
              "type": "string"
            },
            "style": "form"
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page number for pagination when using metadata filters (default 1).\nOnly applies when filtering by metadata fields.\n",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payment complement invoices retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "success": true,
                  "message": "Invoices retrieved successfully",
                  "data": [
                    {
                      "uuid": "D2E3F4A5-3C4D-4E5F-9A0B-234567890CDE",
                      "idempotency_key": null,
                      "client": {
                        "id": "client_1234567890",
                        "name": "ESCUELA KEMPER URGATE",
                        "legal_name": "ESCUELA KEMPER URGATE",
                        "email": "contabilidad@ejemplo.com",
                        "bcc": [],
                        "phone": "+524421234567",
                        "tax_id": "EKU9003173C9",
                        "tax_system": "601",
                        "use": "G03",
                        "address": {
                          "street": "Av. Constituyentes",
                          "exterior": "1000",
                          "neighborhood": "Centro",
                          "city": "Querétaro",
                          "state": "QRO",
                          "zip": "76000",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "efos": {
                          "is_valid": true
                        },
                        "metadata": {},
                        "livemode": true,
                        "from": "api",
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      },
                      "created_at": 1767225600000,
                      "date": 1767225600000,
                      "currency": "XXX",
                      "exchange_rate": 1,
                      "total": 0,
                      "subtotal": 0,
                      "discount": 0,
                      "taxes": 0,
                      "withholding_taxes": 0,
                      "series": "P",
                      "folio_number": 45,
                      "invoice_type": "P",
                      "use": "CP01",
                      "livemode": true,
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "from": "api",
                      "status": "valid",
                      "payments": [],
                      "invoices": [],
                      "items": [
                        {
                          "id": "item_pago",
                          "description": "Pago",
                          "quantity": 1,
                          "unit_price": 0,
                          "product_key": "84111506",
                          "unit_key": "ACT"
                        }
                      ],
                      "metadata": {},
                      "emails": [
                        "contabilidad@ejemplo.com"
                      ],
                      "cancellation": null,
                      "stamp": {
                        "sello": "kQ3xZ9vR2mP7tL4wN8cB1yH6",
                        "stamp_at": 1767225600000
                      },
                      "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=D2E3F4A5-3C4D-4E5F-9A0B-234567890CDE&re=MEE200101ABC&rr=EKU9003173C9&tt=0.00&fe=kQ3xZ9",
                      "related_documents": []
                    }
                  ],
                  "next": null,
                  "has_more": false,
                  "total_results": 1,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createInvoicesPayment",
        "tags": [
          "Invoices"
        ],
        "summary": "Create payment complement (complemento de pago)",
        "description": "Stamp a CFDI type \"P\" payment complement (complemento de pago, Pagos 2.0) that\nregisters one or more payments against PPD (Pago en Parcialidades o Diferido) invoices.\n\nEach entry in `complements[].data` is a payment. Each payment links one or more PPD\ninvoices through `related_documents`, supplying the amount paid, the installment number\nand the previous balance so the SAT can compute the remaining balance.\n\n**Fixed by the SAT** and therefore not required in the body: the comprobante currency\n(`XXX`), the receptor `UsoCFDI` (`CP01`), and the line concept. The per-payment currency\nlives in each payment's `currency` field. The series defaults to the team's payments\nseries (`invoice_serie_payments`).\n\n**gigstack Connect:** Create for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentComplementInput"
              },
              "example": {
                "client": {
                  "id": "client_1234567890"
                },
                "date": 1784915988000,
                "complements": [
                  {
                    "type": "pago",
                    "data": [
                      {
                        "payment_form": "03",
                        "date": "2026-07-24T12:00:00",
                        "currency": "MXN",
                        "exchange": 1,
                        "related_documents": [
                          {
                            "uuid": "A1B2C3D4-E5F6-7890-ABCD-1234567890AB",
                            "amount": 116,
                            "installment": 1,
                            "last_balance": 116,
                            "currency": "MXN",
                            "taxes": [
                              {
                                "base": 100,
                                "rate": "0.16",
                                "factor": "Tasa",
                                "type": "IVA",
                                "withholding": false,
                                "inclusive": false
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ],
                "return_files": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment complement created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Payment complement created"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicIncomeInvoice"
                    }
                  }
                },
                "example": {
                  "message": "Payment complement created",
                  "data": {
                    "uuid": "D2E3F4A5-3C4D-4E5F-9A0B-234567890CDE",
                    "idempotency_key": null,
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "created_at": 1767225600000,
                    "date": 1767225600000,
                    "currency": "XXX",
                    "exchange_rate": 1,
                    "total": 0,
                    "subtotal": 0,
                    "discount": 0,
                    "taxes": 0,
                    "withholding_taxes": 0,
                    "series": "P",
                    "folio_number": 45,
                    "invoice_type": "P",
                    "use": "CP01",
                    "livemode": true,
                    "owner": "user_1234567890",
                    "team": "team_1234567890",
                    "from": "api",
                    "status": "valid",
                    "payments": [],
                    "invoices": [],
                    "items": [
                      {
                        "id": "item_pago",
                        "description": "Pago",
                        "quantity": 1,
                        "unit_price": 0,
                        "product_key": "84111506",
                        "unit_key": "ACT"
                      }
                    ],
                    "metadata": {},
                    "emails": [
                      "contabilidad@ejemplo.com"
                    ],
                    "cancellation": null,
                    "stamp": {
                      "sello": "kQ3xZ9vR2mP7tL4wN8cB1yH6",
                      "stamp_at": 1767225600000
                    },
                    "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=D2E3F4A5-3C4D-4E5F-9A0B-234567890CDE&re=MEE200101ABC&rr=EKU9003173C9&tt=0.00&fe=kQ3xZ9",
                    "related_documents": []
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/payment/{id}": {
      "get": {
        "operationId": "getInvoicesPaymentById",
        "tags": [
          "Invoices"
        ],
        "summary": "Get payment complement invoice",
        "description": "Retrieve a specific payment complement invoice by ID (CFDI type P - Complemento de Pago).\n\nPayment complements contain details about payments made against PPD invoices, including:\n- Payment amounts and dates\n- Payment method and form\n- Related PPD invoices\n- Tax calculations on payments\n\n**gigstack Connect:** Access other teams' invoices using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "SAT UUID (folio fiscal)",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        ],
        "responses": {
          "200": {
            "description": "Payment complement invoice retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Invoice retrieved successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicIncomeInvoice"
                    }
                  }
                },
                "example": {
                  "message": "Invoice retrieved successfully",
                  "data": {
                    "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                    "client": {
                      "id": "client_1234567890",
                      "name": "Juan Pérez García",
                      "email": "juan.perez@example.com",
                      "tax_id": "PEGJ800101ABC",
                      "from": "api",
                      "livemode": true,
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "status": "valid",
                    "currency": "XXX",
                    "exchange_rate": 1,
                    "total": 0,
                    "subtotal": 0,
                    "taxes": 0,
                    "discount": 0,
                    "series": "CP",
                    "folio_number": 456,
                    "invoice_type": "P",
                    "payment_method": "PPD",
                    "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx",
                    "created_at": 1677651234,
                    "livemode": true,
                    "owner": "user_1234567890"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Invoice not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/{id}/files": {
      "get": {
        "operationId": "getInvoicesByIdFiles",
        "tags": [
          "Invoices"
        ],
        "summary": "Get invoice files",
        "description": "Get XML and PDF files for an invoice.\n\n**gigstack Connect:** Access other teams' invoice files using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "SAT UUID (folio fiscal)",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          },
          {
            "name": "file_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "pdf",
                "xml"
              ]
            },
            "description": "Type of file to retrieve. If not specified, returns both PDF and XML files"
          }
        ],
        "responses": {
          "200": {
            "description": "Files as base64 content, not URLs. Raw body (no `success`/`timestamp`). `file_type=pdf|xml` returns only that file.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "message"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "content": {
                            "type": "string",
                            "description": "Base64-encoded file content"
                          },
                          "filename": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "application/pdf",
                              "application/xml"
                            ]
                          }
                        }
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "content": "JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9UeXBlIC9DYXRhbG9nPj4K...",
                      "filename": "Yx7Kp2Lm9Qw4Rt6Bn1Vc.pdf",
                      "type": "application/pdf"
                    },
                    {
                      "content": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4K...",
                      "filename": "Yx7Kp2Lm9Qw4Rt6Bn1Vc.xml",
                      "type": "application/xml"
                    }
                  ],
                  "message": "Files retrieved successfully"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/{id}/send": {
      "post": {
        "operationId": "createInvoicesByIdSend",
        "tags": [
          "Invoices"
        ],
        "summary": "Resend invoice email",
        "description": "Resend an invoice email (PDF + XML attachments) to the client and/or additional recipients.\n\nThe client's email on the invoice is always included. Extra recipients can be added via the `emails` field.\n\n**gigstack Connect:** Send other teams' invoice emails using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Invoice UUID or gigstack invoice ID",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "emails": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "email"
                    },
                    "description": "Additional email recipients beyond the client email on the invoice",
                    "example": [
                      "accounting@example.com"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invoice email sent successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Invoice email sent successfully"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "recipients": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "uuid": {
                          "type": "string"
                        },
                        "attachments": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "message": "Invoice email sent successfully",
                  "data": {
                    "recipients": [
                      "contabilidad@ejemplo.com"
                    ],
                    "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                    "attachments": [
                      "Yx7Kp2Lm9Qw4Rt6Bn1Vc.pdf",
                      "Yx7Kp2Lm9Qw4Rt6Bn1Vc.xml"
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request (cancelled invoice or no recipients)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Invoice not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      }
    },
    "/invoices/{id}/pdf-details": {
      "put": {
        "operationId": "updateInvoicesByIdPdfDetails",
        "tags": [
          "Invoices"
        ],
        "summary": "Edit an invoice's PDF notes and fields (Colombia)",
        "description": "**Colombia (DIAN) only.** Edits what the PDF prints that is not fiscal: the note under each item and\nthe invoice's `pdf_fields` (label/value pairs such as a purchase order number). The stamped document\nis not touched: nothing is sent to Factus or the DIAN.\n\nWhen the team uses the PDF gigstack draws, the stored PDF (the one emails and the portal serve) is\ndrawn again from the stamped XML and `pdf_regenerated` is `true`. Downloads always draw the current\ndetails.\n\n- `items` lines up with the invoice's items by position and must have one entry per item. A `null` or\n  empty `note` removes that item's note.\n- `pdf_fields` replaces the invoice's fields; `null` or `[]` removes them. An entry with the same label\n  as a team-wide field replaces its value, and an empty value hides it on this invoice.\n\nSend `items`, `pdf_fields`, or both.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "gigstack invoice ID"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "note": {
                          "type": "string",
                          "nullable": true,
                          "maxLength": 1000
                        }
                      }
                    }
                  },
                  "pdf_fields": {
                    "type": "array",
                    "nullable": true,
                    "maxItems": 10,
                    "items": {
                      "type": "object",
                      "required": [
                        "label"
                      ],
                      "properties": {
                        "label": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 60
                        },
                        "value": {
                          "type": "string",
                          "nullable": true,
                          "maxLength": 300
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "items": [
                  {
                    "note": "Licencias para 7 colaboradores, vigencia 12 meses"
                  }
                ],
                "pdf_fields": [
                  {
                    "label": "Número de compra",
                    "value": "OC-1042"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Details saved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "note": {
                            "type": "string",
                            "nullable": true
                          }
                        }
                      }
                    },
                    "pdf_fields": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "label": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "pdf_regenerated": {
                      "type": "boolean",
                      "description": "True when the stored PDF was drawn again with the new details"
                    },
                    "pdf_message": {
                      "type": "string",
                      "description": "Why the stored PDF was not drawn again, when it was not"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, item count mismatch, or not a Colombian invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Invoice not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      }
    },
    "/invoices/{id}/support-documents": {
      "post": {
        "operationId": "createInvoicesByIdSupportDocuments",
        "tags": [
          "Invoices"
        ],
        "summary": "Upload an invoice support document",
        "description": "Upload a supporting document (contract, proof of delivery, etc.) for an invoice.\n\n**SAT 2026 Compliance:** The Mexican tax authority (SAT) can request supporting documentation\nto validate invoices. This endpoint helps maintain compliance.\n\n**gigstack Connect:** Upload documents for other teams' invoices using the `team` parameter.\n\n**Supported File Types:**\n- PDF files (.pdf)\n- Images (.png, .jpg, .jpeg, .webp)\n\n**File Size Limit:** 10MB\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "SAT UUID (folio fiscal)",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/UploadSupportDocumentInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Document uploaded. Standardized envelope (`timestamp` in epoch ms).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/SATDocument"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "doc_1234567890",
                    "document_type": "contract",
                    "name": "Contrato de servicios 2026",
                    "description": null,
                    "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_1234567890%2Fdocuments%2Fcontrato-2026.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                    "file_name": "contrato-2026.pdf",
                    "file_size": 284913,
                    "mime_type": "application/pdf",
                    "compliance_status": "pending_review",
                    "created_at": 1767225600000,
                    "linked_entities": [
                      {
                        "entity_type": "invoice",
                        "entity_id": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                        "linked_at": 1767225600000
                      }
                    ]
                  },
                  "message": "Support document uploaded successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Invoice not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "getInvoicesByIdSupportDocuments",
        "tags": [
          "Invoices"
        ],
        "summary": "List an invoice's support documents",
        "description": "Retrieve all supporting documents attached to an invoice.\n\n**gigstack Connect:** View documents for other teams' invoices using the `team` parameter.\n\nDocuments are returned sorted by creation date (newest first).\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "SAT UUID (folio fiscal)",
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        ],
        "responses": {
          "200": {
            "description": "Documents retrieved, newest first. Standardized envelope (`timestamp` in epoch ms).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SATDocument"
                      }
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": [
                    {
                      "id": "doc_1234567890",
                      "document_type": "contract",
                      "name": "Contrato de servicios 2026",
                      "description": null,
                      "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_1234567890%2Fdocuments%2Fcontrato-2026.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                      "file_name": "contrato-2026.pdf",
                      "file_size": 284913,
                      "mime_type": "application/pdf",
                      "compliance_status": "pending_review",
                      "created_at": 1767225600000,
                      "linked_entities": [
                        {
                          "entity_type": "invoice",
                          "entity_id": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                          "linked_at": 1767225600000
                        }
                      ]
                    }
                  ],
                  "message": "Support documents retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Invoice not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      }
    },
    "/invoices/{id}": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "summary": "Get invoice",
        "operationId": "getInvoiceById",
        "description": "Retrieve any invoice by id, regardless of its CFDI type. The type-specific routes\n(`/invoices/income/{id}`, `/invoices/egress/{id}`, `/invoices/payment/{id}`) share this\nhandler but additionally assert the document's type and return `400` on a mismatch;\nthis route performs no type check.\n\n**gigstack Connect:** Access other teams' invoices using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "SAT UUID (folio fiscal).",
            "schema": {
              "type": "string"
            },
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        ],
        "responses": {
          "200": {
            "description": "Invoice retrieved. **Raw legacy shape** — `{ \"message\": …, \"data\": … }`, with no\n`success` or `timestamp`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data"
                  ],
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Invoice retrieved successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicIncomeInvoice"
                    }
                  }
                },
                "example": {
                  "message": "Invoice retrieved successfully",
                  "data": {
                    "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                    "idempotency_key": null,
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "created_at": 1767225600000,
                    "date": 1767225600000,
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "total": 1160,
                    "subtotal": 1000,
                    "discount": 0,
                    "taxes": 160,
                    "withholding_taxes": 0,
                    "series": "A",
                    "folio_number": 123,
                    "invoice_type": "I",
                    "use": "G03",
                    "payment_form": "03",
                    "payment_method": "PUE",
                    "livemode": true,
                    "owner": "user_1234567890",
                    "team": "team_1234567890",
                    "from": "api",
                    "status": "valid",
                    "payments": [
                      "payment_1234567890"
                    ],
                    "invoices": [],
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicios de consultoría profesional",
                        "quantity": 1,
                        "unit_price": 1000,
                        "product_key": "80141503",
                        "unit_key": "E48"
                      }
                    ],
                    "metadata": {},
                    "emails": [
                      "contabilidad@ejemplo.com"
                    ],
                    "cancellation": null,
                    "stamp": {
                      "sello": "kQ3xZ9vR2mP7tL4wN8cB1yH6",
                      "stamp_at": 1767225600000
                    },
                    "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB&re=MEE200101ABC&rr=EKU9003173C9&tt=1160.00&fe=kQ3xZ9"
                  }
                }
              }
            }
          },
          "400": {
            "description": "`{ \"message\": \"Missing id param\" }`, or on the type-specific routes `{ \"error\": \"Invoice type does not match\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Raw shape with only a `message` key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "`{ \"message\": \"Forbidden: invoices is not owned by the team\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "`{ \"error\": \"Invoice data not found\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "`{ \"error\": \"Failed to get invoice due to unknown error. Please try again later.\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Invoices"
        ],
        "summary": "Cancel invoice (deprecated DELETE)",
        "operationId": "cancelInvoice",
        "deprecated": true,
        "description": "[Small working example](/recipes/cancellation)\n\n**Integration note:** This recipe covers Mexican CFDI cancellation. A provider acknowledgment does not prove final cancellation. Read the invoice and confirm its persisted status; public nested cancellation fields can be absent. Colombian annulment uses different semantics.\n\n**Deprecated:** use [`POST /invoices/{id}/cancel`](/reference/cancelInvoiceById), which runs the same handler and takes the same body. Some HTTP clients and proxies drop the body of a DELETE request.\nThis route keeps working; its responses carry `Deprecation: true` and `Link: </v2/invoices/{id}/cancel>; rel=\"successor-version\"`, with the\nconcrete ID in place of each path parameter.\n\nCancel a specific invoice with SAT.\n\n**gigstack Connect:** Cancel other teams' invoices using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "SAT UUID (folio fiscal).",
            "schema": {
              "type": "string"
            },
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "motive"
                ],
                "properties": {
                  "motive": {
                    "type": "string",
                    "enum": [
                      "01",
                      "02",
                      "03",
                      "04"
                    ],
                    "example": "02",
                    "description": "SAT cancellation motive (`c_MotivoCancelacion`): `01` issued with errors, with a\nsubstitute CFDI (send `substitution_uuid`); `02` issued with errors, no substitute;\n`03` the operation did not take place; `04` nominative operation included in a global\ninvoice. The API only checks that the value is at most two characters; any other value\nis rejected by the SAT/PAC at cancellation time.\n"
                  },
                  "substitution_uuid": {
                    "type": "string",
                    "nullable": true,
                    "example": "12345678-1234-1234-1234-123456789012",
                    "description": "UUID of the substituting invoice (required for motive 01)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cancellation accepted by the PAC. **Raw shape** — the PAC's cancellation\nresponse is spread at the top level alongside `cancellation_status`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "cancellation_status"
                  ],
                  "additionalProperties": true,
                  "properties": {
                    "cancellation_status": {
                      "type": "string",
                      "description": "Cancellation state reported by SAT.",
                      "example": "cancelled"
                    }
                  }
                },
                "example": {
                  "cancellation_status": "cancelled"
                }
              }
            }
          },
          "400": {
            "description": "Body validation failure — `{ \"message\": [ …validation errors… ] }` — or a generic\nCFDI/PAC cancellation error in the CFDI error shape (spread at the top level on\nthis operation, not nested under `message`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/LegacyErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/CfdiErrorResponse"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Raw shape with only a `message` key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "`{ \"message\": \"Livemode mismatch: API key and invoice must be in the same mode\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "`{ \"message\": \"Invoice not found\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "412": {
            "description": "SAT not connected — the team has no valid CSD, or the certificate failed\nvalidation. Returned in the CFDI error shape with `retryable: false`.\nUpload a CSD via `POST /v2/teams/{id}/sat-connection` before retrying.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CfdiErrorResponse"
                },
                "example": {
                  "error": "El certificado de sello digital (CSD) no está configurado o no es válido.",
                  "code": "csd_validation_error",
                  "retryable": false
                }
              }
            }
          },
          "422": {
            "description": "The invoice was imported and stamped by an external PAC, so gigstack cannot\ncancel it. Cancel it through the original PAC provider instead.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                },
                "example": {
                  "message": "Imported invoices stamped by an external PAC cannot be canceled through gigstack. Please cancel through your original PAC provider."
                }
              }
            }
          },
          "500": {
            "description": "`{ \"error\": \"Internal server error\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "The PAC is unavailable. CFDI error shape with `retryable: true` — retry after a\nshort delay.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CfdiErrorResponse"
                },
                "example": {
                  "error": "El servicio de timbrado no está disponible en este momento. Vuelve a intentarlo en unos minutos.",
                  "code": "pac_unavailable",
                  "retryable": true
                }
              }
            }
          }
        }
      }
    },
    "/invoices/{id}/cancel": {
      "post": {
        "tags": [
          "Invoices"
        ],
        "summary": "Cancel invoice",
        "operationId": "cancelInvoiceById",
        "description": "[Small working example](/recipes/cancellation)\n\n**Integration note:** This recipe covers Mexican CFDI cancellation. A provider acknowledgment does not prove final cancellation. Read the invoice and confirm its persisted status; public nested cancellation fields can be absent. Colombian annulment uses different semantics.\n\nCancel a specific invoice with SAT.\n\n**gigstack Connect:** Cancel other teams' invoices using the `team` parameter.\n\nReplaces the deprecated [`DELETE /invoices/{id}`](/reference/cancelInvoice), which runs the same handler and takes the same body. Some HTTP clients and proxies drop the body of a DELETE request.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "SAT UUID (folio fiscal).",
            "schema": {
              "type": "string"
            },
            "example": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "motive"
                ],
                "properties": {
                  "motive": {
                    "type": "string",
                    "enum": [
                      "01",
                      "02",
                      "03",
                      "04"
                    ],
                    "example": "02",
                    "description": "SAT cancellation motive (`c_MotivoCancelacion`): `01` issued with errors, with a\nsubstitute CFDI (send `substitution_uuid`); `02` issued with errors, no substitute;\n`03` the operation did not take place; `04` nominative operation included in a global\ninvoice. The API only checks that the value is at most two characters; any other value\nis rejected by the SAT/PAC at cancellation time.\n"
                  },
                  "substitution_uuid": {
                    "type": "string",
                    "nullable": true,
                    "example": "12345678-1234-1234-1234-123456789012",
                    "description": "UUID of the substituting invoice (required for motive 01)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cancellation accepted by the PAC. **Raw shape** — the PAC's cancellation\nresponse is spread at the top level alongside `cancellation_status`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "cancellation_status"
                  ],
                  "additionalProperties": true,
                  "properties": {
                    "cancellation_status": {
                      "type": "string",
                      "description": "Cancellation state reported by SAT.",
                      "example": "cancelled"
                    }
                  }
                },
                "example": {
                  "cancellation_status": "cancelled"
                }
              }
            }
          },
          "400": {
            "description": "Body validation failure — `{ \"message\": [ …validation errors… ] }` — or a generic\nCFDI/PAC cancellation error in the CFDI error shape (spread at the top level on\nthis operation, not nested under `message`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/LegacyErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/CfdiErrorResponse"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Raw shape with only a `message` key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "`{ \"message\": \"Livemode mismatch: API key and invoice must be in the same mode\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "`{ \"message\": \"Invoice not found\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "412": {
            "description": "SAT not connected — the team has no valid CSD, or the certificate failed\nvalidation. Returned in the CFDI error shape with `retryable: false`.\nUpload a CSD via `POST /v2/teams/{id}/sat-connection` before retrying.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CfdiErrorResponse"
                },
                "example": {
                  "error": "El certificado de sello digital (CSD) no está configurado o no es válido.",
                  "code": "csd_validation_error",
                  "retryable": false
                }
              }
            }
          },
          "422": {
            "description": "The invoice was imported and stamped by an external PAC, so gigstack cannot\ncancel it. Cancel it through the original PAC provider instead.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                },
                "example": {
                  "message": "Imported invoices stamped by an external PAC cannot be canceled through gigstack. Please cancel through your original PAC provider."
                }
              }
            }
          },
          "500": {
            "description": "`{ \"error\": \"Internal server error\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "The PAC is unavailable. CFDI error shape with `retryable: true` — retry after a\nshort delay.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CfdiErrorResponse"
                },
                "example": {
                  "error": "El servicio de timbrado no está disponible en este momento. Vuelve a intentarlo en unos minutos.",
                  "code": "pac_unavailable",
                  "retryable": true
                }
              }
            }
          }
        }
      }
    },
    "/invoices/search": {
      "get": {
        "operationId": "getInvoicesSearch",
        "tags": [
          "Invoices"
        ],
        "summary": "Search invoices",
        "description": "Full-text search across invoices using Typesense. Provides fast, typo-tolerant search capabilities.\n\n**gigstack Connect:** Access other teams' invoices using the `team` parameter.\n\n**Search Capabilities:**\n- Search across client name, email, invoice UUID, description, and metadata\n- Typo-tolerant fuzzy matching\n- Paginated results\n\n**Requirements:**\n- Typesense must be configured for your team\n- The `q` (or `query`) parameter is required\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/SearchQueryParam"
          },
          {
            "$ref": "#/components/parameters/SearchQueryBackwardCompatParam"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/SearchPageParam"
          },
          {
            "$ref": "#/components/parameters/InvoicesSearchFieldsParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Invoices searched successfully",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SearchResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "message": "Invoices searched successfully",
                  "data": [
                    {
                      "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                      "idempotency_key": null,
                      "client": {
                        "id": "client_1234567890",
                        "name": "ESCUELA KEMPER URGATE",
                        "legal_name": "ESCUELA KEMPER URGATE",
                        "email": "contabilidad@ejemplo.com",
                        "bcc": [],
                        "phone": "+524421234567",
                        "tax_id": "EKU9003173C9",
                        "tax_system": "601",
                        "use": "G03",
                        "address": {
                          "street": "Av. Constituyentes",
                          "exterior": "1000",
                          "neighborhood": "Centro",
                          "city": "Querétaro",
                          "state": "QRO",
                          "zip": "76000",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "efos": {
                          "is_valid": true
                        },
                        "metadata": {},
                        "livemode": true,
                        "from": "api",
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      },
                      "created_at": 1767225600000,
                      "date": 1767225600000,
                      "currency": "MXN",
                      "exchange_rate": 1,
                      "total": 1160,
                      "subtotal": 1000,
                      "discount": 0,
                      "taxes": 160,
                      "withholding_taxes": 0,
                      "series": "A",
                      "folio_number": 123,
                      "invoice_type": "I",
                      "use": "G03",
                      "payment_form": "03",
                      "payment_method": "PUE",
                      "livemode": true,
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "from": "api",
                      "status": "valid",
                      "payments": [
                        "payment_1234567890"
                      ],
                      "invoices": [],
                      "items": [
                        {
                          "id": "service_1234567890",
                          "description": "Servicios de consultoría profesional",
                          "quantity": 1,
                          "unit_price": 1000,
                          "product_key": "80141503",
                          "unit_key": "E48"
                        }
                      ],
                      "metadata": {},
                      "emails": [
                        "contabilidad@ejemplo.com"
                      ],
                      "cancellation": null,
                      "stamp": {
                        "sello": "kQ3xZ9vR2mP7tL4wN8cB1yH6",
                        "stamp_at": 1767225600000
                      },
                      "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB&re=MEE200101ABC&rr=EKU9003173C9&tt=1160.00&fe=kQ3xZ9"
                    }
                  ],
                  "found": 1,
                  "page": 1,
                  "per_page": 10,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "missing_query": {
                    "summary": "Missing query parameter",
                    "value": {
                      "error": {
                        "code": "missing_query",
                        "message": "Query parameter is required"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "missing_typesense_key": {
                    "summary": "Typesense not configured",
                    "value": {
                      "error": {
                        "code": "missing_typesense_key",
                        "message": "Typesense API key not configured for this team"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_fields": {
                    "summary": "A field that cannot be searched",
                    "value": {
                      "error": {
                        "code": "invalid_fields",
                        "message": "Cannot search in id. `fields` sets the fields to search in; for invoices use any of: uuid, ..., or metadata.<key>"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_search": {
                    "summary": "Requested fields this team's index does not have",
                    "value": {
                      "error": {
                        "code": "invalid_search",
                        "message": "The search request was rejected. Check that the `fields` exist for this team."
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/draft": {
      "get": {
        "operationId": "getInvoicesDraft",
        "tags": [
          "Invoices",
          "Draft Invoices (Pre-Facturas)"
        ],
        "summary": "List draft invoices",
        "description": "Retrieve a paginated list of draft invoices (pre-facturas).\n\nDrafts are incomplete invoices that have not been stamped yet. Use them to prepare invoices incrementally before finalizing.\n\n**gigstack Connect:** Access other teams' drafts using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "name": "invoice_type",
            "in": "query",
            "description": "Filter by invoice type (I = Income, E = Egress)",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "I",
                "E"
              ]
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "description": "Filter by client ID",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Drafts retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "success": true,
                  "message": "Drafts retrieved successfully",
                  "data": [
                    {
                      "id": "Wm4R8tY2uI6oP0aS3dF7",
                      "draft": true,
                      "invoice_type": "I",
                      "client": {
                        "id": "client_1234567890",
                        "name": "ESCUELA KEMPER URGATE",
                        "legal_name": "ESCUELA KEMPER URGATE",
                        "email": "contabilidad@ejemplo.com",
                        "bcc": [],
                        "phone": "+524421234567",
                        "tax_id": "EKU9003173C9",
                        "tax_system": "601",
                        "use": "G03",
                        "address": {
                          "street": "Av. Constituyentes",
                          "exterior": "1000",
                          "neighborhood": "Centro",
                          "city": "Querétaro",
                          "state": "QRO",
                          "zip": "76000",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "efos": {
                          "is_valid": true
                        },
                        "metadata": {},
                        "livemode": true,
                        "from": "api",
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      },
                      "created_at": 1767225600000,
                      "updated_at": 1767225600000,
                      "currency": "MXN",
                      "exchange_rate": 1,
                      "total": 5800,
                      "subtotal": 5000,
                      "discount": 0,
                      "series": "A",
                      "folio_number": null,
                      "use": "G03",
                      "payment_form": "03",
                      "payment_method": "PUE",
                      "date": null,
                      "livemode": true,
                      "owner": "user_1234567890",
                      "from": "api",
                      "status": "draft",
                      "items": [
                        {
                          "quantity": 1,
                          "description": "Servicio de consultoría",
                          "product_key": "80141503",
                          "unit_key": "ACT",
                          "unit_name": "Actividad",
                          "unit_price": 5000,
                          "taxes": [
                            {
                              "type": "IVA",
                              "rate": 0.16,
                              "factor": "Tasa",
                              "withholding": false,
                              "inclusive": false
                            }
                          ]
                        }
                      ],
                      "metadata": {
                        "project_id": "PROJ-2024-001"
                      },
                      "automation_type": "none",
                      "emails": [],
                      "related_documents": [],
                      "complements": []
                    }
                  ],
                  "next": null,
                  "has_more": false,
                  "total_results": 1,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          }
        }
      },
      "post": {
        "operationId": "createInvoicesDraft",
        "tags": [
          "Invoices",
          "Draft Invoices (Pre-Facturas)"
        ],
        "summary": "Create draft invoice (pre-factura)",
        "description": "[Small working example](/recipes/invoice)\n\n**Integration note:** Save data.id as the draft ID and inspect data.livemode before testing fiscal operations. Draft creation does not stamp a CFDI. Read [shared fields](/concepts/shared-fields) and the [Mexico](/countries/mexico) or [Colombia](/countries/colombia) guide for country-specific meaning. The linked fiscal recipes and staging issuance results use a Mexican issuer.\n\nCreate a new draft invoice (pre-factura) that can be edited and stamped later.\n\nOnly the `invoice_type` field is required. All other fields are optional, allowing you to build the invoice incrementally:\n\n1. **Create** a draft with minimal data (`invoice_type`)\n2. **Update** the draft as data becomes available (client, items, payment details)\n3. **Preview** the draft to generate a PDF with \"Sin Validez Fiscal\" watermark\n4. **Stamp** the draft when ready to finalize it into a valid CFDI\n\n**gigstack Connect:** Create drafts for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftInvoiceInput"
              },
              "example": {
                "invoice_type": "I",
                "currency": "MXN",
                "use": "G03",
                "payment_form": "03",
                "payment_method": "PUE",
                "client": {
                  "id": "client_1234567890"
                },
                "items": [
                  {
                    "quantity": 1,
                    "description": "Servicio de consultoría",
                    "product_key": "80141503",
                    "unit_key": "ACT",
                    "unit_name": "Actividad",
                    "unit_price": 5000,
                    "taxes": [
                      {
                        "type": "IVA",
                        "rate": 0.16,
                        "factor": "Tasa",
                        "withholding": false,
                        "inclusive": false
                      }
                    ]
                  }
                ],
                "metadata": {
                  "project_id": "PROJ-2024-001"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Draft created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Draft created"
                    },
                    "data": {
                      "$ref": "#/components/schemas/DraftInvoiceOutput"
                    }
                  }
                },
                "example": {
                  "message": "Draft created",
                  "data": {
                    "id": "Wm4R8tY2uI6oP0aS3dF7",
                    "draft": true,
                    "invoice_type": "I",
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "created_at": 1767225600000,
                    "updated_at": 1767225600000,
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "total": 5800,
                    "subtotal": 5000,
                    "discount": 0,
                    "series": "A",
                    "folio_number": null,
                    "use": "G03",
                    "payment_form": "03",
                    "payment_method": "PUE",
                    "date": null,
                    "livemode": true,
                    "owner": "user_1234567890",
                    "from": "api",
                    "status": "draft",
                    "items": [
                      {
                        "quantity": 1,
                        "description": "Servicio de consultoría",
                        "product_key": "80141503",
                        "unit_key": "ACT",
                        "unit_name": "Actividad",
                        "unit_price": 5000,
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false,
                            "inclusive": false
                          }
                        ]
                      }
                    ],
                    "metadata": {
                      "project_id": "PROJ-2024-001"
                    },
                    "automation_type": "none",
                    "emails": [],
                    "related_documents": [],
                    "complements": []
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          }
        }
      }
    },
    "/invoices/draft/{id}": {
      "get": {
        "operationId": "getInvoicesDraftById",
        "tags": [
          "Invoices",
          "Draft Invoices (Pre-Facturas)"
        ],
        "summary": "Get draft invoice",
        "description": "Retrieve a specific draft invoice by ID. Includes the preview PDF (base64) if one has been generated.\n\n**gigstack Connect:** Access other teams' drafts using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Draft invoice ID",
            "example": "inv-draft_9f2c1a7b4e6d8035c1af92be"
          }
        ],
        "responses": {
          "200": {
            "description": "Draft retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Draft retrieved successfully"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/DraftInvoiceOutput"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "preview_pdf": {
                              "type": "string",
                              "description": "Base64-encoded preview PDF (if previously generated)"
                            }
                          }
                        }
                      ]
                    }
                  }
                },
                "example": {
                  "message": "Draft retrieved successfully",
                  "data": {
                    "id": "Wm4R8tY2uI6oP0aS3dF7",
                    "draft": true,
                    "invoice_type": "I",
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "created_at": 1767225600000,
                    "updated_at": 1767225600000,
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "total": 5800,
                    "subtotal": 5000,
                    "discount": 0,
                    "series": "A",
                    "folio_number": null,
                    "use": "G03",
                    "payment_form": "03",
                    "payment_method": "PUE",
                    "date": null,
                    "livemode": true,
                    "owner": "user_1234567890",
                    "from": "api",
                    "status": "draft",
                    "items": [
                      {
                        "quantity": 1,
                        "description": "Servicio de consultoría",
                        "product_key": "80141503",
                        "unit_key": "ACT",
                        "unit_name": "Actividad",
                        "unit_price": 5000,
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false,
                            "inclusive": false
                          }
                        ]
                      }
                    ],
                    "metadata": {
                      "project_id": "PROJ-2024-001"
                    },
                    "automation_type": "none",
                    "emails": [],
                    "related_documents": [],
                    "complements": []
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Draft not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateInvoicesDraftById",
        "tags": [
          "Invoices",
          "Draft Invoices (Pre-Facturas)"
        ],
        "summary": "Update draft invoice",
        "description": "[Small working example](/recipes/invoice)\n\nUpdate a saved invoice draft. Send the complete intended body, including items. In the staging verification on 2026-10-08, a notes-only update cleared items; several omitted fields also receive defaults. Read the draft back and compare it before stamping. Do not assume partial PATCH semantics.\n\nUse the team parameter only with the documented gigstack Connect permissions.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Draft invoice ID",
            "example": "inv-draft_9f2c1a7b4e6d8035c1af92be"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftInvoiceUpdateInput"
              },
              "example": {
                "client": {
                  "id": "client_updated_id"
                },
                "items": [
                  {
                    "quantity": 2,
                    "description": "Updated service",
                    "unit_price": 3000,
                    "product_key": "80141503",
                    "unit_key": "ACT",
                    "unit_name": "Actividad",
                    "taxes": [
                      {
                        "type": "IVA",
                        "rate": 0.16,
                        "factor": "Tasa",
                        "withholding": false,
                        "inclusive": false
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Draft updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Draft updated"
                    },
                    "data": {
                      "$ref": "#/components/schemas/DraftInvoiceOutput"
                    }
                  }
                },
                "example": {
                  "message": "Draft updated",
                  "data": {
                    "id": "Wm4R8tY2uI6oP0aS3dF7",
                    "draft": true,
                    "invoice_type": "I",
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "created_at": 1767225600000,
                    "updated_at": 1767225660000,
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "total": 5800,
                    "subtotal": 5000,
                    "discount": 0,
                    "series": "A",
                    "folio_number": null,
                    "use": "G03",
                    "payment_form": "03",
                    "payment_method": "PUE",
                    "date": null,
                    "livemode": true,
                    "owner": "user_1234567890",
                    "from": "api",
                    "status": "draft",
                    "items": [
                      {
                        "quantity": 1,
                        "description": "Servicio de consultoría",
                        "product_key": "80141503",
                        "unit_key": "ACT",
                        "unit_name": "Actividad",
                        "unit_price": 5000,
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false,
                            "inclusive": false
                          }
                        ]
                      }
                    ],
                    "metadata": {
                      "project_id": "PROJ-2024-001"
                    },
                    "automation_type": "none",
                    "emails": [],
                    "related_documents": [],
                    "complements": []
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error or document is not a draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Draft not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteInvoicesDraftById",
        "tags": [
          "Invoices",
          "Draft Invoices (Pre-Facturas)"
        ],
        "summary": "Delete draft invoice",
        "description": "Permanently delete a draft invoice. This also removes any generated preview files.\n\n**Note:** Only drafts can be deleted. For stamped invoices, use the cancel endpoint instead.\n\n**gigstack Connect:** Delete other teams' drafts using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Draft invoice ID",
            "example": "inv-draft_9f2c1a7b4e6d8035c1af92be"
          }
        ],
        "responses": {
          "200": {
            "description": "Draft deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Draft deleted"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "message": "Draft deleted",
                  "data": {
                    "id": "Wm4R8tY2uI6oP0aS3dF7"
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Draft not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/invoices/draft/{id}/stamp": {
      "post": {
        "operationId": "createInvoicesDraftByIdStamp",
        "tags": [
          "Invoices",
          "Draft Invoices (Pre-Facturas)"
        ],
        "summary": "Stamp draft invoice (finalize)",
        "description": "[Small working example](/recipes/invoice)\n\n**Integration note:** Verified staging result: HTTP 200, data.uuid, data.status valid, and no data.id. Retrieve the issued invoice using the returned UUID, not the former draft ID. The stored draft determines livemode; a test key does not convert an existing live draft into a test draft. Read [shared fields](/concepts/shared-fields) and the [Mexico](/countries/mexico) or [Colombia](/countries/colombia) guide for country-specific meaning. The linked fiscal recipes and staging issuance results use a Mexican issuer.\n\nStamp (finalize) a draft invoice into a valid CFDI with SAT.\n\nThe draft **must** have all required fields before stamping:\n- `client` — a valid client with fiscal data\n- `items` — at least one item\n- `use` — CFDI use code (e.g., `G03` gastos en general, `S01` sin efectos fiscales)\n- `payment_form` — payment form code (e.g., 03, 99)\n- `payment_method` — PUE or PPD\n- `currency` — currency code (e.g., MXN, USD)\n\nAfter stamping:\n- The draft document is deleted\n- A new stamped invoice document is created with a UUID from SAT\n- The response follows the same format as `POST /invoices/income`\n\n**gigstack Connect:** Stamp other teams' drafts using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Draft invoice ID",
            "example": "inv-draft_9f2c1a7b4e6d8035c1af92be"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "return_files": {
                    "type": "boolean",
                    "description": "Include base64 XML and PDF in response",
                    "example": true
                  },
                  "send_email": {
                    "type": "boolean",
                    "description": "Whether to send the document via email to the client. Defaults to true.",
                    "example": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invoice created from draft",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Invoice created from draft"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicIncomeInvoice"
                    }
                  }
                },
                "example": {
                  "message": "Invoice created from draft",
                  "data": {
                    "uuid": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                    "idempotency_key": null,
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "created_at": 1767225600000,
                    "date": 1767225600000,
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "total": 1160,
                    "subtotal": 1000,
                    "discount": 0,
                    "taxes": 160,
                    "withholding_taxes": 0,
                    "series": "A",
                    "folio_number": 123,
                    "invoice_type": "I",
                    "use": "G03",
                    "payment_form": "03",
                    "payment_method": "PUE",
                    "livemode": true,
                    "owner": "user_1234567890",
                    "team": "team_1234567890",
                    "from": "api",
                    "status": "valid",
                    "payments": [
                      "payment_1234567890"
                    ],
                    "invoices": [],
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicios de consultoría profesional",
                        "quantity": 1,
                        "unit_price": 1000,
                        "product_key": "80141503",
                        "unit_key": "E48"
                      }
                    ],
                    "metadata": {},
                    "emails": [
                      "contabilidad@ejemplo.com"
                    ],
                    "cancellation": null,
                    "stamp": {
                      "sello": "kQ3xZ9vR2mP7tL4wN8cB1yH6",
                      "stamp_at": 1767225600000
                    },
                    "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB&re=MEE200101ABC&rr=EKU9003173C9&tt=1160.00&fe=kQ3xZ9"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Draft is incomplete, not a draft, or the stamp failed. All bodies are **raw**\n(`{ \"message\": … }`), never the standardized envelope. Messages emitted:\n`Missing draft id`, `Billing account not found`,\n`Document is not a draft — it may have already been stamped`,\n`Draft is incomplete — a client and at least one item are required to stamp`,\n`Draft is missing CFDI use (use)`, `Draft is missing payment form (payment_form)`,\n`Draft is missing payment method (payment_method)`, `Draft is missing currency`,\n`Invalid currency`, `Exchange rate not found`. A generic CFDI/PAC stamping\nfailure is nested under `message` in the CFDI error shape.\n",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/LegacyErrorResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "message": {
                          "$ref": "#/components/schemas/CfdiErrorResponse"
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "missing_client": {
                    "summary": "Missing client",
                    "value": {
                      "message": "Draft is incomplete — a client and at least one item are required to stamp"
                    }
                  },
                  "missing_use": {
                    "summary": "Missing CFDI use",
                    "value": {
                      "message": "Draft is missing CFDI use (use)"
                    }
                  },
                  "not_a_draft": {
                    "summary": "Already stamped",
                    "value": {
                      "message": "Document is not a draft — it may have already been stamped"
                    }
                  },
                  "pac_error": {
                    "summary": "Generic PAC stamping failure",
                    "value": {
                      "message": {
                        "error": "Error al timbrar la factura: CFDI40147 - El campo UsoCFDI no es válido",
                        "code": "stamping_error",
                        "providerMessage": "CFDI40147 - El campo UsoCFDI no es válido",
                        "retryable": false
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`{ \"message\": \"Unauthorized\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "`{ \"message\": \"Forbidden: draft is not owned by the team\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "`{ \"message\": \"Draft not found\" }`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "412": {
            "description": "**SAT not connected** — no valid CSD for the team. CFDI error shape nested under\n`message`, `retryable: false`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "$ref": "#/components/schemas/CfdiErrorResponse"
                    }
                  }
                },
                "example": {
                  "message": {
                    "error": "El certificado de sello digital (CSD) no está configurado o no es válido.",
                    "code": "csd_validation_error",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "description": "**Team credit limit reached.** Checked before stamping — the draft is left intact\nand no credit is consumed.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditLimitResponse"
                },
                "example": {
                  "message": "Team credit limit reached",
                  "error": "Credit limit of 100 documents reached for this billing period",
                  "credit_limit": 100,
                  "used_credits": 100
                }
              }
            }
          },
          "500": {
            "description": "`{ \"message\": \"Failed to save stamped invoice\", \"error\": { \"code\": \"invoice_save_error\" } }`\nor `{ \"message\": \"An error occurred while stamping draft\", \"error\": { \"code\": …, \"message\": … } }`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "**PAC unavailable.** CFDI error shape nested under `message` with\n`retryable: true`. The draft is untouched — retry after a short delay.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "$ref": "#/components/schemas/CfdiErrorResponse"
                    }
                  }
                },
                "example": {
                  "message": {
                    "error": "El servicio de timbrado no está disponible en este momento. Vuelve a intentarlo en unos minutos.",
                    "code": "pac_unavailable",
                    "retryable": true
                  }
                }
              }
            }
          }
        }
      }
    },
    "/invoices/draft/{id}/preview": {
      "post": {
        "operationId": "createInvoicesDraftByIdPreview",
        "tags": [
          "Invoices",
          "Draft Invoices (Pre-Facturas)"
        ],
        "summary": "Generate draft preview PDF (pre-factura)",
        "description": "Generate a preview PDF for a draft invoice with a **\"Sin Validez Fiscal\"** watermark.\n\nThis is the **pre-factura** feature: it runs the full CFDI pipeline (normalization, XML mapping, PDF generation) without actually stamping with SAT. The generated PDF is saved and can be retrieved later via `GET /invoices/draft/{id}`.\n\n**Requirements:**\n- Draft must have at least a `client` and one `item`\n\n**What you get:**\n- A PDF that looks like a real CFDI invoice\n- UUID shows `PREFACTURA-0000-0000-0000-SINVALIDEZ`\n- \"Sin Validez Fiscal\" watermark overlay\n- Useful for client approval before stamping\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Draft invoice ID",
            "example": "inv-draft_9f2c1a7b4e6d8035c1af92be"
          }
        ],
        "responses": {
          "200": {
            "description": "Preview PDF generated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Preview PDF generated"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "pdf": {
                          "type": "string",
                          "description": "Base64-encoded PDF with \"Sin Validez Fiscal\" watermark"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "message": "Preview PDF generated",
                  "data": {
                    "pdf": "JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9UeXBlIC9DYXRhbG9nPj4K..."
                  }
                }
              }
            }
          },
          "400": {
            "description": "Draft is incomplete. **Raw shape** — `{ \"message\": … }`, not the standardized envelope.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                },
                "examples": {
                  "incomplete": {
                    "summary": "Missing client or items",
                    "value": {
                      "message": "Draft needs at least a client and one item to generate preview"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Draft not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "The team's invoicing provider has no pre-stamp preview (Colombia and Chile). Mexican\n(SAT) and US teams can preview drafts.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "draft_preview_not_supported",
                    "message": "Draft preview is not available for invoicing provider gigstack-col"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          }
        }
      }
    },
    "/payments": {
      "get": {
        "operationId": "listPayments",
        "tags": [
          "Payments"
        ],
        "summary": "List payments",
        "description": "Retrieve a paginated list of payments with powerful filtering capabilities.\n\n**gigstack Connect:** Access other teams' payments using the `team` parameter.\n\n**Filtering Options:**\n- Filter by payment status, currency, amount\n- Filter by client ID, email, tax ID (RFC), or name\n- Filter by metadata fields using dot or underscore notation (e.g., `metadata.order_id` or `metadata_order_id`)\n- Filter by creation date using comparison operators\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGtParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLtParam"
          },
          {
            "$ref": "#/components/parameters/PaymentStatusParam"
          },
          {
            "$ref": "#/components/parameters/PaymentCurrencyParam"
          },
          {
            "$ref": "#/components/parameters/PaymentAmountParam"
          },
          {
            "$ref": "#/components/parameters/PaymentClientIdParam"
          },
          {
            "$ref": "#/components/parameters/PaymentEmailParam"
          },
          {
            "$ref": "#/components/parameters/PaymentTaxIdParam"
          },
          {
            "$ref": "#/components/parameters/PaymentClientNameParam"
          },
          {
            "name": "metadata.{key}",
            "in": "query",
            "description": "Filter by any metadata field using dot notation (e.g., `metadata.order_id=ORD-123`)\nor underscore notation (e.g., `metadata_order_id=ORD-123`).\nBoth formats are supported and equivalent.\n",
            "required": false,
            "schema": {
              "type": "string"
            },
            "style": "form"
          }
        ],
        "responses": {
          "200": {
            "description": "Payments retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "success": true,
                  "message": "Payments retrieved successfully",
                  "data": [
                    {
                      "id": "payment_1234567890",
                      "client": {
                        "id": "client_1234567890",
                        "name": "ESCUELA KEMPER URGATE",
                        "legal_name": "ESCUELA KEMPER URGATE",
                        "email": "contabilidad@ejemplo.com",
                        "bcc": [],
                        "phone": "+524421234567",
                        "tax_id": "EKU9003173C9",
                        "tax_system": "601",
                        "use": "G03",
                        "address": {
                          "street": "Av. Constituyentes",
                          "exterior": "1000",
                          "neighborhood": "Centro",
                          "city": "Querétaro",
                          "state": "QRO",
                          "zip": "76000",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "efos": {
                          "is_valid": true
                        },
                        "metadata": {},
                        "livemode": true,
                        "from": "api",
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      },
                      "emails": [
                        "contabilidad@ejemplo.com"
                      ],
                      "currency": "MXN",
                      "allowed_payment_methods": [
                        "card",
                        "bank"
                      ],
                      "exchange_rate": 1,
                      "items": [
                        {
                          "id": "service_1234567890",
                          "description": "Servicios de consultoría profesional",
                          "quantity": 1,
                          "unit_price": 1000,
                          "product_key": "80141503",
                          "unit_key": "E48",
                          "unit_name": "Unidad de servicio",
                          "taxes": [
                            {
                              "type": "IVA",
                              "rate": 0.16,
                              "factor": "Tasa",
                              "withholding": false
                            }
                          ],
                          "team": "team_1234567890",
                          "created_at": 1767225600000,
                          "from": "api"
                        }
                      ],
                      "metadata": {},
                      "team": "team_1234567890",
                      "idempotency_key": "payment-2026-0001",
                      "from": "api",
                      "invoices": [
                        "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
                      ],
                      "livemode": true,
                      "owner": "user_1234567890",
                      "payment_form": "03",
                      "payments": [],
                      "receipts": [],
                      "refunds": [],
                      "short_url": "https://gigstack.xyz/Xk3mP9",
                      "success_url": null,
                      "status": "succeeded",
                      "total": 1160,
                      "total_refunded": 0,
                      "subtotal": 1000,
                      "taxes": 160,
                      "discount": 0,
                      "withholding_taxes": 0,
                      "created_at": 1767225600000,
                      "succeeded_at": 1767225900000,
                      "payment_processor": "api"
                    }
                  ],
                  "next": null,
                  "has_more": false,
                  "total_results": 1,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/payments/search": {
      "get": {
        "operationId": "getPaymentsSearch",
        "tags": [
          "Payments"
        ],
        "summary": "Search payments",
        "description": "Full-text search across payments using Typesense. Provides fast, typo-tolerant search capabilities.\n\n**gigstack Connect:** Access other teams' payments using the `team` parameter.\n\n**Search Capabilities:**\n- Search across client name, email, payment ID, description, and metadata\n- Typo-tolerant fuzzy matching\n- Filter search results by status, currency, or client ID\n- Paginated results\n\n**Requirements:**\n- Typesense must be configured for your team\n- The `q` (or `query`) parameter is required\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/SearchQueryParam"
          },
          {
            "$ref": "#/components/parameters/SearchQueryBackwardCompatParam"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/SearchPageParam"
          },
          {
            "$ref": "#/components/parameters/PaymentsSearchFieldsParam"
          },
          {
            "$ref": "#/components/parameters/PaymentStatusParam"
          },
          {
            "$ref": "#/components/parameters/PaymentCurrencyParam"
          },
          {
            "$ref": "#/components/parameters/PaymentClientIdParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Payments searched successfully",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SearchResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "message": "Payments searched successfully",
                  "data": [
                    {
                      "id": "payment_1234567890",
                      "client": {
                        "id": "client_1234567890",
                        "name": "ESCUELA KEMPER URGATE",
                        "legal_name": "ESCUELA KEMPER URGATE",
                        "email": "contabilidad@ejemplo.com",
                        "bcc": [],
                        "phone": "+524421234567",
                        "tax_id": "EKU9003173C9",
                        "tax_system": "601",
                        "use": "G03",
                        "address": {
                          "street": "Av. Constituyentes",
                          "exterior": "1000",
                          "neighborhood": "Centro",
                          "city": "Querétaro",
                          "state": "QRO",
                          "zip": "76000",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "efos": {
                          "is_valid": true
                        },
                        "metadata": {},
                        "livemode": true,
                        "from": "api",
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      },
                      "emails": [
                        "contabilidad@ejemplo.com"
                      ],
                      "currency": "MXN",
                      "allowed_payment_methods": [
                        "card",
                        "bank"
                      ],
                      "exchange_rate": 1,
                      "items": [
                        {
                          "id": "service_1234567890",
                          "description": "Servicios de consultoría profesional",
                          "quantity": 1,
                          "unit_price": 1000,
                          "product_key": "80141503",
                          "unit_key": "E48",
                          "unit_name": "Unidad de servicio",
                          "taxes": [
                            {
                              "type": "IVA",
                              "rate": 0.16,
                              "factor": "Tasa",
                              "withholding": false
                            }
                          ],
                          "team": "team_1234567890",
                          "created_at": 1767225600000,
                          "from": "api"
                        }
                      ],
                      "metadata": {},
                      "team": "team_1234567890",
                      "idempotency_key": "payment-2026-0001",
                      "from": "api",
                      "invoices": [
                        "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
                      ],
                      "livemode": true,
                      "owner": "user_1234567890",
                      "payment_form": "03",
                      "payments": [],
                      "receipts": [],
                      "refunds": [],
                      "short_url": "https://gigstack.xyz/Xk3mP9",
                      "success_url": null,
                      "status": "succeeded",
                      "total": 1160,
                      "total_refunded": 0,
                      "subtotal": 1000,
                      "taxes": 160,
                      "discount": 0,
                      "withholding_taxes": 0,
                      "created_at": 1767225600000,
                      "succeeded_at": 1767225900000,
                      "payment_processor": "api"
                    }
                  ],
                  "found": 1,
                  "page": 1,
                  "per_page": 10,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "missing_query": {
                    "summary": "Missing query parameter",
                    "value": {
                      "error": {
                        "code": "missing_query",
                        "message": "Query parameter is required"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "missing_typesense_key": {
                    "summary": "Typesense not configured",
                    "value": {
                      "error": {
                        "code": "missing_typesense_key",
                        "message": "Typesense API key not configured for this team"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_fields": {
                    "summary": "A field that cannot be searched",
                    "value": {
                      "error": {
                        "code": "invalid_fields",
                        "message": "Cannot search in id. `fields` sets the fields to search in; for payments use any of: fid, ..., or metadata.<key>"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_search": {
                    "summary": "Requested fields this team's index does not have",
                    "value": {
                      "error": {
                        "code": "invalid_search",
                        "message": "The search request was rejected. Check that the `fields` exist for this team."
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/activate/status": {
      "get": {
        "operationId": "getInvoicesDownloadActivateStatus",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Check activation status",
        "description": "Check whether Descarga Masiva SAT is activated for your team and what action (if any) is required.\n\n**Possible statuses:**\n- `active` — Already activated, FIEL setup and scheduling are available\n- `needs_activation` — Not yet turned on; call `POST /invoices/download/activate`. Pricing v3 accounts always get this status until they activate; activating starts the monthly fee per RFC plus per-XML usage, returned in `data.pricing` (`monthlyMxn`, `perDownloadMxn`). While `requiresLive` is `true` the team must go live first. On a legacy plan that includes the feature there is no extra charge.\n- `needs_addon` — Legacy plan without the feature; activating adds the $0.20 MXN/XML download meter to the subscription (no monthly fee)\n- `needs_upgrade` — Legacy free plan; move to a paid plan first\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Activation status retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "active",
                            "needs_activation",
                            "needs_addon",
                            "needs_upgrade"
                          ],
                          "example": "needs_activation"
                        },
                        "planIncludesFeature": {
                          "type": "boolean",
                          "example": true
                        },
                        "isActivated": {
                          "type": "boolean",
                          "example": false
                        },
                        "requiresLive": {
                          "type": "boolean",
                          "description": "Pricing v3 only. The team must go live before activating."
                        },
                        "pricing": {
                          "type": "object",
                          "description": "Pricing v1/v2: the download meter's price. Pricing v3: from the billing catalog; a price the catalog does not have is null.",
                          "properties": {
                            "perDownload": {
                              "type": "string",
                              "nullable": true,
                              "example": "$0.20 MXN"
                            },
                            "perDownloadMxn": {
                              "type": "number",
                              "nullable": true,
                              "description": "Pricing v3. Each downloaded XML, MXN before IVA; 0 while not charged.",
                              "example": 0.2
                            },
                            "monthlyMxn": {
                              "type": "number",
                              "nullable": true,
                              "description": "Pricing v3. Monthly fee, MXN before IVA; 0 while not charged.",
                              "example": 0
                            },
                            "billingThresholdMxn": {
                              "type": "number",
                              "nullable": true,
                              "description": "Pricing v3. Usage is invoiced before the cut once it reaches this (MXN before IVA); null: monthly only.",
                              "example": 500
                            },
                            "addonMonthly": {
                              "type": "string",
                              "nullable": true,
                              "example": null
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "status": "active",
                    "planIncludesFeature": false,
                    "isActivated": true,
                    "pricing": {
                      "perDownload": "$0.20 MXN",
                      "addonMonthly": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/activate": {
      "post": {
        "operationId": "createInvoicesDownloadActivate",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Activate Descarga Masiva SAT",
        "description": "Activate Descarga Masiva SAT for your team. Billing depends on the account's pricing:\n\n- **Pricing v3** (`type: usage`): the team must be live (`409 go_live_required` otherwise). Each XML is charged as usage and the monthly fee per RFC with the account's usage; both prices come from the billing catalog and are returned in `data.pricing` (see `GET /invoices/download/activate/status` and the public `GET /pricing`).\n- **Legacy plan that includes the feature** (`needs_activation` status): Activation is free — you only pay $0.20 MXN per XML downloaded.\n- **Legacy plan without the feature** (`needs_addon` status): Activation adds only the $0.20 MXN per XML download meter to the subscription. There is no monthly base fee.\n\nOnce activated, upload your FIEL via `POST /invoices/download/fiel` to complete setup.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Activated successfully (or already active)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Descarga Masiva activada. Cada descarga de XML consumirá créditos SAT."
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "included",
                            "addon",
                            "usage"
                          ],
                          "example": "included"
                        },
                        "activated": {
                          "type": "boolean",
                          "example": true
                        },
                        "pricing": {
                          "type": "object",
                          "description": "Pricing v3 only. Same fields as the status endpoint's pricing.",
                          "additionalProperties": true
                        },
                        "alreadyActive": {
                          "type": "boolean",
                          "description": "Present and true when the feature was already active"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Descarga Masiva activada. Cada descarga de XML tiene un costo de $0.20 MXN.",
                  "data": {
                    "type": "addon",
                    "activated": true
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — no active subscription or free plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Forbidden — free plan cannot purchase add-on",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/deactivate": {
      "post": {
        "operationId": "createInvoicesDownloadDeactivate",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Deactivate Descarga Masiva SAT",
        "description": "Deactivate Descarga Masiva SAT for your team. Scheduled downloads stop immediately. If the feature was billed as an add-on, the charge is removed from your subscription (prorated). Any remaining XML downloads in the current period are still billed at period end.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Deactivated successfully (or already inactive)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Descarga Masiva desactivada."
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Descarga Masiva desactivada."
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/ciec": {
      "post": {
        "operationId": "createInvoicesDownloadCiec",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Connect with the SAT password (CIEC)",
        "description": "Connect Descarga Masiva SAT with the team's SAT password (CIEC) instead of the e.firma (FIEL). The RFC is always the team's own.\n\ngigstack logs into the SAT once to verify the password. Only a verified password is stored (encrypted); a rejected one leaves nothing behind. The password is never returned.\n\n- `200` with `status: verified`: the SAT accepted the password and the first batch of invoices starts.\n- `202` with `status: verifying`: the SAT is slow to answer. Poll `GET /invoices/download/ciec` until the status changes.\n\nEvery XML downloaded through the CIEC is billed like any Descarga Masiva download. Requires live mode and Descarga Masiva activated (`POST /invoices/download/activate`). A team may start up to 5 connection attempts per day.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "password"
                ],
                "properties": {
                  "password": {
                    "type": "string",
                    "maxLength": 256,
                    "description": "SAT password (CIEC), the one used to log into the SAT portal"
                  },
                  "sync_period": {
                    "type": "string",
                    "enum": [
                      "year",
                      "max"
                    ],
                    "description": "Where the first sync starts: year (January 1 of this year) or max (65 months back, the default)",
                    "example": "max"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The SAT accepted the password",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CiecConnectResponse"
                },
                "example": {
                  "success": true,
                  "message": "Listo: el SAT aceptó tu contraseña. Empezamos a traer tus facturas.",
                  "data": {
                    "status": "verified",
                    "rfc": "XAXX010101000",
                    "verified_at": 1763164800000,
                    "rejected_at": null
                  }
                }
              }
            }
          },
          "202": {
            "description": "Verification still running; poll GET /invoices/download/ciec",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CiecConnectResponse"
                },
                "example": {
                  "success": true,
                  "message": "Estamos verificando tu contraseña con el SAT. Esto puede tardar unos minutos.",
                  "data": {
                    "status": "verifying",
                    "rfc": "XAXX010101000",
                    "verified_at": null,
                    "rejected_at": null
                  }
                }
              }
            }
          },
          "400": {
            "description": "Rejected password, invalid input or test mode (`ciec_rejected`, `password_required`, `rfc_invalid`, `livemode_required`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CiecErrorResponse"
                },
                "example": {
                  "success": false,
                  "message": "El SAT no aceptó tu contraseña. Revisa que sea la misma con la que entras al portal del SAT.",
                  "error": "ciec_rejected"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Descarga Masiva not activated (`billing_not_activated`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CiecErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A verification is already running (`ciec_verification_in_progress`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CiecErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many connection attempts today (`too_many_attempts`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CiecErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "503": {
            "description": "The SAT could not confirm the password right now (`ciec_inconclusive`, `sat_service_unavailable`); retry later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CiecErrorResponse"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "getInvoicesDownloadCiec",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Get the CIEC connection status",
        "description": "Status of the team's CIEC connection: `none`, `verifying`, `verified` or `rejected`. While a verification is pending, this call also checks it with the SAT, so poll it after a `202` from `POST /invoices/download/ciec`. `last_result` says what that check found.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "CIEC connection status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/CiecConnection"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "last_result": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "verified",
                                "rejected",
                                "inconclusive",
                                "unavailable",
                                null
                              ]
                            },
                            "message": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        }
                      ]
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "status": "verified",
                    "rfc": "XAXX010101000",
                    "verified_at": 1763164800000,
                    "rejected_at": null,
                    "last_result": null,
                    "message": null
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "deleteInvoicesDownloadCiec",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Disconnect the CIEC",
        "description": "Remove the team's SAT password. Scheduled CIEC syncs stop; invoices already downloaded stay in gigstack.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Disconnected (or nothing was connected)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "example": "none"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "status": "none"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/fiel": {
      "post": {
        "operationId": "createInvoicesDownloadFiel",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Upload FIEL credentials",
        "description": "Upload your FIEL (Firma Electrónica Avanzada) credentials to enable SAT bulk downloads.\n\n**This is the main setup endpoint.** It accepts your `.cer` and `.key` files, validates them, and — if `phone` is provided — automatically registers your business with the SAT in the same request. No separate `/register` call needed.\n\n**What it does:**\n1. Validates the certificate format, extracts your RFC, and checks it matches your gigstack team RFC\n2. Verifies the certificate is not expired\n3. Securely encrypts and stores your credentials\n4. If `phone` is provided → registers your business with the SAT immediately and enables sync (`registered: true` in the response)\n\n**Request format:** `multipart/form-data`\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `cert` | file | Yes | `.cer` file (DER-encoded certificate from SAT) |\n| `key` | file | Yes | `.key` file (DER-encoded encrypted private key from SAT) |\n| `password` | string | Yes | Password for the `.key` file |\n| `sync_period` | string | No | `year` starts the first sync on January 1 of this year; `max` (default) goes back as far as the SAT allows, 65 months. Free-form dates are not accepted. |\n| `phone` | string | Recommended | Contact phone in international format (e.g. `+5215512345678`) |\n\n> **Note:** The FIEL is different from the CSD (Certificado de Sello Digital). The CSD is used to stamp CFDI invoices. The FIEL is used to authenticate with the SAT for bulk downloads.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "cert",
                  "key",
                  "password"
                ],
                "properties": {
                  "cert": {
                    "type": "string",
                    "format": "binary",
                    "description": ".cer file — DER-encoded certificate from SAT"
                  },
                  "key": {
                    "type": "string",
                    "format": "binary",
                    "description": ".key file — DER-encoded encrypted private key from SAT"
                  },
                  "password": {
                    "type": "string",
                    "description": "Password for the .key file"
                  },
                  "sync_period": {
                    "type": "string",
                    "enum": [
                      "year",
                      "max"
                    ],
                    "description": "Where the first sync starts: year (January 1 of this year) or max (65 months back, the default)",
                    "example": "max"
                  },
                  "phone": {
                    "type": "string",
                    "description": "Contact phone in international format",
                    "example": "+5215512345678"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "FIEL uploaded (and optionally registered) successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "FIEL credentials stored successfully. Business registered with SAT sync enabled."
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rfc": {
                          "type": "string",
                          "example": "XAXX010101000"
                        },
                        "expires_at": {
                          "type": "integer",
                          "description": "Certificate expiry timestamp (ms)",
                          "example": 1893456000000
                        },
                        "expires_at_readable": {
                          "type": "string",
                          "example": "2029-12-31T00:00:00.000Z"
                        },
                        "serial_number": {
                          "type": "string",
                          "example": "00001000000504465028"
                        },
                        "sync_start_date": {
                          "type": "string",
                          "nullable": true,
                          "example": "2023-01-01"
                        },
                        "phone": {
                          "type": "string",
                          "nullable": true,
                          "example": "+5215512345678"
                        },
                        "registered": {
                          "type": "boolean",
                          "description": "true if auto-registration with SAT succeeded",
                          "example": true
                        },
                        "registered_at": {
                          "type": "integer",
                          "nullable": true,
                          "description": "Registration timestamp (ms), null if not yet registered"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "FIEL credentials stored successfully",
                  "data": {
                    "rfc": "MEE200101ABC",
                    "expires_at": 1893456000000,
                    "expires_at_readable": "2030-01-01T06:00:00.000Z",
                    "serial_number": "00001000000712345678",
                    "sync_start_date": null,
                    "phone": "+525512345678",
                    "registered": true,
                    "registered_at": 1767225600000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — missing files, RFC mismatch, expired certificate, invalid format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/register": {
      "post": {
        "operationId": "createInvoicesDownloadRegister",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Register business with SAT (manual)",
        "description": "Manually register your business with the SAT. Only needed if the automatic registration during `POST /invoices/download/fiel` failed.\n\n**In most cases you don't need to call this directly** — `POST /invoices/download/fiel` handles registration automatically when `sync_start_date` and `phone` are provided.\n\nRequires that FIEL credentials were already uploaded via `POST /invoices/download/fiel`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sync_start_date": {
                    "type": "string",
                    "format": "date",
                    "description": "Deprecated compatibility input, ignored. Registration always uses the maximum 71-month history.",
                    "example": "2023-01-01",
                    "deprecated": true
                  },
                  "phone": {
                    "type": "string",
                    "description": "Required unless the stored FIEL already has a stored registration phone.",
                    "example": "+5215512345678"
                  },
                  "legal_name": {
                    "type": "string",
                    "description": "Business legal name (defaults to team legal name)"
                  },
                  "max_monthly_invoices": {
                    "type": "integer",
                    "description": "Maximum monthly invoices limit (default: 10000)",
                    "default": 10000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Business registered with the bulk-download provider.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rfc": {
                          "type": "string"
                        },
                        "legal_name": {
                          "type": "string"
                        },
                        "registered": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Business entity registered successfully",
                  "data": {
                    "rfc": "MEE200101ABC",
                    "legal_name": "MI EMPRESA EJEMPLO SA DE CV",
                    "registered": true
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — FIEL not uploaded or missing fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/schedule": {
      "get": {
        "operationId": "getInvoicesDownloadSchedule",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Get schedule configuration",
        "description": "Returns the current scheduled download configuration plus FIEL and registration status. Use this to check setup progress before configuring a schedule or submitting download requests.\n\n- `fiel_uploaded: true` — FIEL credentials are stored\n- `registered: true` — Business is registered with the SAT, downloads are enabled\n- `schedule` — Current schedule config, or `null` if not configured yet\n- `fiel` — FIEL certificate metadata (RFC, expiry, serial number)\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Schedule configuration retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "fiel_uploaded": {
                          "type": "boolean",
                          "example": true
                        },
                        "registered": {
                          "type": "boolean",
                          "example": true
                        },
                        "registered_at": {
                          "type": "integer",
                          "nullable": true,
                          "description": "Registration timestamp (ms)"
                        },
                        "sat_completed": {
                          "type": "boolean",
                          "description": "Whether the team has SAT invoicing (CSD) configured"
                        },
                        "fiel": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "rfc": {
                              "type": "string",
                              "example": "XAXX010101000"
                            },
                            "expires_at": {
                              "type": "integer",
                              "example": 1893456000000
                            },
                            "serial_number": {
                              "type": "string"
                            },
                            "uploaded_at": {
                              "type": "integer"
                            }
                          }
                        },
                        "schedule": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "enabled": {
                              "type": "boolean"
                            },
                            "time": {
                              "type": "string",
                              "example": "21:00"
                            },
                            "downloadTypes": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "issued",
                                  "received"
                                ]
                              }
                            },
                            "daysBack": {
                              "type": "integer",
                              "example": 1
                            },
                            "lastRunAt": {
                              "type": "integer",
                              "nullable": true
                            },
                            "lastRunStatus": {
                              "type": "string",
                              "nullable": true
                            },
                            "lastRunError": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "schedule": {
                      "enabled": true,
                      "time": "06:00",
                      "downloadTypes": [
                        "received"
                      ],
                      "daysBack": 3,
                      "lastRunAt": 1767225600000,
                      "lastRunStatus": "success",
                      "lastRunError": null
                    },
                    "sat_completed": true,
                    "fiel_uploaded": true,
                    "registered": true,
                    "registered_at": 1767225600000,
                    "sync_start_date": "2021-01-01",
                    "fiel": {
                      "rfc": "MEE200101ABC",
                      "expires_at": 1893456000000,
                      "serial_number": "00001000000712345678",
                      "uploaded_at": 1767225600000
                    },
                    "sync_status": null
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "operationId": "updateInvoicesDownloadSchedule",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Save schedule configuration",
        "description": "Create or update the daily scheduled download. The schedule runs once per day at the specified time (America/Mexico_City timezone) and downloads invoices from the last `days_back` days.\n\n**Prerequisites:** FIEL must be uploaded and business must be registered. Returns `400` otherwise.\n\n**Warning:** If you include `issued` in `download_types` and your team already has SAT invoicing (CSD) configured, the response includes a `warning` field noting that issued invoices already exist in the system.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "enabled",
                  "time",
                  "download_types",
                  "days_back"
                ],
                "properties": {
                  "enabled": {
                    "type": "boolean",
                    "description": "Enable or disable scheduled downloads"
                  },
                  "time": {
                    "type": "string",
                    "description": "Run time in HH:mm format (America/Mexico_City timezone)",
                    "example": "21:00"
                  },
                  "download_types": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "issued",
                        "received"
                      ]
                    },
                    "description": "Which invoice directions to download. Must be non-empty when `enabled` is true; may be an empty array when turning the schedule off",
                    "example": [
                      "received"
                    ]
                  },
                  "days_back": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 90,
                    "description": "How many days back to look on each run",
                    "example": 1
                  }
                }
              },
              "example": {
                "enabled": true,
                "time": "21:00",
                "download_types": [
                  "received"
                ],
                "days_back": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Schedule saved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Scheduled download enabled successfully"
                    },
                    "warning": {
                      "type": "string",
                      "description": "Optional warning if issued invoices may be duplicated"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "schedule": {
                          "type": "object"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "schedule": {
                      "enabled": true,
                      "time": "06:00",
                      "downloadTypes": [
                        "received"
                      ],
                      "daysBack": 3,
                      "lastRunAt": 1767225600000,
                      "lastRunStatus": "success",
                      "lastRunError": null
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — FIEL not uploaded, not registered, invalid time/types/days_back",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/schedule/history": {
      "get": {
        "operationId": "getInvoicesDownloadScheduleHistory",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Get download request history",
        "description": "Returns the last 20 download requests for your team, ordered by most recent first.\n\n**Live status check:** Any pending requests (`accepted`, `processing`, `pending`) are checked against the SAT in real time before the response is returned, so you always get up-to-date statuses in a single call.\n\n**Statuses:**\n| Status | Meaning |\n|--------|---------|\n| `pending` | Request queued, being sent to SAT |\n| `accepted` | SAT accepted the request, processing started |\n| `processing` | SAT is generating the package |\n| `completed` | Done — invoice metadata is available in the response |\n| `failed` | SAT rejected the request (see `statusMessage`) |\n| `expired` | Package expired before it was downloaded |\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "History retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "history": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "rfcType": {
                                "type": "string",
                                "enum": [
                                  "issued",
                                  "received"
                                ]
                              },
                              "startDate": {
                                "type": "string",
                                "format": "date"
                              },
                              "endDate": {
                                "type": "string",
                                "format": "date"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "pending",
                                  "accepted",
                                  "processing",
                                  "completed",
                                  "failed",
                                  "expired"
                                ]
                              },
                              "invoiceCount": {
                                "type": "integer",
                                "description": "Total invoices found by SAT"
                              },
                              "processedCount": {
                                "type": "integer",
                                "description": "Invoices saved to sat_invoices"
                              },
                              "statusMessage": {
                                "type": "string",
                                "nullable": true
                              },
                              "source": {
                                "type": "string",
                                "enum": [
                                  "manual",
                                  "scheduled"
                                ]
                              },
                              "owner": {
                                "type": "string",
                                "nullable": true
                              },
                              "latestIssueDate": {
                                "type": "string",
                                "nullable": true
                              },
                              "earliestIssueDate": {
                                "type": "string",
                                "nullable": true
                              },
                              "createdAt": {
                                "type": "integer"
                              },
                              "completedAt": {
                                "type": "integer",
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "history": [
                      {
                        "id": "satreq_Ab12Cd34",
                        "rfcType": "received",
                        "startDate": "2026-01-01",
                        "endDate": "2026-01-31",
                        "status": "completed",
                        "invoiceCount": 143,
                        "processedCount": 143,
                        "source": "manual",
                        "latestIssueDate": "2026-01-30",
                        "earliestIssueDate": "2026-01-02",
                        "createdAt": 1767225600000,
                        "completedAt": 1767312000000
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/progress": {
      "get": {
        "operationId": "getInvoicesDownloadProgress",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Get SAT history sync progress",
        "description": "Reports how far the SAT has handed over your invoice history.\n\nThe SAT does not deliver a history all at once. It is backfilled forward from your sync start date in month-sized windows, and until that reaches the present, a query for a recent date range succeeds and returns nothing — identical to genuinely having no invoices. This endpoint is how you tell those apart.\n\n**Fields:**\n| Field | Meaning |\n|-------|---------|\n| `percent` | How much of the requested history has arrived |\n| `covered_through` | Last date the backfill has reached |\n| `months_remaining` | Roughly how much history is still pending |\n| `current` | History is close enough to the present to be usable |\n| `stalled` | Coverage is more than three days behind today and has not advanced in over two days |\n| `enabled` | Sync is active. When `false` it will not advance on its own |\n| `eta_at` | Projected completion, epoch ms. Omitted while `stalled`, since a stopped sync has no meaningful estimate |\n\nValues are refreshed periodically in the background. Pass `refresh=true` to recompute against the provider, which takes a few seconds.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "Recompute against the provider instead of serving the cached snapshot"
          }
        ],
        "responses": {
          "200": {
            "description": "Progress retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "registered": {
                          "type": "boolean",
                          "description": "False until FIEL credentials are connected"
                        },
                        "provider": {
                          "type": "object",
                          "nullable": true,
                          "description": "Null until the first background refresh has run",
                          "properties": {
                            "percent": {
                              "type": "number",
                              "example": 34.7
                            },
                            "covered_through": {
                              "type": "string",
                              "format": "date",
                              "example": "2022-10-13"
                            },
                            "months_remaining": {
                              "type": "number",
                              "example": 46.5
                            },
                            "current": {
                              "type": "boolean"
                            },
                            "stalled": {
                              "type": "boolean"
                            },
                            "enabled": {
                              "type": "boolean"
                            },
                            "eta_at": {
                              "type": "integer",
                              "nullable": true,
                              "description": "Projected completion, epoch ms. Omitted while stalled, since a stopped sync has no meaningful estimate"
                            },
                            "eta_confidence": {
                              "type": "string",
                              "nullable": true,
                              "enum": [
                                "observed",
                                "estimated",
                                null
                              ],
                              "description": "`observed` means the frontier was seen to move between two readings. `estimated` means it was averaged over everything covered since the sync began, which reads optimistically for an account that advanced early and then stopped"
                            },
                            "updated_at": {
                              "type": "integer"
                            }
                          }
                        },
                        "stored": {
                          "type": "object",
                          "nullable": true,
                          "description": "What we have saved so far, which lags the provider",
                          "properties": {
                            "total": {
                              "type": "integer"
                            }
                          }
                        },
                        "message": {
                          "type": "string",
                          "description": "Human-readable explanation of the current state, in Spanish"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "registered": true,
                    "provider": {
                      "percent": 34.7,
                      "covered_through": "2022-10-13",
                      "months_remaining": 46.5,
                      "current": false,
                      "stalled": false,
                      "enabled": true,
                      "eta_at": 1790000000000,
                      "updated_at": 1767225600000
                    },
                    "stored": {
                      "total": 18234
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Team RFC not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/preview": {
      "post": {
        "operationId": "createInvoicesDownloadPreview",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Preview a range of SAT history before paying for it",
        "description": "Queues a metadata pull for a date range and reports how many CFDIs exist and what downloading them would cost.\n\nReading header data from the SAT costs nothing; only fetching an XML is billed. This endpoint uses that gap: it stores what it finds as browsable rows in the `metadata` stage, which you can list with `GET /invoices/sat?sync_state=metadata` and then selectively import.\n\nAnswers **202**, not 200. One month is roughly a twelve second round trip to the SAT and a full history is dozens of them, well past any HTTP timeout. Poll `GET /invoices/download/jobs/{id}` for progress.\n\nOnly one job may run per team at a time.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "start_date",
                  "end_date"
                ],
                "properties": {
                  "start_date": {
                    "type": "string",
                    "format": "date",
                    "example": "2026-01-01"
                  },
                  "end_date": {
                    "type": "string",
                    "format": "date",
                    "example": "2026-08-31"
                  },
                  "directions": {
                    "type": "array",
                    "description": "Defaults to received only",
                    "items": {
                      "type": "string",
                      "enum": [
                        "issued",
                        "received"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Job queued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "satjob_a1b2c3d4e5"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        },
                        "total_windows": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Sincronización encolada",
                  "data": {
                    "id": "satjob_a1b2c3d4e5",
                    "status": "queued",
                    "total_windows": 8
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid date range or directions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Descarga Masiva not activated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "A job is already running for this team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/jobs": {
      "get": {
        "operationId": "listInvoicesDownloadJobs",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "List recent preview and import jobs",
        "description": "The last 20 jobs for your team, newest first, each with its progress and cost estimate.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Jobs retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "jobs": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/SatImportJobSummary"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "jobs": [
                      {
                        "id": "satjob_a1b2c3d4e5",
                        "type": "preview",
                        "status": "running",
                        "params": {
                          "startDate": "2026-01-01",
                          "endDate": "2026-08-31",
                          "directions": [
                            "received"
                          ]
                        },
                        "progress": {
                          "totalWindows": 8,
                          "doneWindows": 3,
                          "invoicesFound": 412,
                          "invoicesSaved": 412,
                          "alreadyInGigstack": 0
                        }
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/jobs/{id}": {
      "get": {
        "operationId": "getInvoicesDownloadJob",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Get one job with per-window detail",
        "description": "Same shape as the list, plus the individual month windows and their state. Useful for showing which part of a long history pull is still outstanding.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/SatImportJobSummary"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "windows": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string"
                                  },
                                  "start": {
                                    "type": "string",
                                    "format": "date"
                                  },
                                  "end": {
                                    "type": "string",
                                    "format": "date"
                                  },
                                  "direction": {
                                    "type": "string",
                                    "enum": [
                                      "issued",
                                      "received"
                                    ]
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "pending",
                                      "requested",
                                      "done",
                                      "error"
                                    ]
                                  },
                                  "foundCount": {
                                    "type": "integer"
                                  },
                                  "savedCount": {
                                    "type": "integer"
                                  },
                                  "error": {
                                    "type": "string",
                                    "nullable": true
                                  }
                                }
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "satjob_a1b2c3d4e5",
                    "type": "preview",
                    "status": "running",
                    "params": {
                      "startDate": "2026-01-01",
                      "endDate": "2026-08-31",
                      "directions": [
                        "received"
                      ]
                    },
                    "progress": {
                      "totalWindows": 8,
                      "doneWindows": 3,
                      "invoicesFound": 412,
                      "invoicesSaved": 412,
                      "alreadyInGigstack": 0
                    },
                    "windows": [
                      {
                        "key": "2026-01-received",
                        "start": "2026-01-01",
                        "end": "2026-01-31",
                        "direction": "received",
                        "status": "done",
                        "foundCount": 57,
                        "savedCount": 57,
                        "error": null
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Job not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/jobs/{id}/cancel": {
      "post": {
        "operationId": "cancelInvoicesDownloadJob",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Stop a running job",
        "description": "Marks the job cancelled. The worker checks between windows, so it stops after finishing the one in flight rather than immediately. Already-completed jobs are returned unchanged.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "satjob_a1b2c3d4e5",
                    "status": "cancelled"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Job not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/import": {
      "post": {
        "operationId": "importInvoicesDownload",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Download XMLs for chosen CFDIs",
        "description": "**This is the billed call.** Each XML costs $0.20 MXN, charged once per CFDI.\n\nTakes UUIDs that are currently in the `metadata` stage — typically ones you found via a preview and `GET /invoices/sat?sync_state=metadata` — and queues their XML download.\n\n**Cost confirmation.** The server always recomputes the cost; `confirm_cost_mxn` is only ever checked against it, never trusted. Send it and a mismatch returns **409** rather than charging a different amount than you were shown. Omit it and the call is allowed only up to 100 invoices; past that confirmation is required, so a large import cannot happen by accident.\n\nAnything not importable is reported in `skipped` with a reason rather than failing the call: `not_found`, `wrong_team`, `already_imported`, `already_queued`, `is_nomina` (nómina XMLs carry employee PII and are never downloadable), `not_importable`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "uuids"
                ],
                "properties": {
                  "uuids": {
                    "type": "array",
                    "maxItems": 500,
                    "items": {
                      "type": "string"
                    }
                  },
                  "confirm_cost_mxn": {
                    "type": "number",
                    "description": "Cost you expect to be charged. Required above 100 invoices.",
                    "example": 12.4
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Invoices queued for download",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "queued": {
                          "type": "integer"
                        },
                        "estimated_cost_mxn": {
                          "type": "number"
                        },
                        "skipped": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "uuid": {
                                "type": "string"
                              },
                              "reason": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "2 facturas en cola de descarga",
                  "data": {
                    "queued": 2,
                    "estimated_cost_mxn": 0.4,
                    "skipped": [
                      {
                        "uuid": "A1B2C3D4-E5F6-7890-ABCD-1234567890AB",
                        "reason": "already_imported"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing uuids or over the per-call limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Descarga Masiva not activated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Cost confirmation required or mismatched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/request": {
      "post": {
        "operationId": "createInvoicesDownloadRequest",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Create bulk download request",
        "description": "Submit a bulk download request to the SAT. The SAT processes these asynchronously — use `GET /invoices/download/schedule/history` to poll for status updates.\n\n**Prerequisites:** FIEL uploaded (`fiel_uploaded: true`) + business registered (`registered: true`) + Descarga Masiva activated.\n\n**Date range:** SAT limits each request to a maximum of 1 month. For longer periods, submit one request per month.\n\nOnce the request reaches `completed` status, the invoice metadata is available in the history response (`invoiceCount`, `processedCount`, `latestIssueDate`, `earliestIssueDate`).\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "start_date",
                  "end_date"
                ],
                "properties": {
                  "start_date": {
                    "type": "string",
                    "format": "date",
                    "description": "Start of date range (YYYY-MM-DD)",
                    "example": "2024-01-01"
                  },
                  "end_date": {
                    "type": "string",
                    "format": "date",
                    "description": "End of date range (YYYY-MM-DD)",
                    "example": "2024-01-31"
                  },
                  "rfc_type": {
                    "type": "string",
                    "enum": [
                      "issued",
                      "received"
                    ],
                    "description": "Direction of invoices to download (default: received)",
                    "default": "received"
                  },
                  "request_type": {
                    "type": "string",
                    "enum": [
                      "cfdi",
                      "metadata"
                    ],
                    "description": "Download XML files (cfdi) or metadata only (default: cfdi)",
                    "default": "cfdi"
                  },
                  "invoice_type": {
                    "type": "string",
                    "enum": [
                      "I",
                      "E",
                      "P",
                      "N",
                      "T"
                    ],
                    "description": "Filter by CFDI type: I=income, E=expense, P=payment, N=payroll, T=transfer"
                  },
                  "invoice_status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "cancelled",
                      "all"
                    ],
                    "description": "Filter by invoice status (default: all)"
                  },
                  "third_party_rfc": {
                    "type": "string",
                    "description": "Filter by counterparty RFC"
                  },
                  "min_amount": {
                    "type": "string",
                    "description": "Minimum invoice amount"
                  },
                  "max_amount": {
                    "type": "string",
                    "description": "Maximum invoice amount"
                  }
                }
              },
              "example": {
                "start_date": "2024-01-01",
                "end_date": "2024-01-31",
                "rfc_type": "received"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Requests created, one per calendar month of the range. Already-pending months are reported in `duplicates` instead of being submitted again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "created": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Ids of the requests created (use with `GET /invoices/download/status/{request_id}`)."
                        },
                        "duplicates": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Ids of identical requests already pending."
                        },
                        "chunks": {
                          "type": "integer",
                          "description": "Number of monthly periods the range was split into."
                        },
                        "duplicate": {
                          "type": "boolean",
                          "description": "`true` when every period already had a pending request."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "2 solicitud(es) creada(s) para 2 período(s) mensual(es)",
                  "data": {
                    "created": [
                      "satreq_Ab12Cd34",
                      "satreq_Ef56Gh78"
                    ],
                    "duplicates": [],
                    "chunks": 2,
                    "duplicate": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — FIEL not uploaded, not registered, or billing not activated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Descarga Masiva is not activated for the team (`error: billing_not_activated`) — call\n`POST /invoices/download/activate` first. Raw body, not the standardized envelope. An\nauthentication-layer `403` (see `AuthForbidden`) is also possible.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "Descarga Masiva is not activated for this team. Activate it first using POST /v2/invoices/download/activate.",
                  "error": "billing_not_activated"
                }
              }
            }
          },
          "429": {
            "description": "Daily limit reached: at most **10 manual download requests per team per calendar day**\n(America/Mexico_City). The counter resets at midnight Mexico City time. Raw body, not the\nstandardized envelope; no `Retry-After` header is sent.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string",
                      "enum": [
                        "rate_limit_exceeded"
                      ]
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "resets_at": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "Daily limit reached. You can submit up to 10 manual download requests per day. Resets at midnight Mexico City time.",
                  "error": "rate_limit_exceeded",
                  "data": {
                    "limit": 10,
                    "resets_at": "midnight America/Mexico_City"
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/status/{request_id}": {
      "get": {
        "operationId": "getInvoicesDownloadStatusByRequestId",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Check download request status",
        "description": "Check the current SAT processing status of a download request (an id from the `created` array of\n`POST /invoices/download/request`).\n\nWhen `status` is `completed`, `packages` lists the packages to download with\n`GET /invoices/download/package/{package_id}`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "request_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Request ID returned from POST /invoices/download/request",
            "example": "req_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Current SAT status. Download each entry of `packages` with `GET /invoices/download/package/{package_id}`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "gigstack request id"
                        },
                        "request_id": {
                          "type": "string",
                          "description": "Provider request id"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending",
                            "accepted",
                            "processing",
                            "completed",
                            "failed",
                            "expired"
                          ]
                        },
                        "status_code": {
                          "type": "string"
                        },
                        "invoice_count": {
                          "type": "integer"
                        },
                        "invoices_saved": {
                          "type": "integer",
                          "description": "Present once invoices were stored."
                        },
                        "invoices": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "packages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "index": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        "message": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Status retrieved successfully",
                  "data": {
                    "id": "satreq_Ab12Cd34",
                    "request_id": "9f1c2a3b-4d5e-6f70-8192-a3b4c5d6e7f8",
                    "status": "completed",
                    "status_code": "5000",
                    "invoice_count": 143,
                    "invoices_saved": 143,
                    "invoices": [],
                    "packages": [
                      {
                        "id": "9F1C2A3B-4D5E-6F70-8192-A3B4C5D6E7F8_01",
                        "index": 1
                      }
                    ],
                    "message": null
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/package/{package_id}": {
      "get": {
        "operationId": "getInvoicesDownloadPackageByPackageId",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Download XML package",
        "description": "Download a package of XML files for a completed download request. Package ids come from `packages[].id`\nin `GET /invoices/download/status/{request_id}`.\n\nThe ZIP is returned **base64-encoded inside JSON** (`data.content`), not as a binary response. Packages\nexpire after a period set by the SAT — download them promptly.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "package_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Package ID from the status response",
            "example": "pkg_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "The package, as **base64** inside a JSON body (not a binary download).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "package_id": {
                          "type": "string"
                        },
                        "content": {
                          "type": "string",
                          "description": "Base64-encoded ZIP of the XML files."
                        },
                        "content_type": {
                          "type": "string",
                          "enum": [
                            "application/zip"
                          ]
                        },
                        "encoding": {
                          "type": "string",
                          "enum": [
                            "base64"
                          ]
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Package downloaded successfully",
                  "data": {
                    "package_id": "9F1C2A3B-4D5E-6F70-8192-A3B4C5D6E7F8_01",
                    "content": "UEsDBBQAAAAIAA...",
                    "content_type": "application/zip",
                    "encoding": "base64"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/invoice/{uuid}": {
      "get": {
        "operationId": "getInvoicesDownloadInvoiceByUuid",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Get single invoice from SAT",
        "description": "Fetch a single invoice's XML from the SAT by UUID. Useful for retrieving a specific CFDI without submitting a full bulk download request.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "CFDI UUID (folio fiscal)",
            "example": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e"
          }
        ],
        "responses": {
          "200": {
            "description": "The CFDI XML, base64-encoded. `cached: true` when served from gigstack's copy.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "uuid": {
                          "type": "string"
                        },
                        "xml_base64": {
                          "type": "string"
                        },
                        "cached": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Invoice retrieved successfully",
                  "data": {
                    "uuid": "6741A863-04BE-49FE-BB76-E1657AB6B7EA",
                    "xml_base64": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4K...",
                    "cached": false
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/debug": {
      "get": {
        "operationId": "getInvoicesDownloadDebug",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Debug registration status",
        "description": "Returns detailed debug information about your team's Descarga Masiva setup: FIEL status, registration status, schedule config, and SAT connectivity. Intended for troubleshooting.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Debug info retrieved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Debug info retrieved",
                  "data": {
                    "team_rfc": "MEE200101ABC",
                    "registered_business": null,
                    "sat_requests": []
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/invoices/download/enable-sync": {
      "post": {
        "operationId": "createInvoicesDownloadEnableSync",
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Enable SAT sync",
        "description": "Enables automatic SAT synchronization for your team. This is a lower-level toggle — in most flows the schedule configuration (`PUT /invoices/download/schedule`) is the right endpoint to use.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Automatic sync enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rfc": {
                          "type": "string"
                        },
                        "sync_enabled": {
                          "type": "boolean"
                        },
                        "api_message": {
                          "type": "string",
                          "description": "Message from the provider."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "SAT sync enabled successfully",
                  "data": {
                    "rfc": "MEE200101ABC",
                    "sync_enabled": true
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/payments/{id}": {
      "get": {
        "operationId": "getPaymentsById",
        "tags": [
          "Payments"
        ],
        "summary": "Get payment",
        "description": "Retrieve a specific payment by ID.\n\n**gigstack Connect:** Access other teams' payments using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "payment_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Payment retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "payment_1234567890",
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "emails": [
                      "contabilidad@ejemplo.com"
                    ],
                    "currency": "MXN",
                    "allowed_payment_methods": [
                      "card",
                      "bank"
                    ],
                    "exchange_rate": 1,
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicios de consultoría profesional",
                        "quantity": 1,
                        "unit_price": 1000,
                        "product_key": "80141503",
                        "unit_key": "E48",
                        "unit_name": "Unidad de servicio",
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false
                          }
                        ],
                        "team": "team_1234567890",
                        "created_at": 1767225600000,
                        "from": "api"
                      }
                    ],
                    "metadata": {},
                    "team": "team_1234567890",
                    "idempotency_key": "payment-2026-0001",
                    "from": "api",
                    "invoices": [
                      "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
                    ],
                    "livemode": true,
                    "owner": "user_1234567890",
                    "payment_form": "03",
                    "payments": [],
                    "receipts": [],
                    "refunds": [],
                    "short_url": "https://gigstack.xyz/Xk3mP9",
                    "success_url": null,
                    "status": "succeeded",
                    "total": 1160,
                    "total_refunded": 0,
                    "subtotal": 1000,
                    "taxes": 160,
                    "discount": 0,
                    "withholding_taxes": 0,
                    "created_at": 1767225600000,
                    "succeeded_at": 1767225900000,
                    "payment_processor": "api"
                  },
                  "message": "Payment retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "operationId": "updatePaymentsById",
        "tags": [
          "Payments"
        ],
        "summary": "Update payment",
        "description": "**Partial update:** send only the fields you want to change; omitted fields keep their current values.\n\nUpdate a payment. The endpoint supports modifying the `description` of items, attaching `automation_type` to a payment that has no automations, and patching the embedded `client` (with the change propagated to the `/clients/{id}` master record). The body must include at least one of `items`, `automation_type` or `client`.\n\n**gigstack Connect:** Update other teams' payments using the `team` parameter.\n\n## What can be updated\n\n- **Item description**: For each entry in `items`, the item is matched by `id` inside the payment and its `description` is replaced. Any other field on the item (taxes, discounts, quantity, unit_price, etc.) is rejected by validation. Item totals, taxes and `itemsAmounts` are not recalculated.\n- **Automations**: `automation_type` is only accepted when the payment has no existing automations. If the payment already has automations, the request returns 400. The same enum values used by `POST /payments/register` apply (`pue_invoice`, `ppd_invoice_and_complement`, `none`).\n- **Client**: The `client` object accepts a partial patch (`name`, `company`, `phone`, `email`, `bcc`, `metadata`, `legal_name`, `tax_id`, `use`, `tax_system`, `address`). The client `id` cannot be modified. Each provided field is written both to the `client` embedded in the payment and to the `/clients/{id}` master document via a partial merge. Fiscal/SAT validation is not re-run from this endpoint — call `PUT /clients/{id}` if full re-validation is needed.\n\n## Trigger re-fire for already succeeded payments\n\nWhen non-empty automations are added (i.e. `automation_type` is `pue_invoice` or `ppd_invoice_and_complement`) and the payment is already `succeeded`, the endpoint performs a second write that sets `status` to `succeeded_` so that the downstream automation trigger (which fires on transitions into `succeeded`) can re-fire on a subsequent flip back to `succeeded`.\n\n## Allowed payment statuses\n\nThe endpoint accepts updates regardless of payment status (including `succeeded` and `cancelled`) so descriptions can be corrected after the fact. Note that this endpoint does not re-issue or modify any CFDI already linked to the payment.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "payment_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePaymentInput"
              },
              "examples": {
                "update_item_description": {
                  "summary": "Fix the description of one item",
                  "value": {
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicio de consultoría profesional - corregido"
                      }
                    ]
                  }
                },
                "add_automation": {
                  "summary": "Attach a PUE invoice automation to a payment that had none",
                  "value": {
                    "automation_type": "pue_invoice"
                  }
                },
                "update_both": {
                  "summary": "Update item description and add automations in a single call",
                  "value": {
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicio de consultoría profesional - corregido"
                      }
                    ],
                    "automation_type": "pue_invoice"
                  }
                },
                "update_client_email": {
                  "summary": "Update only the email of the client",
                  "value": {
                    "client": {
                      "email": "nuevo.correo@ejemplo.com"
                    }
                  }
                },
                "update_client_fiscal": {
                  "summary": "Update fiscal info and address of the client",
                  "value": {
                    "client": {
                      "legal_name": "JUAN PEREZ GARCIA",
                      "tax_id": "PEGJ800101ABC",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "country": "MEX",
                        "zip": "06600",
                        "state": "CDMX"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "payment_1234567890",
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "emails": [
                      "contabilidad@ejemplo.com"
                    ],
                    "currency": "MXN",
                    "allowed_payment_methods": [
                      "card",
                      "bank"
                    ],
                    "exchange_rate": 1,
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicios de consultoría profesional",
                        "quantity": 1,
                        "unit_price": 1000,
                        "product_key": "80141503",
                        "unit_key": "E48",
                        "unit_name": "Unidad de servicio",
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false
                          }
                        ],
                        "team": "team_1234567890",
                        "created_at": 1767225600000,
                        "from": "api"
                      }
                    ],
                    "metadata": {},
                    "team": "team_1234567890",
                    "idempotency_key": "payment-2026-0001",
                    "from": "api",
                    "invoices": [
                      "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
                    ],
                    "livemode": true,
                    "owner": "user_1234567890",
                    "payment_form": "03",
                    "payments": [],
                    "receipts": [],
                    "refunds": [],
                    "short_url": "https://gigstack.xyz/Xk3mP9",
                    "success_url": null,
                    "status": "succeeded",
                    "total": 1160,
                    "total_refunded": 0,
                    "subtotal": 1000,
                    "taxes": 160,
                    "discount": 0,
                    "withholding_taxes": 0,
                    "created_at": 1767225600000,
                    "succeeded_at": 1767225900000,
                    "payment_processor": "api"
                  },
                  "message": "Payment updated successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Validation error. Possible causes: empty body, item id not found in payment, payment already has automations, or unexpected fields on items.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The authenticated team does not own this payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Payment not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deletePaymentsById",
        "deprecated": true,
        "tags": [
          "Payments"
        ],
        "summary": "Cancel payment (deprecated DELETE)",
        "description": "**Deprecated:** use [`POST /payments/{id}/cancel`](/reference/cancelPaymentById), which runs the same handler. Cancelling does not delete the payment: it stays readable with status `canceled`.\nThis route keeps working; its responses carry `Deprecation: true` and `Link: </v2/payments/{id}/cancel>; rel=\"successor-version\"`, with the\nconcrete ID in place of each path parameter.\n\nCancel a specific payment.\n\n**gigstack Connect:** Cancel other teams' payments using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "payment_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Payment cancelled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "payment_1234567890",
                    "status": "canceled",
                    "cancelled_at": 1767225600000
                  },
                  "message": "Payment cancelled successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/payments/{id}/cancel": {
      "post": {
        "operationId": "cancelPaymentById",
        "tags": [
          "Payments"
        ],
        "summary": "Cancel payment",
        "description": "Cancel a specific payment.\n\n**gigstack Connect:** Cancel other teams' payments using the `team` parameter.\n\nReplaces the deprecated [`DELETE /payments/{id}`](/reference/deletePaymentsById), which runs the same handler. Cancelling does not delete the payment: it stays readable with status `canceled`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "payment_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Payment cancelled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "payment_1234567890",
                    "status": "canceled",
                    "cancelled_at": 1767225600000
                  },
                  "message": "Payment cancelled successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/payments/request": {
      "post": {
        "operationId": "createPaymentsRequest",
        "tags": [
          "Payments"
        ],
        "summary": "Request payment (you want to get paid)",
        "description": "Use this when **you want to get paid**: it creates a payment request, a payment in\n'requires_payment_method' status with a link your customer opens to pay. Nothing is\ncollected yet; any `automation_type` you set (for example an invoice) runs when the\ncustomer completes the payment. If you were **already paid**, use\n[`POST /payments/register`](/reference/createPaymentsRegister) instead.\n\n**gigstack Connect:** Create payment requests for other teams using the `team` parameter.\n\n## Payment Request Flow\n\nThis endpoint creates a payment request that customers can complete using various payment methods.\nThe payment will be created with status 'requires_payment_method'.\n\n## Allowed Payment Methods\n\n`allowed_payment_methods` is required. The validator accepts exactly these five values:\n\n- **`card`** — credit/debit card\n- **`bank`** — Mexican bank transfer (SPEI)\n- **`oxxo`** — OXXO convenience store\n- **`stripe-spei`** — Stripe customer balance\n- **`mercadopago-wallet`** — Mercado Pago wallet\n\nThe handler then narrows the list per processor and rejects anything outside the\nprocessor's own set:\n\n| `payment_processor` | accepted methods | currency |\n|---|---|---|\n| `stripe` (default) | `card`, `oxxo`, `bank`, `stripe-spei` | any |\n| `mercadopago` | `card`, `oxxo`, `mercadopago-wallet` | `MXN` only |\n| `openpay` | `card`, `bank_account`, `store` | `MXN` only |\n| `pagoralia` | `hosted`, `card`, `oxxo` | `MXN` only |\n| `conekta` | `hosted`, `card`, `oxxo`, `spei` | `MXN` only |\n\n> The processor-specific names in the right-hand column (`bank_account`, `store`,\n> `hosted`, `spei`) are **not** accepted by body validation — only the five enum values\n> above pass, so those processors are effectively limited to their overlap with the enum.\n\n## Required fields\n\n`client`, `currency`, `allowed_payment_methods`, `items` and **`automation_type`** are\nall required. `automation_type` has no default: omitting it fails validation with\n`missing_required`. Allowed values: `pue_invoice`, `ppd_invoice_and_complement`, `none`.\n\n## Email suppression\n\n`ignore_emails` takes precedence over `send_email`: the handler stores\n`ignore_emails ?? (send_email === false)`, so `ignore_emails: true` suppresses\nnotifications regardless of `send_email`.\n\n## Unknown fields\n\nBody validation runs in strict allowlist mode — any key not declared in the schema is\nrejected with `400 validation_failed` / `unexpected_key`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequestPaymentInput"
              },
              "example": {
                "client": {
                  "id": "client_1234567890"
                },
                "automation_type": "pue_invoice",
                "currency": "MXN",
                "exchange_rate": 1,
                "allowed_payment_methods": [
                  "card",
                  "bank",
                  "oxxo"
                ],
                "items": [
                  {
                    "id": "service_1234567890",
                    "quantity": 1,
                    "unit_price": 1000
                  }
                ],
                "send_email": true,
                "emails": [
                  "customer@example.com"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment request created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Payment request created successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicPayment"
                    }
                  }
                },
                "example": {
                  "message": "Payment request created successfully",
                  "data": {
                    "id": "payment_1234567890",
                    "client": {
                      "id": "client_1234567890",
                      "name": "Juan Pérez García",
                      "email": "juan.perez@ejemplo.com",
                      "tax_id": "PEGJ800101ABC",
                      "from": "api",
                      "livemode": true,
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "status": "requires_payment_method",
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "allowed_payment_methods": [
                      {
                        "id": "card"
                      },
                      {
                        "id": "bank"
                      },
                      {
                        "id": "oxxo"
                      }
                    ],
                    "short_url": "https://gigstack.xyz/Xk3mP9",
                    "total": 1160,
                    "subtotal": 1000,
                    "taxes": 160,
                    "discount": 0,
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Professional consulting services",
                        "quantity": 1,
                        "unit_price": 1000,
                        "product_key": "80141503",
                        "unit_key": "E48",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      }
                    ],
                    "emails": [
                      "customer@example.com"
                    ],
                    "created_at": 1677651234,
                    "payment_processor": "api",
                    "livemode": true,
                    "team": "team_1234567890",
                    "owner": "user_1234567890",
                    "from": "api",
                    "refunds": [],
                    "total_refunded": 0,
                    "withholding_taxes": 0,
                    "succeeded_at": 1767225600000,
                    "payment_form": "",
                    "idempotency_key": "",
                    "invoices": [],
                    "payments": [],
                    "receipts": []
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — `validation_failed` (missing `automation_type`, a method outside the\nenum, or an unknown key) or `invalid_request_body` (method not supported by the\nselected processor, non-`MXN` currency on a MXN-only processor, `Invalid automation type`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Referenced client or service belongs to another team, or `livemode` mismatch.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Referenced client or service id was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "409": {
            "description": "`idempotency_key` already used (`error.code: resource_conflict`), or a concurrent create holds the client/service lock — retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/payments/register": {
      "post": {
        "operationId": "createPaymentsRegister",
        "tags": [
          "Payments"
        ],
        "summary": "Register payment (you were already paid)",
        "description": "[Small working example](/recipes/payment)\n\n**Integration note:** Records money already received; does not charge a card. Repeating a creation idempotency_key returned HTTP 400 with error.code resource_conflict in staging. Reconcile the existing payment. ppd_invoice_id is a SAT UUID and enables complement automation even with automation_type none. Registration success is not proof that the asynchronous complement finished.\n\nUse this when **you were already paid** (cash, bank transfer, or any payment received\noutside gigstack): it records the payment as `succeeded` and runs its automations, such as\nissuing the invoice, right away. No payment link is created and nobody is charged. To\n**ask a customer to pay you**, use [`POST /payments/request`](/reference/createPaymentsRequest)\ninstead.\n\n**gigstack Connect:** Register payments for other teams using the `team` parameter.\n\n## Automation Types\n\nControl what happens automatically when registering a payment:\n\n- **`pue_invoice`**: Creates a PUE (Pago en Una sola Exhibición) invoice immediately\n- **`none`**: No automation, registers payment only\n\n## PPD Invoice Linking\n\nYou can link a payment to an existing PPD (Pago en Parcialidades o Diferido) invoice by providing the `ppd_invoice_id` field.\nWhen set, a payment complement (complemento de pago) CFDI will be automatically generated and linked to the PPD invoice.\nThe referenced invoice must have `payment_method='PPD'` and `status='valid'`.\n\n## Payment Form\n\nThe `payment_form` field specifies the Mexican SAT payment form code:\n\nCommon codes include: `01` (cash), `02` (check), `03` (electronic transfer), `04` (credit card), etc.\n\nThe payment will be marked as 'succeeded' immediately upon registration.\n\n## Required fields\n\n`client`, `currency`, `items` (at least one), `payment_form` and **`automation_type`**\nare required. `automation_type` has no default — omitting it fails validation.\nAllowed values: `pue_invoice`, `ppd_invoice_and_complement`, `none`.\n\n## `date`\n\nOptional, in **Unix epoch milliseconds** (13 digits). Compared against\n`Luxon.now().toMillis()`; a future value returns `400`.\n\n## `transfer_data` — all-or-nothing\n\n`transfer_data` is optional, but **when it is present all four of `master`, `connect`,\n`master_to` and `connect_to` are required**; omitting any one fails validation.\n\n| field | type | constraint |\n|---|---|---|\n| `master` | number | required, `0 ≤ master ≤ 100` (percentage retained by the master team) |\n| `connect` | string | required, non-empty — RFC of the connected team |\n| `master_to` | enum | required — `client` or `connect` |\n| `connect_to` | enum | required — `client` or `master` |\n| `connect_custom_config` | object | optional; every field inside it is optional except `type`, `rate` and `withholding` on each `taxes[]` entry |\n\n## `invoice_config`\n\nAll nested fields are optional:\n\n| field | type | meaning |\n|---|---|---|\n| `serie` | string | invoice series |\n| `folio` | number | invoice folio number |\n| `date` | number | invoice issue date, Unix epoch **milliseconds** |\n| `global.year` | number | fiscal year of the global (EOM) invoice, e.g. `2026` |\n| `global.months` | string | SAT `c_Meses` code, e.g. `01` for January or `13` for Jan–Feb |\n| `global.periodicity` | string | SAT `c_Periodicidad` code — `01` daily, `02` weekly, `03` fortnightly, `04` monthly, `05` bimonthly |\n| `validUntil` | number | expiry of the self-invoicing window, Unix epoch **milliseconds** |\n\n## Email suppression\n\n`ignore_emails: true` suppresses notification emails. On this endpoint `send_email` is\naccepted but has no effect — only `ignore_emails` is persisted onto the payment.\n\n## Unknown fields\n\nBody validation runs in strict allowlist mode — any undeclared key is rejected with\n`400 validation_failed` / `unexpected_key`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterPaymentInput"
              },
              "examples": {
                "standard_payment": {
                  "summary": "Standard payment without splitting",
                  "value": {
                    "client": {
                      "id": "client_1234567890"
                    },
                    "automation_type": "pue_invoice",
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "payment_form": "03",
                    "items": [
                      {
                        "id": "service_1234567890",
                        "quantity": 1,
                        "unit_price": 1000
                      }
                    ]
                  }
                },
                "percentage_split": {
                  "summary": "Payment with percentage-based splitting",
                  "value": {
                    "client": {
                      "id": "client_1234567890"
                    },
                    "automation_type": "pue_invoice",
                    "currency": "MXN",
                    "payment_form": "03",
                    "items": [
                      {
                        "id": "service_1234567890",
                        "quantity": 1,
                        "unit_price": 1000
                      }
                    ],
                    "transfer_data": {
                      "master": 30,
                      "connect": "EMP800101ABC",
                      "master_to": "client",
                      "connect_to": "master"
                    }
                  }
                },
                "ppd_complement": {
                  "summary": "Payment linked to an existing PPD invoice",
                  "description": "Register a payment and automatically generate a payment complement (complemento de pago) linked to an existing PPD invoice",
                  "value": {
                    "client": {
                      "id": "client_1234567890"
                    },
                    "automation_type": "none",
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "payment_form": "03",
                    "ppd_invoice_id": "invoice_ppd_1234567890",
                    "items": [
                      {
                        "id": "service_1234567890",
                        "quantity": 1,
                        "unit_price": 1000
                      }
                    ]
                  }
                },
                "fixed_commission": {
                  "summary": "Payment with fixed commission fee",
                  "description": "Use custom_price to charge a fixed commission instead of percentage",
                  "value": {
                    "client": {
                      "id": "client_1234567890"
                    },
                    "automation_type": "pue_invoice",
                    "currency": "MXN",
                    "payment_form": "03",
                    "items": [
                      {
                        "id": "service_1234567890",
                        "quantity": 1,
                        "unit_price": 1000
                      }
                    ],
                    "transfer_data": {
                      "master": 0,
                      "connect": "EMP800101ABC",
                      "master_to": "client",
                      "connect_to": "master",
                      "connect_custom_config": {
                        "custom_price": 50,
                        "custom_description": "Platform service fee"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Payment registered successfully. **Both** the standard path and the\n`transfer_data` split path return `201` with the standardized success envelope.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "description": "`Payment registered successfully` on the standard path, `Split payments registered successfully` on the split path.",
                          "example": "Payment registered successfully"
                        },
                        "data": {
                          "oneOf": [
                            {
                              "$ref": "#/components/schemas/ApiPublicPayment"
                            },
                            {
                              "type": "object",
                              "description": "Split payment result (returned when `transfer_data` is present)",
                              "properties": {
                                "split_reference": {
                                  "type": "string",
                                  "example": "split_abc123xyz"
                                },
                                "master_payment_id": {
                                  "type": "string",
                                  "example": "payment_master_123"
                                },
                                "connect_payment_id": {
                                  "type": "string",
                                  "example": "payment_connect_456"
                                },
                                "master_amount": {
                                  "type": "number",
                                  "example": 696
                                },
                                "connect_amount": {
                                  "type": "number",
                                  "example": 464
                                },
                                "total_amount": {
                                  "type": "number",
                                  "example": 1160
                                },
                                "master_payment": {
                                  "type": "object"
                                },
                                "connect_payment": {
                                  "type": "object"
                                },
                                "connect_team": {
                                  "type": "object",
                                  "nullable": true,
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "tax_id": {
                                      "type": "string"
                                    },
                                    "legal_name": {
                                      "type": "string"
                                    },
                                    "is_newly_created": {
                                      "type": "boolean"
                                    },
                                    "onboarding_url": {
                                      "type": "string"
                                    }
                                  }
                                }
                              }
                            }
                          ]
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "standard_payment": {
                    "summary": "Standard payment response",
                    "value": {
                      "success": true,
                      "message": "Payment registered successfully",
                      "timestamp": 1767225600000,
                      "data": {
                        "id": "payment_1234567890",
                        "client": {
                          "id": "client_1234567890",
                          "name": "Juan Pérez García",
                          "email": "juan.perez@ejemplo.com",
                          "tax_id": "PEGJ800101ABC"
                        },
                        "status": "succeeded",
                        "currency": "MXN",
                        "exchange_rate": 1,
                        "payment_form": "03",
                        "total": 1160,
                        "subtotal": 1000,
                        "taxes": 160,
                        "discount": 0,
                        "items": [
                          {
                            "id": "service_1234567890",
                            "description": "Professional consulting services",
                            "quantity": 1,
                            "unit_price": 1000,
                            "product_key": "80141503",
                            "unit_key": "E48"
                          }
                        ],
                        "invoices": [
                          "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
                        ],
                        "created_at": 1677651234,
                        "succeeded_at": 1677651234,
                        "payment_processor": "api",
                        "livemode": true,
                        "team": "team_1234567890",
                        "owner": "user_1234567890"
                      }
                    }
                  },
                  "split_payment": {
                    "summary": "Split payment response",
                    "description": "Response when using transfer_data to split payments",
                    "value": {
                      "success": true,
                      "message": "Split payments registered successfully",
                      "timestamp": 1767225600000,
                      "data": {
                        "split_reference": "split_abc123xyz",
                        "master_payment_id": "payment_master_123",
                        "connect_payment_id": "payment_connect_456",
                        "master_amount": 696,
                        "connect_amount": 464,
                        "total_amount": 1160,
                        "master_payment": {
                          "id": "payment_master_123",
                          "client": "client_1234567890",
                          "amount": 696,
                          "team": "team_master_123",
                          "split_role": "master"
                        },
                        "connect_payment": {
                          "id": "payment_connect_456",
                          "client": "client_connect_789",
                          "amount": 464,
                          "team": "team_connect_456",
                          "split_role": "connect"
                        },
                        "connect_team": {
                          "id": "team_connect_456",
                          "tax_id": "EMP800101ABC",
                          "legal_name": "Empresa Ejemplo SA de CV",
                          "is_newly_created": true,
                          "onboarding_url": "https://embeded.gigstack.pro/?sessionId=otpOnboarding_7Kd2Pq&c=193847"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request. Emitted with `error.code`:\n- `validation_failed` — body failed schema validation (missing required field,\n  bad enum value, or an unknown key: the validator rejects fields it does not declare).\n- `invalid_request_body` — `Invalid automation type`, `PPD invoice not found with uuid: …`,\n  `The referenced invoice is not valid (stamped)`, `Payment date cannot be in the future`,\n  or `Exchange rate not found for the specified currency`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Forbidden — the referenced client or service belongs to another team, or its\n`livemode` does not match the API key. Raised by resource resolution with\n`error.code: resource_resolution_failed`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Referenced client or service id was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "409": {
            "description": "Conflict — the supplied `idempotency_key` has already been used\n(`error.code: resource_conflict`, message `Idempotency key error`). On the split\npath either the master or the connect payment can trigger this. Resource\nresolution also returns 409 when a concurrent create for the same client/service\nholds the lock; retry the request. A 409 with message `Idempotency key in progress`\nmeans another request with the same `idempotency_key` is still writing its payment\n(the key is claimed in a transaction before the write, so two concurrent requests\nnever register two payments): read the payment back by its key, or retry shortly.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/payments/register/batch": {
      "post": {
        "operationId": "createPaymentRegisterBatch",
        "tags": [
          "Payments"
        ],
        "summary": "Register a batch of payments",
        "description": "Accepts up to **10,000** payments in one request and registers them in the background. Each item is\nexactly the body of `POST /payments/register`, and must carry its own `idempotency_key`, unique within\nthe batch. To register more than 10,000 payments, send more batches, each with its own `Idempotency-Key`.\n\n**What happens in the request.** Every item is validated against the `POST /payments/register` body\nschema, with no I/O. An invalid item is listed in `rejected` with its reason and the rest go ahead;\nonly an empty or missing `payments` array, or more than 10,000 items, refuses the whole request (`400`).\nThe answer is `202` with the batch in `processing`; the first items may already have started.\n\n**What happens after.** Each accepted item is registered by the same code as `POST /payments/register`,\nwith the credential that created the batch, so it fails for the same reasons (a client or service that\ndoes not resolve, a date in the future, a currency with no exchange rate) and triggers the same\nautomations (`automation_type`, `ppd_invoice_id`). A temporary failure is retried automatically, up to\n6 attempts per item. Items run about 10 at a time per team, sharing the queue with the team's income\ninvoice batches, and a worker pauses about a second after each payment whose automation stamps an\ninvoice, so a large batch reaches proserver at a few stamps a second. Follow the batch with `GET /payments/register/batch/{id}`, or subscribe a webhook to\n`payment_batch.completed` (body `PaymentBatchCompletedWebhookEvent`, signed, sent once and never\nretried; see the `webhookEvent` callback of `POST /webhooks`), then read the per-item results with\n`GET /payments/register/batch/{id}/items`.\n\n**Two levels of idempotency.**\n- The `Idempotency-Key` header names the **batch**. The batch id is derived from your team, the\n  credential's mode and the header, so the same key with the same body returns the same batch (`200`),\n  and nothing is created again. The same key with a different body is `409` `idempotency_key_reused`.\n  Bodies are compared as sent, including key order, so resend the exact same JSON.\n- Each item's `idempotency_key` names the **payment**. It is the same key `POST /payments/register`\n  uses: a payment already registered under it, by an earlier batch or a single call, is not registered\n  again, and the item ends `duplicate`. So a new batch that repeats items of a previous one is safe.\n\n**gigstack Connect:** create the batch for a connected team with the `team` parameter, and read it with the\nsame `team`.\n\n**Mode.** `livemode` comes only from the credential: a test key creates a test batch.\n\nNot supported here: split payments (`transfer_data`), which are rejected per item; register those one\nat a time with `POST /payments/register`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Your identifier for this batch, 8-128 characters of `A-Z a-z 0-9 . _ : -`. Reusing it with the same\nbody returns the batch it first created; reusing it with a different body is `409 idempotency_key_reused`.\n",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            },
            "example": "settlement-2026-10-22-part-1"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentBatchCreateInput"
              },
              "example": {
                "payments": [
                  {
                    "idempotency_key": "txn-2026-10-000123",
                    "automation_type": "pue_invoice",
                    "currency": "MXN",
                    "payment_form": "03",
                    "date": 1790700000000,
                    "client": {
                      "id": "client_1234567890"
                    },
                    "items": [
                      {
                        "id": "service_1234567890",
                        "quantity": 1,
                        "unit_price": 1000
                      }
                    ],
                    "metadata": {
                      "order_id": "ORD-000123"
                    }
                  },
                  {
                    "idempotency_key": "txn-2026-10-000124",
                    "automation_type": "none",
                    "currency": "MXN",
                    "payment_form": "01",
                    "client": {
                      "id": "client_0987654321"
                    },
                    "items": [
                      {
                        "description": "Annual support plan",
                        "product_key": "81111811",
                        "unit_key": "E48",
                        "unit_price": 2500,
                        "quantity": 1,
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Retry of an earlier request with the same `Idempotency-Key` and the same body: the batch it created,\nas it is now. Nothing is created again. If the first request died while writing the batch, this\nrequest finishes creating it.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicPaymentBatch"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "pbatch_7f3a9c1e5b2d4f6a8c0e2a4b6d8f0a1c",
                    "object": "payment_batch",
                    "livemode": true,
                    "status": "processing",
                    "result": null,
                    "total": 120,
                    "accepted": 119,
                    "rejected": [
                      {
                        "index": 7,
                        "idempotency_key": "txn-2026-10-000130",
                        "error": {
                          "code": "invalid_body",
                          "message": "payment_form: Invalid enum value"
                        }
                      }
                    ],
                    "counts": {
                      "queued": 60,
                      "registered": 58,
                      "failed": 0,
                      "duplicate": 1
                    },
                    "created_at": 1790780400000,
                    "completed_at": null
                  },
                  "timestamp": 1790781000000
                }
              }
            }
          },
          "202": {
            "description": "Batch created. `status` is `processing`; the accepted items are being registered in the\nbackground. Items refused by validation are in `rejected` and will not be registered. A batch\nin which every item was rejected has nothing to do and is usually already `completed`, with\n`result: failed`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicPaymentBatch"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "pbatch_7f3a9c1e5b2d4f6a8c0e2a4b6d8f0a1c",
                    "object": "payment_batch",
                    "livemode": true,
                    "status": "processing",
                    "result": null,
                    "total": 120,
                    "accepted": 119,
                    "rejected": [
                      {
                        "index": 7,
                        "idempotency_key": "txn-2026-10-000130",
                        "error": {
                          "code": "invalid_body",
                          "message": "payment_form: Invalid enum value"
                        }
                      }
                    ],
                    "counts": {
                      "queued": 119,
                      "registered": 0,
                      "failed": 0,
                      "duplicate": 0
                    },
                    "created_at": 1790780400000,
                    "completed_at": null
                  },
                  "timestamp": 1790780401250
                }
              }
            }
          },
          "400": {
            "description": "The request was refused and no batch was created. `error.code`:\n\n- `invalid_request_body`: the `Idempotency-Key` header is missing or malformed.\n- `invalid_body`: the body is not `{ \"payments\": [ … ] }` with at least one item.\n- `too_many_items`: more than 10,000 items. Split them into several batches.\n\nProblems with a single item don't refuse the request; they are listed in the batch's `rejected`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "examples": {
                  "missing_idempotency_key": {
                    "summary": "Idempotency-Key header missing",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Idempotency-Key header is required"
                      },
                      "timestamp": 1790780400000
                    }
                  },
                  "invalid_body": {
                    "summary": "No payments array",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_body",
                        "message": "Body must be { \"payments\": [ ... ] } with at least one payment"
                      },
                      "timestamp": 1790780400000
                    }
                  },
                  "too_many_items": {
                    "summary": "More than 10,000 payments",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "too_many_items",
                        "message": "A batch holds at most 10000 payments; send the rest in more batches"
                      },
                      "timestamp": 1790780400000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Either the authentication layer refused the credential (raw body, see `AuthForbidden`), or a\nuser-scoped token (MCP, dashboard) lacks `editor` permission on payments (standardized envelope,\n`forbidden`). API keys and OAuth tokens act as the team and are not role-checked.\n",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/StandardErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/AuthMiddlewareError"
                    }
                  ]
                },
                "examples": {
                  "missing_payments_permission": {
                    "summary": "User-scoped token without editor permission on payments",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "forbidden",
                        "message": "This action requires editor access to payments"
                      },
                      "timestamp": 1790780400000
                    }
                  },
                  "revoked_api_key": {
                    "summary": "Authentication layer - API key revoked or disabled",
                    "value": {
                      "message": "API Key inválida.",
                      "details": "Invalid API Key"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`idempotency_key_reused`: the `Idempotency-Key` was already used with a **different body**. Nothing\nwas created. Send the new body under a new key; to read the original batch, use\n`GET /payments/register/batch/{id}`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "idempotency_key_reused",
                    "message": "This Idempotency-Key was already used with a different body. Use a new key for a different batch."
                  },
                  "timestamp": 1790780400000
                }
              }
            }
          },
          "500": {
            "description": "Unexpected failure (`internal_server_error`). Retrying with the **same** `Idempotency-Key` and body\nis safe: it returns the batch if it was created, or creates it.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "internal_server_error",
                    "message": "An internal server error occurred"
                  },
                  "timestamp": 1790780400000
                }
              }
            }
          }
        }
      }
    },
    "/payments/register/batch/{id}": {
      "get": {
        "operationId": "getPaymentRegisterBatch",
        "tags": [
          "Payments"
        ],
        "summary": "Get a payment batch",
        "description": "Returns the batch: the items rejected up front, and the progress of the accepted ones in `counts`. Poll it\nuntil `status` is `completed`, then read `result`, not `status`, to know how it went: `completed`\n(everything registered), `partially_completed` (some items have no payment) or `failed` (none registered).\n\nFor each payment's outcome, page through `GET /payments/register/batch/{id}/items`.\n\nA batch of another team, of the other mode (a live batch read with a test key), or an invoice batch\n(`ibatch_…`) answers `404`. Under gigstack Connect, send the same `team` the batch was created with.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Batch id, as returned by `POST /payments/register/batch`.",
            "schema": {
              "type": "string"
            },
            "example": "pbatch_7f3a9c1e5b2d4f6a8c0e2a4b6d8f0a1c"
          }
        ],
        "responses": {
          "200": {
            "description": "The batch.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicPaymentBatch"
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "processing": {
                    "summary": "Still registering",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "pbatch_7f3a9c1e5b2d4f6a8c0e2a4b6d8f0a1c",
                        "object": "payment_batch",
                        "livemode": true,
                        "status": "processing",
                        "result": null,
                        "total": 120,
                        "accepted": 119,
                        "rejected": [
                          {
                            "index": 7,
                            "idempotency_key": "txn-2026-10-000130",
                            "error": {
                              "code": "invalid_body",
                              "message": "payment_form: Invalid enum value"
                            }
                          }
                        ],
                        "counts": {
                          "queued": 60,
                          "registered": 58,
                          "failed": 0,
                          "duplicate": 1
                        },
                        "created_at": 1790780400000,
                        "completed_at": null
                      },
                      "timestamp": 1790781000000
                    }
                  },
                  "partially_completed": {
                    "summary": "Finished, some items have no payment",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "pbatch_7f3a9c1e5b2d4f6a8c0e2a4b6d8f0a1c",
                        "object": "payment_batch",
                        "livemode": true,
                        "status": "completed",
                        "result": "partially_completed",
                        "total": 120,
                        "accepted": 119,
                        "rejected": [
                          {
                            "index": 7,
                            "idempotency_key": "txn-2026-10-000130",
                            "error": {
                              "code": "invalid_body",
                              "message": "payment_form: Invalid enum value"
                            }
                          }
                        ],
                        "counts": {
                          "queued": 0,
                          "registered": 117,
                          "failed": 1,
                          "duplicate": 1
                        },
                        "created_at": 1790780400000,
                        "completed_at": 1790784000000
                      },
                      "timestamp": 1790784060000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "No payment batch with this id in your team and mode (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "not_found",
                    "message": "Payment batch not found"
                  },
                  "timestamp": 1790781000000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/payments/register/batch/{id}/items": {
      "get": {
        "operationId": "listPaymentRegisterBatchItems",
        "tags": [
          "Payments"
        ],
        "summary": "List the items of a payment batch",
        "description": "One entry per **accepted** item, in request order (ascending `index`), with its status and, once\nregistered, its payment. Items rejected up front are not listed; they are in the batch's `rejected`.\n\nCursor pagination: pass `data.next` back as `next` while `data.has_more` is `true`. The cursor is the last\n`index` of the page, so pages never overlap or skip items while statuses change. Filter with `status`,\nfor example `status=failed` to list only what needs fixing.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Batch id.",
            "schema": {
              "type": "string"
            },
            "example": "pbatch_7f3a9c1e5b2d4f6a8c0e2a4b6d8f0a1c"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items per page (default **100**, 1-500). Anything else is `400 invalid_limit`.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            },
            "example": 100
          },
          {
            "name": "next",
            "in": "query",
            "required": false,
            "description": "Cursor from the previous page's `data.next`. Omit for the first page. An invalid one is `400 invalid_cursor`.",
            "schema": {
              "type": "string"
            },
            "example": "99"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only items in this status. `queued` covers every item still in flight. Any other value is\n`400 invalid_status`. Omit for all items.\n",
            "schema": {
              "$ref": "#/components/schemas/PaymentBatchItemStatusEnum"
            },
            "example": "failed"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of items. Note the nesting: the array is at `data.data`, the cursor at `data.next`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicPaymentBatchItemsPage"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "data": [
                      {
                        "index": 0,
                        "idempotency_key": "txn-2026-10-000123",
                        "status": "registered",
                        "payment_id": "payment_a1b2c3d4e5",
                        "error": null,
                        "attempts": 1
                      },
                      {
                        "index": 1,
                        "idempotency_key": "txn-2026-10-000124",
                        "status": "duplicate",
                        "payment_id": "payment_f6e5d4c3b2",
                        "error": null,
                        "attempts": 1
                      },
                      {
                        "index": 2,
                        "idempotency_key": "txn-2026-10-000125",
                        "status": "failed",
                        "payment_id": null,
                        "error": {
                          "code": "validation_failed",
                          "message": "Resource resolution failed"
                        },
                        "attempts": 1
                      },
                      {
                        "index": 3,
                        "idempotency_key": "txn-2026-10-000126",
                        "status": "queued",
                        "payment_id": null,
                        "error": null,
                        "attempts": 2
                      }
                    ],
                    "next": "3",
                    "has_more": true
                  },
                  "timestamp": 1790781000000
                }
              }
            }
          },
          "400": {
            "description": "A query parameter is invalid. `error.code`: `invalid_limit`, `invalid_status` or `invalid_cursor`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "examples": {
                  "invalid_limit": {
                    "summary": "limit out of range",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_limit",
                        "message": "limit must be an integer between 1 and 500"
                      },
                      "timestamp": 1790781000000
                    }
                  },
                  "invalid_status": {
                    "summary": "Unknown status filter",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_status",
                        "message": "status must be one of queued, registered, failed, duplicate"
                      },
                      "timestamp": 1790781000000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "No payment batch with this id in your team and mode (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "not_found",
                    "message": "Payment batch not found"
                  },
                  "timestamp": 1790781000000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/payments/{id}/paid": {
      "post": {
        "operationId": "createPaymentsByIdPaid",
        "tags": [
          "Payments"
        ],
        "summary": "Mark payment as paid",
        "description": "Mark a payment as paid with the specified payment form.\n\n**gigstack Connect:** Mark other teams' payments as paid using the `team` parameter.\n\n## Required Information\n- **payment_form** (required): SAT-compliant payment form code (`01`–`31`, `99`)\n- **date** (optional): when the payment was received, in **Unix epoch milliseconds**\n  (13 digits). The handler passes the value straight to `Luxon.fromMillis()` and\n  compares it against `Luxon.now().toMillis()`; a seconds-based timestamp resolves to\n  1970 and is silently accepted. Defaults to now. A future date returns `400`.\n- **send_email** / **ignore_emails** (optional): `ignore_emails` takes precedence —\n  the handler resolves `ignore_emails ?? (send_email === false)`, so `ignore_emails: true`\n  suppresses notifications even when `send_email: true`.\n- **amount_received** (optional): cumulative amount received so far, in the payment's\n  currency. Omit it, or send the full payment amount, to mark the payment `succeeded`\n  (unchanged default behavior). Send less than the full amount to record a partial\n  top-up: the payment is set to `partially_paid` instead, triggering a partial payment\n  complement on the related PPD invoice. Requires the team's\n  `automatePartialPaymentComplements` default to be on and a `payment_complement`\n  automation already present on the payment. Sending more than the payment amount\n  returns `400`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Payment id.",
            "schema": {
              "type": "string"
            },
            "example": "payment_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MarkPaymentAsPaidInput"
              },
              "example": {
                "payment_form": "03",
                "date": 1767225600000,
                "ignore_emails": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment marked as paid successfully. When `amount_received` was less than the\npayment amount, the returned payment has `status: partially_paid` instead of\n`succeeded`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "payment_1234567890",
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "emails": [
                      "contabilidad@ejemplo.com"
                    ],
                    "currency": "MXN",
                    "allowed_payment_methods": [
                      "card",
                      "bank"
                    ],
                    "exchange_rate": 1,
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicios de consultoría profesional",
                        "quantity": 1,
                        "unit_price": 1000,
                        "product_key": "80141503",
                        "unit_key": "E48",
                        "unit_name": "Unidad de servicio",
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false
                          }
                        ],
                        "team": "team_1234567890",
                        "created_at": 1767225600000,
                        "from": "api"
                      }
                    ],
                    "metadata": {},
                    "team": "team_1234567890",
                    "idempotency_key": "payment-2026-0001",
                    "from": "api",
                    "invoices": [
                      "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
                    ],
                    "livemode": true,
                    "owner": "user_1234567890",
                    "payment_form": "03",
                    "payments": [],
                    "receipts": [],
                    "refunds": [],
                    "short_url": "https://gigstack.xyz/Xk3mP9",
                    "success_url": null,
                    "status": "succeeded",
                    "total": 1160,
                    "total_refunded": 0,
                    "subtotal": 1000,
                    "taxes": 160,
                    "discount": 0,
                    "withholding_taxes": 0,
                    "created_at": 1767225600000,
                    "succeeded_at": 1767225900000,
                    "payment_processor": "api"
                  },
                  "message": "Payment marked as paid successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad Request. `error.code: validation_failed` for schema failures (including\nunknown keys), or `invalid_request_body` for\n`date cannot be in the future`, `Payment is already marked as paid`,\n`Cannot mark a cancelled payment as paid`, `amount_received cannot exceed the\npayment amount`, `Partial payment complements are not enabled for this team`,\n`Payment does not have a payment complement automation configured`, and\n`amount_received must be greater than the amount already received`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Payment not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error — `Error marking payment as paid`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/payments/{id}/refund": {
      "post": {
        "operationId": "createPaymentsByIdRefund",
        "tags": [
          "Payments"
        ],
        "summary": "Refund payment",
        "description": "[Small working example](/recipes/refund)\n\n**Integration note:** Choose record-only versus an eligible Stripe refund before calling. amount is in currency units; response data.payment.amount and total_refunded are in minor units. Internal refund.status succeeded does not prove processor settlement. No idempotency key is documented for this endpoint.\n\nRefund a payment with a specified reason and amount.\n\n**gigstack Connect:** Refund other teams' payments using the `team` parameter.\n\n## Key Features\n- Partial or full refunds supported\n- Optional external processor refund handling\n- Automatic refund tracking and reporting\n- Supports Stripe integration for automatic processor refunds\n\n`reason` and `amount` are both required. `amount` must be at least **0.01** — the\nvalidator rejects anything below it.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Payment id.",
            "schema": {
              "type": "string"
            },
            "example": "payment_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundPaymentInput"
              },
              "example": {
                "reason": "Customer requested cancellation",
                "amount": 1160,
                "external_processor_refund": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment refunded successfully",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "refund": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "example": "refund_1234567890"
                                },
                                "reason": {
                                  "type": "string",
                                  "example": "Customer requested cancellation"
                                },
                                "total": {
                                  "type": "number",
                                  "description": "The refunded amount as supplied in the request.",
                                  "example": 1160
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "succeeded"
                                  ],
                                  "example": "succeeded"
                                },
                                "timestamp": {
                                  "type": "integer",
                                  "format": "int64",
                                  "example": 1767225600000
                                },
                                "from": {
                                  "type": "string",
                                  "enum": [
                                    "api"
                                  ],
                                  "example": "api"
                                },
                                "external_processor_refund": {
                                  "type": "boolean",
                                  "example": true
                                }
                              }
                            },
                            "payment": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "example": "payment_1234567890"
                                },
                                "amount": {
                                  "type": "number",
                                  "description": "Payment amount in cents.",
                                  "example": 116000
                                },
                                "total_refunded": {
                                  "type": "number",
                                  "description": "Cumulative refunded amount in cents.",
                                  "example": 116000
                                },
                                "refund_status": {
                                  "type": "string",
                                  "example": "refunded"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "refund": {
                      "id": "re_example",
                      "reason": "Agreed partial refund",
                      "total": 116,
                      "status": "succeeded",
                      "timestamp": 1767225600000,
                      "from": "api",
                      "external_processor_refund": false
                    },
                    "payment": {
                      "id": "payment_example",
                      "amount": 116000,
                      "total_refunded": 11600,
                      "refund_status": "requires_action"
                    }
                  },
                  "message": "Refund processed successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad Request. `validation_failed` when `amount < 0.01` or the body has unknown\nkeys; `invalid_request_body` for\n`Can only refund payments that have succeeded`,\n`Total refunded amount (…) cannot exceed payment amount (…)`, and\n`External processor refund is not allowed for this payment`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Payment not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error — `Error processing refund`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/payments/{id}/support-documents": {
      "post": {
        "operationId": "createPaymentsByIdSupportDocuments",
        "tags": [
          "Payments"
        ],
        "summary": "Upload a payment support document",
        "description": "Upload a supporting document (contract, proof of delivery, etc.) for a payment.\n\n**SAT 2026 Compliance:** The Mexican tax authority (SAT) can request supporting documentation\nto validate invoices and payments. This endpoint helps maintain compliance.\n\n**gigstack Connect:** Upload documents for other teams' payments using the `team` parameter.\n\n**Supported File Types:**\n- PDF files (.pdf)\n- Images (.png, .jpg, .jpeg, .webp)\n\n**File Size Limit:** 10MB\n\n**Document Types:**\n- `contract`: Service or product contracts\n- `delivery_proof`: Proof of delivery or service completion\n- `payment_proof`: Payment receipts or confirmations\n- `communication`: Emails, messages, or agreements\n- `payment_confirmation`: Payment processor confirmations\n- `subscription_info`: Subscription or recurring service details\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Payment ID",
            "example": "payment_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/UploadSupportDocumentInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Document uploaded. Standardized envelope (`timestamp` in epoch ms).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/SATDocument"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "doc_1234567890",
                    "document_type": "contract",
                    "name": "Contrato de servicios 2026",
                    "description": null,
                    "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_1234567890%2Fdocuments%2Fcontrato-2026.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                    "file_name": "contrato-2026.pdf",
                    "file_size": 284913,
                    "mime_type": "application/pdf",
                    "compliance_status": "pending_review",
                    "created_at": 1767225600000,
                    "linked_entities": [
                      {
                        "entity_type": "payment",
                        "entity_id": "payment_1234567890",
                        "linked_at": 1767225600000
                      }
                    ]
                  },
                  "message": "Support document uploaded successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Payment not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "getPaymentsByIdSupportDocuments",
        "tags": [
          "Payments"
        ],
        "summary": "List a payment's support documents",
        "description": "Retrieve all supporting documents attached to a payment.\n\n**gigstack Connect:** View documents for other teams' payments using the `team` parameter.\n\nDocuments are returned sorted by creation date (newest first).\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Payment ID",
            "example": "payment_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Documents retrieved, newest first. Standardized envelope (`timestamp` in epoch ms).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SATDocument"
                      }
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": [
                    {
                      "id": "doc_1234567890",
                      "document_type": "contract",
                      "name": "Contrato de servicios 2026",
                      "description": null,
                      "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_1234567890%2Fdocuments%2Fcontrato-2026.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                      "file_name": "contrato-2026.pdf",
                      "file_size": 284913,
                      "mime_type": "application/pdf",
                      "compliance_status": "pending_review",
                      "created_at": 1767225600000,
                      "linked_entities": [
                        {
                          "entity_type": "payment",
                          "entity_id": "payment_1234567890",
                          "linked_at": 1767225600000
                        }
                      ]
                    }
                  ],
                  "message": "Support documents retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Payment not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      }
    },
    "/receipts": {
      "get": {
        "operationId": "listReceipts",
        "tags": [
          "Receipts"
        ],
        "summary": "List receipts",
        "description": "Retrieve a paginated list of receipts.\n\n**gigstack Connect:** View other teams' receipts using the `team` parameter.\n\n**Filters:** only `client_id`, `tax_id` and the `created[...]` range are applied. `status`, `valid_until` and\n`metadata` are accepted but **ignored** — they do not narrow the results. Filter on those fields client-side.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGtParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLtParam"
          },
          {
            "$ref": "#/components/parameters/ClientIdFilterParam"
          },
          {
            "$ref": "#/components/parameters/TaxIdFilterParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Receipts retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "success": true,
                  "message": "Receipts retrieved successfully",
                  "data": [
                    {
                      "id": "receipt_1234567890",
                      "client": {
                        "id": "client_1234567890",
                        "name": "ESCUELA KEMPER URGATE",
                        "legal_name": "ESCUELA KEMPER URGATE",
                        "email": "contabilidad@ejemplo.com",
                        "bcc": [],
                        "phone": "+524421234567",
                        "tax_id": "EKU9003173C9",
                        "tax_system": "601",
                        "use": "G03",
                        "address": {
                          "street": "Av. Constituyentes",
                          "exterior": "1000",
                          "neighborhood": "Centro",
                          "city": "Querétaro",
                          "state": "QRO",
                          "zip": "76000",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "efos": {
                          "is_valid": true
                        },
                        "metadata": {},
                        "livemode": true,
                        "from": "api",
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      },
                      "currency": "MXN",
                      "exchange_rate": 1,
                      "from": "api",
                      "url": "https://invoicing.gigstack.pro/autofactura?id=receipt_1234567890",
                      "created_at": 1767225600000,
                      "invoices": [],
                      "items": [
                        {
                          "id": "service_1234567890",
                          "description": "Servicios de consultoría profesional",
                          "quantity": 1,
                          "unit_price": 1000,
                          "product_key": "80141503",
                          "unit_key": "E48",
                          "unit_name": "Unidad de servicio",
                          "taxes": [
                            {
                              "type": "IVA",
                              "rate": 0.16,
                              "factor": "Tasa",
                              "withholding": false
                            }
                          ],
                          "team": "team_1234567890",
                          "created_at": 1767225600000,
                          "from": "api"
                        }
                      ],
                      "livemode": true,
                      "metadata": {
                        "order_id": "ORD-12345"
                      },
                      "owner": "user_1234567890",
                      "payments": [
                        "payment_1234567890"
                      ],
                      "periodicity": "month",
                      "short_url": "https://gigstack.xyz/Rc8vQ2",
                      "status": "pending",
                      "team": "team_1234567890",
                      "valid_until": 1769817600000,
                      "automatic_invoice_error": null,
                      "payment_form": "03",
                      "total": 1160,
                      "total_refunded": 0,
                      "subtotal": 1000,
                      "taxes": 160,
                      "discount": 0,
                      "withholding_taxes": 0,
                      "idempotency_key": "receipt-key-12345"
                    }
                  ],
                  "next": null,
                  "has_more": false,
                  "total_results": 1,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createReceipts",
        "tags": [
          "Receipts"
        ],
        "summary": "Create receipt",
        "description": "[Small working example](/recipes/receipt)\n\n**Integration note:** A receipt is not yet a stamped CFDI. Repeating a creation idempotency_key returned HTTP 400 resource_conflict in staging. The tested response returned payment_form null despite a request value of 03; verify the fiscal document before issuing it.\n\nCreate a new receipt with items and client information. Receipts are pre-invoice documents\nthat can be later stamped as CFDI invoices.\n\n**Features:**\n- Automatic amount calculations with taxes\n- Flexible validity periods\n- Client auto-creation support\n- Metadata support for tracking\n- Idempotency support to prevent duplicate receipts\n\n**gigstack Connect:** Create receipts for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReceiptInput"
              },
              "example": {
                "client": {
                  "id": "client_1234567890"
                },
                "currency": "MXN",
                "items": [
                  {
                    "id": "service_1234567890",
                    "quantity": 1
                  }
                ],
                "periodicity": "month",
                "payment_form": "03",
                "idempotency_key": "receipt-key-12345",
                "metadata": {
                  "order_id": "ORD-12345"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Receipt created successfully. The receipt is stored with `status: pending` —\nno PAC call happens here, so no PAC-related error can be returned by this\noperation. Stamping happens later, via `POST /v2/receipts/{id}/stamp` or the\nself-invoicing portal.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "example": "Receipt created successfully"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "receipt_1234567890",
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "from": "api",
                    "url": "https://invoicing.gigstack.pro/autofactura?id=receipt_1234567890",
                    "created_at": 1767225600000,
                    "invoices": [],
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicios de consultoría profesional",
                        "quantity": 1,
                        "unit_price": 1000,
                        "product_key": "80141503",
                        "unit_key": "E48",
                        "unit_name": "Unidad de servicio",
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false
                          }
                        ],
                        "team": "team_1234567890",
                        "created_at": 1767225600000,
                        "from": "api"
                      }
                    ],
                    "livemode": true,
                    "metadata": {
                      "order_id": "ORD-12345"
                    },
                    "owner": "user_1234567890",
                    "payments": [
                      "payment_1234567890"
                    ],
                    "periodicity": "month",
                    "short_url": "https://gigstack.xyz/Rc8vQ2",
                    "status": "pending",
                    "team": "team_1234567890",
                    "valid_until": 1769817600000,
                    "automatic_invoice_error": null,
                    "payment_form": "03",
                    "total": 1160,
                    "total_refunded": 0,
                    "subtotal": 1000,
                    "taxes": 160,
                    "discount": 0,
                    "withholding_taxes": 0,
                    "idempotency_key": "receipt-key-12345"
                  },
                  "message": "Receipt created successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad Request. `error.code`:\n- `validation_failed` — schema failure, including unknown keys.\n- `invalid_request_body` — `Items are required for receipt creation`, `Exchange rate not found`.\n- `resource_conflict` — the supplied `idempotency_key` already exists. Note the\n  status is **400**, not 409, despite the code name.\n- `resource_resolution_failed` — the `client`/`items` reference could not be\n  resolved (e.g. both `id` and `search` supplied, or `safety_check` matched\n  several records).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Referenced client or service belongs to another team, or `livemode` mismatch.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Referenced client or service id was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "409": {
            "description": "A concurrent create holds the client/service lock — retry the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Team credit limit reached. Returned in the standardized envelope with\n`error.code: team_credit_limit_reached`; `error.details` carries the reason\nreported by the credit checker.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "team_credit_limit_reached",
                    "message": "Team credit limit reached",
                    "details": "Credit limit of 100 documents reached for this billing period"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error — `An error occurred while creating receipt`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/receipts/search": {
      "get": {
        "operationId": "getReceiptsSearch",
        "tags": [
          "Receipts"
        ],
        "summary": "Search receipts",
        "description": "Full-text search across receipts using Typesense. Provides fast, typo-tolerant search capabilities.\n\n**gigstack Connect:** Access other teams' receipts using the `team` parameter.\n\n**Search Capabilities:**\n- Search across client name, email, receipt description, and metadata\n- Typo-tolerant fuzzy matching\n- Paginated results\n\n**Requirements:**\n- Typesense must be configured for your team\n- The `q` (or `query`) parameter is required\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/SearchQueryParam"
          },
          {
            "$ref": "#/components/parameters/SearchQueryBackwardCompatParam"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/SearchPageParam"
          },
          {
            "$ref": "#/components/parameters/ReceiptsSearchFieldsParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Receipts searched successfully",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SearchResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "message": "Receipts searched successfully",
                  "data": [
                    {
                      "id": "receipt_1234567890",
                      "client": {
                        "id": "client_1234567890",
                        "name": "ESCUELA KEMPER URGATE",
                        "legal_name": "ESCUELA KEMPER URGATE",
                        "email": "contabilidad@ejemplo.com",
                        "bcc": [],
                        "phone": "+524421234567",
                        "tax_id": "EKU9003173C9",
                        "tax_system": "601",
                        "use": "G03",
                        "address": {
                          "street": "Av. Constituyentes",
                          "exterior": "1000",
                          "neighborhood": "Centro",
                          "city": "Querétaro",
                          "state": "QRO",
                          "zip": "76000",
                          "country": "MEX"
                        },
                        "is_valid": true,
                        "efos": {
                          "is_valid": true
                        },
                        "metadata": {},
                        "livemode": true,
                        "from": "api",
                        "owner": "user_1234567890",
                        "team": "team_1234567890",
                        "created_at": 1767225600000
                      },
                      "currency": "MXN",
                      "exchange_rate": 1,
                      "from": "api",
                      "url": "https://invoicing.gigstack.pro/autofactura?id=receipt_1234567890",
                      "created_at": 1767225600000,
                      "invoices": [],
                      "items": [
                        {
                          "id": "service_1234567890",
                          "description": "Servicios de consultoría profesional",
                          "quantity": 1,
                          "unit_price": 1000,
                          "product_key": "80141503",
                          "unit_key": "E48",
                          "unit_name": "Unidad de servicio",
                          "taxes": [
                            {
                              "type": "IVA",
                              "rate": 0.16,
                              "factor": "Tasa",
                              "withholding": false
                            }
                          ],
                          "team": "team_1234567890",
                          "created_at": 1767225600000,
                          "from": "api"
                        }
                      ],
                      "livemode": true,
                      "metadata": {
                        "order_id": "ORD-12345"
                      },
                      "owner": "user_1234567890",
                      "payments": [
                        "payment_1234567890"
                      ],
                      "periodicity": "month",
                      "short_url": "https://gigstack.xyz/Rc8vQ2",
                      "status": "pending",
                      "team": "team_1234567890",
                      "valid_until": 1769817600000,
                      "automatic_invoice_error": null,
                      "payment_form": "03",
                      "total": 1160,
                      "total_refunded": 0,
                      "subtotal": 1000,
                      "taxes": 160,
                      "discount": 0,
                      "withholding_taxes": 0,
                      "idempotency_key": "receipt-key-12345"
                    }
                  ],
                  "found": 1,
                  "page": 1,
                  "per_page": 10,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "missing_query": {
                    "summary": "Missing query parameter",
                    "value": {
                      "error": {
                        "code": "missing_query",
                        "message": "Query parameter is required"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "missing_typesense_key": {
                    "summary": "Typesense not configured",
                    "value": {
                      "error": {
                        "code": "missing_typesense_key",
                        "message": "Typesense API key not configured for this team"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_fields": {
                    "summary": "A field that cannot be searched",
                    "value": {
                      "error": {
                        "code": "invalid_fields",
                        "message": "Cannot search in id. `fields` sets the fields to search in; for receipts use any of: objectId, ..., or metadata.<key>"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_search": {
                    "summary": "Requested fields this team's index does not have",
                    "value": {
                      "error": {
                        "code": "invalid_search",
                        "message": "The search request was rejected. Check that the `fields` exist for this team."
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/receipts/from-payments": {
      "post": {
        "operationId": "createReceiptsFromPayments",
        "tags": [
          "Receipts"
        ],
        "summary": "Create receipts for paid payments",
        "description": "Create one pending receipt for every paid payment in a date range that has neither an\ninvoice nor a receipt yet, so each client can invoice it from the self-invoicing portal.\nThe range is on the payment's creation date and defaults to the current month\n(Mexico City time); it can span at most one year.\n\nSend `dry_run: true` first: it only counts (`count`, `total`, `with_email`) and works\non any plan. Creating the receipts is only available on Pricing v3 plans (`403 v3_only`\non earlier plans), and live v3 teams need the self-invoice portal (`self_invoice_portal`,\n`403 feature_not_enabled` otherwise). Each call creates at most 200\nreceipts, oldest first; `remaining` says how many are left, so call again until it is 0.\nPayments that got a receipt meanwhile are skipped, so repeating a call is safe.\n\nThe receipt is dated when the payment was made (`date`), is billed when it is created,\nand is valid until the end of the current month. Clients are emailed the link only with\n`send_email: true`. Teams with receipts turned off (`avoid_receipts`) get `409`.\n\n**gigstack Connect:** create other teams' receipts with the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "start": {
                    "type": "number",
                    "nullable": true,
                    "example": 1790834400000,
                    "description": "Range start (ms). Default: first day of the current month."
                  },
                  "end": {
                    "type": "number",
                    "nullable": true,
                    "example": 1793512799000,
                    "description": "Range end (ms). Default: now."
                  },
                  "dry_run": {
                    "type": "boolean",
                    "nullable": true,
                    "example": true,
                    "description": "Only count; create nothing."
                  },
                  "send_email": {
                    "type": "boolean",
                    "nullable": true,
                    "example": false,
                    "description": "Email each client the self-invoicing link. Default false."
                  }
                }
              },
              "example": {
                "dry_run": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Preview (`dry_run`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "start": 1790834400000,
                    "end": 1793041200000,
                    "count": 24,
                    "total": 52310.5,
                    "with_email": 24,
                    "truncated": false,
                    "dry_run": true
                  },
                  "message": "Preview of receipts to create",
                  "timestamp": 1793041200000
                }
              }
            }
          },
          "201": {
            "description": "Receipts created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "start": 1790834400000,
                    "end": 1793041200000,
                    "count": 24,
                    "total": 52310.5,
                    "with_email": 24,
                    "truncated": false,
                    "dry_run": false,
                    "created": 24,
                    "skipped": 0,
                    "remaining": 0,
                    "stopped_reason": null,
                    "receipts": [
                      {
                        "receipt": "receipt_1234567890",
                        "payment": "payment_1234567890"
                      }
                    ]
                  },
                  "message": "24 receipts created",
                  "timestamp": 1793041200000
                }
              }
            }
          },
          "400": {
            "description": "`start`/`end` are not timestamps, `end` is before `start`, or the range is longer than a year.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`v3_only`: creating receipts from payments needs a Pricing v3 plan. `feature_not_enabled`: the self-invoice portal is not on for this live v3 team.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Receipts are turned off for this team (`avoid_receipts`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/receipts/{id}": {
      "get": {
        "operationId": "getReceiptsById",
        "tags": [
          "Receipts"
        ],
        "summary": "Get receipt",
        "description": "Retrieve a specific receipt by ID.\n\n**gigstack Connect:** View other teams' receipts using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "receipt_1234567890",
            "description": "Receipt ID"
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Receipt retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "receipt_1234567890",
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "from": "api",
                    "url": "https://invoicing.gigstack.pro/autofactura?id=receipt_1234567890",
                    "created_at": 1767225600000,
                    "invoices": [],
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicios de consultoría profesional",
                        "quantity": 1,
                        "unit_price": 1000,
                        "product_key": "80141503",
                        "unit_key": "E48",
                        "unit_name": "Unidad de servicio",
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false
                          }
                        ],
                        "team": "team_1234567890",
                        "created_at": 1767225600000,
                        "from": "api"
                      }
                    ],
                    "livemode": true,
                    "metadata": {
                      "order_id": "ORD-12345"
                    },
                    "owner": "user_1234567890",
                    "payments": [
                      "payment_1234567890"
                    ],
                    "periodicity": "month",
                    "short_url": "https://gigstack.xyz/Rc8vQ2",
                    "status": "pending",
                    "team": "team_1234567890",
                    "valid_until": 1769817600000,
                    "automatic_invoice_error": null,
                    "payment_form": "03",
                    "total": 1160,
                    "total_refunded": 0,
                    "subtotal": 1000,
                    "taxes": 160,
                    "discount": 0,
                    "withholding_taxes": 0,
                    "idempotency_key": "receipt-key-12345"
                  },
                  "message": "Receipt retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Receipt not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "deleteReceiptsById",
        "deprecated": true,
        "tags": [
          "Receipts"
        ],
        "summary": "Cancel receipt (deprecated DELETE)",
        "description": "**Deprecated:** use [`POST /receipts/{id}/cancel`](/reference/cancelReceiptById), which runs the same handler. Cancelling does not delete the receipt: it stays readable, completed without an invoice.\nThis route keeps working; its responses carry `Deprecation: true` and `Link: </v2/receipts/{id}/cancel>; rel=\"successor-version\"`, with the\nconcrete ID in place of each path parameter.\n\nCancel a receipt. This action cannot be undone.\n\n**gigstack Connect:** Cancel other teams' receipts using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "receipt_1234567890",
            "description": "Receipt ID"
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Receipt canceled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "receipt_1234567890",
                    "status": "completed",
                    "cancelled_at": 1767225600000
                  },
                  "message": "Receipt cancelled successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/receipts/{id}/cancel": {
      "post": {
        "operationId": "cancelReceiptById",
        "tags": [
          "Receipts"
        ],
        "summary": "Cancel receipt",
        "description": "Cancel a receipt. This action cannot be undone.\n\n**gigstack Connect:** Cancel other teams' receipts using the `team` parameter.\n\nReplaces the deprecated [`DELETE /receipts/{id}`](/reference/deleteReceiptsById), which runs the same handler. Cancelling does not delete the receipt: it stays readable, completed without an invoice.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "receipt_1234567890",
            "description": "Receipt ID"
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Receipt canceled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "receipt_1234567890",
                    "status": "completed",
                    "cancelled_at": 1767225600000
                  },
                  "message": "Receipt cancelled successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/receipts/{id}/stamp": {
      "post": {
        "operationId": "createReceiptsByIdStamp",
        "tags": [
          "Receipts"
        ],
        "summary": "Stamp receipt",
        "description": "Convert a receipt into a CFDI invoice by stamping it with SAT.\n\nOnly receipts with `status: pending` can be stamped. A receipt that already has\nentries in `invoices[]` is returned as-is with a `200` and no new CFDI; any other\nnon-pending receipt (a cancelled one is stored as `completed`) is rejected with a\n`409`.\n\n**Stamp Options:**\n- `client`: Stamp to the associated client\n- `general_public_national`: Stamp to Mexican general public\n- `general_public_foreign`: Stamp to foreign general public\n\n**gigstack Connect:** Stamp other teams' receipts using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "receipt_1234567890",
            "description": "Receipt ID"
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "stamp_to"
                ],
                "properties": {
                  "idempotency_key": {
                    "type": "string",
                    "nullable": true,
                    "example": "stamp-receipt-2026-09-11-001",
                    "description": "Optional. A retry that reuses the key returns 409 with the receipt id instead of attempting a second stamp."
                  },
                  "stamp_to": {
                    "type": "string",
                    "enum": [
                      "client",
                      "general_public_national",
                      "general_public_foreign"
                    ],
                    "example": "client",
                    "description": "Who to stamp the receipt to"
                  },
                  "fiscal_information": {
                    "type": "object",
                    "nullable": true,
                    "properties": {
                      "legal_name": {
                        "type": "string",
                        "nullable": true,
                        "example": "Juan Pérez García"
                      },
                      "tax_id": {
                        "type": "string",
                        "nullable": true,
                        "example": "PEGJ800101ABC"
                      },
                      "tax_system": {
                        "type": "string",
                        "nullable": true,
                        "example": "601"
                      },
                      "zip": {
                        "type": "string",
                        "nullable": true,
                        "example": "01000"
                      }
                    },
                    "description": "Custom fiscal information (overrides client data)"
                  },
                  "date": {
                    "type": "number",
                    "nullable": true,
                    "example": 1677651234000,
                    "description": "Custom invoice date (timestamp in milliseconds)"
                  }
                }
              },
              "example": {
                "stamp_to": "client",
                "date": 1767225600000
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Receipt stamped successfully. **This handler predates the standardized\nenvelope** — it returns the raw shape `{ \"message\": …, \"data\": … }` with no\n`success` or `timestamp` keys.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data"
                  ],
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Receipt stamped successfully"
                    },
                    "data": {
                      "type": "object",
                      "description": "The stamped receipt."
                    }
                  }
                },
                "example": {
                  "message": "Receipt stamped successfully",
                  "data": {
                    "id": "receipt_1234567890",
                    "client": {
                      "id": "client_1234567890",
                      "name": "ESCUELA KEMPER URGATE",
                      "legal_name": "ESCUELA KEMPER URGATE",
                      "email": "contabilidad@ejemplo.com",
                      "bcc": [],
                      "phone": "+524421234567",
                      "tax_id": "EKU9003173C9",
                      "tax_system": "601",
                      "use": "G03",
                      "address": {
                        "street": "Av. Constituyentes",
                        "exterior": "1000",
                        "neighborhood": "Centro",
                        "city": "Querétaro",
                        "state": "QRO",
                        "zip": "76000",
                        "country": "MEX"
                      },
                      "is_valid": true,
                      "efos": {
                        "is_valid": true
                      },
                      "metadata": {},
                      "livemode": true,
                      "from": "api",
                      "owner": "user_1234567890",
                      "team": "team_1234567890",
                      "created_at": 1767225600000
                    },
                    "currency": "MXN",
                    "exchange_rate": 1,
                    "from": "api",
                    "url": "https://invoicing.gigstack.pro/autofactura?id=receipt_1234567890",
                    "created_at": 1767225600000,
                    "invoices": [
                      "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
                    ],
                    "items": [
                      {
                        "id": "service_1234567890",
                        "description": "Servicios de consultoría profesional",
                        "quantity": 1,
                        "unit_price": 1000,
                        "product_key": "80141503",
                        "unit_key": "E48",
                        "unit_name": "Unidad de servicio",
                        "taxes": [
                          {
                            "type": "IVA",
                            "rate": 0.16,
                            "factor": "Tasa",
                            "withholding": false
                          }
                        ],
                        "team": "team_1234567890",
                        "created_at": 1767225600000,
                        "from": "api"
                      }
                    ],
                    "livemode": true,
                    "metadata": {
                      "order_id": "ORD-12345"
                    },
                    "owner": "user_1234567890",
                    "payments": [
                      "payment_1234567890"
                    ],
                    "periodicity": "month",
                    "short_url": "https://gigstack.xyz/Rc8vQ2",
                    "status": "completed",
                    "team": "team_1234567890",
                    "valid_until": 1769817600000,
                    "automatic_invoice_error": null,
                    "payment_form": "03",
                    "total": 1160,
                    "total_refunded": 0,
                    "subtotal": 1000,
                    "taxes": 160,
                    "discount": 0,
                    "withholding_taxes": 0,
                    "idempotency_key": "receipt-key-12345"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, returned in the raw legacy shape. Cases:\n- body validation failure — `{ \"error\": \"Invalid request body\", \"errors\": [...] }`\n- `fiscal_information cannot be provided when stamp_to is general_public`\n- `fiscal_information is required when stamp_to is client and receipt has no client`\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "`Receipt data not found`, or `Client not found in database` when `stamp_to: client`\nresolves to a client document that no longer exists.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The receipt is not pending, so it cannot be stamped. Receipts that already\nproduced a CFDI return `200` with their `invoices[]` instead.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal error, raw shape. **PAC failures surface here as 500, not 503** — when\nthe stamping provider returns a non-OK response the handler emits\n`{ \"error\": <provider message>, \"message\": \"Failed to process receipt: <status> <statusText>\" }`.\nAlso covers `Receipt reference not found` and the uncaught-exception body\n`{ \"error\": { \"code\": \"stamp_receipt_handler_error\", \"message\": …, \"details\": … }, \"message\": … }`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/receipts/{id}/reopen": {
      "post": {
        "operationId": "createReceiptsByIdReopen",
        "tags": [
          "Receipts"
        ],
        "summary": "Reopen receipt",
        "description": "Return a receipt whose self-invoicing failed to `status: pending`, so the client can\ntry again from the self-invoicing portal.\n\nOnly a receipt that is **not** `pending` and has **no** entries in `invoices[]` can be\nreopened: an already-pending receipt and one that produced a CFDI are both rejected\nwith `409`. The response clears `automatic_invoice_error`; who reopened it and why are\nrecorded on the receipt but are not part of the API response.\n\n**gigstack Connect:** reopen other teams' receipts with the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "receipt_1234567890",
            "description": "Receipt ID"
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 500,
                    "example": "El cliente pidió corregir su RFC",
                    "description": "Optional note kept on the receipt for your own audit trail."
                  }
                }
              },
              "example": {
                "reason": "El cliente pidió corregir su RFC"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Receipt reopened for self-invoicing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "receipt_1234567890",
                    "status": "pending",
                    "automatic_invoice_error": null,
                    "periodicity": "month",
                    "valid_until": 1769817600000
                  },
                  "message": "Receipt reopened for self-invoicing",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "`reason` is not a string, or is longer than 500 characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The receipt belongs to another team.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "The receipt does not exist, or its `livemode` does not match the API key — a\ntest key never resolves a live receipt, and a live key never resolves a test\none, so the other environment's ids are answered as not found.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "409": {
            "description": "The receipt is already `pending`, or it already has one or more invoices.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/retentions": {
      "get": {
        "operationId": "listRetentions",
        "tags": [
          "Retentions"
        ],
        "summary": "List retentions",
        "description": "Retrieve a paginated list of tax retention documents (CFDI Retenciones 2.0).\n\n**gigstack Connect:** View other teams' retentions using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGtParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLtParam"
          },
          {
            "$ref": "#/components/parameters/ClientIdFilterParam"
          },
          {
            "$ref": "#/components/parameters/TaxIdFilterParam"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "valid",
                "canceled"
              ]
            },
            "description": "Filter by retention status"
          },
          {
            "name": "retention_key",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by SAT retention key (cveRetenc), e.g. \"26\" for Plataformas Tecnológicas"
          }
        ],
        "responses": {
          "200": {
            "description": "Retentions retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "examples": {
                  "list_retentions": {
                    "summary": "List of retentions",
                    "value": {
                      "data": [
                        {
                          "id": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                          "uuid": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                          "status": "valid",
                          "document_type": "retenciones",
                          "retention_key": "26",
                          "folio_number": "1",
                          "series": "RET",
                          "issuer": {
                            "legal_name": "MI EMPRESA SA DE CV",
                            "tax_id": "MEE200101ABC",
                            "tax_system": "601"
                          },
                          "receiver": {
                            "legal_name": "GRUPO JINIM",
                            "tax_id": "EKU9003173C9",
                            "nationality": "Nacional"
                          },
                          "period": {
                            "start": 1,
                            "end": 1,
                            "year": 2026
                          },
                          "totals": {
                            "total_operation": 93116.98,
                            "total_taxable": 93116.98,
                            "total_exempt": 0,
                            "total_retained": 9777.27,
                            "tax_retained": [
                              {
                                "tax": "001",
                                "base": 93116.98,
                                "amount": 2327.92,
                                "payment_type": "03"
                              },
                              {
                                "tax": "002",
                                "base": 14898.71,
                                "amount": 7449.35,
                                "payment_type": "01"
                              }
                            ]
                          },
                          "stamp": {
                            "uuid": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                            "stamped_at": "2026-01-15T10:30:45.000Z"
                          },
                          "livemode": true,
                          "created_at": 1736942445000
                        },
                        {
                          "id": "c4e2f1a8-9b3d-4e7f-a1c2-8d5e6f7a0b3c",
                          "uuid": "c4e2f1a8-9b3d-4e7f-a1c2-8d5e6f7a0b3c",
                          "status": "valid",
                          "document_type": "retenciones",
                          "retention_key": "01",
                          "folio_number": "2",
                          "series": "RET",
                          "receiver": {
                            "legal_name": "JUAN PEREZ GARCIA",
                            "tax_id": "PEGJ800101ABC",
                            "nationality": "Nacional"
                          },
                          "period": {
                            "start": 1,
                            "end": 3,
                            "year": 2026
                          },
                          "totals": {
                            "total_operation": 50000,
                            "total_taxable": 50000,
                            "total_exempt": 0,
                            "total_retained": 5000,
                            "tax_retained": [
                              {
                                "tax": "001",
                                "base": 50000,
                                "amount": 5000,
                                "payment_type": "03"
                              }
                            ]
                          },
                          "livemode": true,
                          "created_at": 1736510430000
                        }
                      ],
                      "has_more": false,
                      "message": "Operation completed successfully",
                      "total_results": 1,
                      "success": true,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          }
        }
      },
      "post": {
        "operationId": "createRetentions",
        "tags": [
          "Retentions"
        ],
        "summary": "Create retention",
        "description": "Create and stamp a new tax retention document (CFDI Retenciones 2.0).\n\nThe API accepts a **simplified format** — the backend handles:\n- **Client lookup** by ID (fetches RFC, legal name, address automatically)\n- **Nationality detection** from client's country\n- **Tax code mapping** (`ISR` → 001, `IVA` → 002, `IEPS` → 003)\n- **Payment type defaults** per tax (ISR → provisional, IVA/IEPS → definitivo)\n- **Totals auto-calculation** (taxable = operation − exempt, retained = sum of taxes)\n- **Folio auto-generation**\n- SAT stamping, PDF and XML generation\n\n**gigstack Connect:** Create retentions for other teams using the `team` parameter.\n\n## Conditional requirements per `retention_key`\n\n`retention_key` is validated as a free-form string — any SAT key is accepted — but three\nkeys carry extra requirements enforced before the document is stamped. A violation\nreturns `400` with `error.code: invalid_request_body` and the message quoted below.\n\n| `retention_key` | additional requirement | error message on violation |\n|---|---|---|\n| `16` — Intereses | `interest` object is required | `interest object is required for retention key 16 (Intereses)` |\n| `25` — Otro tipo de retenciones | `retention_description` is required and non-empty | `retention_description is required for retention key 25 (Otro tipo de retenciones)` |\n| `26` — Plataformas Tecnológicas | `platform_services` object is required **and** `taxes` must contain at least one entry whose `tax` is not `IVA` (i.e. `ISR` or `IEPS`) | `platform_services object is required for retention key 26 (Plataformas Tecnológicas)` / `At least one non-IVA tax (ISR or IEPS) is required for Plataformas Tecnológicas` |\n\nEvery other key requires only the base fields (`retention_key`, `client`,\n`period_start`, `period_end`, `period_year`, `total_operation`, `taxes`).\n\nWithin `interest`, `financial_system`, `nominal_interest` and `real_interest` are\nrequired. Within `platform_services`, `periodicity` and `services` are required, and\neach entry in `services` requires `payment_form`, `service_type`, `service_date` and\n`price_without_tax`.\n\n> Unlike the other modules, this endpoint **strips** unknown keys instead of rejecting\n> them (`stripUnknown: true`), so an undeclared field is silently discarded rather than\n> returning `400`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "retention_key",
                  "client",
                  "period_start",
                  "period_end",
                  "period_year",
                  "total_operation",
                  "taxes"
                ],
                "properties": {
                  "retention_key": {
                    "type": "string",
                    "description": "SAT retention type code (01-26). E.g. \"26\" for Plataformas Tecnológicas",
                    "example": "26"
                  },
                  "client": {
                    "type": "object",
                    "description": "Client reference. Same format as invoices/payments. Three modes:\n- **By ID:** `{ id: \"client_123\" }` — looks up existing client\n- **By search:** `{ search: { on_key: \"tax_id\", on_value: \"XAXX010101000\", auto_create: true } }` — finds or creates\n- **Inline:** `{ tax_id: \"XAXX010101000\", legal_name: \"EMPRESA SA\", address: { zip: \"06700\" } }` — creates on-the-fly\n",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Existing client ID"
                      },
                      "search": {
                        "type": "object",
                        "description": "Search for client by field value",
                        "properties": {
                          "on_key": {
                            "type": "string",
                            "description": "Field to search on (e.g. \"tax_id\", \"email\", \"rfc\")"
                          },
                          "on_value": {
                            "type": "string",
                            "description": "Value to match"
                          },
                          "auto_create": {
                            "type": "boolean",
                            "description": "Create client if not found (default false)"
                          },
                          "safety_check": {
                            "type": "boolean",
                            "description": "Fail if multiple clients match (default false)"
                          }
                        }
                      },
                      "tax_id": {
                        "type": "string",
                        "description": "RFC / Tax ID (for inline creation)"
                      },
                      "legal_name": {
                        "type": "string",
                        "description": "Legal name (for inline creation)"
                      },
                      "email": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "address": {
                        "type": "object",
                        "properties": {
                          "zip": {
                            "type": "string"
                          },
                          "country": {
                            "type": "string"
                          },
                          "street": {
                            "type": "string"
                          },
                          "state": {
                            "type": "string"
                          }
                        }
                      },
                      "tax_system": {
                        "type": "string",
                        "description": "Tax system code (e.g. \"601\")"
                      }
                    }
                  },
                  "period_start": {
                    "type": "number",
                    "description": "Start month (1-12)",
                    "example": 1
                  },
                  "period_end": {
                    "type": "number",
                    "description": "End month (1-12)",
                    "example": 3
                  },
                  "period_year": {
                    "type": "number",
                    "description": "Fiscal year",
                    "example": 2026
                  },
                  "total_operation": {
                    "type": "number",
                    "description": "Total operation amount. Taxable amount is auto-calculated as `total_operation - total_exempt`",
                    "example": 93116.98
                  },
                  "total_exempt": {
                    "type": "number",
                    "nullable": true,
                    "description": "Total exempt amount (defaults to 0)",
                    "example": 0
                  },
                  "taxes": {
                    "type": "array",
                    "description": "Retained taxes. Use friendly names (ISR, IVA, IEPS) — SAT codes are mapped automatically",
                    "items": {
                      "type": "object",
                      "required": [
                        "tax",
                        "base",
                        "amount"
                      ],
                      "properties": {
                        "tax": {
                          "type": "string",
                          "description": "Tax name: ISR, IVA, or IEPS (mapped to SAT codes 001, 002, 003)",
                          "example": "ISR"
                        },
                        "base": {
                          "type": "number",
                          "description": "Tax base amount",
                          "example": 93116.98
                        },
                        "amount": {
                          "type": "number",
                          "description": "Retained amount",
                          "example": 2327.92
                        },
                        "payment_type": {
                          "type": "string",
                          "nullable": true,
                          "description": "Override payment type (01=Definitivo, 03=Provisional). Defaults: ISR→03, IVA→01, IEPS→01"
                        }
                      }
                    }
                  },
                  "series": {
                    "type": "string",
                    "nullable": true,
                    "description": "Series for folio management (defaults to \"RET\")"
                  },
                  "metadata": {
                    "type": "object",
                    "nullable": true,
                    "description": "Custom metadata"
                  },
                  "idempotency_key": {
                    "type": "string",
                    "nullable": true,
                    "description": "Optional stored reference. This handler does not claim or replay this key to prevent duplicate issuance. Reconcile an ambiguous result before another request; do not assume retry safety."
                  },
                  "retention_description": {
                    "type": "string",
                    "nullable": true,
                    "description": "Required only for key \"25\" (Otro tipo de retenciones). Free-text description of the retention type."
                  },
                  "interest": {
                    "type": "object",
                    "nullable": true,
                    "description": "Required only for key \"16\" (Intereses). Financial interest complement data.",
                    "properties": {
                      "financial_system": {
                        "type": "string",
                        "description": "Financial system flag (SI/NO)",
                        "enum": [
                          "SI",
                          "NO"
                        ]
                      },
                      "withdrawal_aores": {
                        "type": "string",
                        "nullable": true,
                        "description": "Retiro AORES flag (SI/NO)",
                        "enum": [
                          "SI",
                          "NO",
                          null
                        ]
                      },
                      "financial_derivatives": {
                        "type": "string",
                        "nullable": true,
                        "description": "Financial derivatives flag (SI/NO)",
                        "enum": [
                          "SI",
                          "NO",
                          null
                        ]
                      },
                      "nominal_interest": {
                        "type": "number",
                        "description": "Nominal interest amount (3 decimal places)"
                      },
                      "real_interest": {
                        "type": "number",
                        "description": "Real interest amount (3 decimal places)"
                      },
                      "loss": {
                        "type": "number",
                        "nullable": true,
                        "description": "Loss amount (3 decimal places)"
                      }
                    }
                  },
                  "platform_services": {
                    "type": "object",
                    "nullable": true,
                    "description": "Required only for key \"26\" (Plataformas Tecnológicas). Service details for technology platform retentions. Header totals (IVA trasladado, ISR retenido, etc.) are auto-calculated.",
                    "required": [
                      "periodicity",
                      "services"
                    ],
                    "properties": {
                      "periodicity": {
                        "type": "string",
                        "description": "Reporting periodicity: 01=Diario, 02=Semanal, 03=Quincenal, 04=Mensual, 05=Bimestral",
                        "example": "04"
                      },
                      "services": {
                        "type": "array",
                        "description": "Individual service entries",
                        "items": {
                          "type": "object",
                          "required": [
                            "payment_form",
                            "service_type",
                            "service_date",
                            "price_without_tax"
                          ],
                          "properties": {
                            "payment_form": {
                              "type": "string",
                              "description": "Payment form: 01=Efectivo, 02=Transferencia, 03=Tarjeta débito, 04=Tarjeta crédito, 05=Monedero electrónico",
                              "example": "02"
                            },
                            "service_type": {
                              "type": "string",
                              "description": "Service type: 01=Transporte terrestre, 02=Entrega alimentos, 03=Hospedaje, 04=Otros",
                              "example": "01"
                            },
                            "service_date": {
                              "type": "string",
                              "description": "Service date (YYYY-MM-DD)",
                              "example": "2026-01-15"
                            },
                            "price_without_tax": {
                              "type": "number",
                              "description": "Service price without IVA",
                              "example": 500
                            },
                            "tax_rate": {
                              "type": "number",
                              "nullable": true,
                              "description": "IVA tax rate (defaults to 0.16 = 16%)",
                              "example": 0.16
                            },
                            "commission": {
                              "type": "number",
                              "nullable": true,
                              "description": "Platform commission amount",
                              "example": 125
                            },
                            "government_contribution": {
                              "type": "number",
                              "nullable": true,
                              "description": "Government contribution amount (if applicable)"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              },
              "examples": {
                "plataformas_tecnologicas": {
                  "summary": "Plataformas Tecnológicas (key 26) — with services complement",
                  "description": "Digital platform retention (Uber, Rappi, etc.). Requires platform_services with service details. Header totals are auto-calculated from services and taxes.",
                  "value": {
                    "retention_key": "26",
                    "client": {
                      "id": "abc123clientId"
                    },
                    "period_start": 1,
                    "period_end": 1,
                    "period_year": 2026,
                    "total_operation": 93116.98,
                    "total_exempt": 0,
                    "taxes": [
                      {
                        "tax": "ISR",
                        "base": 93116.98,
                        "amount": 2327.92
                      },
                      {
                        "tax": "IVA",
                        "base": 14898.71,
                        "amount": 7449.35
                      }
                    ],
                    "platform_services": {
                      "periodicity": "04",
                      "services": [
                        {
                          "payment_form": "02",
                          "service_type": "01",
                          "service_date": "2026-01-10",
                          "price_without_tax": 46558.49,
                          "tax_rate": 0.16,
                          "commission": 11639.62
                        },
                        {
                          "payment_form": "02",
                          "service_type": "01",
                          "service_date": "2026-01-20",
                          "price_without_tax": 46558.49,
                          "tax_rate": 0.16,
                          "commission": 11639.62
                        }
                      ]
                    }
                  }
                },
                "intereses": {
                  "summary": "Intereses (key 16) — with interest complement",
                  "description": "Interest income retention. Requires the interest object with financial system details.",
                  "value": {
                    "retention_key": "16",
                    "client": {
                      "search": {
                        "on_key": "tax_id",
                        "on_value": "BNK200101ABC",
                        "auto_create": false
                      }
                    },
                    "period_start": 1,
                    "period_end": 12,
                    "period_year": 2026,
                    "total_operation": 150000,
                    "total_exempt": 0,
                    "taxes": [
                      {
                        "tax": "ISR",
                        "base": 150000,
                        "amount": 3000
                      }
                    ],
                    "interest": {
                      "financial_system": "SI",
                      "withdrawal_aores": "NO",
                      "financial_derivatives": "NO",
                      "nominal_interest": 8500.5,
                      "real_interest": 5200.3,
                      "loss": 0
                    }
                  }
                },
                "honorarios_profesionales": {
                  "summary": "Honorarios profesionales (key 01) — ISR only",
                  "description": "Professional fees retention. Only ISR is withheld (typically 10% of the gross amount).",
                  "value": {
                    "retention_key": "01",
                    "client": {
                      "id": "client_professional_abc"
                    },
                    "period_start": 1,
                    "period_end": 3,
                    "period_year": 2026,
                    "total_operation": 50000,
                    "total_exempt": 0,
                    "taxes": [
                      {
                        "tax": "ISR",
                        "base": 50000,
                        "amount": 5000
                      }
                    ]
                  }
                },
                "arrendamiento": {
                  "summary": "Arrendamiento (key 02) — ISR + IVA",
                  "description": "Rental income retention. ISR (10%) and IVA (2/3 of IVA) are withheld.",
                  "value": {
                    "retention_key": "02",
                    "client": {
                      "id": "client_landlord_xyz"
                    },
                    "period_start": 1,
                    "period_end": 1,
                    "period_year": 2026,
                    "total_operation": 30000,
                    "total_exempt": 0,
                    "taxes": [
                      {
                        "tax": "ISR",
                        "base": 30000,
                        "amount": 3000
                      },
                      {
                        "tax": "IVA",
                        "base": 4800,
                        "amount": 3200
                      }
                    ]
                  }
                },
                "with_exempt_and_metadata": {
                  "summary": "With exempt amount, series, and metadata",
                  "description": "Full example with all optional fields. Taxable amount is auto-calculated as total_operation minus total_exempt.",
                  "value": {
                    "retention_key": "14",
                    "client": {
                      "tax_id": "EMP200101ABC",
                      "legal_name": "EMPRESA EJEMPLO SA DE CV",
                      "address": {
                        "zip": "06700",
                        "country": "MEX"
                      }
                    },
                    "period_start": 1,
                    "period_end": 6,
                    "period_year": 2026,
                    "total_operation": 100000,
                    "total_exempt": 20000,
                    "taxes": [
                      {
                        "tax": "ISR",
                        "base": 80000,
                        "amount": 8000
                      },
                      {
                        "tax": "IVA",
                        "base": 12800,
                        "amount": 8533.33
                      }
                    ],
                    "series": "RET-A",
                    "metadata": {
                      "internal_ref": "Q1-2026-RETENTION",
                      "department": "finance"
                    },
                    "idempotency_key": "ret-2026-q1-client456"
                  }
                },
                "otro_tipo_retenciones": {
                  "summary": "Otro tipo de retenciones (key 25) — with description",
                  "description": "Generic retention type. Requires retention_description to describe the type of retention.",
                  "value": {
                    "retention_key": "25",
                    "client": {
                      "id": "client_misc_abc"
                    },
                    "period_start": 1,
                    "period_end": 6,
                    "period_year": 2026,
                    "total_operation": 40000,
                    "total_exempt": 0,
                    "taxes": [
                      {
                        "tax": "ISR",
                        "base": 40000,
                        "amount": 4000
                      }
                    ],
                    "retention_description": "Retención por servicios de consultoría especializada en seguridad informática"
                  }
                },
                "isr_only_with_custom_payment_type": {
                  "summary": "ISR with custom payment type override",
                  "description": "Override the default payment type. By default ISR uses \"03\" (provisional), but you can set it to \"01\" (definitivo) if needed.",
                  "value": {
                    "retention_key": "01",
                    "client": {
                      "id": "client_consultant_789"
                    },
                    "period_start": 3,
                    "period_end": 3,
                    "period_year": 2026,
                    "total_operation": 25000,
                    "taxes": [
                      {
                        "tax": "ISR",
                        "base": 25000,
                        "amount": 2500,
                        "payment_type": "01"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Retention created and stamped successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "examples": {
                  "success": {
                    "summary": "Retention stamped successfully",
                    "value": {
                      "message": "Retention created successfully",
                      "data": {
                        "id": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                        "uuid": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                        "status": "valid",
                        "document_type": "retenciones",
                        "retention_key": "26",
                        "folio_number": "1",
                        "series": "RET",
                        "issuer": {
                          "legal_name": "MI EMPRESA SA DE CV",
                          "tax_id": "MEE200101ABC",
                          "tax_system": "601"
                        },
                        "receiver": {
                          "legal_name": "GRUPO JINIM",
                          "tax_id": "EKU9003173C9",
                          "nationality": "Nacional"
                        },
                        "period": {
                          "start": 1,
                          "end": 1,
                          "year": 2026
                        },
                        "totals": {
                          "total_operation": 93116.98,
                          "total_taxable": 93116.98,
                          "total_exempt": 0,
                          "total_retained": 9777.27,
                          "tax_retained": [
                            {
                              "tax": "001",
                              "base": 93116.98,
                              "amount": 2327.92,
                              "payment_type": "03"
                            },
                            {
                              "tax": "002",
                              "base": 14898.71,
                              "amount": 7449.35,
                              "payment_type": "01"
                            }
                          ]
                        },
                        "stamp": {
                          "uuid": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                          "stamped_at": "2026-01-15T10:30:45.000Z"
                        },
                        "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=9d9b0e5b-034c-42f7-bd21-3a868a57c13e&re=MEE200101ABC&rr=EKU9003173C9&tt=93116.98&fe=abcd1234",
                        "livemode": true,
                        "created_at": 1736942445000,
                        "metadata": null
                      },
                      "success": true,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request or stamping error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "validation_error": {
                    "summary": "Missing required fields",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "retention_key: Missing required field; taxes: Missing required field"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "client_not_found": {
                    "summary": "Client ID not found",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "Client not found: invalid_client_id"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "no_provider": {
                    "summary": "No SAT provider configured",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "No SAT provider configured for this team"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "stamping_error": {
                    "summary": "SAT stamping failed",
                    "value": {
                      "error": {
                        "code": "cfdi_service_error",
                        "message": "CFDI33184 - El valor del atributo RFC del receptor no existe en la lista de RFC inscritos no cancelados del SAT"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          }
        }
      }
    },
    "/retentions/{id}": {
      "get": {
        "operationId": "getRetentionsById",
        "tags": [
          "Retentions"
        ],
        "summary": "Get retention",
        "description": "Retrieve a specific tax retention document by ID (UUID).\n\n**gigstack Connect:** View other teams' retentions using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Retention UUID",
            "example": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e"
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Retention retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "examples": {
                  "valid_retention": {
                    "summary": "Valid stamped retention",
                    "value": {
                      "message": "Retention retrieved successfully",
                      "data": {
                        "id": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                        "uuid": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                        "status": "valid",
                        "document_type": "retenciones",
                        "retention_key": "26",
                        "folio_number": "1",
                        "series": "RET",
                        "issuer": {
                          "legal_name": "MI EMPRESA SA DE CV",
                          "tax_id": "MEE200101ABC",
                          "tax_system": "601"
                        },
                        "receiver": {
                          "legal_name": "GRUPO JINIM",
                          "tax_id": "EKU9003173C9",
                          "nationality": "Nacional"
                        },
                        "period": {
                          "start": 1,
                          "end": 1,
                          "year": 2026
                        },
                        "totals": {
                          "total_operation": 93116.98,
                          "total_taxable": 93116.98,
                          "total_exempt": 0,
                          "total_retained": 9777.27,
                          "tax_retained": [
                            {
                              "tax": "001",
                              "base": 93116.98,
                              "amount": 2327.92,
                              "payment_type": "03"
                            },
                            {
                              "tax": "002",
                              "base": 14898.71,
                              "amount": 7449.35,
                              "payment_type": "01"
                            }
                          ]
                        },
                        "stamp": {
                          "uuid": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                          "stamped_at": "2026-01-15T10:30:45.000Z"
                        },
                        "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=9d9b0e5b-034c-42f7-bd21-3a868a57c13e&re=MEE200101ABC&rr=EKU9003173C9&tt=93116.98&fe=abcd1234",
                        "livemode": true,
                        "created_at": 1736942445000,
                        "metadata": null
                      },
                      "success": true,
                      "timestamp": 1767225600000
                    }
                  },
                  "canceled_retention": {
                    "summary": "Canceled retention",
                    "value": {
                      "message": "Retention retrieved successfully",
                      "data": {
                        "id": "c4e2f1a8-9b3d-4e7f-a1c2-8d5e6f7a0b3c",
                        "uuid": "c4e2f1a8-9b3d-4e7f-a1c2-8d5e6f7a0b3c",
                        "status": "canceled",
                        "document_type": "retenciones",
                        "retention_key": "01",
                        "folio_number": "5",
                        "series": "RET",
                        "issuer": {
                          "legal_name": "MI EMPRESA SA DE CV",
                          "tax_id": "MEE200101ABC",
                          "tax_system": "601"
                        },
                        "receiver": {
                          "legal_name": "JUAN PEREZ GARCIA",
                          "tax_id": "PEGJ800101ABC",
                          "nationality": "Nacional"
                        },
                        "period": {
                          "start": 1,
                          "end": 3,
                          "year": 2026
                        },
                        "totals": {
                          "total_operation": 50000,
                          "total_taxable": 50000,
                          "total_exempt": 0,
                          "total_retained": 5000,
                          "tax_retained": [
                            {
                              "tax": "001",
                              "base": 50000,
                              "amount": 5000,
                              "payment_type": "03"
                            }
                          ]
                        },
                        "stamp": {
                          "uuid": "c4e2f1a8-9b3d-4e7f-a1c2-8d5e6f7a0b3c",
                          "stamped_at": "2026-01-10T14:20:30.000Z"
                        },
                        "verification_url": "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=c4e2f1a8-9b3d-4e7f-a1c2-8d5e6f7a0b3c&re=MEE200101ABC&rr=PEGJ800101ABC&tt=50000.00&fe=efgh5678",
                        "livemode": true,
                        "created_at": 1736510430000,
                        "metadata": null
                      },
                      "success": true,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Retention not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteRetentionsById",
        "deprecated": true,
        "tags": [
          "Retentions"
        ],
        "summary": "Cancel retention (deprecated DELETE)",
        "description": "**Deprecated:** use [`POST /retentions/{id}/cancel`](/reference/cancelRetentionById), which runs the same handler and takes the same body. Some HTTP clients and proxies drop the body of a DELETE request.\nThis route keeps working; its responses carry `Deprecation: true` and `Link: </v2/retentions/{id}/cancel>; rel=\"successor-version\"`, with the\nconcrete ID in place of each path parameter.\n\nCancel a stamped tax retention document with the SAT.\n\n**Cancellation motives** (SAT catalog):\n- `01` - Comprobante emitido con errores con relación\n- `02` - Comprobante emitido con errores sin relación\n- `03` - No se llevó a cabo la operación\n- `04` - Operación nominativa relacionada en una factura global\n\n**gigstack Connect:** Cancel other teams' retentions using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Retention UUID",
            "example": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e"
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "motive"
                ],
                "properties": {
                  "motive": {
                    "type": "string",
                    "description": "SAT cancellation motive code",
                    "enum": [
                      "01",
                      "02",
                      "03",
                      "04"
                    ],
                    "example": "02"
                  },
                  "replace_uuid": {
                    "type": "string",
                    "description": "UUID of replacement document (required when motive is \"01\")"
                  }
                }
              },
              "examples": {
                "cancel_with_errors": {
                  "summary": "Cancel — document had errors (no replacement)",
                  "value": {
                    "motive": "02"
                  }
                },
                "cancel_with_replacement": {
                  "summary": "Cancel — replace with new document",
                  "description": "Motive 01 requires the UUID of the replacement document",
                  "value": {
                    "motive": "01",
                    "replace_uuid": "a1b2c3d4-5678-90ab-cdef-1234567890ab"
                  }
                },
                "cancel_not_carried_out": {
                  "summary": "Cancel — operation not carried out",
                  "value": {
                    "motive": "03"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Retention canceled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "examples": {
                  "canceled": {
                    "summary": "Retention canceled",
                    "value": {
                      "message": "Retention canceled successfully",
                      "data": {
                        "id": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                        "uuid": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                        "status": "canceled",
                        "document_type": "retenciones",
                        "retention_key": "26",
                        "cancellation": {
                          "motive": "02",
                          "canceled_at": "2026-03-06T12:00:00.000Z"
                        }
                      },
                      "success": true,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request or cancellation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "already_canceled": {
                    "summary": "Already canceled",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "Retention is already canceled"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "missing_replacement": {
                    "summary": "Missing replacement UUID for motive 01",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "replace_uuid is required when motive is 01"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "`Retention not found`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "resource_not_found",
                    "message": "Retention not found"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/retentions/{id}/cancel": {
      "post": {
        "operationId": "cancelRetentionById",
        "tags": [
          "Retentions"
        ],
        "summary": "Cancel retention",
        "description": "Cancel a stamped tax retention document with the SAT.\n\n**Cancellation motives** (SAT catalog):\n- `01` - Comprobante emitido con errores con relación\n- `02` - Comprobante emitido con errores sin relación\n- `03` - No se llevó a cabo la operación\n- `04` - Operación nominativa relacionada en una factura global\n\n**gigstack Connect:** Cancel other teams' retentions using the `team` parameter.\n\nReplaces the deprecated [`DELETE /retentions/{id}`](/reference/deleteRetentionsById), which runs the same handler and takes the same body. Some HTTP clients and proxies drop the body of a DELETE request.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Retention UUID",
            "example": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e"
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "motive"
                ],
                "properties": {
                  "motive": {
                    "type": "string",
                    "description": "SAT cancellation motive code",
                    "enum": [
                      "01",
                      "02",
                      "03",
                      "04"
                    ],
                    "example": "02"
                  },
                  "replace_uuid": {
                    "type": "string",
                    "description": "UUID of replacement document (required when motive is \"01\")"
                  }
                }
              },
              "examples": {
                "cancel_with_errors": {
                  "summary": "Cancel — document had errors (no replacement)",
                  "value": {
                    "motive": "02"
                  }
                },
                "cancel_with_replacement": {
                  "summary": "Cancel — replace with new document",
                  "description": "Motive 01 requires the UUID of the replacement document",
                  "value": {
                    "motive": "01",
                    "replace_uuid": "a1b2c3d4-5678-90ab-cdef-1234567890ab"
                  }
                },
                "cancel_not_carried_out": {
                  "summary": "Cancel — operation not carried out",
                  "value": {
                    "motive": "03"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Retention canceled successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "examples": {
                  "canceled": {
                    "summary": "Retention canceled",
                    "value": {
                      "message": "Retention canceled successfully",
                      "data": {
                        "id": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                        "uuid": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e",
                        "status": "canceled",
                        "document_type": "retenciones",
                        "retention_key": "26",
                        "cancellation": {
                          "motive": "02",
                          "canceled_at": "2026-03-06T12:00:00.000Z"
                        }
                      },
                      "success": true,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request or cancellation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "already_canceled": {
                    "summary": "Already canceled",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "Retention is already canceled"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "missing_replacement": {
                    "summary": "Missing replacement UUID for motive 01",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "replace_uuid is required when motive is 01"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "`Retention not found`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "resource_not_found",
                    "message": "Retention not found"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/retentions/{id}/files": {
      "get": {
        "operationId": "getRetentionsByIdFiles",
        "tags": [
          "Retentions"
        ],
        "summary": "Get retention files",
        "description": "Retrieve PDF and/or XML files for a stamped tax retention document.\n\nUse `file_type` query parameter to request specific file types.\n\n**gigstack Connect:** Access other teams' retention files using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Retention UUID",
            "example": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e"
          },
          {
            "name": "file_type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pdf",
                "xml"
              ]
            },
            "description": "Filter by file type. If omitted, returns both PDF and XML."
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Files retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "content": {
                            "type": "string",
                            "description": "Base64-encoded file content"
                          },
                          "filename": {
                            "type": "string",
                            "example": "9d9b0e5b-034c-42f7-bd21-3a868a57c13e.pdf"
                          },
                          "type": {
                            "type": "string",
                            "example": "application/pdf"
                          }
                        }
                      }
                    },
                    "message": {
                      "type": "string",
                      "example": "Files retrieved successfully"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": [
                    {
                      "content": "JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9UeXBlIC9DYXRhbG9nPj4K...",
                      "filename": "7F3A1C2E-4B5D-4E6F-8A9B-0C1D2E3F4A5B.pdf",
                      "type": "application/pdf"
                    }
                  ],
                  "message": "Files retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Files not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      }
    },
    "/teams": {
      "get": {
        "operationId": "listTeams",
        "tags": [
          "Teams"
        ],
        "summary": "List teams",
        "description": "Retrieve a paginated list of teams.\n\n**gigstack Connect:** Access other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGtParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLtParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Teams retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiPublicTeam"
                      }
                    },
                    "next": {
                      "type": "string",
                      "nullable": true,
                      "description": "Cursor for next page of results",
                      "example": "team_dmU311Ajzj"
                    },
                    "total_results": {
                      "type": "number",
                      "example": 105
                    },
                    "has_more": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Clients retrieved successfully"
                    },
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "timestamp": {
                      "type": "number",
                      "example": 1768240724433
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "team_1234567890",
                      "legal_name": "MI EMPRESA EJEMPLO SA DE CV",
                      "address": {
                        "street": "Av. Paseo de la Reforma",
                        "exterior": "222",
                        "neighborhood": "Juárez",
                        "city": "Ciudad de México",
                        "state": "CDMX",
                        "zip": "06600",
                        "country": "MEX"
                      },
                      "brand": {
                        "alias": "Mi Empresa",
                        "primary_color": "#1F2937",
                        "secondary_color": "#10B981",
                        "logo": null
                      },
                      "settings": {
                        "default_description": null,
                        "emails": {
                          "invoices_bcc": [],
                          "avoid_invoice_emails": false,
                          "avoid_test_invoice_emails": true,
                          "avoid_receipts_emails": false
                        },
                        "global_invoice_disabled": false,
                        "use": "G03",
                        "periodicity": {
                          "label": "Mes",
                          "value": "month"
                        }
                      },
                      "members": [
                        {
                          "id": "user_1234567890",
                          "email": "admin@ejemplo.com",
                          "role": "admin"
                        }
                      ],
                      "owner": "user_1234567890",
                      "support_email": "soporte@ejemplo.com",
                      "support_phone": "+525512345678",
                      "tax_id": "MEE200101ABC",
                      "tax_system": "601",
                      "created_at": 1767225600000,
                      "sat": {
                        "completed": true,
                        "connected_at": 1767225600000,
                        "csd_expires_at": 1893456000000
                      },
                      "integrations": {
                        "stripe": {
                          "completed": false,
                          "category": null
                        }
                      },
                      "metadata": {},
                      "credit_limit": null,
                      "used_credits": 12,
                      "credit_period_start": 1767225600000,
                      "status": "active",
                      "scheduled_deletion": null
                    }
                  ],
                  "next": null,
                  "total_results": 1,
                  "has_more": false,
                  "message": "Clients retrieved successfully",
                  "success": true,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createTeams",
        "tags": [
          "Teams"
        ],
        "summary": "Create team",
        "description": "Create a new team after independently verifying the original credential and current\nsource-team, billing-account and member authority. Personal credentials require a\ncurrent administrator and make that verified person the owner. Machine credentials\nrequire a current master team (`403 master_team_required` otherwise); the current\nmaster-team owner becomes the child owner, with no grant to the credential's creator.\n\nAdditional administrator seats require review: `add_members` requesting another\nadmin, or `add_master_team_members` copying an active admin, returns\n`403 account_approval_required` before writes. Create without those seats, then\nprepare `team.members.add_admin` or `team.members.promote_admin` for owner review.\n\nRequires the `multipleIssuerAccounts` feature on your plan → `403 insufficient_permissions` without it.\n\n**gigstack Connect:** Create teams using the `team` parameter.\n\nRequires a plan with the \"Proveedores\" feature: otherwise the call answers `401` with\n`You should subscribe to a plan that allows \"Proveedores\" feature.` (standardized envelope).\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TeamInput"
              },
              "example": {
                "address": {
                  "country": "MEX",
                  "street": "Av. Reforma",
                  "zip": "11000",
                  "city": "Ciudad de México",
                  "state": "CDMX",
                  "exterior": "456",
                  "municipality": "Miguel Hidalgo",
                  "neighborhood": "Polanco"
                },
                "brand": {
                  "alias": "Empresa Innovadora",
                  "primary_color": "#2563eb",
                  "secondary_color": "#1d4ed8",
                  "logo": "https://example.com/logo.png"
                },
                "support_email": "soporte@empresa.com",
                "support_phone": "+52 55 9876 5432",
                "tax_id": "EIN850123ABC",
                "tax_system": "601",
                "generate_onboarding_url": true,
                "add_members": [
                  {
                    "id": "user123abc",
                    "role": "editor"
                  },
                  {
                    "id": "user456def",
                    "role": "viewer"
                  }
                ],
                "add_master_team_members": false,
                "legal_name": "Empresa de Tecnología S.A. de C.V.",
                "credit_limit": 1000
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Team created. `onboarding_url` is included when requested with `generate_onboarding_url`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ApiPublicTeam"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "onboarding_url": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        }
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "team_1234567890",
                    "legal_name": "MI EMPRESA EJEMPLO SA DE CV",
                    "address": {
                      "street": "Av. Paseo de la Reforma",
                      "exterior": "222",
                      "neighborhood": "Juárez",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "zip": "06600",
                      "country": "MEX"
                    },
                    "brand": {
                      "alias": "Mi Empresa",
                      "primary_color": "#1F2937",
                      "secondary_color": "#10B981",
                      "logo": null
                    },
                    "settings": {
                      "default_description": null,
                      "emails": {
                        "invoices_bcc": [],
                        "avoid_invoice_emails": false,
                        "avoid_test_invoice_emails": true,
                        "avoid_receipts_emails": false
                      },
                      "global_invoice_disabled": false,
                      "use": "G03",
                      "periodicity": {
                        "label": "Mes",
                        "value": "month"
                      }
                    },
                    "members": [
                      {
                        "id": "user_1234567890",
                        "email": "admin@ejemplo.com",
                        "role": "admin"
                      }
                    ],
                    "owner": "user_1234567890",
                    "support_email": "soporte@ejemplo.com",
                    "support_phone": "+525512345678",
                    "tax_id": "MEE200101ABC",
                    "tax_system": "601",
                    "created_at": 1767225600000,
                    "sat": {
                      "completed": true,
                      "connected_at": 1767225600000,
                      "csd_expires_at": 1893456000000
                    },
                    "integrations": {
                      "stripe": {
                        "completed": false,
                        "category": null
                      }
                    },
                    "metadata": {},
                    "credit_limit": null,
                    "used_credits": 12,
                    "credit_period_start": 1767225600000,
                    "status": "active",
                    "scheduled_deletion": null,
                    "onboarding_url": "https://embeded.gigstack.pro/?sessionId=otpOnboarding_7Kd2Pq&c=193847"
                  },
                  "message": "Team created successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Body validation failed (`validation_failed`), or `Only livemode teams are allowed to be created` (`invalid_request_body`) when called with a test key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "examples": {
                  "test_key": {
                    "summary": "Test-mode key",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Only livemode teams are allowed to be created"
                      },
                      "timestamp": 1767225600000
                    }
                  },
                  "validation": {
                    "summary": "Invalid body",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "validation_failed",
                        "message": "Request validation failed",
                        "details": [
                          "tax_id: Expected string"
                        ]
                      },
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}": {
      "get": {
        "operationId": "getTeamsById",
        "tags": [
          "Teams"
        ],
        "summary": "Get team",
        "description": "Retrieve a specific team by ID.\n\n**gigstack Connect:** Access other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "team_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Team retrieved. Standardized envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicTeam"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "team_1234567890",
                    "legal_name": "MI EMPRESA EJEMPLO SA DE CV",
                    "address": {
                      "street": "Av. Paseo de la Reforma",
                      "exterior": "222",
                      "neighborhood": "Juárez",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "zip": "06600",
                      "country": "MEX"
                    },
                    "brand": {
                      "alias": "Mi Empresa",
                      "primary_color": "#1F2937",
                      "secondary_color": "#10B981",
                      "logo": null
                    },
                    "settings": {
                      "default_description": null,
                      "emails": {
                        "invoices_bcc": [],
                        "avoid_invoice_emails": false,
                        "avoid_test_invoice_emails": true,
                        "avoid_receipts_emails": false
                      },
                      "global_invoice_disabled": false,
                      "use": "G03",
                      "periodicity": {
                        "label": "Mes",
                        "value": "month"
                      }
                    },
                    "members": [
                      {
                        "id": "user_1234567890",
                        "email": "admin@ejemplo.com",
                        "role": "admin"
                      }
                    ],
                    "owner": "user_1234567890",
                    "support_email": "soporte@ejemplo.com",
                    "support_phone": "+525512345678",
                    "tax_id": "MEE200101ABC",
                    "tax_system": "601",
                    "created_at": 1767225600000,
                    "sat": {
                      "completed": true,
                      "connected_at": 1767225600000,
                      "csd_expires_at": 1893456000000
                    },
                    "integrations": {
                      "stripe": {
                        "completed": false,
                        "category": null
                      }
                    },
                    "metadata": {},
                    "credit_limit": null,
                    "used_credits": 12,
                    "credit_period_start": 1767225600000,
                    "status": "active",
                    "scheduled_deletion": null
                  },
                  "message": "Team retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "operationId": "updateTeamsById",
        "tags": [
          "Teams"
        ],
        "summary": "Update team",
        "description": "**Partial update:** send only the fields you want to change; omitted fields keep their current values. `metadata`, when sent, replaces the stored metadata object as a whole.\nUpdate an existing team.\n\n**gigstack Connect:** Update other teams using the `team` parameter.\n\n\nPartial brand/address objects need only changed fields. Null/empty values clear fields. Membership and onboarding controls use their dedicated routes.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "team_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TeamUpdateInput"
              },
              "example": {
                "address": {
                  "country": "MEX",
                  "street": "Av. Reforma (Updated)",
                  "zip": "11000",
                  "city": "Ciudad de México",
                  "state": "CDMX",
                  "exterior": "456-B",
                  "municipality": "Miguel Hidalgo",
                  "neighborhood": "Polanco"
                },
                "brand": {
                  "alias": "Empresa Innovadora 2025",
                  "primary_color": "#1e40af",
                  "secondary_color": "#1e3a8a",
                  "logo": "https://example.com/new-logo.png"
                },
                "support_email": "soporte@empresa.com",
                "support_phone": "+52 55 9876 5432",
                "tax_id": "EIN850123ABC",
                "tax_system": "601"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated. Raw body (no `success`/`timestamp`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicTeam"
                    }
                  }
                },
                "example": {
                  "message": "Team updated successfully",
                  "data": {
                    "id": "team_1234567890",
                    "legal_name": "MI EMPRESA EJEMPLO SA DE CV",
                    "address": {
                      "street": "Av. Paseo de la Reforma",
                      "exterior": "222",
                      "neighborhood": "Juárez",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "zip": "06600",
                      "country": "MEX"
                    },
                    "brand": {
                      "alias": "Mi Empresa",
                      "primary_color": "#1F2937",
                      "secondary_color": "#10B981",
                      "logo": null
                    },
                    "settings": {
                      "default_description": null,
                      "emails": {
                        "invoices_bcc": [],
                        "avoid_invoice_emails": false,
                        "avoid_test_invoice_emails": true,
                        "avoid_receipts_emails": false
                      },
                      "global_invoice_disabled": false,
                      "use": "G03",
                      "periodicity": {
                        "label": "Mes",
                        "value": "month"
                      }
                    },
                    "members": [
                      {
                        "id": "user_1234567890",
                        "email": "admin@ejemplo.com",
                        "role": "admin"
                      }
                    ],
                    "owner": "user_1234567890",
                    "support_email": "soporte@ejemplo.com",
                    "support_phone": "+525512345678",
                    "tax_id": "MEE200101ABC",
                    "tax_system": "601",
                    "created_at": 1767225600000,
                    "sat": {
                      "completed": true,
                      "connected_at": 1767225600000,
                      "csd_expires_at": 1893456000000
                    },
                    "integrations": {
                      "stripe": {
                        "completed": false,
                        "category": null
                      }
                    },
                    "metadata": {},
                    "credit_limit": null,
                    "used_credits": 12,
                    "credit_period_start": 1767225600000,
                    "status": "active",
                    "scheduled_deletion": null
                  }
                }
              }
            }
          },
          "400": {
            "description": "Body validation failed. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string"
                          },
                          "code": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "error": "Invalid request body",
                  "errors": [
                    {
                      "path": "email",
                      "code": "invalid_type",
                      "message": "Field is reserved and cannot be updated"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected failure. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "error": "Failed to update team"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteTeamsById",
        "tags": [
          "Teams"
        ],
        "summary": "Delete team",
        "description": "Schedule a team for deletion (soft delete).\n\nThe team's `status` is set to `pending_deletion` and a hard deletion is scheduled **30 days** from now.\nDuring this grace period the team is retained for recovery purposes. All members are removed from the team,\nand each member's `teams` array is updated accordingly. A member's `billingAccount` is cleared when no\nother team of theirs shares it.\n\nRequires the `multipleIssuerAccounts` feature on your plan (Pricing v3: gigstack Connect) → `403 insufficient_permissions` without it. Exception on Pricing v3: the owner or an administrator of the billing account, signed in as a person (web app or MCP personal credential, not a team API key), may delete any team of that account except the master team without Connect, so that RFC stops being billed. The preconditions below still apply.\n\n## Preconditions\n\nThe team **cannot** be deleted when any of the following are true:\n\n- The team already has `status = pending_deletion` → `409 resource_conflict`.\n- The team has existing `invoices`, `payments`, or `receipts` → `400 business_rule_violation`.\n- The team has any active integration (`completed = true`) among:\n  `stripe`, `mercadopago`, `paypal`, `openpay`, `conekta`, `clip`, `bank`, `shopify`, `whmcs`, `hilos`\n  → `400 business_rule_violation`.\n\n**gigstack Connect:** Delete other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Team ID",
            "example": "team_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Team scheduled for deletion",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "message": {
                          "example": "Team scheduled for deletion"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "team_1234567890"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "pending_deletion"
                              ],
                              "example": "pending_deletion"
                            },
                            "scheduled_deletion": {
                              "type": "object",
                              "properties": {
                                "date": {
                                  "type": "integer",
                                  "format": "int64",
                                  "description": "Unix timestamp (ms) when hard deletion will occur (≈30 days from now)",
                                  "example": 1779984000000
                                },
                                "flagged_at": {
                                  "type": "integer",
                                  "format": "int64",
                                  "description": "Unix timestamp (ms) when the team was scheduled for deletion",
                                  "example": 1777392000000
                                },
                                "flagged_by": {
                                  "type": "string",
                                  "description": "User ID that scheduled the deletion",
                                  "example": "user_abc123"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "team_1234567890",
                    "status": "pending_deletion",
                    "scheduled_deletion": {
                      "date": 1769817600000,
                      "flagged_at": 1767225600000,
                      "flagged_by": "user_1234567890"
                    }
                  },
                  "message": "Team scheduled for deletion",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - The team has blocking resources (invoices/payments/receipts) or active integrations\nthat must be removed or disconnected before deletion.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "blockingResources": {
                    "summary": "Team has existing resources",
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Team has existing resources that must be removed before deletion"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "activeIntegrations": {
                    "summary": "Team has active integrations",
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Team has active integrations that must be disconnected before deletion"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Team not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "409": {
            "description": "Team is already pending deletion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_request_body",
                    "message": "Team is already pending deletion"
                  },
                  "success": false,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/integrations": {
      "get": {
        "tags": [
          "Teams"
        ],
        "summary": "Get stored integration status",
        "operationId": "getTeamIntegrations",
        "description": "Read the credential-free connection flags for the effective team. This returns the same integration summary as GET team; it is not a provider health check or the complete integration catalog. Choose another authorized effective team using the team parameter.",
        "deprecated": false,
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Allowlisted integration flags, without provider credentials",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "stripe": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "mercadopago": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "clip": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "whmcs": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "paypal": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "openpay": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "conekta": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "bank": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "shopify": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "zapier": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "airtable": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "google_sheets": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "payments"
                            }
                          }
                        },
                        "hilos": {
                          "type": "object",
                          "properties": {
                            "completed": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "category": {
                              "type": "string",
                              "nullable": true,
                              "example": "messaging"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          }
        }
      }
    },
    "/teams/{id}/add-member": {
      "post": {
        "operationId": "createTeamsByIdAddMember",
        "tags": [
          "Teams"
        ],
        "summary": "Add team member",
        "description": "Add an existing user from the same billing account. Requires administrator authority. Existing seats are not duplicated or silently assigned a new role; use the member PATCH route for role changes. Requests with role: admin return 403 account_approval_required. The current owner must prepare team.members.add_admin through POST /users/me/account-approvals and confirm in the private browser. Editor/viewer and existing permitted non-admin operations remain direct. To invite someone by email instead, use POST /teams/{id}/invitations.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "team_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "User ID to add as a team member",
                    "example": "user123abc"
                  },
                  "role": {
                    "type": "string",
                    "description": "Role for the team member. Defaults to 'viewer' if not specified.",
                    "enum": [
                      "admin",
                      "editor",
                      "viewer"
                    ],
                    "default": "viewer",
                    "example": "editor"
                  },
                  "ghost": {
                    "type": "boolean",
                    "description": "When true, the member is hidden from the team members list in the dashboard.\nGhost members have full access based on their role but are invisible to other team members.\nUseful for platform partners that need persistent, hidden access to managed teams.\n",
                    "default": false,
                    "example": true
                  }
                }
              },
              "example": {
                "id": "user123abc",
                "role": "editor",
                "ghost": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Canonical persisted membership result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "required": [
                        "id",
                        "role",
                        "is_owner",
                        "permissions"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string",
                          "nullable": true
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "admin",
                            "editor",
                            "viewer",
                            "blocked"
                          ]
                        },
                        "is_owner": {
                          "type": "boolean"
                        },
                        "permissions": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "invoices": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            },
                            "receipts": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            },
                            "payments": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            },
                            "services": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            },
                            "expenses": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            }
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient current authority, or account_approval_required for role: admin. Prepare and confirm the corresponding membership approval."
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/remove-member": {
      "post": {
        "operationId": "createTeamsByIdRemoveMember",
        "deprecated": true,
        "tags": [
          "Teams"
        ],
        "summary": "Remove team member (deprecated)",
        "description": "**Deprecated:** use [`DELETE /teams/{id}/members/{memberId}`](/reference/removeTeamMember), which\nruns the same removal with the member ID in the path instead of `id` in the body. This route keeps\nworking unchanged.\n\nRequires the current team owner using a user-scoped Firebase or MCP credential. Team API keys and OAuth credentials cannot impersonate their creator. Owner removal/demotion is refused. State changes and membership mirrors are transactional.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "team_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "Id of the user to remove from the team."
                  }
                }
              },
              "example": {
                "id": "user_9876543210"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Canonical persisted membership result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128,
                          "pattern": "^[^/]+$"
                        },
                        "removed": {
                          "type": "boolean"
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body (`Invalid request body`, with `errors`), or `User is not a member of the team`. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string"
                          },
                          "code": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "error": "User is not a member of the team"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "`User not found` or `Team not found`. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "error": "User not found"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/series": {
      "get": {
        "operationId": "getTeamsByIdSeries",
        "tags": [
          "Teams"
        ],
        "summary": "Get team series",
        "description": "Get series for a team.\n\n**gigstack Connect:** Get series for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "team_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Series and their last folio per mode. Raw body. For all series, `data` is an array of `{ series, live, test }` (last folio used); for a single series it is one object with `currentFolio` / `nextFolio` per mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "oneOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "series": {
                                "type": "string"
                              },
                              "live": {
                                "type": "integer"
                              },
                              "test": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        {
                          "type": "object",
                          "properties": {
                            "series": {
                              "type": "string"
                            },
                            "live": {
                              "type": "object",
                              "properties": {
                                "currentFolio": {
                                  "type": "integer"
                                },
                                "nextFolio": {
                                  "type": "integer"
                                }
                              }
                            },
                            "test": {
                              "type": "object",
                              "properties": {
                                "currentFolio": {
                                  "type": "integer"
                                },
                                "nextFolio": {
                                  "type": "integer"
                                }
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "series": "A",
                      "live": 123,
                      "test": 7
                    },
                    {
                      "series": "P",
                      "live": 45,
                      "test": 0
                    }
                  ],
                  "message": "Series data retrieved successfully"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createTeamsByIdSeries",
        "tags": [
          "Teams"
        ],
        "summary": "Create team series",
        "description": "Create a series for a team.\n\n**gigstack Connect:** Create series for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "team_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "series": {
                    "type": "string",
                    "description": "Series identifier (alphanumeric, max 10 characters)",
                    "example": "B"
                  },
                  "live": {
                    "type": "number",
                    "nullable": true,
                    "description": "Initial folio number for live mode",
                    "default": 0,
                    "example": 1000
                  },
                  "test": {
                    "type": "number",
                    "nullable": true,
                    "description": "Initial folio number for test mode",
                    "default": 0,
                    "example": 1
                  }
                },
                "required": [
                  "series"
                ]
              },
              "example": {
                "series": "B",
                "live": 1000,
                "test": 1
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Series created. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "series": {
                          "type": "string"
                        },
                        "live": {
                          "type": "object",
                          "properties": {
                            "currentFolio": {
                              "type": "integer"
                            },
                            "nextFolio": {
                              "type": "integer"
                            }
                          }
                        },
                        "test": {
                          "type": "object",
                          "properties": {
                            "currentFolio": {
                              "type": "integer"
                            },
                            "nextFolio": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "series": "A",
                    "live": {
                      "currentFolio": 0,
                      "nextFolio": 1
                    },
                    "test": {
                      "currentFolio": 0,
                      "nextFolio": 1
                    }
                  },
                  "message": "Series created successfully"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/series/{seriesId}": {
      "put": {
        "operationId": "updateTeamsByIdSeriesBySeriesId",
        "tags": [
          "Teams"
        ],
        "summary": "Update team series",
        "description": "**Partial update:** send `live`, `test` or both; an omitted mode keeps its current folio.\nA folio can only move forward: a value at or below the current counter is ignored.\n\nUpdate a team series.\n\n**gigstack Connect:** Update series for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "team_1234567890"
          },
          {
            "name": "seriesId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "series_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "live": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Current folio counter; zero is accepted. Supply at least one counter."
                  },
                  "test": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Current folio counter; zero is accepted. Supply at least one counter."
                  }
                },
                "description": "At least one of live or test must be provided",
                "anyOf": [
                  {
                    "required": [
                      "live"
                    ]
                  },
                  {
                    "required": [
                      "test"
                    ]
                  }
                ]
              },
              "example": {
                "live": 2000
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Folio counters updated. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "series": {
                          "type": "string"
                        },
                        "live": {
                          "type": "object",
                          "properties": {
                            "currentFolio": {
                              "type": "integer"
                            },
                            "nextFolio": {
                              "type": "integer"
                            }
                          }
                        },
                        "test": {
                          "type": "object",
                          "properties": {
                            "currentFolio": {
                              "type": "integer"
                            },
                            "nextFolio": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "series": "A",
                    "live": {
                      "currentFolio": 123,
                      "nextFolio": 124
                    },
                    "test": {
                      "currentFolio": 7,
                      "nextFolio": 8
                    }
                  },
                  "message": "Series folio numbers updated successfully"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/email-templates": {
      "get": {
        "operationId": "getTeamEmailTemplates",
        "tags": [
          "Teams"
        ],
        "summary": "Read email template defaults",
        "description": "Read the built-in editor templates for the current team’s business/nonprofit variant in Spanish and English. These are baseline subjects and bodies, not saved overrides, rendered recipient content or proof of delivery. Placeholders remain literal. The receipts-reminder subject is the editor’s upcoming-deadline default; actual delivery may choose a different deadline-specific subject. english_enabled reports the saved English-PDF opt-in, not a guarantee every recipient receives English. Settings are shared across live/test modes. Requires a current verified credential and current team read access. Use team settings to read or change authored overrides; this operation sends no email.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Team ID",
            "example": "team_example"
          }
        ],
        "responses": {
          "200": {
            "description": "Team-specific editor baselines; no email sent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/TeamEmailTemplateCatalog"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "team_id": "team_example",
                    "effect_scope": "team_shared",
                    "source": "editor_baseline",
                    "is_nonprofit": false,
                    "english_enabled": false,
                    "legacy_is_nonprofit": false,
                    "legacy_templates": {
                      "invoiceMessage": {
                        "body": "¡Hola {cliente}!,\n\nEspero que se encuentre de maravilla. Queremos hacerle llegar la factura número {folio} correspondiente a los servicios que le brindamos. ¡Gracias por confiar en nosotros!\n\nLe ruego revise detalladamente la factura y, si tiene alguna duda o comentario, no dude en ponerse en contacto con nosotros respondiendo a este correo.\n\nAdjunto encontrará la factura en formato PDF y XML.\n\n¡Saludos cordiales!",
                        "subject": "{alias} - Factura/Invoice #{folio}"
                      },
                      "invoiceMessageComplements": {
                        "body": "¡Hola {cliente}!,\n\nEspero que se encuentre de maravilla. Queremos hacerle llegar la factura número {folio} correspondiente a los servicios que le brindamos. ¡Gracias por confiar en nosotros!\n\nLe ruego revise detalladamente la factura y, si tiene alguna duda o comentario, no dude en ponerse en contacto con nosotros respondiendo a este correo.\n\nAdjunto encontrará la factura en formato PDF y XML.\n\n¡Saludos cordiales!",
                        "subject": "{alias} - Complemento de pago #{folio}"
                      },
                      "invoiceMessageEgress": {
                        "body": "¡Hola {cliente}!,\n\nEspero que se encuentre de maravilla. Queremos hacerle llegar la factura número {folio} correspondiente a los servicios que le brindamos. ¡Gracias por confiar en nosotros!\n\nLe ruego revise detalladamente la factura y, si tiene alguna duda o comentario, no dude en ponerse en contacto con nosotros respondiendo a este correo.\n\nAdjunto encontrará la factura en formato PDF y XML.\n\n¡Saludos cordiales!",
                        "subject": "{alias} - Nota de crédito #{folio}"
                      },
                      "paymentsEmailsTemplate": {
                        "body": "Hola {cliente}, por favor realiza el pago correspondiente por la cantidad de {total} {moneda}",
                        "subject": "Solicitud de pago - {alias}"
                      },
                      "paymentsReminderTemplate": {
                        "body": "Hola {cliente}, por favor no olvides realizar el pago correspondiente por la cantidad de {total} {moneda}, quedan pocos días para su vencimiento.\nFecha límite de pago: {fechaLimite}\n",
                        "subject": "No olvides realizar tu pago - {alias}"
                      },
                      "paymentsReminderAfterTemplate": {
                        "body": "Hola {cliente}, queremos recordarte que tu pago por la cantidad de {total} {moneda} está vencido desde hace {diasVencido} día(s).\nFecha límite de pago: {fechaLimite}\n\nTe pedimos regularizar tu pago lo antes posible para evitar contratiempos. Puedes realizarlo desde el siguiente enlace: {linkDePago}\n\nSi ya realizaste tu pago, por favor ignora este mensaje. ¡Gracias por tu confianza!",
                        "subject": "Tu pago está vencido - {alias}"
                      },
                      "receiptsEmailsTemplate": {
                        "body": "Estimado/a {cliente},\nLe agradecemos por su compra. Adjunto encontrará su recibo de ventas correspondiente a la compra realizada el {fecha}.\n\nDetalles del recibo:\n\nID de recibo: {recibo}\n\nFecha de la compra: {fecha}\n\nTotal: {total}\n\nPor favor, revise detenidamente la información del recibo. Si encuentra algún error o tiene alguna pregunta, no dude en contactarnos para que podamos corregirlo.\n\nUna vez más, gracias por su confianza.\n\nAtentamente, \n{alias}",
                        "subject": "Genera tu factura - {alias}"
                      },
                      "receiptsRemindersTemplate": {
                        "body": "Estimado/a {cliente}, le enviamos este correo para recordarle que aún puede facturar la transacción que realizó el día {paid_date} por un total de {total} {moneda}.\nFecha límite para facturar: {fecha_limite}.\n\n Si encuentra algún error o tiene alguna pregunta, no dude en contactarnos para que podamos corregirlo.\n\nUna vez más, gracias por su confianza.\nAtentamente {alias}",
                        "subject": "Quedan pocos días para realizar tu factura - {alias}"
                      }
                    },
                    "templates_by_language": {
                      "es": {
                        "invoices": {
                          "body": "¡Hola {cliente}!,\n\nEspero que se encuentre de maravilla. Queremos hacerle llegar la factura número {folio} correspondiente a los servicios que le brindamos. ¡Gracias por confiar en nosotros!\n\nLe ruego revise detalladamente la factura y, si tiene alguna duda o comentario, no dude en ponerse en contacto con nosotros respondiendo a este correo.\n\nAdjunto encontrará la factura en formato PDF y XML.\n\n¡Saludos cordiales!",
                          "subject": "{alias} - Factura/Invoice #{folio}"
                        },
                        "invoicesComplements": {
                          "body": "¡Hola {cliente}!,\n\nEspero que se encuentre de maravilla. Queremos hacerle llegar la factura número {folio} correspondiente a los servicios que le brindamos. ¡Gracias por confiar en nosotros!\n\nLe ruego revise detalladamente la factura y, si tiene alguna duda o comentario, no dude en ponerse en contacto con nosotros respondiendo a este correo.\n\nAdjunto encontrará la factura en formato PDF y XML.\n\n¡Saludos cordiales!",
                          "subject": "{alias} - Complemento de pago #{folio}"
                        },
                        "invoicesEgress": {
                          "body": "¡Hola {cliente}!,\n\nEspero que se encuentre de maravilla. Queremos hacerle llegar la factura número {folio} correspondiente a los servicios que le brindamos. ¡Gracias por confiar en nosotros!\n\nLe ruego revise detalladamente la factura y, si tiene alguna duda o comentario, no dude en ponerse en contacto con nosotros respondiendo a este correo.\n\nAdjunto encontrará la factura en formato PDF y XML.\n\n¡Saludos cordiales!",
                          "subject": "{alias} - Nota de crédito #{folio}"
                        },
                        "payments": {
                          "body": "Hola {cliente}, por favor realiza el pago correspondiente por la cantidad de {total} {moneda}",
                          "subject": "Solicitud de pago - {alias}"
                        },
                        "paymentsReminders": {
                          "body": "Hola {cliente}, por favor no olvides realizar el pago correspondiente por la cantidad de {total} {moneda}, quedan pocos días para su vencimiento.\nFecha límite de pago: {fechaLimite}\n",
                          "subject": "No olvides realizar tu pago - {alias}"
                        },
                        "paymentsRemindersAfter": {
                          "body": "Hola {cliente}, queremos recordarte que tu pago por la cantidad de {total} {moneda} está vencido desde hace {diasVencido} día(s).\nFecha límite de pago: {fechaLimite}\n\nTe pedimos regularizar tu pago lo antes posible para evitar contratiempos. Puedes realizarlo desde el siguiente enlace: {linkDePago}\n\nSi ya realizaste tu pago, por favor ignora este mensaje. ¡Gracias por tu confianza!",
                          "subject": "Tu pago está vencido - {alias}"
                        },
                        "receipts": {
                          "body": "Estimado/a {cliente},\nLe agradecemos por su compra. Adjunto encontrará su recibo de ventas correspondiente a la compra realizada el {fecha}.\n\nDetalles del recibo:\n\nID de recibo: {recibo}\n\nFecha de la compra: {fecha}\n\nTotal: {total}\n\nPor favor, revise detenidamente la información del recibo. Si encuentra algún error o tiene alguna pregunta, no dude en contactarnos para que podamos corregirlo.\n\nUna vez más, gracias por su confianza.\n\nAtentamente,\n{alias}",
                          "subject": "Genera tu factura - {alias}"
                        },
                        "receiptsReminders": {
                          "body": "Estimado/a {cliente}, le enviamos este correo para recordarle que aún puede facturar la transacción que realizó el día {paid_date} por un total de {total} {moneda}.\nFecha límite para facturar: {fecha_limite}.\n\n Si encuentra algún error o tiene alguna pregunta, no dude en contactarnos para que podamos corregirlo.\n\nUna vez más, gracias por su confianza.\nAtentamente {alias}",
                          "subject": "Quedan pocos días para realizar tu factura - {alias}"
                        },
                        "bankReview": {
                          "body": "Estimado/a {cliente},\nLe agradecemos por su compra. Estamos revisando su pago. Por favor aguarde.\n¡Muchas gracias!",
                          "subject": "Estamos revisando su pago"
                        }
                      },
                      "en": {
                        "invoices": {
                          "body": "Dear {cliente},\n\n Here is CFDI invoice number {folio} corresponding to the services we provided. Thank you for trusting us!\n\nPlease review the CFDI invoice carefully and, if you have any questions or comments, do not hesitate to contact us by replying to this email.\n\nAttached you will find the invoice in PDF.\n\nBest regards!",
                          "subject": "{alias} - Invoice #{folio}"
                        },
                        "invoicesComplements": {
                          "body": "Dear {cliente},\n\n Here is CFDI invoice number {folio} corresponding to the services we provided. Thank you for trusting us!\n\nPlease review the CFDI invoice carefully and, if you have any questions or comments, do not hesitate to contact us by replying to this email.\n\nAttached you will find the invoice in PDF.\n\nBest regards!",
                          "subject": "{alias} - Payment complement #{folio}"
                        },
                        "invoicesEgress": {
                          "body": "Dear {cliente},\n\n Here is CFDI invoice number {folio} corresponding to the services we provided. Thank you for trusting us!\n\nPlease review the CFDI invoice carefully and, if you have any questions or comments, do not hesitate to contact us by replying to this email.\n\nAttached you will find the invoice in PDF.\n\nBest regards!",
                          "subject": "{alias} - Credit note #{folio}"
                        },
                        "payments": {
                          "body": "Hi {cliente}, please make the corresponding payment for the amount of {total} {moneda}",
                          "subject": "Payment request - {alias}"
                        },
                        "paymentsReminders": {
                          "body": "Hi {cliente}, please remember to make the corresponding payment for the amount of {total} {moneda}. Only a few days left before it is due.\nPayment deadline: {fechaLimite}\n",
                          "subject": "Don't forget to complete your payment - {alias}"
                        },
                        "paymentsRemindersAfter": {
                          "body": "Hi {cliente}, we would like to remind you that your payment for the amount of {total} {moneda} has been overdue for {diasVencido} day(s).\nPayment deadline: {fechaLimite}\n\nPlease settle your payment as soon as possible to avoid any inconvenience. You can complete it through the following link: {linkDePago}\n\nIf you have already made your payment, please ignore this message. Thank you for your trust!",
                          "subject": "Your payment is overdue - {alias}"
                        },
                        "receipts": {
                          "body": "Dear {cliente},\nThank you for your purchase. Attached you will find the sales receipt for the purchase made on {fecha}.\n\nReceipt details:\n\nReceipt ID: {recibo}\n\nPurchase date: {fecha}\n\nTotal: {total}\n\nPlease review the receipt information carefully. If you find any errors or have any questions, do not hesitate to contact us so we can correct it.\n\nOnce again, thank you for your trust.\n\nBest regards,\n{alias}",
                          "subject": "Generate your invoice - {alias}"
                        },
                        "receiptsReminders": {
                          "body": "Dear {cliente}, we are sending you this email to remind you that you can still invoice the transaction you made on {paid_date} for a total of {total} {moneda}.\nInvoicing deadline: {fecha_limite}.\n\n If you find any errors or have any questions, do not hesitate to contact us so we can correct it.\n\nOnce again, thank you for your trust.\nBest regards, {alias}",
                          "subject": "Only a few days left to generate your invoice - {alias}"
                        },
                        "bankReview": {
                          "body": "Dear {cliente},\nThank you for your purchase. We are currently reviewing your payment. Please stand by.\nThank you very much!",
                          "subject": "We are reviewing your payment"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Original credential could not be verified"
          },
          "403": {
            "description": "Current credential scope denied"
          },
          "404": {
            "description": "Team is unavailable or current membership does not allow reading it"
          },
          "503": {
            "description": "Verifier configuration or template read unavailable"
          }
        }
      }
    },
    "/teams/{id}/settings": {
      "put": {
        "operationId": "updateTeamsByIdSettings",
        "tags": [
          "Teams"
        ],
        "summary": "Update team settings",
        "description": "**Partial update:** send only the fields you want to change; omitted fields keep their current values.\nPatch team defaults, reminders, templates, receipts, refunds and fiscal settings. Only supplied fields change. Null resets a field or the documented leaves of a group; empty strings/arrays clear values; empty objects leave the group unchanged. Spanish email templates mirror both web storage formats. Contradictory aliases return 400. Requires team administrator authority (team API keys are team credentials and pass). customer_portal_id registers the canonical top-level customer portal slug with the same rules, uniqueness and audit as PUT /teams/{id}/customer-portal, before any other field is written; it only registers a first slug or repeats the current one (a different slug returns 409 portal_confirmation_required, rename through PUT /customer-portal), and null never unregisters. For Mexican teams (invoicing.country not US/CO), once product_key, unit_key and use are all set, defaults.completed becomes true, completing the app's automatic-invoicing setup step; it is never unset. The response is the persisted full team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Team ID",
            "example": "team_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TeamSettingsInput"
              },
              "example": {
                "default_description": "Consulting services",
                "avoid_legal_name_replacer": true,
                "emails": {
                  "invoices_bcc": []
                },
                "payment_reminders": {
                  "enabled": false,
                  "days": 0
                },
                "default_series": {
                  "income": {
                    "serie": "A"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Settings saved; `data` is the whole team. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicTeam"
                    }
                  }
                },
                "example": {
                  "message": "Team settings updated",
                  "data": {
                    "id": "team_1234567890",
                    "legal_name": "MI EMPRESA EJEMPLO SA DE CV",
                    "address": {
                      "street": "Av. Paseo de la Reforma",
                      "exterior": "222",
                      "neighborhood": "Juárez",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "zip": "06600",
                      "country": "MEX"
                    },
                    "brand": {
                      "alias": "Mi Empresa",
                      "primary_color": "#1F2937",
                      "secondary_color": "#10B981",
                      "logo": null
                    },
                    "settings": {
                      "default_description": null,
                      "emails": {
                        "invoices_bcc": [],
                        "avoid_invoice_emails": false,
                        "avoid_test_invoice_emails": true,
                        "avoid_receipts_emails": false
                      },
                      "global_invoice_disabled": false,
                      "use": "G03",
                      "periodicity": {
                        "label": "Mes",
                        "value": "month"
                      }
                    },
                    "members": [
                      {
                        "id": "user_1234567890",
                        "email": "admin@ejemplo.com",
                        "role": "admin"
                      }
                    ],
                    "owner": "user_1234567890",
                    "support_email": "soporte@ejemplo.com",
                    "support_phone": "+525512345678",
                    "tax_id": "MEE200101ABC",
                    "tax_system": "601",
                    "created_at": 1767225600000,
                    "sat": {
                      "completed": true,
                      "connected_at": 1767225600000,
                      "csd_expires_at": 1893456000000
                    },
                    "integrations": {
                      "stripe": {
                        "completed": false,
                        "category": null
                      }
                    },
                    "metadata": {},
                    "credit_limit": null,
                    "used_credits": 12,
                    "credit_period_start": 1767225600000,
                    "status": "active",
                    "scheduled_deletion": null
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Invalid settings data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Team not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "get": {
        "operationId": "getTeamSettings",
        "tags": [
          "Teams"
        ],
        "summary": "Get team settings",
        "description": "Read the authorized team defaults without credential values. PUT on this route patches supplied fields only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "nullable": true,
                      "properties": {
                        "avoid_legal_name_replacer": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "enforce_client_country_taxes": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "global_invoice_disabled": {
                          "type": "boolean",
                          "nullable": true,
                          "example": false
                        },
                        "automate_complement_for_ppd_invoices": {
                          "type": "boolean",
                          "nullable": true,
                          "example": true
                        },
                        "automate_partial_payment_complements": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "use_foreign_public_in_usd": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "avoid_receipts": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "cancel_receipts_on_refunds": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "invoice_per_receipt": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "allow_notes_on_self_invoice": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "allow_product_code_on_self_invoice": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "send_invoice_english_pdf": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "default_description": {
                          "type": "string",
                          "nullable": true,
                          "example": "Default invoice description"
                        },
                        "override_item_description": {
                          "type": "string",
                          "nullable": true,
                          "example": "Custom item description"
                        },
                        "invoice_pdf_notes": {
                          "type": "string",
                          "nullable": true,
                          "example": "Additional notes for PDF"
                        },
                        "product_key": {
                          "type": "string",
                          "nullable": true,
                          "example": "81112209"
                        },
                        "unit_key": {
                          "type": "string",
                          "nullable": true,
                          "example": "E48"
                        },
                        "unit_name": {
                          "type": "string",
                          "nullable": true
                        },
                        "use": {
                          "type": "string",
                          "nullable": true,
                          "example": "G03"
                        },
                        "sku": {
                          "type": "string",
                          "nullable": true
                        },
                        "addenda": {
                          "type": "string",
                          "nullable": true
                        },
                        "order_reference": {
                          "type": "string",
                          "nullable": true
                        },
                        "custom_payment_description": {
                          "type": "string",
                          "nullable": true
                        },
                        "customer_portal_id": {
                          "type": "string",
                          "nullable": true,
                          "example": "portal_1234567890"
                        },
                        "force_series": {
                          "type": "string",
                          "nullable": true
                        },
                        "avoid_automations_on_currencies": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "string"
                          },
                          "example": [
                            "USD",
                            "EUR"
                          ]
                        },
                        "uses_on_self_invoice_portal": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "string"
                          },
                          "example": [
                            "G03",
                            "S01"
                          ]
                        },
                        "concepts_catalog": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "nullable": true
                        },
                        "taxes": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object"
                          }
                        },
                        "taxes_usd": {
                          "oneOf": [
                            {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "object"
                              }
                            },
                            {
                              "type": "boolean",
                              "nullable": true
                            }
                          ]
                        },
                        "withholding_taxes": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object"
                          }
                        },
                        "local_taxes": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": true,
                            "properties": {}
                          },
                          "nullable": true
                        },
                        "complements": {
                          "type": "array",
                          "nullable": true,
                          "items": {
                            "type": "object",
                            "properties": {
                              "data": {
                                "type": "string",
                                "nullable": true
                              },
                              "description": {
                                "type": "string",
                                "nullable": true
                              },
                              "type": {
                                "type": "string",
                                "nullable": true
                              }
                            }
                          }
                        },
                        "allowed_product_codes": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "required": [
                              "key",
                              "description"
                            ],
                            "properties": {
                              "key": {
                                "type": "string"
                              },
                              "description": {
                                "type": "string"
                              }
                            }
                          },
                          "nullable": true
                        },
                        "allowed_uses_by_product_key": {
                          "description": "Self-invoice portal limit on the uso CFDI per SAT product key. A receipt allows only the uses common to every item whose product key has a rule.",
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "required": [
                              "key",
                              "uses"
                            ],
                            "properties": {
                              "key": {
                                "type": "string",
                                "example": "01010101"
                              },
                              "description": {
                                "type": "string",
                                "nullable": true
                              },
                              "uses": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "example": [
                                  "G03",
                                  "D07"
                                ]
                              }
                            }
                          },
                          "nullable": true
                        },
                        "periodicity": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "label": {
                              "type": "string",
                              "example": "Mes"
                            },
                            "value": {
                              "type": "string",
                              "example": "month"
                            }
                          }
                        },
                        "pdf_language": {
                          "type": "string",
                          "enum": [
                            "en",
                            "es",
                            null
                          ],
                          "nullable": true
                        },
                        "global_invoicing_monthly_cuts": {
                          "type": "number",
                          "enum": [
                            2,
                            3,
                            4,
                            5,
                            null
                          ],
                          "nullable": true
                        },
                        "eom_ppd_threshold_days": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 0,
                          "maximum": 31
                        },
                        "limit_days_to_pay": {
                          "type": "integer",
                          "nullable": true,
                          "minimum": 0
                        },
                        "payment_reminders": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "days": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0
                            },
                            "enabled": {
                              "type": "boolean",
                              "nullable": true
                            },
                            "before_body": {
                              "type": "string",
                              "nullable": true
                            },
                            "before_subject": {
                              "type": "string",
                              "nullable": true
                            },
                            "after_body": {
                              "type": "string",
                              "nullable": true
                            },
                            "after_subject": {
                              "type": "string",
                              "nullable": true
                            }
                          },
                          "nullable": true
                        },
                        "reinvoice": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "window_days": {
                              "type": "integer",
                              "nullable": true,
                              "minimum": 0
                            },
                            "handler": {
                              "type": "string",
                              "enum": [
                                "credit_note",
                                "cancel_resources",
                                null
                              ],
                              "nullable": true
                            }
                          },
                          "nullable": true
                        },
                        "refunds": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "automatic_refunds": {
                              "type": "boolean",
                              "nullable": true
                            },
                            "current_month_handler": {
                              "type": "string",
                              "enum": [
                                "credit_note",
                                "cancel_resources",
                                null
                              ],
                              "nullable": true
                            }
                          },
                          "nullable": true
                        },
                        "emails": {
                          "type": "object",
                          "properties": {
                            "invoices_bcc": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "string"
                              },
                              "example": [
                                "accounting@example.com"
                              ]
                            },
                            "avoid_invoice_emails": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            },
                            "avoid_test_invoice_emails": {
                              "type": "boolean",
                              "nullable": true,
                              "example": true
                            },
                            "avoid_receipts_emails": {
                              "type": "boolean",
                              "nullable": true,
                              "example": false
                            }
                          }
                        },
                        "email_templates": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "invoices": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "es": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                },
                                "en": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                }
                              },
                              "nullable": true
                            },
                            "complements": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "es": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                },
                                "en": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                }
                              },
                              "nullable": true
                            },
                            "credit_notes": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "es": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                },
                                "en": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                }
                              },
                              "nullable": true
                            },
                            "payments": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "es": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                },
                                "en": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                }
                              },
                              "nullable": true
                            },
                            "receipts": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "es": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                },
                                "en": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                }
                              },
                              "nullable": true
                            },
                            "receipt_reminders": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "es": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                },
                                "en": {
                                  "type": "object",
                                  "additionalProperties": false,
                                  "properties": {
                                    "body": {
                                      "type": "string",
                                      "nullable": true
                                    },
                                    "subject": {
                                      "type": "string",
                                      "nullable": true
                                    }
                                  },
                                  "nullable": true
                                }
                              },
                              "nullable": true
                            }
                          },
                          "nullable": true
                        },
                        "default_series": {
                          "type": "object",
                          "properties": {
                            "income": {
                              "type": "object",
                              "properties": {
                                "serie": {
                                  "type": "string",
                                  "nullable": true,
                                  "example": "A"
                                }
                              }
                            },
                            "complements": {
                              "type": "object",
                              "properties": {
                                "serie": {
                                  "type": "string",
                                  "nullable": true,
                                  "example": "P"
                                }
                              }
                            },
                            "credit_note": {
                              "type": "object",
                              "properties": {
                                "serie": {
                                  "type": "string",
                                  "nullable": true,
                                  "example": "NC"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/onboarding": {
      "get": {
        "operationId": "getTeamsByIdOnboarding",
        "tags": [
          "Teams"
        ],
        "summary": "Get team onboarding status",
        "description": "Where a team stands between test mode and production, in one read. Built for agents\n(MCP, CLI) that guide a person from a first test invoice to going live.\n\n- `stage`: `sandbox_unclaimed` (agent sandbox not claimed yet), `test` (Pricing v3, not\n  live yet) or `live`. Accounts on legacy plans are always `live`.\n- `checklist`: what going live needs: own RFC and fiscal data, a valid CSD that is not a\n  SAT test certificate, the signed SAT manifest, and the payment method added at go-live\n  (nothing is charged then).\n- `next_step`: `issue_test_invoice`, `claim_sandbox`, `complete_fiscal_data`,\n  `upload_csd`, `sign_manifest`, `go_live` or `live`.\n- `go_live_url`: the app page where the person goes live; null once live.\n\nRead-only and free of credential material, so the test key of an unclaimed sandbox can\nread it. Prices are in the public `GET /v2/pricing`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Team ID",
            "example": "team_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Onboarding status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "team_id": {
                          "type": "string"
                        },
                        "stage": {
                          "type": "string",
                          "enum": [
                            "sandbox_unclaimed",
                            "test",
                            "live"
                          ]
                        },
                        "pricing_version": {
                          "type": "string",
                          "nullable": true
                        },
                        "live_since": {
                          "type": "integer",
                          "nullable": true
                        },
                        "sandbox": {
                          "type": "object",
                          "nullable": true,
                          "properties": {
                            "status": {
                              "type": "string"
                            },
                            "expires_at": {
                              "type": "integer",
                              "nullable": true
                            }
                          }
                        },
                        "checklist": {
                          "type": "object",
                          "properties": {
                            "fiscal_data": {
                              "type": "object",
                              "properties": {
                                "done": {
                                  "type": "boolean"
                                },
                                "rfc": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "test_rfc": {
                                  "type": "boolean"
                                },
                                "legal_name": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "tax_system": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "zip": {
                                  "type": "string",
                                  "nullable": true
                                },
                                "missing": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              }
                            },
                            "csd": {
                              "type": "object",
                              "properties": {
                                "done": {
                                  "type": "boolean"
                                },
                                "state": {
                                  "type": "string",
                                  "enum": [
                                    "missing",
                                    "test",
                                    "invalid",
                                    "expired",
                                    "valid"
                                  ]
                                },
                                "expires_at": {
                                  "type": "integer",
                                  "nullable": true
                                }
                              }
                            },
                            "manifest": {
                              "type": "object",
                              "properties": {
                                "done": {
                                  "type": "boolean"
                                }
                              }
                            },
                            "payment_method": {
                              "type": "object",
                              "properties": {
                                "done": {
                                  "type": "boolean"
                                }
                              }
                            }
                          }
                        },
                        "test_invoices": {
                          "type": "object",
                          "properties": {
                            "count": {
                              "type": "integer",
                              "nullable": true
                            },
                            "last_id": {
                              "type": "string",
                              "nullable": true
                            }
                          }
                        },
                        "live_invoices": {
                          "type": "object",
                          "properties": {
                            "count": {
                              "type": "integer",
                              "nullable": true
                            }
                          }
                        },
                        "credits": {
                          "type": "object",
                          "nullable": true,
                          "description": "Credit balance of a live Pricing v3 account (same as the billing summary `credits`)"
                        },
                        "next_step": {
                          "type": "string",
                          "enum": [
                            "issue_test_invoice",
                            "claim_sandbox",
                            "complete_fiscal_data",
                            "upload_csd",
                            "sign_manifest",
                            "go_live",
                            "live"
                          ]
                        },
                        "go_live_url": {
                          "type": "string",
                          "nullable": true
                        },
                        "app_url": {
                          "type": "string"
                        }
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "data": {
                    "team_id": "team_1234567890",
                    "stage": "test",
                    "pricing_version": "v3",
                    "live_since": null,
                    "sandbox": null,
                    "checklist": {
                      "fiscal_data": {
                        "done": true,
                        "rfc": "GOMA800101AB1",
                        "test_rfc": false,
                        "legal_name": "ANA GOMEZ",
                        "tax_system": "612",
                        "zip": "06600",
                        "missing": []
                      },
                      "csd": {
                        "done": false,
                        "state": "missing",
                        "expires_at": null
                      },
                      "manifest": {
                        "done": false
                      },
                      "payment_method": {
                        "done": false
                      }
                    },
                    "test_invoices": {
                      "count": 1,
                      "last_id": "inv_test_123"
                    },
                    "live_invoices": {
                      "count": 0
                    },
                    "credits": null,
                    "next_step": "upload_csd",
                    "go_live_url": "https://app.gigstack.pro/home",
                    "app_url": "https://app.gigstack.pro"
                  },
                  "message": "Onboarding status retrieved successfully"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Team not found or outside the authorized account"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/onboarding-url": {
      "get": {
        "operationId": "getTeamsByIdOnboardingUrl",
        "tags": [
          "Teams"
        ],
        "summary": "Get team onboarding URL",
        "description": "Generate a secure onboarding URL for team setup and configuration.\n\n**Important:** This endpoint is only available for gigstack Connect accounts (master teams).\n\n## Use Cases\n- Generate onboarding links for new teams\n- Allow secure team configuration setup\n- Enable embedded team management flows\n\n**gigstack Connect:** Generate onboarding URLs for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Team ID to generate onboarding URL for",
            "example": "team_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Onboarding URL generated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "string",
                      "example": "https://embeded.gigstack.pro/?sessionId=otpOnboarding_abc123&c=secure_token",
                      "description": "Secure onboarding URL with session ID and code"
                    },
                    "message": {
                      "type": "string",
                      "example": "Onboarding URL generated successfully"
                    }
                  }
                },
                "example": {
                  "data": "https://embeded.gigstack.pro/?sessionId=otpOnboarding_7Kd2Pq&c=193847",
                  "message": "Onboarding URL retrieved successfully"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Only available for master teams",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Unauthorized"
                    },
                    "error": {
                      "type": "string",
                      "example": "Unauthorized endpoint only available for connect accounts"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Team not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{id}/portal-access-token": {
      "post": {
        "operationId": "createTeamsByIdPortalAccessToken",
        "tags": [
          "Teams"
        ],
        "summary": "Create a portal access token",
        "description": "Deprecated, kept for one release as a compatibility window (backend PR 490). Personal sessions and unscoped API keys still receive one; scoped API keys get 410. Prepare /v2/teams/{id}/invoice-portal-operations with a persisted UUID and explicit mode; review and issue only in the private personal browser. Safe metadata never replays a bearer.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Team ID to mint the portal access token for",
            "example": "team_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Issued (compatibility window; personal sessions and unscoped API keys only)"
          },
          "410": {
            "description": "private_portal_review_required"
          }
        },
        "deprecated": true
      }
    },
    "/teams/{id}/sat-connection": {
      "post": {
        "operationId": "createTeamsByIdSatConnection",
        "tags": [
          "Teams"
        ],
        "summary": "Upload SAT CSD certificates",
        "description": "Upload SAT CSD (Certificado de Sello Digital) certificates to establish SAT connection for CFDI invoicing.\n\nThis endpoint accepts multipart form data with the certificate files and password.\n\n## Required Files\n- **cert**: Certificate file (.cer) - The public certificate\n- **key**: Private key file (.key) - The encrypted private key\n- **keyPass**: Password for the private key\n\n## First-Time Connection\nWhen this is the first SAT connection for a team (no previous SAT setup),\nthe system will automatically initialize default invoice series (G, NC, P, T).\n\n**gigstack Connect:** Upload SAT certificates for other teams using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Team ID to upload SAT certificates for",
            "example": "team_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "cert": {
                    "type": "string",
                    "format": "binary",
                    "description": "Certificate file (.cer)"
                  },
                  "key": {
                    "type": "string",
                    "format": "binary",
                    "description": "Private key file (.key)"
                  },
                  "keyPass": {
                    "type": "string",
                    "description": "Password for the private key"
                  }
                },
                "required": [
                  "cert",
                  "key",
                  "keyPass"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SAT connection established successfully",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "isValid": {
                              "type": "boolean",
                              "example": true
                            },
                            "details": {
                              "type": "object",
                              "properties": {
                                "serialNumber": {
                                  "type": "string",
                                  "example": "30001000000500003416"
                                },
                                "validTo": {
                                  "type": "number",
                                  "example": 1735689600000
                                }
                              }
                            }
                          }
                        },
                        "message": {
                          "example": "SAT connection established successfully"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "isValid": true,
                    "details": {
                      "subject": "CN=MI EMPRESA EJEMPLO SA DE CV, x500UniqueIdentifier=MEE200101ABC",
                      "issuer": "CN=AC UAT, O=SERVICIO DE ADMINISTRACION TRIBUTARIA",
                      "validFrom": 1767225600000,
                      "validTo": 1893456000000,
                      "serialNumber": "30001000000500003416",
                      "fingerprint": "A1:B2:C3:D4:E5:F6:07:18:29:3A:4B:5C:6D:7E:8F:90:A1:B2:C3:D4",
                      "fingerprint256": "A1:B2:C3:D4:E5:F6:07:18:29:3A:4B:5C:6D:7E:8F:90:A1:B2:C3:D4:E5:F6:07:18:29:3A:4B:5C:6D:7E:8F:90"
                    }
                  },
                  "message": "SAT connection established successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Missing files or invalid certificate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Forbidden - Team not in same billing account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Team not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/manifest/sign": {
      "post": {
        "operationId": "createTeamsByIdManifestSign",
        "tags": [
          "Teams"
        ],
        "summary": "Sign manifest document",
        "description": "Signs a manifest document (Carta Manifiesto) using the FIEL (Firma Electrónica Avanzada) for SAT compliance.\n\nThis endpoint is used to sign the authorization manifest that authorizes the PAC (Proveedor Autorizado de Certificación)\nto issue CFDI invoices on behalf of your team's RFC. The manifest must be signed to grant the PAC permission to stamp\nand process invoices under your team's tax identification.\n\n**Important Notes:**\n- Your SAT configuration must be completed before signing the manifest\n- The FIEL certificate must be valid and issued by SAT\n- The certificate must match your team's RFC\n- Once signed, the manifest is stored in your team's SAT configuration\n- The manifest includes both XML and PDF files\n\n**Supported Formats:**\n\n1. **JSON format (application/json):**\n   - Send Base64 encoded certificate files\n   - Useful for API integrations\n\n2. **Form Data format (multipart/form-data):**\n   - Upload certificate files directly\n   - Useful for web form submissions\n\n**Note:** The `team` and `livemode` parameters are automatically extracted from your JWT token and applied to the request.\nYou do not need to include these fields in the request body.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Team ID to sign manifest for",
            "example": "team_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "key",
                  "cert",
                  "password"
                ],
                "properties": {
                  "key": {
                    "type": "string",
                    "description": "Base64 encoded FIEL .key file",
                    "example": "MIIFDjBABgkqhkiG9w0BBQ0wMz..."
                  },
                  "cert": {
                    "type": "string",
                    "description": "Base64 encoded FIEL .cer file",
                    "example": "MIIFuzCCA6OgAwIBAgIUMzAwMD..."
                  },
                  "password": {
                    "type": "string",
                    "format": "password",
                    "description": "FIEL password (private key password)",
                    "example": "my_secure_password"
                  }
                }
              },
              "examples": {
                "basic": {
                  "summary": "Basic manifest signing request",
                  "value": {
                    "key": "MIIFDjBABgkqhkiG9w0BBQ0wMz...",
                    "cert": "MIIFuzCCA6OgAwIBAgIUMzAwMD...",
                    "password": "my_secure_password"
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "key",
                  "cert",
                  "password"
                ],
                "properties": {
                  "key": {
                    "type": "string",
                    "format": "binary",
                    "description": "FIEL .key file upload"
                  },
                  "cert": {
                    "type": "string",
                    "format": "binary",
                    "description": "FIEL .cer file upload"
                  },
                  "password": {
                    "type": "string",
                    "description": "FIEL password (private key password)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Manifest signed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Manifest signed successfully"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "xmlBase64": {
                          "type": "string",
                          "description": "Base64 encoded signed manifest XML"
                        },
                        "pdfBase64": {
                          "type": "string",
                          "description": "Base64 encoded manifest PDF"
                        },
                        "fechaFirma": {
                          "type": "string",
                          "format": "date-time",
                          "description": "Signature date and time",
                          "example": "2024-01-08T15:30:00.000Z"
                        },
                        "mensajeResultado": {
                          "type": "string",
                          "description": "Result message from signing service",
                          "example": "Firma exitosa"
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful manifest signing",
                    "value": {
                      "message": "Manifest signed successfully",
                      "data": {
                        "xmlBase64": "PD94bWwgdmVyc2lvbj0iMS4wIi...",
                        "pdfBase64": "JVBERi0xLjQKJeLjz9MKMyAwIG...",
                        "fechaFirma": "2024-01-08T15:30:00.000Z",
                        "mensajeResultado": "Firma exitosa"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Invalid input or validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "missing_field": {
                    "summary": "Missing required field",
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Bad Request"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_certificate": {
                    "summary": "Invalid FIEL certificate",
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Bad Request"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "certificate_mismatch": {
                    "summary": "Certificate RFC mismatch",
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Bad Request"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "sat_incomplete": {
                    "summary": "SAT configuration incomplete",
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Bad Request"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "signing_failed": {
                    "summary": "Manifest signing failed",
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "CFDI Service Error"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Team not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "team_not_found": {
                    "summary": "Team not found",
                    "value": {
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Not Found"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/users": {
      "get": {
        "operationId": "listUsers",
        "tags": [
          "Users"
        ],
        "summary": "List users",
        "description": "Retrieve a paginated list of users.\n\n**gigstack Connect:** Access other teams' users using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/NextParam"
          },
          {
            "$ref": "#/components/parameters/OrderByParam"
          },
          {
            "$ref": "#/components/parameters/SortParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLteParam"
          },
          {
            "$ref": "#/components/parameters/CreatedGtParam"
          },
          {
            "$ref": "#/components/parameters/CreatedLtParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Users retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "success": true,
                  "message": "Users retrieved successfully",
                  "data": [
                    {
                      "id": "user_1234567890",
                      "email": "admin@ejemplo.com",
                      "first_name": "Ana",
                      "last_name": "López",
                      "phone": "+525512345678",
                      "teams": [
                        "team_1234567890"
                      ],
                      "created_at": 1767225600000,
                      "company_role": "Contadora",
                      "address": {
                        "street": "Av. Paseo de la Reforma",
                        "exterior": "222",
                        "neighborhood": "Juárez",
                        "city": "Ciudad de México",
                        "state": "CDMX",
                        "zip": "06600",
                        "country": "MEX"
                      }
                    }
                  ],
                  "next": null,
                  "has_more": false,
                  "total_results": 1,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createUsers",
        "tags": [
          "Users"
        ],
        "summary": "Create user",
        "description": "Create a new user.\n\n**gigstack Connect:** Create users for other teams using the `team` parameter.\n\nDirect administrator creation is retired with 403 account_approval_required. Prepare managed_users.create_admin and complete its browser reviews. Ordinary viewer/editor creation remains available, with private provenance. A managed_creation_unconfirmed response means an identity may exist: preserve its user reference and obtain operator readback instead of repeating creation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserInput"
              },
              "example": {
                "email": "maria.gonzalez@empresa.com",
                "first_name": "María",
                "last_name": "González",
                "phone": "+52 55 2345 6789",
                "company_role": "Gerente de Ventas",
                "address": {
                  "country": "MEX",
                  "street": "Calle Morelos",
                  "zip": "06000",
                  "city": "Ciudad de México",
                  "state": "CDMX",
                  "exterior": "789",
                  "neighborhood": "Centro"
                },
                "auto_join": true,
                "role": "editor"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "User created. Standardized envelope with the new user in `data`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "User created"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicUser"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "user_1234567890",
                    "email": "admin@ejemplo.com",
                    "first_name": "Ana",
                    "last_name": "López",
                    "phone": "+525512345678",
                    "teams": [
                      "team_1234567890"
                    ],
                    "created_at": 1767225600000,
                    "company_role": "Contadora",
                    "address": {
                      "street": "Av. Paseo de la Reforma",
                      "exterior": "222",
                      "neighborhood": "Juárez",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "zip": "06600",
                      "country": "MEX"
                    }
                  },
                  "message": "User created",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Two shapes:\n- Body validation failure: standardized envelope, `error.code: validation_failed`, message `Invalid body`.\n- Rejected by the identity provider: raw `{ \"error\", \"message\" }` body. `error` is one of\n  `Email already exists`, `Invalid phone number` (phone must be E.164, e.g. `+525512345678`),\n  `Invalid email`, `Validation error`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/StandardErrorResponse"
                    },
                    {
                      "type": "object",
                      "required": [
                        "error",
                        "message"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "email_exists": {
                    "summary": "Email already registered",
                    "value": {
                      "error": "Email already exists",
                      "message": "A user with this email already exists"
                    }
                  },
                  "invalid_phone": {
                    "summary": "Phone not in E.164",
                    "value": {
                      "error": "Invalid phone number",
                      "message": "Phone number must be in E.164 format (e.g., +1234567890)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/users/{id}": {
      "get": {
        "operationId": "getUsersById",
        "tags": [
          "Users"
        ],
        "summary": "Get user",
        "description": "Retrieve a specific user by ID.\n\n**gigstack Connect:** Access other teams' users using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "user_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "User retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardSuccessResponse"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "user_1234567890",
                    "email": "admin@ejemplo.com",
                    "first_name": "Ana",
                    "last_name": "López",
                    "phone": "+525512345678",
                    "teams": [
                      "team_1234567890"
                    ],
                    "created_at": 1767225600000,
                    "company_role": "Contadora",
                    "address": {
                      "street": "Av. Paseo de la Reforma",
                      "exterior": "222",
                      "neighborhood": "Juárez",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "zip": "06600",
                      "country": "MEX"
                    }
                  },
                  "message": "User retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "put": {
        "operationId": "updateUsersById",
        "tags": [
          "Users"
        ],
        "summary": "Update user",
        "description": "**Partial update:** send only the fields you want to change; omitted fields keep their current values.\n\nUpdate an existing user.\n\n**gigstack Connect:** Update other teams' users using the `team` parameter.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "user_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserInput"
              },
              "example": {
                "first_name": "María Fernanda",
                "last_name": "González López",
                "phone": "+52 55 2345 6789",
                "company_role": "Gerente Regional de Ventas",
                "address": {
                  "country": "MEX",
                  "street": "Calle Morelos (Oficina Nueva)",
                  "zip": "06000",
                  "city": "Ciudad de México",
                  "state": "CDMX",
                  "exterior": "789-A",
                  "neighborhood": "Centro"
                },
                "auto_join": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated. Raw body (no `success`/`timestamp`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicUser"
                    }
                  }
                },
                "example": {
                  "message": "User updated successfully",
                  "data": {
                    "id": "user_1234567890",
                    "email": "admin@ejemplo.com",
                    "first_name": "Ana",
                    "last_name": "López",
                    "phone": "+525512345678",
                    "teams": [
                      "team_1234567890"
                    ],
                    "created_at": 1767225600000,
                    "company_role": "Contadora",
                    "address": {
                      "street": "Av. Paseo de la Reforma",
                      "exterior": "222",
                      "neighborhood": "Juárez",
                      "city": "Ciudad de México",
                      "state": "CDMX",
                      "zip": "06600",
                      "country": "MEX"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Body validation failed. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "path": {
                            "type": "string"
                          },
                          "code": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "error": "Invalid request body",
                  "errors": [
                    {
                      "path": "email",
                      "code": "invalid_type",
                      "message": "Field is reserved and cannot be updated"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The resource belongs to another team, or its `livemode` does not match the API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected failure. Raw body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "error": "Failed to update user"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Users"
        ],
        "summary": "Remove a user from administered teams",
        "operationId": "deleteUser",
        "description": "Remove a user from teams in the caller's billing account that the caller currently administers. The target must be accessible in the selected team. Owner memberships and teams outside current authority are retained. Confirm the target and scope before calling. The login and user profile are retained. Both deleted and account_deleted are false. Inspect removed_from_teams for confirmed removals; account_deletion.status is not_attempted and its requirement explains the unresolved destruction boundary. Private managed custody, the current Auth identity, complete access evidence and separate reviewed approval are required before identity destruction can be implemented safely. This route does not claim complete account deletion. You cannot remove yourself through this route. Use the team parameter to select an authorized gigstack Connect team; it does not expand authority.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the user to delete.",
            "schema": {
              "type": "string"
            },
            "example": "user_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmed team removals with the identity and profile retained.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "required": [
                            "id",
                            "deleted",
                            "account_deleted",
                            "removed_from_teams",
                            "account_deletion"
                          ],
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "user_1234567890"
                            },
                            "deleted": {
                              "type": "boolean",
                              "enum": [
                                false
                              ],
                              "description": "Identity destruction was not attempted.",
                              "example": false
                            },
                            "account_deleted": {
                              "type": "boolean",
                              "enum": [
                                false
                              ],
                              "description": "The login and user profile are retained.",
                              "example": false
                            },
                            "removed_from_teams": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "example": [
                                "team_1234567890"
                              ]
                            },
                            "account_deletion": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status",
                                "requirement"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_attempted"
                                  ]
                                },
                                "requirement": {
                                  "type": "string",
                                  "enum": [
                                    "retained_membership",
                                    "private_custody",
                                    "current_identity",
                                    "authoritative_scope_and_approval"
                                  ]
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "message": "Authorized memberships removed; profile and Auth identity retained",
                  "timestamp": 1767225600000,
                  "data": {
                    "id": "user_1234567890",
                    "deleted": false,
                    "account_deleted": false,
                    "removed_from_teams": [
                      "team_1234567890"
                    ],
                    "account_deletion": {
                      "status": "not_attempted",
                      "requirement": "authoritative_scope_and_approval"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`error.code: business_rule_violation` — `Cannot delete yourself`\n(`Users cannot delete their own account through the API`), or\n`error.code: resource_access_failed` when the user cannot be accessed.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "business_rule_violation",
                    "message": "Cannot delete yourself",
                    "details": "Users cannot delete their own account through the API"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller has no billing account, or (dashboard) is not an admin of the team.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "User not found, or not a member of the team the request is authenticated for.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "`Failed to delete user`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/users/reset-password/{id}": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Retired direct password-reset email",
        "operationId": "resetUserPassword",
        "description": "Returns 410 without generating a code or sending mail. Use the saved UUID password-reset-operations workflow; never automatically repeat an unknown effect.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Id of the user whose password should be reset.",
            "schema": {
              "type": "string"
            },
            "example": "user_1234567890"
          }
        ],
        "responses": {
          "410": {
            "description": "reset_delivery_operation_required; no reset effect attempted."
          }
        },
        "deprecated": true
      }
    },
    "/users/login-link": {
      "post": {
        "operationId": "createUsersLoginLink",
        "tags": [
          "Users"
        ],
        "summary": "Legacy direct login link (deprecated)",
        "description": "Deprecated, kept for one release as a compatibility window (backend PR 490): unscoped API keys still receive a one-hour login link for a user this billing account manages, as before. Scoped API keys get 403 account_approval_required without generating a login token. Prepare managed_users.issue_session through POST /users/me/account-approvals using a verified personal identity, then open review_url for the current owner to review. Agents receive safe metadata only. The legacy Proserver loginUrl and redeem terminals follow the same window.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Login link (compatibility window; unscoped API keys only)"
          },
          "403": {
            "description": "account_approval_required: use the credential approval handoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountApprovalRequired"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "account_approval_required",
                    "message": "Prepare and confirm this credential action through an account approval"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          }
        },
        "deprecated": true
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "listWebhooks",
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhooks",
        "description": "List configured webhooks in descending creation order. Follow next_cursor until has_more is false. Cursors are scoped to the selected team and status filter.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of webhooks to return (default 10, max 100)",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter webhooks by status",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor from the previous page; keep team and status unchanged."
          }
        ],
        "responses": {
          "200": {
            "description": "Webhooks retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Webhooks retrieved successfully"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiPublicWebhook"
                      }
                    },
                    "timestamp": {
                      "type": "number",
                      "example": 1709090576567
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Webhooks retrieved successfully",
                  "data": [
                    {
                      "id": "wh_dyS2ZVTj",
                      "url": "https://webhook.site/7cd05529-40fe-4c98-88e5-761de9c5feb1",
                      "events": [
                        "payment.created",
                        "payment.succeeded",
                        "invoice.created"
                      ],
                      "status": "active",
                      "description": "Production payment notifications",
                      "owner": "8UWdgXELUhf022vuoq249mtGytG2",
                      "created_at": 1709090576567,
                      "version": "v2",
                      "type": null,
                      "revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                      "effect_scope": "shared_team_webhooks",
                      "security": {
                        "header_names": [],
                        "configured": false,
                        "status": "not_configured"
                      },
                      "signing": {
                        "enabled": false,
                        "configured": false,
                        "status": "disabled"
                      }
                    }
                  ],
                  "timestamp": 1709090576567,
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Invalid limit or cursor, or cursor used with a different team or status filter."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createWebhooks",
        "tags": [
          "Webhooks"
        ],
        "summary": "Create webhook",
        "description": "Configuration is shared across live and test data. Current administrator authority and the original credential are rechecked. Personal administrators on v2 plans need apiAndWebhooks for create/update; legacy access is preserved. Readback and authorized deletion remain available after a downgrade. Use a stable operation_id and expected_revision to avoid overwriting a newer configuration. Secret header/signing fields require an authenticated browser; use the saved-endpoint browser handoff from MCP/CLI. Omitted security preserves headers; security.headers:{} clears them. Never put secrets in agent arguments. An inactive endpoint may have an empty events list. New endpoints do not mint a legacy secret.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookInput"
              },
              "example": {
                "url": "https://your-domain.com/webhooks/gigstack",
                "events": [
                  "payment.created",
                  "payment.succeeded"
                ],
                "description": "Production webhook for payment events",
                "status": "active",
                "operation_id": "ae7388d2-79d2-4333-9eb8-33b1a1e21b58",
                "version": "v2"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Configuration completed; key values are never replayed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookConfigurationWriteResult"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "wh_example",
                    "url": "https://receiver.example/webhook",
                    "events": [
                      "payment.succeeded"
                    ],
                    "status": "inactive",
                    "owner": "user_example",
                    "created_at": 1709090576567,
                    "version": "v2",
                    "type": null,
                    "revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "effect_scope": "shared_team_webhooks",
                    "security": {
                      "header_names": [],
                      "configured": false,
                      "status": "not_configured"
                    },
                    "signing": {
                      "enabled": false,
                      "configured": false,
                      "status": "disabled"
                    }
                  },
                  "operation": {
                    "operation_id": "ae7388d2-79d2-4333-9eb8-33b1a1e21b58",
                    "team_id": "team_example",
                    "webhook_id": "wh_example",
                    "action": "create",
                    "status": "completed",
                    "created_at": 1709090576567,
                    "effect_scope": "shared_team_webhooks",
                    "secret_attempts": 0,
                    "error": null,
                    "credential_delivery": "not_replayed"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid webhook data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "409": {
            "description": "An operation may remain processing, conflicted or uncertain. Read the same operation; never automatically repeat secret entry. Other pre-reservation conflicts return only success:false and error.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/WebhookConfigurationWriteResult"
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "success",
                        "error"
                      ],
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            false
                          ]
                        },
                        "error": {
                          "type": "object",
                          "required": [
                            "code",
                            "message"
                          ],
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": false,
                  "data": null,
                  "operation": {
                    "operation_id": "ae7388d2-79d2-4333-9eb8-33b1a1e21b58",
                    "team_id": "team_example",
                    "webhook_id": "wh_example",
                    "action": "create",
                    "status": "outcome_unknown",
                    "created_at": 1709090576567,
                    "effect_scope": "shared_team_webhooks",
                    "secret_attempts": 1,
                    "error": "webhook_secret_write_unconfirmed",
                    "credential_delivery": "not_replayed"
                  },
                  "error": {
                    "code": "webhook_configuration_unconfirmed",
                    "message": "Read this operation before any new change."
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          },
          "503": {
            "description": "Current credential or configuration result could not be confirmed; recover by reading the known operation."
          }
        },
        "callbacks": {
          "webhookEvent": {
            "{$request.body#/url}": {
              "post": {
                "summary": "Event delivery (sent by gigstack to your URL)",
                "description": "gigstack sends a `POST` for each event to every **active** webhook subscribed to it.\nThe body formats are described in `WebhookEventPayload`.\n\n**Resource events** (`payment.*`, `invoice.*`, `receipt.*`, `customer.*`, `service.*`)\n- Body: `WebhookPayloadV1` or `WebhookPayloadV2`, depending on the webhook's payload version.\n- Headers: `Content-Type: application/json`, plus any custom headers configured on the\n  webhook in the gigstack dashboard (for example `Authorization`). When configured, the delivery worker sends Webhook-Id, Webhook-Timestamp and Webhook-Signature.\n- Each attempt times out after 10 seconds.\n- `408`, `429`, `5xx`, timeouts and network errors are retried with exponential backoff,\n  up to 16 attempts in total. Any other `4xx` is final.\n- Webhooks are never disabled automatically because of failed deliveries.\n\n**`sat.invoice.synced`**\n- Body: `SatInvoiceSyncedWebhookEvent`.\n- Headers: `Content-Type: application/json`, `X-Gigstack-Event`, and `X-Gigstack-Signature`.\n  The signature is `sha256=` + hex HMAC-SHA256 of the raw body, keyed with the webhook's\n  `secret`. It is present only on existing endpoints that still hold a legacy signing secret. New endpoint creation does not generate this legacy secret. Configured canonical signing adds the separate Webhook-Id, Webhook-Timestamp and Webhook-Signature headers; configured custom headers also apply. Unresolved configured credentials stop delivery.\n- One attempt with a 10-second timeout. It is never retried, and the response is ignored.\n\n**`invoice_batch.completed`**\n- Sent once when every accepted item of a `POST /invoices/income/batch` batch has a final\n  status. Body: `InvoiceBatchCompletedWebhookEvent`.\n- Headers, signature and delivery are the same as for `sat.invoice.synced`: signed, one\n  attempt, never retried. Poll `GET /invoices/income/batch/{id}` as a fallback.\n\n**`payment_batch.completed`**\n- Sent once when every accepted item of a `POST /payments/register/batch` batch has a\n  final status. Body: `PaymentBatchCompletedWebhookEvent`.\n- Delivered exactly like `invoice_batch.completed`. Poll\n  `GET /payments/register/batch/{id}` as a fallback.\n\nOrder across events is not guaranteed, and the same event can arrive more than once.\nDe-duplicate, and respond with a `2xx` quickly.\n",
                "parameters": [
                  {
                    "name": "X-Gigstack-Event",
                    "in": "header",
                    "required": false,
                    "description": "`sat.invoice.synced`, `invoice_batch.completed` and `payment_batch.completed` deliveries only: the event type.",
                    "schema": {
                      "$ref": "#/components/schemas/WebhookEventType"
                    }
                  },
                  {
                    "name": "X-Gigstack-Signature",
                    "in": "header",
                    "required": false,
                    "description": "`sat.invoice.synced`, `invoice_batch.completed` and `payment_batch.completed` deliveries only: `sha256=<hex HMAC-SHA256 of the raw body, keyed with the webhook secret>`",
                    "schema": {
                      "type": "string",
                      "pattern": "^sha256=[0-9a-f]{64}$"
                    }
                  }
                ],
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/WebhookEventPayload"
                      },
                      "examples": {
                        "v1": {
                          "summary": "Resource event, v1 body",
                          "value": {
                            "event": "payment.succeeded",
                            "team": "team_1234567890",
                            "webhook": "wh_dyS2ZVTj",
                            "livemode": true,
                            "data": {
                              "id": "payment_1234567890",
                              "status": "succeeded"
                            }
                          }
                        },
                        "v2": {
                          "summary": "Resource event, v2 body",
                          "value": {
                            "id": "log_4GqT7mZx9LpR2vWc8NdK--wh_dyS2ZVTj",
                            "type": "payment.succeeded",
                            "created": 1767225600000,
                            "livemode": true,
                            "data": {
                              "object": {
                                "id": "payment_1234567890",
                                "status": "succeeded"
                              }
                            }
                          }
                        },
                        "satInvoiceSynced": {
                          "summary": "sat.invoice.synced",
                          "value": {
                            "id": "evt_4f1c9a7e2b3d5c6a",
                            "event": "sat.invoice.synced",
                            "created_at": 1767225600,
                            "data": {
                              "uuid": "9D9B0E5B-0341-4C2B-8F3A-6E1D2C4B5A70",
                              "direction": "received",
                              "resource_status": "ready",
                              "issuer": {
                                "rfc": "EKU9003173C9",
                                "name": "ESCUELA KEMPER URGATE"
                              },
                              "receiver": {
                                "rfc": "MEE200101ABC",
                                "name": "MI EMPRESA EJEMPLO"
                              },
                              "total": 1160,
                              "currency": "MXN",
                              "issue_date": "2026-01-15T10:30:00",
                              "invoice_type": "I",
                              "status": "Vigente",
                              "team": "team_1234567890",
                              "credit_charged": true
                            }
                          }
                        },
                        "invoiceBatchCompleted": {
                          "summary": "invoice_batch.completed",
                          "value": {
                            "id": "evt_9a2b7c4d1e6f3a8b",
                            "event": "invoice_batch.completed",
                            "created_at": 1790784000,
                            "data": {
                              "id": "ibatch_5d41402abc4b2a76b9719d911017c592",
                              "livemode": true,
                              "total": 250,
                              "accepted": 248,
                              "rejected": 2,
                              "counts": {
                                "queued": 0,
                                "stamped": 245,
                                "failed": 2,
                                "duplicate": 1,
                                "needs_review": 0
                              },
                              "result": "partially_completed"
                            }
                          }
                        },
                        "paymentBatchCompleted": {
                          "summary": "payment_batch.completed",
                          "value": {
                            "id": "evt_3c8d1e5f7a9b2c4d",
                            "event": "payment_batch.completed",
                            "created_at": 1790784000,
                            "data": {
                              "id": "pbatch_7f3a9c1e5b2d4f6a8c0e2a4b6d8f0a1c",
                              "livemode": true,
                              "total": 120,
                              "accepted": 119,
                              "rejected": 1,
                              "counts": {
                                "queued": 0,
                                "registered": 117,
                                "failed": 1,
                                "duplicate": 1
                              },
                              "result": "partially_completed"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "Any `2xx` acknowledges the delivery.\n- For resource events, `408`, `429` and `5xx` trigger a retry, and any other `4xx` is final.\n- For `sat.invoice.synced`, `invoice_batch.completed` and `payment_batch.completed` the response is ignored.\n"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{id}": {
      "get": {
        "operationId": "getWebhooksById",
        "tags": [
          "Webhooks"
        ],
        "summary": "Get webhook",
        "description": "Retrieve details of a specific webhook by ID.\n\n**gigstack Connect:** Access other teams' webhooks using the `team` parameter.\n With configuration_access=true, the original credential and current admin role are verified, and configuration_access identifies the reviewed endpoint, actor, revision and whether the current plan permits configuration.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Webhook ID",
            "schema": {
              "type": "string",
              "example": "wh_dyS2ZVTj"
            },
            "example": "webhook_1234567890"
          },
          {
            "name": "configuration_access",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "Set true for a current administrator review of this saved endpoint. Returns safe configuration_access scope and can_configure; no secret values or writes."
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Webhook retrieved successfully"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicWebhook"
                    },
                    "timestamp": {
                      "type": "number",
                      "example": 1709090576567
                    },
                    "configuration_access": {
                      "$ref": "#/components/schemas/WebhookConfigurationAccess"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Webhook retrieved successfully",
                  "data": {
                    "id": "wh_dyS2ZVTj",
                    "url": "https://your-domain.com/webhooks/gigstack",
                    "events": [
                      "payment.succeeded",
                      "sat.invoice.synced"
                    ],
                    "status": "active",
                    "description": "Production webhook",
                    "owner": "8UWdgXELUhf022vuoq249mtGytG2",
                    "created_at": 1709090576567,
                    "version": "v2",
                    "type": null,
                    "revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "effect_scope": "shared_team_webhooks",
                    "security": {
                      "header_names": [],
                      "configured": false,
                      "status": "not_configured"
                    },
                    "signing": {
                      "enabled": false,
                      "configured": false,
                      "status": "disabled"
                    }
                  },
                  "timestamp": 1709090576567
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Webhook not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateWebhooksById",
        "tags": [
          "Webhooks"
        ],
        "summary": "Update webhook",
        "description": "**Partial update:** send only the fields you want to change; omitted fields keep their current values.\nConfiguration is shared across live and test data. Current administrator authority and the original credential are rechecked. Personal administrators on v2 plans need apiAndWebhooks for create/update; legacy access is preserved. Readback and authorized deletion remain available after a downgrade. Use a stable operation_id and expected_revision to avoid overwriting a newer configuration. Secret header/signing fields require an authenticated browser; use the saved-endpoint browser handoff from MCP/CLI. Omitted security preserves headers; security.headers:{} clears them. Never put secrets in agent arguments. Update only supplied fields. Secret updates require expected_revision.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Webhook ID",
            "schema": {
              "type": "string",
              "example": "wh_dyS2ZVTj"
            },
            "example": "webhook_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookUpdateInput"
              },
              "example": {
                "status": "inactive",
                "description": "Temporarily disabled for maintenance",
                "operation_id": "ae7388d2-79d2-4333-9eb8-33b1a1e21b58",
                "expected_revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Configuration completed; key values are never replayed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookConfigurationWriteResult"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "wh_example",
                    "url": "https://receiver.example/webhook",
                    "events": [
                      "payment.succeeded"
                    ],
                    "status": "inactive",
                    "owner": "user_example",
                    "created_at": 1709090576567,
                    "version": "v2",
                    "type": null,
                    "revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "effect_scope": "shared_team_webhooks",
                    "security": {
                      "header_names": [],
                      "configured": false,
                      "status": "not_configured"
                    },
                    "signing": {
                      "enabled": false,
                      "configured": false,
                      "status": "disabled"
                    }
                  },
                  "operation": {
                    "operation_id": "ae7388d2-79d2-4333-9eb8-33b1a1e21b58",
                    "team_id": "team_example",
                    "webhook_id": "wh_example",
                    "action": "update",
                    "status": "completed",
                    "created_at": 1709090576567,
                    "effect_scope": "shared_team_webhooks",
                    "secret_attempts": 0,
                    "error": null,
                    "credential_delivery": "not_replayed"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid webhook data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Webhook not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "409": {
            "description": "An operation may remain processing, conflicted or uncertain. Read the same operation; never automatically repeat secret entry. Other pre-reservation conflicts return only success:false and error.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/WebhookConfigurationWriteResult"
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "success",
                        "error"
                      ],
                      "properties": {
                        "success": {
                          "type": "boolean",
                          "enum": [
                            false
                          ]
                        },
                        "error": {
                          "type": "object",
                          "required": [
                            "code",
                            "message"
                          ],
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": false,
                  "data": null,
                  "operation": {
                    "operation_id": "ae7388d2-79d2-4333-9eb8-33b1a1e21b58",
                    "team_id": "team_example",
                    "webhook_id": "wh_example",
                    "action": "update",
                    "status": "outcome_unknown",
                    "created_at": 1709090576567,
                    "effect_scope": "shared_team_webhooks",
                    "secret_attempts": 1,
                    "error": "webhook_secret_write_unconfirmed",
                    "credential_delivery": "not_replayed"
                  },
                  "error": {
                    "code": "webhook_configuration_unconfirmed",
                    "message": "Read this operation before any new change."
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          },
          "503": {
            "description": "Current credential or configuration result could not be confirmed; recover by reading the known operation."
          }
        }
      },
      "delete": {
        "operationId": "deleteWebhooksById",
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete webhook",
        "description": "Delete only the selected saved endpoint after current credential and administrator checks. Send expected_revision to refuse stale removal. Other endpoints and Secret Manager resources are retained. After a lost response, GET the endpoint: 404 confirms absence, not which caller deleted it.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Webhook ID",
            "schema": {
              "type": "string",
              "example": "wh_dyS2ZVTj"
            },
            "example": "webhook_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string",
                      "example": "Webhook deleted successfully"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "deleted": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Webhook deleted successfully",
                  "data": {
                    "deleted": true
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Webhook not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "expected_revision": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  }
                }
              },
              "example": {
                "expected_revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
              }
            }
          }
        }
      }
    },
    "/catalogs/product-keys": {
      "get": {
        "operationId": "getCatalogsProductKeys",
        "tags": [
          "Catalogs"
        ],
        "summary": "Search SAT product keys",
        "description": "Full-text search over the SAT `c_ClaveProdServ` catalog, the same catalog the dashboard\nsearches when you pick a default product key. Returns the codes you assign to an item's\n`product_key`.\n\n**Search Capabilities:**\n- Matches on code, description and SAT taxonomy (type, division, group)\n- Typo-tolerant fuzzy matching, ranked by relevance\n- Paginated results\n\n**Notes:**\n- The catalog is published by the SAT and is identical for every team, so results are not\n  affected by `livemode` and contain no team data. Authentication is still required.\n- Typesense must be configured for your team.\n- The `q` (or `query`) parameter is required.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/SearchQueryParam"
          },
          {
            "$ref": "#/components/parameters/SearchQueryBackwardCompatParam"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/SearchPageParam"
          },
          {
            "$ref": "#/components/parameters/ProductKeysSearchFieldsParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Product keys searched successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data",
                    "found",
                    "page",
                    "per_page",
                    "success",
                    "timestamp"
                  ],
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Product keys searched successfully"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiPublicProductKey"
                      }
                    },
                    "found": {
                      "type": "integer",
                      "description": "Total number of results found",
                      "example": 15
                    },
                    "page": {
                      "type": "integer",
                      "description": "Current page number",
                      "example": 1
                    },
                    "per_page": {
                      "type": "integer",
                      "description": "Number of results per page",
                      "example": 10
                    },
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64",
                      "example": 1704067200000
                    }
                  }
                },
                "example": {
                  "message": "Product keys searched successfully",
                  "data": [
                    {
                      "code": "84111506",
                      "description": "Servicios de facturación"
                    }
                  ],
                  "found": 1,
                  "page": 1,
                  "per_page": 10,
                  "success": true,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "missing_query": {
                    "summary": "Missing query parameter",
                    "value": {
                      "error": {
                        "code": "missing_query",
                        "message": "Query parameter is required"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "missing_typesense_key": {
                    "summary": "Typesense not configured",
                    "value": {
                      "error": {
                        "code": "missing_typesense_key",
                        "message": "Typesense API key not configured for this team"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_fields": {
                    "summary": "A field that cannot be searched",
                    "value": {
                      "error": {
                        "code": "invalid_fields",
                        "message": "Cannot search in id. `fields` sets the fields to search in; for product_keys use any of: code, ..."
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/catalogs/unit-keys": {
      "get": {
        "operationId": "getCatalogsUnitKeys",
        "tags": [
          "Catalogs"
        ],
        "summary": "Search SAT unit keys",
        "description": "Full-text search over the SAT `c_ClaveUnidad` catalog. Returns the codes you assign to an\nitem's `unit_key`, together with the name commonly stored as `unit_name`.\n\n**Search Capabilities:**\n- Matches on unit key and name\n- Typo-tolerant fuzzy matching, ranked by relevance\n- Paginated results\n\n**Notes:**\n- The catalog is published by the SAT and is identical for every team, so results are not\n  affected by `livemode` and contain no team data. Authentication is still required.\n- Typesense must be configured for your team.\n- The `q` (or `query`) parameter is required.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "$ref": "#/components/parameters/SearchQueryParam"
          },
          {
            "$ref": "#/components/parameters/SearchQueryBackwardCompatParam"
          },
          {
            "$ref": "#/components/parameters/LimitParam"
          },
          {
            "$ref": "#/components/parameters/SearchPageParam"
          },
          {
            "$ref": "#/components/parameters/UnitKeysSearchFieldsParam"
          }
        ],
        "responses": {
          "200": {
            "description": "Unit keys searched successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "data",
                    "found",
                    "page",
                    "per_page",
                    "success",
                    "timestamp"
                  ],
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Unit keys searched successfully"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiPublicUnitKey"
                      }
                    },
                    "found": {
                      "type": "integer",
                      "description": "Total number of results found",
                      "example": 4
                    },
                    "page": {
                      "type": "integer",
                      "description": "Current page number",
                      "example": 1
                    },
                    "per_page": {
                      "type": "integer",
                      "description": "Number of results per page",
                      "example": 10
                    },
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64",
                      "example": 1704067200000
                    }
                  }
                },
                "example": {
                  "message": "Unit keys searched successfully",
                  "data": [
                    {
                      "code": "E48",
                      "name": "Unidad de servicio"
                    }
                  ],
                  "found": 1,
                  "page": 1,
                  "per_page": 10,
                  "success": true,
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                },
                "examples": {
                  "missing_query": {
                    "summary": "Missing query parameter",
                    "value": {
                      "error": {
                        "code": "missing_query",
                        "message": "Query parameter is required"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "missing_typesense_key": {
                    "summary": "Typesense not configured",
                    "value": {
                      "error": {
                        "code": "missing_typesense_key",
                        "message": "Typesense API key not configured for this team"
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  },
                  "invalid_fields": {
                    "summary": "A field that cannot be searched",
                    "value": {
                      "error": {
                        "code": "invalid_fields",
                        "message": "Cannot search in id. `fields` sets the fields to search in; for unit_keys use any of: name, ..."
                      },
                      "success": false,
                      "timestamp": 1767225600000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/auth/health": {
      "get": {
        "tags": [
          "Auth"
        ],
        "summary": "Health check",
        "operationId": "authHealth",
        "description": "Liveness probe for the auth module. Unauthenticated — the whole auth router is mounted\nas a public endpoint, so no credential is required or inspected.\n",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "auth"
                }
              }
            }
          }
        }
      }
    },
    "/auth/sandbox": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Create a test-only sandbox account for a person",
        "operationId": "createAgentSandbox",
        "description": "Lets an agent create a gigstack account for a person without a partner secret. The account\nis a pricing v3 account with **one test API key** (`sk_test_`, `livemode: false`), so it\ncannot stamp CFDI before the SAT or charge anything. Going live needs a person: they claim the\nsandbox with the code emailed to them, set a password and go live from app.gigstack.pro.\n\n- **Off by default.** The route answers `404 not_found` until the operator enables it.\n- **Idempotent.** `Idempotency-Key` is required. Replaying it with the same body returns the\n  same `team_id` and `billing_account_id` with `200`, without new effects; the test key is\n  returned only in the first `201` response (`api_key.test: null`,\n  `credential_delivery: not_replayed` on replay). The same key with a different body is\n  `409 idempotency_conflict`.\n- **One open sandbox per email.** If the email already has an unclaimed sandbox, a fresh claim\n  code is sent to it and the answer is `409 sandbox_pending_claim` with the `team_id` and\n  claim details, never keys. Any other existing account is `409 email_already_exists`.\n- **Abuse controls.** Per caller IP (3 an hour, 10 a day), per company email domain (50 a\n  day; large consumer mailbox providers are exempt), up to 3 claim codes an hour per email,\n  and disposable inbox domains are refused with `400 email_not_allowed`.\n- **Test data only until claimed.** The test key can use clients, services, payments,\n  receipts, invoices, catalogs, SAT lists, retentions and `GET /teams/{id}`. Everything\n  else (users, login links, API keys, team members, billing, go-live, portals, webhooks)\n  answers `403 sandbox_unclaimed` until the person claims the sandbox.\n- An unclaimed sandbox expires 7 days after creation: its keys are revoked and, when the\n  person has no other gigstack account, the login is removed so the email can be used\n  again. Team data is never deleted.\n\nThe claim code is never returned or logged. Hand `team_id` to the person, or ask them for the\ncode and call `POST /auth/sandbox/claim`.\n",
        "security": [],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Your identifier for this request, 8-128 characters of `A-Z a-z 0-9 . _ : -`.\n",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "email",
                  "name"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 254,
                    "description": "The person's email. The claim code is sent here."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "The person's or business name."
                  },
                  "agent": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "client": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9 ._:/@+-]{1,64}$",
                        "description": "Name of the agent or tool creating the sandbox, kept for audit."
                      }
                    }
                  }
                }
              },
              "example": {
                "email": "persona@empresa.mx",
                "name": "Persona Ejemplo",
                "agent": {
                  "client": "claude-code"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replay of the same `Idempotency-Key` and body. Same ids, no key, no new effects.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentSandbox"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "team_id": "team_a1b2c3d4e5f6",
                    "billing_account_id": "ba_a1b2c3d4e5f6g7h",
                    "livemode": false,
                    "api_key": {
                      "test": null
                    },
                    "credential_delivery": "not_replayed",
                    "claim": {
                      "sent_to": "persona@empresa.mx",
                      "expires_at": 1767830400000
                    }
                  },
                  "message": "Sandbox already created; the test key is not returned again",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "201": {
            "description": "Sandbox created. The test key is returned only in this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentSandbox"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "team_id": "team_a1b2c3d4e5f6",
                    "billing_account_id": "ba_a1b2c3d4e5f6g7h",
                    "livemode": false,
                    "api_key": {
                      "test": "eyJhbGciOiJIUzI1NiJ9.example.signature"
                    },
                    "credential_delivery": "first_response",
                    "claim": {
                      "sent_to": "persona@empresa.mx",
                      "expires_at": 1767830400000,
                      "delivery": "sent"
                    }
                  },
                  "message": "Sandbox created; the test key is returned only in this response",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Invalid body or header (`validation_failed`, `invalid_request_body`), or a disposable\ninbox domain (`email_not_allowed`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "email_not_allowed",
                    "message": "Use a permanent email address the person reads; disposable inboxes are not accepted"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "404": {
            "description": "Agent sandboxes are not enabled in this environment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "not_found",
                    "message": "Not found"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "409": {
            "description": "`sandbox_pending_claim` (a new claim code was sent; `data` has `team_id` and `claim`),\n`sandbox_claim_locked` (15 wrong codes over the sandbox's life; it is released when it\nexpires), `email_already_exists`, `idempotency_conflict`, `idempotency_in_progress` or\n`sandbox_outcome_unknown` (do not retry with a new key).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "sandbox_pending_claim",
                    "message": "This email has an unclaimed sandbox; a new claim code was sent to it"
                  },
                  "data": {
                    "team_id": "team_a1b2c3d4e5f6",
                    "claim": {
                      "sent_to": "persona@empresa.mx",
                      "expires_at": 1767830400000,
                      "delivery": "sent"
                    }
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "429": {
            "description": "Per-IP, per-domain or claim-code budget exhausted. `Retry-After` says when to retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "rate_limit_exceeded",
                    "message": "Too many sandbox requests. Retry in 1800 seconds."
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "503": {
            "description": "Nothing was created, or the state could not be confirmed. Retry the same request later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "sandbox_state_unavailable",
                    "message": "Retry the same request later"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          }
        }
      }
    },
    "/auth/sandbox/claim": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Claim a sandbox with the emailed code",
        "operationId": "claimAgentSandbox",
        "description": "The person proves they read the inbox the sandbox was created for. On success the sandbox is\ntheirs: their email is marked verified, the test key is no longer limited to test data, and\nthey receive a link to set a password and sign in to app.gigstack.pro, where they can go live.\nThe code works once and locks after 5 wrong attempts; a sandbox locks for good after 15 wrong\nattempts across re-sent codes. Every mismatch, expired or spent code answers the same\n`400 invalid_or_expired_code`.\n\nOff by default (`404 not_found`), like `POST /auth/sandbox`.\n",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "team_id",
                  "code"
                ],
                "properties": {
                  "team_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,64}$",
                    "description": "`team_id` returned by `POST /auth/sandbox`."
                  },
                  "code": {
                    "type": "string",
                    "pattern": "^[0-9]{6}$",
                    "description": "Six-digit code from the email."
                  }
                }
              },
              "example": {
                "team_id": "team_a1b2c3d4e5f6",
                "code": "123456"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sandbox claimed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "claimed",
                        "team_id",
                        "next"
                      ],
                      "properties": {
                        "claimed": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "password_email": {
                          "type": "string",
                          "enum": [
                            "sent",
                            "failed"
                          ],
                          "description": "Whether the set-password email was handed to the mail provider. On `failed`, use \"forgot password\" in the app."
                        },
                        "next": {
                          "type": "string"
                        }
                      }
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "claimed": true,
                    "team_id": "team_a1b2c3d4e5f6",
                    "password_email": "sent",
                    "next": "Check your email to set your password, then go live from the app"
                  },
                  "message": "Sandbox claimed",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Wrong, expired, locked or already used code (`invalid_or_expired_code`), or an invalid body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "invalid_or_expired_code",
                    "message": "The code is not valid for this sandbox or has expired"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "404": {
            "description": "Agent sandboxes are not enabled in this environment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "not_found",
                    "message": "Not found"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "429": {
            "description": "Too many attempts from this IP or for this sandbox. `Retry-After` says when to retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "rate_limit_exceeded",
                    "message": "Too many claim attempts. Retry in 900 seconds."
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          }
        }
      }
    },
    "/sat-lists": {
      "get": {
        "operationId": "listSatLists",
        "tags": [
          "SAT Lists"
        ],
        "summary": "List SAT lists and sync status",
        "description": "Returns every SAT list definition tracked by gigstack, together with the metadata from its most recent sync.\n\ngigstack mirrors the RFC lists the SAT publishes under **Artículo 69**, **Artículo 69-B** and **Artículo 69-B Bis**.\nThe lists are re-synced automatically every Sunday from the SAT's published CSVs.\n\nEach list carries an `is_risky` flag. Risky lists (for example `Cancelados`, `Definitivos 69-B`, `No localizados`,\n`CSD sin efectos`) are the ones that indicate a counterparty you should not invoice; the remaining lists are\ninformational only.\n\nThe `sync` object is `null` for a list that has never completed a sync.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "SAT lists retrieved successfully. `data` is an array of list definitions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SatListDefinition"
                      }
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer",
                      "format": "int64"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": [
                    {
                      "key": "art_69b_definitivos",
                      "label": "Definitivos 69-B",
                      "source": "art_69b",
                      "is_risky": true,
                      "filename": "Definitivos.csv",
                      "sync": {
                        "last_sync_at": "2026-09-06T06:00:00.000Z",
                        "last_status": "ok",
                        "row_count": 12843,
                        "previous_row_count": 12790,
                        "net_new": 53,
                        "removed": 0,
                        "duration_ms": 48210
                      }
                    }
                  ],
                  "message": "SAT lists retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/sat-lists/check/{rfc}": {
      "get": {
        "operationId": "getSatListsCheckByRfc",
        "tags": [
          "SAT Lists"
        ],
        "summary": "Check an RFC against the SAT lists",
        "description": "Checks whether an RFC appears on any of the SAT lists gigstack tracks, and returns every matching entry.\n\nUse this before invoicing a counterparty: `is_risky` is `true` when the RFC appears on at least one list\nflagged as risky (`Cancelados`, `Definitivos 69-B`, `Presuntos 69-B`, `No localizados`, `CSD sin efectos`, …),\nand `risky_lists` names exactly which ones.\n\nAn RFC that appears on no list returns `200` with `found: false` — a clean RFC is not a `404`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "rfc",
            "in": "path",
            "required": true,
            "description": "The RFC to check. Case-insensitive; must be 10-13 characters.",
            "schema": {
              "type": "string",
              "minLength": 10,
              "maxLength": 13,
              "example": "XAXX010101000"
            },
            "example": "PEGJ800101ABC"
          },
          {
            "name": "risky_only",
            "in": "query",
            "required": false,
            "description": "When `true`, only entries from lists flagged as risky are returned.",
            "schema": {
              "type": "boolean",
              "example": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "RFC checked against the SAT lists",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/SatListRfcCheck"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "rfc": "EKU9003173C9",
                    "found": false,
                    "is_risky": false,
                    "risky_lists": [],
                    "entries": []
                  },
                  "message": "RFC EKU9003173C9 checked against SAT lists",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Invalid RFC (must be between 10 and 13 characters)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/sat-lists/32d/{rfc}": {
      "get": {
        "operationId": "getSatOpinion32dByRfc",
        "tags": [
          "SAT Lists"
        ],
        "summary": "Consult the SAT \"Opinión del Cumplimiento\" (32-D) for an RFC",
        "description": "Consults the SAT's public *Opinión del Cumplimiento de Obligaciones Fiscales* (Artículo 32-D) service\nfor an RFC and, when the SAT publishes one, returns a link to the constancia PDF.\n\n### How to read the result — please read before building on this\n\nThe SAT's public service **only ever publishes positive opinions**, and only for taxpayers who\nexplicitly authorized public disclosure of their opinion. There are exactly two outcomes:\n\n- `status: \"positiva\"` (`found: true`) — the SAT publishes a positive opinion for this RFC, and\n  `pdf_url` links to the constancia.\n- `status: \"no_autorizado\"` (`found: false`) — the SAT publishes nothing for this RFC. **This means\n  the result is unknown.** Either the taxpayer never opted in to public disclosure, or no opinion is\n  published. It is **not** a negative opinion, it is **not** evidence of non-compliance, and it must\n  never be shown to a user as \"opinión negativa\", \"incumplido\", or anything equivalent. The only\n  correct reading is \"the SAT does not publish an opinion for this RFC\".\n\nThere is no third status: the SAT never exposes negative opinions through this service, so this\nendpoint can never tell you that a taxpayer is non-compliant.\n\nA failure reaching the SAT — network error, or the SAT changing its page — returns `500`. It is never\ncollapsed into `no_autorizado`, so `no_autorizado` always reflects a real answer from the SAT.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "rfc",
            "in": "path",
            "required": true,
            "description": "The RFC to consult. Case-insensitive; must be 10-13 characters.",
            "schema": {
              "type": "string",
              "minLength": 10,
              "maxLength": 13,
              "example": "EKU9003173C9"
            },
            "example": "EKU9003173C9"
          }
        ],
        "responses": {
          "200": {
            "description": "The SAT was consulted successfully (for both `positiva` and `no_autorizado`)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/SatOpinion32dCheck"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "rfc": "EKU9003173C9",
                    "status": "no_autorizado",
                    "found": false,
                    "pdf_url": null,
                    "checked_at": 1767225600000
                  },
                  "message": "SAT publishes no 32-D opinion for RFC EKU9003173C9 — the result is unknown, not negative",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Invalid RFC (must be between 10 and 13 characters)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "description": "The SAT could not be reached or its response could not be parsed. The taxpayer's status is\nunknown — do not interpret this as `no_autorizado` or as a negative opinion.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/catalogs/health": {
      "get": {
        "tags": [
          "Catalogs"
        ],
        "summary": "Health check",
        "operationId": "catalogsHealth",
        "description": "Liveness probe for the catalogs module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "catalogs"
                }
              }
            }
          }
        }
      }
    },
    "/clients/health": {
      "get": {
        "tags": [
          "Clients"
        ],
        "summary": "Health check",
        "operationId": "clientsHealth",
        "description": "Liveness probe for the clients module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "clients"
                }
              }
            }
          }
        }
      }
    },
    "/invoices/health": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "summary": "Health check",
        "operationId": "invoicesHealth",
        "description": "Liveness probe for the invoices module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "invoices"
                }
              }
            }
          }
        }
      }
    },
    "/payments/health": {
      "get": {
        "tags": [
          "Payments"
        ],
        "summary": "Health check",
        "operationId": "paymentsHealth",
        "description": "Liveness probe for the payments module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "payments"
                }
              }
            }
          }
        }
      }
    },
    "/receipts/health": {
      "get": {
        "tags": [
          "Receipts"
        ],
        "summary": "Health check",
        "operationId": "receiptsHealth",
        "description": "Liveness probe for the receipts module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "receipts"
                }
              }
            }
          }
        }
      }
    },
    "/services/health": {
      "get": {
        "tags": [
          "Services"
        ],
        "summary": "Health check",
        "operationId": "servicesHealth",
        "description": "Liveness probe for the services module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "services"
                }
              }
            }
          }
        }
      }
    },
    "/teams/health": {
      "get": {
        "tags": [
          "Teams"
        ],
        "summary": "Health check",
        "operationId": "teamsHealth",
        "description": "Liveness probe for the teams module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "teams"
                }
              }
            }
          }
        }
      }
    },
    "/users/health": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Health check",
        "operationId": "usersHealth",
        "description": "Liveness probe for the users module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "users"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/health": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Health check",
        "operationId": "webhooksHealth",
        "description": "Liveness probe for the webhooks module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "webhooks"
                }
              }
            }
          }
        }
      }
    },
    "/documents": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "List documents",
        "operationId": "listDocuments",
        "description": "List documents for the authenticated team and credential mode, newest first with an ID tie-breaker.\nSoft-deleted rows and nonmatching filters are removed after scanning a bounded page.\nAn empty data array can still have has_more: true; continue with next_cursor until false.\nThe opaque cursor is bound to team, mode and filters. Raw document IDs are not accepted.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum rows scanned per page, from 1 to 100; defaults to 50. Filtered result pages can be smaller.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque next_cursor from the previous page; bound to team, credential mode and filters.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "document_type",
            "in": "query",
            "required": false,
            "description": "Filter by document type.",
            "schema": {
              "$ref": "#/components/schemas/DocumentTypeEnum"
            }
          },
          {
            "name": "compliance_status",
            "in": "query",
            "required": false,
            "description": "Filter by compliance review state.",
            "schema": {
              "$ref": "#/components/schemas/DocumentComplianceStatusEnum"
            }
          },
          {
            "name": "entity_type",
            "in": "query",
            "required": false,
            "description": "Filter to documents linked to this kind of entity.",
            "schema": {
              "$ref": "#/components/schemas/DocumentLinkEntityTypeEnum"
            }
          },
          {
            "name": "entity_id",
            "in": "query",
            "required": false,
            "description": "Filter to documents linked to this specific entity id. Applied after the query.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Documents retrieved. Note the nested shape: the array lives at `data.data`, with\npagination alongside it inside `data`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "required": [
                            "data",
                            "has_more"
                          ],
                          "properties": {
                            "data": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/ApiPublicDocument"
                              }
                            },
                            "has_more": {
                              "type": "boolean",
                              "example": false
                            },
                            "next_cursor": {
                              "type": "string",
                              "nullable": true,
                              "description": "Pass back as `cursor` to fetch the next page. `null` on the last page.",
                              "example": "doc_1234567890"
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "data": [
                      {
                        "id": "doc_1234567890",
                        "document_type": "contract",
                        "name": "Contrato de servicios 2026 — Cliente ACME",
                        "description": "Contrato marco de prestación de servicios",
                        "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_123%2Fsat_documents%2Fcontrato-acme.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                        "file_name": "contrato-acme.pdf",
                        "file_size": 284913,
                        "mime_type": "application/pdf",
                        "linked_entities": [
                          {
                            "entity_type": "client",
                            "entity_id": "client_1234567890",
                            "linked_at": 1767225600000
                          }
                        ],
                        "compliance_status": "pending_review",
                        "compliance_notes": null,
                        "valid_from": 1767225600000,
                        "valid_until": 1798761600000,
                        "ai_extraction": null,
                        "tags": [
                          "contrato",
                          "acme"
                        ],
                        "metadata": null,
                        "created_at": 1767225600000,
                        "created_by": "user_1234567890",
                        "updated_at": null,
                        "livemode": true
                      }
                    ],
                    "has_more": false,
                    "next_cursor": null
                  },
                  "message": "Documents retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "description": "`An error occurred while listing documents`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Create document",
        "operationId": "createDocument",
        "description": "Upload a standalone PDF or PNG/JPEG/WEBP image as multipart form data (maximum 10 MiB), or register metadata for an already uploaded object using JSON. User-scoped writes require a current editor/admin. Multipart requires file and documentType; name defaults to the file name, and description is optional. Use metadata/link operations afterward for structured fields.\n\nJSON fileUrl and storagePath must identify the same object in the runtime bucket under teams/{team}/{live|test}/support-documents/ matching the credential mode. The historical teams/{team}/sat_documents/ path requires verified Firebase browser identity. Private paths, foreign buckets/teams, mismatched URLs and cross-mode links are rejected. complianceStatus starts as pending_review. analyzeWithAI is accepted for compatibility but does not trigger analysis; use the analyze operation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentInput"
              },
              "example": {
                "documentType": "contract",
                "name": "Contrato de servicios 2026 — Cliente ACME",
                "description": "Contrato marco de prestación de servicios",
                "fileUrl": "https://storage.googleapis.com/gigstackpro.appspot.com/teams/team_123/live/support-documents/contrato-acme.pdf",
                "storagePath": "teams/team_123/live/support-documents/contrato-acme.pdf",
                "fileName": "contrato-acme.pdf",
                "fileSize": 284913,
                "mimeType": "application/pdf",
                "validFrom": 1767225600000,
                "validUntil": 1798761600000,
                "tags": [
                  "contrato",
                  "acme"
                ],
                "linkedEntities": [
                  {
                    "entityType": "client",
                    "entityId": "client_1234567890"
                  }
                ],
                "analyzeWithAI": false
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "documentType"
                ],
                "additionalProperties": false,
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "documentType": {
                    "type": "string",
                    "enum": [
                      "contract",
                      "delivery_proof",
                      "payment_proof",
                      "communication"
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Document created.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicDocument"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "doc_1234567890",
                    "document_type": "contract",
                    "name": "Contrato de servicios 2026 — Cliente ACME",
                    "description": "Contrato marco de prestación de servicios",
                    "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_123%2Fsat_documents%2Fcontrato-acme.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                    "file_name": "contrato-acme.pdf",
                    "file_size": 284913,
                    "mime_type": "application/pdf",
                    "linked_entities": [
                      {
                        "entity_type": "client",
                        "entity_id": "client_1234567890",
                        "linked_at": 1767225600000
                      }
                    ],
                    "compliance_status": "pending_review",
                    "compliance_notes": null,
                    "valid_from": 1767225600000,
                    "valid_until": 1798761600000,
                    "ai_extraction": null,
                    "tags": [
                      "contrato",
                      "acme"
                    ],
                    "metadata": null,
                    "created_at": 1767225600000,
                    "created_by": "user_1234567890",
                    "updated_at": null,
                    "livemode": true
                  },
                  "message": "Document created successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Body validation failure, including unknown keys.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "description": "`An error occurred while creating document`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Get document",
        "operationId": "getDocument",
        "description": "Retrieve one document. Documents belonging to another team or credential mode, and\nsoft-deleted documents, return `404`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Document id.",
            "schema": {
              "type": "string"
            },
            "example": "doc_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Document retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicDocument"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "doc_1234567890",
                    "document_type": "contract",
                    "name": "Contrato de servicios 2026 — Cliente ACME",
                    "description": "Contrato marco de prestación de servicios",
                    "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_123%2Fsat_documents%2Fcontrato-acme.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                    "file_name": "contrato-acme.pdf",
                    "file_size": 284913,
                    "mime_type": "application/pdf",
                    "linked_entities": [
                      {
                        "entity_type": "client",
                        "entity_id": "client_1234567890",
                        "linked_at": 1767225600000
                      }
                    ],
                    "compliance_status": "pending_review",
                    "compliance_notes": null,
                    "valid_from": 1767225600000,
                    "valid_until": 1798761600000,
                    "ai_extraction": null,
                    "tags": [
                      "contrato",
                      "acme"
                    ],
                    "metadata": null,
                    "created_at": 1767225600000,
                    "created_by": "user_1234567890",
                    "updated_at": null,
                    "livemode": true
                  },
                  "message": "Document retrieved successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "`Document not found` — missing, owned by another team, or soft-deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "`An error occurred while retrieving document`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Documents"
        ],
        "summary": "Update document",
        "operationId": "updateDocument",
        "description": "Update a document's metadata and compliance review state. Only fields explicitly\npresent in the body are written; omitted fields are left untouched.\n\nThe file itself (`fileUrl`, `storagePath`, `fileName`, `documentType`) is immutable —\nthose keys are not part of the update schema and are rejected as unknown.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Document id.",
            "schema": {
              "type": "string"
            },
            "example": "doc_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentUpdateInput"
              },
              "example": {
                "complianceStatus": "valid",
                "complianceNotes": "Revisado por el área fiscal, cumple con el requisito de materialidad.",
                "tags": [
                  "contrato",
                  "acme",
                  "revisado"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Document updated.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicDocument"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "doc_1234567890",
                    "document_type": "contract",
                    "name": "Contrato de servicios 2026 — Cliente ACME",
                    "description": "Contrato marco de prestación de servicios",
                    "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_123%2Fsat_documents%2Fcontrato-acme.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                    "file_name": "contrato-acme.pdf",
                    "file_size": 284913,
                    "mime_type": "application/pdf",
                    "linked_entities": [
                      {
                        "entity_type": "client",
                        "entity_id": "client_1234567890",
                        "linked_at": 1767225600000
                      }
                    ],
                    "compliance_status": "valid",
                    "compliance_notes": "Revisado por el área fiscal, cumple con el requisito de materialidad.",
                    "valid_from": 1767225600000,
                    "valid_until": 1798761600000,
                    "ai_extraction": null,
                    "tags": [
                      "contrato",
                      "acme"
                    ],
                    "metadata": null,
                    "created_at": 1767225600000,
                    "created_by": "user_1234567890",
                    "updated_at": 1767312000000,
                    "livemode": true
                  },
                  "message": "Document updated successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Body validation failure, including unknown keys.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "`Document not found`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "`An error occurred while updating document`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Documents"
        ],
        "summary": "Delete document",
        "operationId": "deleteDocument",
        "description": "**Soft delete.** The document is flagged `deleted` (with `deletedAt`/`deletedBy`) rather\nthan removed, and its id is pulled from the `satDocuments` array of every entity it was\nlinked to. It stops appearing in list and get responses.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Document id.",
            "schema": {
              "type": "string"
            },
            "example": "doc_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Document deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "required": [
                            "id"
                          ],
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "doc_1234567890"
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "message": "Document deleted successfully",
                  "timestamp": 1767225600000,
                  "data": {
                    "id": "doc_1234567890"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "`Document not found` — including a document that was already deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "`An error occurred while deleting document`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/analyze": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Analyze document with AI",
        "operationId": "analyzeDocument",
        "description": "Run AI extraction over the document and store the result on it under `ai_extraction`.\n\nOnly PDFs and PNG/JPEG/WEBP images can be analyzed. For PDFs the text layer is\nextracted first — a scanned PDF with no selectable text is rejected with `400`.\n\nThe request body is ignored; the prompt is derived from the document's `documentType`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Document id.",
            "schema": {
              "type": "string"
            },
            "example": "doc_1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Document analyzed. The returned document carries the new `ai_extraction`.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicDocument"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "doc_1234567890",
                    "document_type": "contract",
                    "name": "Contrato de servicios 2026 — Cliente ACME",
                    "description": "Contrato marco de prestación de servicios",
                    "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_123%2Fsat_documents%2Fcontrato-acme.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                    "file_name": "contrato-acme.pdf",
                    "file_size": 284913,
                    "mime_type": "application/pdf",
                    "linked_entities": [
                      {
                        "entity_type": "client",
                        "entity_id": "client_1234567890",
                        "linked_at": 1767225600000
                      }
                    ],
                    "compliance_status": "pending_review",
                    "compliance_notes": null,
                    "valid_from": 1767225600000,
                    "valid_until": 1798761600000,
                    "ai_extraction": {
                      "summary": "Contrato de prestación de servicios de consultoría con vigencia de 12 meses.",
                      "parties": [
                        "MI EMPRESA EJEMPLO SA DE CV",
                        "ESCUELA KEMPER URGATE"
                      ]
                    },
                    "tags": [
                      "contrato",
                      "acme"
                    ],
                    "metadata": null,
                    "created_at": 1767225600000,
                    "created_by": "user_1234567890",
                    "updated_at": 1767225660000,
                    "livemode": true
                  },
                  "message": "Document analyzed successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "`error.code: invalid_request_body`. Messages:\n`Only PDF and image files (PNG, JPG, WEBP) can be analyzed`,\n`Failed to download file from storage`,\n`Failed to read PDF content. The file may be damaged or protected.`,\n`PDF does not contain enough text to analyze. It may be a scanned document.`\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "`Document not found`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "`Failed to process document analysis results` when the model output could not be\nparsed as JSON, or `An error occurred while analyzing document`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/link": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Link document to an entity",
        "operationId": "linkDocument",
        "description": "Attach the document to an invoice, payment, receipt or client. The link is appended to\nthe document's `linkedEntities` and the document id is added to the entity's\n`satDocuments` array.\n\nLinking the same document to the same entity twice returns `400`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Document id.",
            "schema": {
              "type": "string"
            },
            "example": "doc_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentLinkInput"
              },
              "example": {
                "entityType": "invoice",
                "entityId": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Document linked. Returns the updated document.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicDocument"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "doc_1234567890",
                    "document_type": "contract",
                    "name": "Contrato de servicios 2026 — Cliente ACME",
                    "description": "Contrato marco de prestación de servicios",
                    "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_123%2Fsat_documents%2Fcontrato-acme.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                    "file_name": "contrato-acme.pdf",
                    "file_size": 284913,
                    "mime_type": "application/pdf",
                    "linked_entities": [
                      {
                        "entity_type": "client",
                        "entity_id": "client_1234567890",
                        "linked_at": 1767225600000
                      },
                      {
                        "entity_type": "invoice",
                        "entity_id": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB",
                        "linked_at": 1767225660000
                      }
                    ],
                    "compliance_status": "pending_review",
                    "compliance_notes": null,
                    "valid_from": 1767225600000,
                    "valid_until": 1798761600000,
                    "ai_extraction": null,
                    "tags": [
                      "contrato",
                      "acme"
                    ],
                    "metadata": null,
                    "created_at": 1767225600000,
                    "created_by": "user_1234567890",
                    "updated_at": null,
                    "livemode": true
                  },
                  "message": "Document linked successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Body validation failure, or `Document is already linked to this entity`\n(`error.code: invalid_request_body`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "`Document not found`, or `<entityType> not found` when the target entity does not\nexist or belongs to another team.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "`An error occurred while linking document`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Documents"
        ],
        "summary": "Unlink document from an entity",
        "operationId": "unlinkDocument",
        "description": "Remove the link between the document and an entity. The document itself is not deleted.\n\nThis `DELETE` takes a **request body** identifying the entity — the same shape as the\nlink call.\n\nIf the entity no longer exists, the link is still removed from the document and the call\nsucceeds.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Document id.",
            "schema": {
              "type": "string"
            },
            "example": "doc_1234567890"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentLinkInput"
              },
              "example": {
                "entityType": "invoice",
                "entityId": "B0C3E4F2-1A2B-4C5D-9E8F-0123456789AB"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Document unlinked. Returns the updated document.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicDocument"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "doc_1234567890",
                    "document_type": "contract",
                    "name": "Contrato de servicios 2026 — Cliente ACME",
                    "description": "Contrato marco de prestación de servicios",
                    "file_url": "https://firebasestorage.googleapis.com/v0/b/gigstackpro.appspot.com/o/teams%2Fteam_123%2Fsat_documents%2Fcontrato-acme.pdf?alt=media&token=9f1c7d84-3b2e-4a56-8c0d-1e7f5b9a2c43",
                    "file_name": "contrato-acme.pdf",
                    "file_size": 284913,
                    "mime_type": "application/pdf",
                    "linked_entities": [
                      {
                        "entity_type": "client",
                        "entity_id": "client_1234567890",
                        "linked_at": 1767225600000
                      }
                    ],
                    "compliance_status": "pending_review",
                    "compliance_notes": null,
                    "valid_from": 1767225600000,
                    "valid_until": 1798761600000,
                    "ai_extraction": null,
                    "tags": [
                      "contrato",
                      "acme"
                    ],
                    "metadata": null,
                    "created_at": 1767225600000,
                    "created_by": "user_1234567890",
                    "updated_at": null,
                    "livemode": true
                  },
                  "message": "Document unlinked successfully",
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "400": {
            "description": "Body validation failure, or `Document is not linked to this entity`\n(`error.code: invalid_request_body`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "`Document not found`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "500": {
            "description": "`An error occurred while unlinking document`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerError"
                }
              }
            }
          }
        }
      }
    },
    "/invoices/eom/run": {
      "post": {
        "tags": [
          "Invoices"
        ],
        "summary": "Trigger end-of-month global invoicing",
        "operationId": "runEndOfMonthInvoicing",
        "description": "Manually trigger the end-of-month (EOM) global invoicing process for your team, which\ngroups pending receipts into global invoices.\n\n**Four preconditions:**\n- The runtime must be production. Staging and emulators are rejected with `403` before effects.\n- The API key must be **livemode**. Test keys are rejected with `403`.\n- The call must happen on the **last calendar day of the month** (America/Mexico_City).\n  Any other day is rejected with `400`.\n- The call must happen **before 23:00 America/Mexico_City**. From 23:00 on, the automatic\n  end-of-month run takes over and manual calls are rejected with `400`.\n\nThe request body is ignored.\n\nThe response is returned as soon as the process is *triggered* — it does not wait for\nthe run to finish. A validation pass runs asynchronously afterwards; failures there are\nlogged server-side and are not reflected in this response.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "EOM process triggered.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "global_invoice_time": {
                              "type": "string",
                              "description": "Trigger time, formatted `dd/MM/yyyy HH:mm:ss` in America/Mexico_City.",
                              "example": "31/01/2026 12:00:00"
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "message": "The end-of-month global invoicing process has been triggered successfully.",
                  "timestamp": 1767225600000,
                  "data": {
                    "global_invoice_time": "31/01/2026 12:00:00"
                  }
                }
              }
            }
          },
          "400": {
            "description": "`error.code: operation_not_allowed` — `This endpoint is only available on the last\nday of each month.` (`error.details` names today's date and the next eligible date),\nor `Manual end-of-month runs are not available from 23:00 (America/Mexico_City) on\nthe last day of the month.`\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "operation_not_allowed",
                    "message": "This endpoint is only available on the last day of each month.",
                    "details": "Today is 15/01/2026. The next eligible date is 31/01/2026."
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "`error.code: operation_not_allowed` — `This endpoint is only available with\nlivemode API keys.` Staging and emulators also return this error code.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          },
          "502": {
            "description": "`error.code: external_service_error` — the downstream EOM execution function\nreturned an error. `error.details` carries the upstream text. Effects may already have\noccurred; inspect resulting records before deciding whether to submit another run.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "external_service_error",
                    "message": "The EOM execution function returned an error. Please try again.",
                    "details": "upstream returned 500"
                  },
                  "timestamp": 1767225600000
                }
              }
            }
          }
        }
      }
    },
    "/invoices/download/pfx": {
      "post": {
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Connect FIEL credentials from a PFX file",
        "operationId": "connectFielPfx",
        "description": "Register the team's FIEL (e.firma) with the bulk-download service by uploading a\nPKCS#12 / PFX bundle and its password.\n\n> ### ⚠️ Sensitive credentials\n> `pfx` and `pfx_password` are **live security credentials** — the PFX embeds the FIEL\n> private key, and the password unlocks it. Together they can impersonate the taxpayer\n> before the SAT.\n>\n> - Send them only over TLS, only to this endpoint.\n> - Never log them, never put them in a URL, never commit them, never paste them into a\n>   shared document or ticket.\n> - The example values below are **placeholders**, not usable credentials. Do not treat\n>   any example in this document as a real secret to copy.\n>\n> The server encrypts both values at rest and never returns them in any response.\n\nThe certificate is validated before anything is stored: it must parse with the supplied\npassword, must not be expired, and its RFC must match the team's configured RFC. Each\nRFC needs its own team.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "pfx",
                  "pfx_password"
                ],
                "properties": {
                  "pfx": {
                    "type": "string",
                    "writeOnly": true,
                    "description": "**Sensitive.** Base64-encoded PFX/PKCS#12 file containing the FIEL\ncertificate and private key. Never logged or echoed back.\n",
                    "example": "<BASE64_PFX_PLACEHOLDER>"
                  },
                  "pfx_password": {
                    "type": "string",
                    "format": "password",
                    "writeOnly": true,
                    "description": "**Sensitive.** Password protecting the PFX file. Never logged or\nechoed back.\n",
                    "example": "<PFX_PASSWORD_PLACEHOLDER>"
                  }
                }
              },
              "example": {
                "pfx": "<BASE64_PFX_PLACEHOLDER>",
                "pfx_password": "<PFX_PASSWORD_PLACEHOLDER>"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "FIEL connected. The response describes the certificate but never echoes the PFX\nor its password.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "FIEL credentials connected successfully"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rfc": {
                          "type": "string",
                          "example": "MEE200101ABC"
                        },
                        "expires_at": {
                          "type": "integer",
                          "format": "int64",
                          "description": "Certificate expiry, epoch milliseconds.",
                          "example": 1893456000000
                        },
                        "expires_at_readable": {
                          "type": "string",
                          "example": "31/12/2029"
                        },
                        "serial_number": {
                          "type": "string",
                          "example": "00001000000512345678"
                        },
                        "sync_start_date": {
                          "type": "string",
                          "description": "Earliest date invoices will sync from.",
                          "example": "2023-08-05"
                        },
                        "registered": {
                          "type": "boolean",
                          "example": true
                        },
                        "registered_at": {
                          "type": "integer",
                          "format": "int64",
                          "example": 1767225600000
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "FIEL credentials connected successfully",
                  "data": {
                    "rfc": "MEE200101ABC",
                    "expires_at": 1893456000000,
                    "expires_at_readable": "31/12/2029",
                    "serial_number": "00001000000512345678",
                    "sync_start_date": "2023-08-05",
                    "registered": true,
                    "registered_at": 1767225600000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Rejected before anything is stored. `message` is one of: `Team not found`,\n`Team RFC not configured`, `Missing PFX`, `Missing PFX password`,\n`Invalid PFX file or password`, `Could not extract RFC from certificate`,\n`RFC mismatch`, `Certificate expired`.\n\n`Invalid PFX file or password` does not distinguish between a corrupt bundle and\na wrong password — by design.\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "RFC mismatch",
                  "error": "FIEL certificate RFC (AAA010101AAA) does not match your team RFC (MEE200101ABC). Each RFC requires its own team."
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "description": "`An error occurred while connecting FIEL credentials`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/invoices/download/sync-period": {
      "put": {
        "tags": [
          "Descarga Masiva SAT"
        ],
        "summary": "Update bulk-download sync period",
        "operationId": "updateBulkDownloadSyncPeriod",
        "description": "Re-register the team with the bulk-download provider so it syncs invoices from the\nearliest date the service allows.\n\n**The request body is ignored.** `sync_start_date` is always computed server-side and is\nnever accepted as user input — you cannot ask for an arbitrary start date.\n\nRequires a team RFC, a prior FIEL registration, stored FIEL credentials, and a phone\nnumber on the stored FIEL record.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Sync period updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "message": {
                      "type": "string",
                      "example": "Sync period updated. Invoices will sync from 2023-08-05."
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rfc": {
                          "type": "string",
                          "example": "MEE200101ABC"
                        },
                        "sync_start_date": {
                          "type": "string",
                          "example": "2023-08-05"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "message": "Sync period updated. Invoices will sync from 2023-08-05.",
                  "data": {
                    "rfc": "MEE200101ABC",
                    "sync_start_date": "2023-08-05"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A precondition failed. `message` is one of: `Team RFC not configured`,\n`Team not registered for bulk downloads. Complete FIEL upload first.`,\n`No stored FIEL credentials found. Upload your FIEL first.`,\n`Phone number required. Re-upload your FIEL with a phone number.`,\n`Failed to update sync period` (with the provider's reason in `error`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "Team not registered for bulk downloads. Complete FIEL upload first."
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "500": {
            "description": "`Error updating sync period`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/platform-payouts": {
      "post": {
        "operationId": "createPlatformPayoutRun",
        "tags": [
          "Platform Payouts"
        ],
        "summary": "Upload files and plan a platform payouts run",
        "description": "Uploads the **movements** and **commissions** files and computes the plan: which CFDIs will be\nissued for each provider, and why any row is excluded. Nothing is stamped here; review the plan with\n`GET /platform-payouts/{id}` and `GET /platform-payouts/{id}/movements`, then call\n`POST /platform-payouts/{id}/confirm`.\n\n**Who can call it.** The credential's team must be a marketplace **master team** whose billing\naccount has platform payouts enabled. API keys and OAuth tokens act as the team; user-scoped\ntokens (MCP, dashboard) must belong to the team and hold `editor` permission on invoices.\nSending gigstack Connect's `team` parameter moves the request to a connected team, which is not a\nmaster team, so it is refused with `not_master_team`. These checks (`403` `not_master_team`,\n`no_billing_account`, `feature_disabled`, `team_not_found`, `not_a_member`) run right after the\n`Idempotency-Key` check and **before the upload is read**: a refused request's files are never\nprocessed or stored.\n\n**Planning is synchronous.** The response carries the run with status `plan_ready`, or\n`plan_failed` with a Spanish `error` (unreadable file, missing columns, empty file, too many rows).\nRow-level problems do not fail the plan: the row becomes an excluded movement with a reason.\n\n**Idempotent on `Idempotency-Key` (required).** The run id is derived from your team, the key's\nmode and the header value, and the run records a fingerprint of the two files' **contents** (their\nbytes; file names don't count). The first request creates the run (`201`). A later request with the\nsame key and the same files returns that same run (`200`), whatever its status, without planning\nagain. The same key with **different** files is refused with `409 idempotency_key_reused`. Runs\ncreated before the fingerprint existed have none and are returned as before (`200`) whatever files\nyou send. A retry that arrives while the first request is still planning gets the run in\n`planning`: poll `GET /platform-payouts/{id}`. A failed plan stays failed under its key: fix the\nfile and send a **new** key.\n\n**Tax policy.** Which documents each provider gets, and their SAT keys and withholding rates,\ncome from your master account's policy, set at onboarding (defaults: ground passenger transport,\nrégimen `625`, CSD required, service type `01`, 2.1% ISR). Contact support to configure it.\n\n**Mode.** `livemode` comes only from the credential: a test key creates a test run.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Your identifier for this upload, 8-128 characters of `A-Z a-z 0-9 . _ : -`. Checked before the\nfiles are read. Reusing it with the same files returns the run it first created; reusing it with\ndifferent files is `409 idempotency_key_reused`.\n",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            },
            "example": "payouts-2026-08-v1"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/PlatformPayoutRunCreateInput"
              },
              "encoding": {
                "movements_file": {
                  "contentType": "text/csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, application/octet-stream"
                },
                "commissions_file": {
                  "contentType": "text/csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, application/octet-stream"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Retry of an earlier request with the same `Idempotency-Key` and the same file contents (or a\nrun created before file fingerprints existed): the run it created, in whatever status it is\nnow. Nothing is planned again. `planning` means the first request is still working; poll\n`GET /platform-payouts/{id}`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicPlatformPayoutRun"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c",
                    "status": "planning",
                    "result": null,
                    "livemode": true,
                    "team": "team_1234567890",
                    "created_at": 1788220800000,
                    "plan_ready_at": null,
                    "confirmed_at": null,
                    "completed_at": null,
                    "files": {
                      "movements": "movimientos-agosto-2026.csv",
                      "commissions": "comisiones-agosto-2026.xlsx"
                    },
                    "months": [],
                    "total_movements": 0,
                    "included_count": 0,
                    "excluded_count": 0,
                    "planned_documents": {
                      "income": 0,
                      "certificate": 0,
                      "commission": 0
                    },
                    "exclusion_summary": {},
                    "exclusion_code_summary": {},
                    "progress": {
                      "stamped_count": 0,
                      "failed_count": 0,
                      "income_invoices_count": 0,
                      "certificates_count": 0,
                      "commission_invoices_count": 0,
                      "commission_failed_count": 0,
                      "income_invoices_amount": 0
                    },
                    "error": null
                  },
                  "timestamp": 1788220802000
                }
              }
            }
          },
          "201": {
            "description": "Run created and planned. `data.status` is `plan_ready` or `plan_failed` (with `data.error`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicPlatformPayoutRun"
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "plan_ready": {
                    "summary": "Plan computed",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c",
                        "status": "plan_ready",
                        "result": null,
                        "livemode": true,
                        "team": "team_1234567890",
                        "created_at": 1788220800000,
                        "plan_ready_at": 1788220804120,
                        "confirmed_at": null,
                        "completed_at": null,
                        "files": {
                          "movements": "movimientos-agosto-2026.csv",
                          "commissions": "comisiones-agosto-2026.xlsx"
                        },
                        "months": [
                          "2026-08"
                        ],
                        "total_movements": 412,
                        "included_count": 398,
                        "excluded_count": 14,
                        "planned_documents": {
                          "income": 398,
                          "certificate": 398,
                          "commission": 57
                        },
                        "exclusion_summary": {
                          "Sin sellos (CSD) en Gigstack": 9,
                          "El proveedor no tiene cuenta en Gigstack": 5
                        },
                        "exclusion_code_summary": {
                          "missing_csd": 9,
                          "provider_not_found": 5
                        },
                        "progress": {
                          "stamped_count": 0,
                          "failed_count": 0,
                          "income_invoices_count": 0,
                          "certificates_count": 0,
                          "commission_invoices_count": 0,
                          "commission_failed_count": 0,
                          "income_invoices_amount": 0
                        },
                        "error": null
                      },
                      "timestamp": 1788220804180
                    }
                  },
                  "plan_failed": {
                    "summary": "Plan failed on the file (use a new Idempotency-Key after fixing it)",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "batchrun_9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e",
                        "status": "plan_failed",
                        "result": null,
                        "livemode": true,
                        "team": "team_1234567890",
                        "created_at": 1788220800000,
                        "plan_ready_at": 1788220801020,
                        "confirmed_at": null,
                        "completed_at": null,
                        "files": {
                          "movements": "movimientos-agosto-2026.csv",
                          "commissions": "comisiones-agosto-2026.xlsx"
                        },
                        "months": [],
                        "total_movements": 0,
                        "included_count": 0,
                        "excluded_count": 0,
                        "planned_documents": {
                          "income": 0,
                          "certificate": 0,
                          "commission": 0
                        },
                        "exclusion_summary": {},
                        "exclusion_code_summary": {},
                        "progress": {
                          "stamped_count": 0,
                          "failed_count": 0,
                          "income_invoices_count": 0,
                          "certificates_count": 0,
                          "commission_invoices_count": 0,
                          "commission_failed_count": 0,
                          "income_invoices_amount": 0
                        },
                        "error": "Al archivo de movimientos le faltan estas columnas: Fecha del movimiento, Subtotal."
                      },
                      "timestamp": 1788220801070
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The request was refused before any run was created. `error.code`:\n\n- `invalid_request_body` - `Idempotency-Key` missing or malformed.\n- `invalid_content_type` - the body is not `multipart/form-data`.\n- `file_required` - `movements_file` or `commissions_file` is missing (`details` names it).\n- `empty_file` - a file has zero bytes.\n- `invalid_file_format` - the extension is not `.csv`, `.txt`, `.xlsx`, `.xls` or `.xlsm`.\n- `unexpected_file` - a file part other than the two above, one of them sent twice, or more than two files.\n- `too_many_fields` - more than 10 plain form fields.\n- `file_upload_error` - the multipart body could not be parsed.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "examples": {
                  "missing_idempotency_key": {
                    "summary": "Idempotency-Key header missing",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Idempotency-Key header is required"
                      },
                      "timestamp": 1788220800000
                    }
                  },
                  "malformed_idempotency_key": {
                    "summary": "Idempotency-Key does not match the format",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_request_body",
                        "message": "Idempotency-Key must be 8-128 chars matching [A-Za-z0-9._:-]"
                      },
                      "timestamp": 1788220800000
                    }
                  },
                  "file_required": {
                    "summary": "A file is missing",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "file_required",
                        "message": "File is required",
                        "details": "Field 'commissions_file' must contain a file"
                      },
                      "timestamp": 1788220800000
                    }
                  },
                  "invalid_file_format": {
                    "summary": "Unsupported extension",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_file_format",
                        "message": "Invalid file extension. Allowed extensions: .csv, .txt, .xlsx, .xls, .xlsm"
                      },
                      "timestamp": 1788220800000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Either the authentication layer refused the credential (raw body, see `AuthForbidden`), or\nthe team may not use platform payouts (standardized envelope). The team checks run before the\nupload is read, so the files are not processed. `error.code`:\n\n- `not_master_team` - the team is not a marketplace master team (also the answer when the\n  gigstack Connect `team` parameter points at a connected team).\n- `no_billing_account` - the team has no billing account.\n- `feature_disabled` - platform payouts is not enabled on the billing account. Contact support.\n- `team_not_found` - the team document does not exist.\n- `not_a_member` / `forbidden` - a user-scoped token whose user is not a member of the team,\n  or lacks `editor` permission on invoices (`This action requires editor access to invoices`).\n",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/StandardErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/AuthMiddlewareError"
                    }
                  ]
                },
                "examples": {
                  "feature_disabled": {
                    "summary": "Platform payouts not enabled on the billing account",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "feature_disabled",
                        "message": "La facturación por archivo no está habilitada en esta cuenta. Contacta a soporte."
                      },
                      "timestamp": 1788220800000
                    }
                  },
                  "not_master_team": {
                    "summary": "Not a marketplace master team",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "not_master_team",
                        "message": "Esta cuenta no es una cuenta principal de marketplace."
                      },
                      "timestamp": 1788220800000
                    }
                  },
                  "missing_invoices_permission": {
                    "summary": "User-scoped token without editor permission on invoices",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "forbidden",
                        "message": "This action requires editor access to invoices"
                      },
                      "timestamp": 1788220800000
                    }
                  },
                  "revoked_api_key": {
                    "summary": "Authentication layer - API key revoked or disabled",
                    "value": {
                      "message": "API Key inválida.",
                      "details": "Invalid API Key"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The `Idempotency-Key` names a run this request can't be answered with. `error.code`:\n\n- `idempotency_key_reused` - the key was already used with **different file contents**\n  (compared by bytes, not names). The new files were not planned. Send them under a new\n  `Idempotency-Key`; to get the original run, use `GET /platform-payouts/{id}`.\n- `run_exists` - the derived run id is held by a run of another team. Not expected in\n  practice, since the id includes your team; send a different `Idempotency-Key`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "examples": {
                  "idempotency_key_reused": {
                    "summary": "Same Idempotency-Key, different files",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "idempotency_key_reused",
                        "message": "Esta Idempotency-Key ya se usó con otros archivos. Usa una nueva para subir archivos distintos."
                      },
                      "timestamp": 1788220800000
                    }
                  },
                  "run_exists": {
                    "summary": "Run id held by another team",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "run_exists",
                        "message": "Esta corrida ya existe."
                      },
                      "timestamp": 1788220800000
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`file_too_large`: a file exceeds 5 MB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "file_too_large",
                    "message": "File size exceeds maximum allowed size of 5MB",
                    "details": "Field 'movements_file'"
                  },
                  "timestamp": 1788220800000
                }
              }
            }
          },
          "500": {
            "description": "Unexpected failure (`internal_server_error`). Failures while planning are normally returned as\na `plan_failed` run instead; this status means the run could not be created or read at all.\nRetrying with the **same** `Idempotency-Key` is safe.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "internal_server_error",
                    "message": "No pudimos calcular el plan. Intenta de nuevo o contacta a soporte."
                  },
                  "timestamp": 1788220800000
                }
              }
            }
          }
        }
      }
    },
    "/platform-payouts/{id}": {
      "get": {
        "operationId": "getPlatformPayoutRun",
        "tags": [
          "Platform Payouts"
        ],
        "summary": "Get a platform payouts run",
        "description": "Returns the run: its status, plan totals and, once confirmed, the worker's progress. Poll it after\nconfirming until `status` is `completed` or `failed`; the worker runs every minute. Then read\n`result`, not `status`, to know how the run went: `status: completed` only means the worker has\nnothing left to try, while `result` tells `completed` (everything issued) from\n`partially_completed` (some documents failed) and `failed` (nothing issued).\n\nA run of another team, or of the other mode (a live run with a test key), answers `404`\n`run_not_found`, never `403`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Run id, as returned by `POST /platform-payouts`.",
            "schema": {
              "type": "string",
              "pattern": "^batchrun_[A-Za-z0-9]{6,40}$"
            },
            "example": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c"
          }
        ],
        "responses": {
          "200": {
            "description": "The run. Once it is finished, `result` says how it went: `completed`, `partially_completed`\nor `failed`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicPlatformPayoutRun"
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "stamping": {
                    "summary": "Confirmed, worker in progress",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c",
                        "status": "stamping",
                        "result": null,
                        "livemode": true,
                        "team": "team_1234567890",
                        "created_at": 1788220800000,
                        "plan_ready_at": 1788220804120,
                        "confirmed_at": 1788221400000,
                        "completed_at": null,
                        "files": {
                          "movements": "movimientos-agosto-2026.csv",
                          "commissions": "comisiones-agosto-2026.xlsx"
                        },
                        "months": [
                          "2026-08"
                        ],
                        "total_movements": 412,
                        "included_count": 398,
                        "excluded_count": 14,
                        "planned_documents": {
                          "income": 398,
                          "certificate": 398,
                          "commission": 57
                        },
                        "exclusion_summary": {
                          "Sin sellos (CSD) en Gigstack": 9,
                          "El proveedor no tiene cuenta en Gigstack": 5
                        },
                        "exclusion_code_summary": {
                          "missing_csd": 9,
                          "provider_not_found": 5
                        },
                        "progress": {
                          "stamped_count": 120,
                          "failed_count": 2,
                          "income_invoices_count": 122,
                          "certificates_count": 120,
                          "commission_invoices_count": 0,
                          "commission_failed_count": 0,
                          "income_invoices_amount": 161497.5
                        },
                        "error": null
                      },
                      "timestamp": 1788221700000
                    }
                  },
                  "partially_completed": {
                    "summary": "Finished, some documents failed",
                    "value": {
                      "success": true,
                      "data": {
                        "id": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c",
                        "status": "completed",
                        "result": "partially_completed",
                        "livemode": true,
                        "team": "team_1234567890",
                        "created_at": 1788220800000,
                        "plan_ready_at": 1788220804120,
                        "confirmed_at": 1788221400000,
                        "completed_at": 1788224100000,
                        "files": {
                          "movements": "movimientos-agosto-2026.csv",
                          "commissions": "comisiones-agosto-2026.xlsx"
                        },
                        "months": [
                          "2026-08"
                        ],
                        "total_movements": 412,
                        "included_count": 398,
                        "excluded_count": 14,
                        "planned_documents": {
                          "income": 398,
                          "certificate": 398,
                          "commission": 57
                        },
                        "exclusion_summary": {
                          "Sin sellos (CSD) en Gigstack": 9,
                          "El proveedor no tiene cuenta en Gigstack": 5
                        },
                        "exclusion_code_summary": {
                          "missing_csd": 9,
                          "provider_not_found": 5
                        },
                        "progress": {
                          "stamped_count": 395,
                          "failed_count": 3,
                          "income_invoices_count": 397,
                          "certificates_count": 396,
                          "commission_invoices_count": 56,
                          "commission_failed_count": 1,
                          "income_invoices_amount": 525528.75
                        },
                        "error": null
                      },
                      "timestamp": 1788224160000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "No run with this id in your team and mode (`run_not_found`). A user-scoped token whose user is\nnot a member of the team gets `resource_not_found` (`Batch run not found`) instead.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "run_not_found",
                    "message": "No encontramos esta corrida."
                  },
                  "timestamp": 1788221700000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/platform-payouts/{id}/movements": {
      "get": {
        "operationId": "listPlatformPayoutMovements",
        "tags": [
          "Platform Payouts"
        ],
        "summary": "List a platform payouts run's movements",
        "description": "One entry per row of the movements file, in file order, with the state of its income invoice and\nretention certificate. Use it to review exclusions before confirming, and to find failures after.\n\nCursor pagination: pass `data.next` back as `next` while `data.has_more` is `true`. The cursor is\nstable while the worker updates statuses, so pages never overlap or skip rows.\n\nCommission invoices (one per provider-month) are not listed here; the run only reports their counts.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Run id.",
            "schema": {
              "type": "string",
              "pattern": "^batchrun_[A-Za-z0-9]{6,40}$"
            },
            "example": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Movements per page (default **50**, 1-100).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "example": 50
          },
          {
            "name": "next",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from the previous page's `data.next`. Omit for the first page.",
            "schema": {
              "type": "string"
            },
            "example": "51"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of movements. Note the nesting: the array is at `data.data`, the cursor at `data.next`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicPlatformPayoutMovementsPage"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "data": [
                      {
                        "id": "P10482_2026-08-04_125000_0",
                        "line": 2,
                        "status": "stamped",
                        "provider": {
                          "id": "P10482",
                          "name": "ESCUELA KEMPER URGATE",
                          "email": "proveedor@example.com",
                          "tax_id": "EKU9003173C9",
                          "team": "team_0987654321"
                        },
                        "movement_type": "Pago semanal",
                        "date": "2026-08-04",
                        "month": "2026-08",
                        "subtotal": 1250,
                        "commission": 96.15,
                        "exclusion_reason": null,
                        "exclusion_codes": [],
                        "error": null,
                        "income": {
                          "planned": true,
                          "status": "stamped",
                          "reason": null,
                          "reason_code": null,
                          "invoice_id": "7C2E4B1A-9D3F-4E8A-B6C5-1F2A3B4C5D6E",
                          "uuid": "7C2E4B1A-9D3F-4E8A-B6C5-1F2A3B4C5D6E",
                          "total": 1323.75,
                          "error": null,
                          "error_code": null
                        },
                        "certificate": {
                          "planned": true,
                          "status": "stamped",
                          "reason": null,
                          "reason_code": null,
                          "invoice_id": "0A1B2C3D-4E5F-4A6B-8C7D-9E0F1A2B3C4D",
                          "uuid": "0A1B2C3D-4E5F-4A6B-8C7D-9E0F1A2B3C4D",
                          "total": null,
                          "error": null,
                          "error_code": null
                        }
                      },
                      {
                        "id": "P20931_2026-08-04_98000_0",
                        "line": 3,
                        "status": "excluded",
                        "provider": {
                          "id": "P20931",
                          "name": "ESCUELA KEMPER URGATE",
                          "email": "otro.proveedor@example.com",
                          "tax_id": "EKU9003173C9",
                          "team": "team_1122334455"
                        },
                        "movement_type": "Pago semanal",
                        "date": "2026-08-04",
                        "month": "2026-08",
                        "subtotal": 980,
                        "commission": 75.38,
                        "exclusion_reason": "Sin sellos (CSD) en Gigstack",
                        "exclusion_codes": [
                          "missing_csd"
                        ],
                        "error": null,
                        "income": {
                          "planned": false,
                          "status": "skipped",
                          "reason": "Sin sellos (CSD) en Gigstack",
                          "reason_code": "missing_csd",
                          "invoice_id": null,
                          "uuid": null,
                          "total": null,
                          "error": null,
                          "error_code": null
                        },
                        "certificate": {
                          "planned": false,
                          "status": "skipped",
                          "reason": "Sin sellos (CSD) en Gigstack",
                          "reason_code": "missing_csd",
                          "invoice_id": null,
                          "uuid": null,
                          "total": null,
                          "error": null,
                          "error_code": null
                        }
                      },
                      {
                        "id": "P30577_2026-08-05_110000_0",
                        "line": 4,
                        "status": "failed",
                        "provider": {
                          "id": "P30577",
                          "name": "ESCUELA KEMPER URGATE",
                          "email": "tercer.proveedor@example.com",
                          "tax_id": "EKU9003173C9",
                          "team": "team_5566778899"
                        },
                        "movement_type": "Pago semanal",
                        "date": "2026-08-05",
                        "month": "2026-08",
                        "subtotal": 1100,
                        "commission": 84.62,
                        "exclusion_reason": null,
                        "exclusion_codes": [],
                        "error": "Timbrado interrumpido: verificar en el PAC antes de reintentar",
                        "income": {
                          "planned": false,
                          "status": "skipped",
                          "reason": "Sin serie de facturación configurada",
                          "reason_code": "missing_series",
                          "invoice_id": null,
                          "uuid": null,
                          "total": null,
                          "error": null,
                          "error_code": null
                        },
                        "certificate": {
                          "planned": true,
                          "status": "failed",
                          "reason": null,
                          "reason_code": null,
                          "invoice_id": null,
                          "uuid": null,
                          "total": null,
                          "error": "Timbrado interrumpido: verificar en el PAC antes de reintentar",
                          "error_code": "interrupted_stamp"
                        }
                      }
                    ],
                    "next": "4",
                    "has_more": true
                  },
                  "timestamp": 1788224160000
                }
              }
            }
          },
          "400": {
            "description": "`invalid_limit` - `limit` is not an integer between 1 and 100.\n`invalid_cursor` - `next` is not a cursor returned by this endpoint.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "examples": {
                  "invalid_limit": {
                    "summary": "limit out of range",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_limit",
                        "message": "limit must be an integer between 1 and 100"
                      },
                      "timestamp": 1788221700000
                    }
                  },
                  "invalid_cursor": {
                    "summary": "next is not a valid cursor",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "invalid_cursor",
                        "message": "next is not a valid cursor"
                      },
                      "timestamp": 1788221700000
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "No run with this id in your team and mode (`run_not_found`); `resource_not_found` for a\nuser-scoped token whose user is not a member of the team. Checked before `limit` and `next`.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "run_not_found",
                    "message": "No encontramos esta corrida."
                  },
                  "timestamp": 1788221700000
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/platform-payouts/{id}/confirm": {
      "post": {
        "operationId": "confirmPlatformPayoutRun",
        "tags": [
          "Platform Payouts"
        ],
        "summary": "Confirm a platform payouts run for stamping",
        "description": "**Irreversible.** Hands a `plan_ready` run to the background worker, which stamps its CFDIs (it runs\nevery minute). A stamped CFDI can only be cancelled, not undone. The response only acknowledges the\nhand-off; follow progress with `GET /platform-payouts/{id}` until `status` is `completed` or\n`failed`, then read its `result`.\n\n**Safe to retry.** Confirming a run that is already `stamping` or `completed` returns its current\nstatus with `200` and does nothing else.\n\n**Provider-months already certified.** Before the run flips to `stamping`, each provider-month it\ncertifies is reserved. If an earlier run of your team (same mode) already reserved a provider-month,\nthis run's retention certificates for it are skipped (their `reason` names the earlier run,\n`reason_code` is `certificate_month_reserved`) and the counts in `included_count`,\n`excluded_count`, `exclusion_summary`, `exclusion_code_summary` and\n`planned_documents.certificate` are recomputed. Income and commission invoices are not affected.\n\nNo request body. Requires `editor` permission on invoices for user-scoped tokens.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Run id.",
            "schema": {
              "type": "string",
              "pattern": "^batchrun_[A-Za-z0-9]{6,40}$"
            },
            "example": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c"
          }
        ],
        "responses": {
          "200": {
            "description": "The run is (or already was) with the worker.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/StandardSuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "$ref": "#/components/schemas/ApiPublicPlatformPayoutRunConfirmation"
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "batchrun_3f9a1c7e2b4d6f8a0c1e3a5b7d9f1a2c",
                    "status": "stamping"
                  },
                  "timestamp": 1788221400000
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Authentication layer refusal (raw body, see `AuthForbidden`), or the team may no longer use\nplatform payouts: `feature_disabled`, `not_master_team`, `no_billing_account`,\n`team_not_found`, `not_a_member`; or `forbidden` for a user-scoped token without `editor`\npermission on invoices.\n",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/StandardErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/AuthMiddlewareError"
                    }
                  ]
                },
                "examples": {
                  "feature_disabled": {
                    "summary": "Platform payouts no longer enabled on the billing account",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "feature_disabled",
                        "message": "La facturación por archivo no está habilitada en esta cuenta. Contacta a soporte."
                      },
                      "timestamp": 1788221400000
                    }
                  },
                  "missing_invoices_permission": {
                    "summary": "User-scoped token without editor permission on invoices",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "forbidden",
                        "message": "This action requires editor access to invoices"
                      },
                      "timestamp": 1788221400000
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No run with this id in your team and mode (`run_not_found`); `resource_not_found` for a\nuser-scoped token whose user is not a member of the team.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "run_not_found",
                    "message": "No encontramos esta corrida."
                  },
                  "timestamp": 1788221400000
                }
              }
            }
          },
          "409": {
            "description": "The run cannot be confirmed. `error.code`:\n\n- `plan_not_ready` - still `planning`; poll `GET /platform-payouts/{id}` and try again.\n- `not_confirmable` - the plan failed (`plan_failed`) or the run already `failed`.\n- `nothing_to_stamp` - the plan issues no document at all.\n",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "examples": {
                  "plan_not_ready": {
                    "summary": "Plan still being computed",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "plan_not_ready",
                        "message": "El plan todavía se está calculando."
                      },
                      "timestamp": 1788221400000
                    }
                  },
                  "not_confirmable": {
                    "summary": "Plan failed, or run failed",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "not_confirmable",
                        "message": "Esta corrida no se puede timbrar."
                      },
                      "timestamp": 1788221400000
                    }
                  },
                  "nothing_to_stamp": {
                    "summary": "The plan has no documents",
                    "value": {
                      "success": false,
                      "error": {
                        "code": "nothing_to_stamp",
                        "message": "No hay documentos que timbrar en este plan."
                      },
                      "timestamp": 1788221400000
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Unexpected failure (`internal_server_error`). Retrying is safe.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "internal_server_error",
                    "message": "No pudimos confirmar la corrida. Intenta de nuevo."
                  },
                  "timestamp": 1788221400000
                }
              }
            }
          }
        }
      }
    },
    "/platform-payouts/health": {
      "get": {
        "tags": [
          "Platform Payouts"
        ],
        "summary": "Health check",
        "operationId": "platformPayoutsHealth",
        "description": "Liveness probe for the platform payouts module. Unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "module": "platform-payouts"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{id}/members": {
      "get": {
        "operationId": "listTeamMembers",
        "tags": [
          "Teams"
        ],
        "summary": "List team members",
        "description": "Read the canonical roster, effective roles and module permissions. Requires current membership or an authorized team credential.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "role",
                          "is_owner",
                          "permissions"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string",
                            "nullable": true
                          },
                          "role": {
                            "type": "string",
                            "enum": [
                              "admin",
                              "editor",
                              "viewer",
                              "blocked"
                            ]
                          },
                          "is_owner": {
                            "type": "boolean"
                          },
                          "permissions": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "invoices": {
                                "type": "string",
                                "enum": [
                                  "editor",
                                  "viewer",
                                  "none"
                                ]
                              },
                              "receipts": {
                                "type": "string",
                                "enum": [
                                  "editor",
                                  "viewer",
                                  "none"
                                ]
                              },
                              "payments": {
                                "type": "string",
                                "enum": [
                                  "editor",
                                  "viewer",
                                  "none"
                                ]
                              },
                              "services": {
                                "type": "string",
                                "enum": [
                                  "editor",
                                  "viewer",
                                  "none"
                                ]
                              },
                              "expenses": {
                                "type": "string",
                                "enum": [
                                  "editor",
                                  "viewer",
                                  "none"
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/members/{memberId}": {
      "patch": {
        "operationId": "updateTeamMember",
        "tags": [
          "Teams"
        ],
        "summary": "Update member role or permissions",
        "description": "Requires the current team owner using a user-scoped Firebase or MCP credential. Team API keys and OAuth credentials cannot impersonate their creator. Owner removal/demotion is refused. State changes and membership mirrors are transactional. Permissions-only patches also allow a current roster administrator to edit another viewer member. User-scoped self-edits are refused; a billing-account admin without a roster admin seat cannot use this exception. Team API/OAuth credentials may administer module grants without impersonating their creator. Ineffective restrictions on an editor role are refused. Canonical and raw aliases are updated together; independent disabled/status denials are never cleared by a role update. The original credential is reverified immediately before writes. Requests with role: admin return 403 account_approval_required. The current owner must prepare team.members.promote_admin through POST /users/me/account-approvals and confirm in the private browser. Editor/viewer and existing permitted non-admin operations remain direct.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "memberId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin",
                      "editor",
                      "viewer",
                      "blocked"
                    ]
                  },
                  "permissions": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "invoices": {
                        "type": "string",
                        "enum": [
                          "editor",
                          "viewer",
                          "none"
                        ]
                      },
                      "receipts": {
                        "type": "string",
                        "enum": [
                          "editor",
                          "viewer",
                          "none"
                        ]
                      },
                      "payments": {
                        "type": "string",
                        "enum": [
                          "editor",
                          "viewer",
                          "none"
                        ]
                      },
                      "services": {
                        "type": "string",
                        "enum": [
                          "editor",
                          "viewer",
                          "none"
                        ]
                      },
                      "expenses": {
                        "type": "string",
                        "enum": [
                          "editor",
                          "viewer",
                          "none"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "required": [
                        "id",
                        "role",
                        "is_owner",
                        "permissions"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string",
                          "nullable": true
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "admin",
                            "editor",
                            "viewer",
                            "blocked"
                          ]
                        },
                        "is_owner": {
                          "type": "boolean"
                        },
                        "permissions": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "invoices": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            },
                            "receipts": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            },
                            "payments": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            },
                            "services": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            },
                            "expenses": {
                              "type": "string",
                              "enum": [
                                "editor",
                                "viewer",
                                "none"
                              ]
                            }
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Insufficient current authority, or account_approval_required for role: admin. Prepare and confirm the corresponding membership approval."
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "removeTeamMember",
        "tags": [
          "Teams"
        ],
        "summary": "Remove team member",
        "description": "Requires the current team owner using a user-scoped Firebase or MCP credential. Team API keys and OAuth credentials cannot impersonate their creator. Owner removal/demotion is refused. State changes and membership mirrors are transactional. Removes the seat without deleting the user login.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "memberId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128,
                          "pattern": "^[^/]+$"
                        },
                        "removed": {
                          "type": "boolean"
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/deactivate": {
      "post": {
        "operationId": "deactivateTeam",
        "tags": [
          "Teams"
        ],
        "summary": "Deactivate a business (dar de baja)",
        "description": "Pricing v3 only. Deactivates a non-master team of the caller's billing account so its RFC stops being billed from the next monthly cut (it is not billed for the month it is deactivated in unless it already issued something live that month). Use it for a business with invoices, payments or receipts, which `DELETE /teams/{id}` refuses (`team_has_existing_resources`) because they are kept for the SAT. While deactivated the team can be read, listed and its XML and PDF downloaded, but every stamp answers 412 `TEAM_DEACTIVATED` and creating receipts, payment requests, recurrences, retentions, drafts or SAT downloads answers 403 `team_deactivated`. Payments that arrive from connected processors are not written to the team; each one is kept as a `frozenEvents` record. Only the owner or an administrator of the billing account signed in as a person (web app or MCP personal credential); never a team API key.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "The team, with `deactivated` and `deactivated_at`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicTeam"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`team_deactivation_forbidden`, `pricing_v3_required` or `master_team_cannot_be_deactivated`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "`team_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "`team_already_deactivated`, `team_pending_deletion` or `team_has_active_addons` (turn off the paid add-ons of this business first)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{id}/reactivate": {
      "post": {
        "operationId": "reactivateTeam",
        "tags": [
          "Teams"
        ],
        "summary": "Reactivate a business",
        "description": "Pricing v3 only. Puts a deactivated business back: it issues again and its RFC fee counts again from the current month. Same authority as `POST /teams/{id}/deactivate`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "The team, with `deactivated` and `deactivated_at`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicTeam"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`team_deactivation_forbidden`, `pricing_v3_required` or `master_team_cannot_be_deactivated`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "`team_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "`team_not_deactivated` or `team_pending_deletion`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{id}/transfer-ownership": {
      "post": {
        "operationId": "transferTeamOwnership",
        "tags": [
          "Teams"
        ],
        "summary": "Transfer team ownership",
        "description": "Direct ownership transfer is retired and returns 403 account_approval_required. Prepare team.ownership.transfer through POST /users/me/account-approvals, then open review_url for the current owner to review and confirm. The previous owner remains an administrator; billing-account ownership does not change.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "403": {
            "description": "account_approval_required: use the credential approval handoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountApprovalRequired"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "account_approval_required",
                    "message": "Prepare and confirm this credential action through an account approval"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          }
        },
        "deprecated": true
      }
    },
    "/teams/{id}/invitations": {
      "get": {
        "operationId": "listTeamInvitations",
        "tags": [
          "Teams"
        ],
        "summary": "List team invitations",
        "description": "Read team invitations and delivery state without invitation tokens. Requires administrator authority.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AccountInvitation"
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "post": {
        "operationId": "createTeamInvitation",
        "tags": [
          "Teams"
        ],
        "summary": "Invite a member",
        "description": "Requires a current user-scoped team/account administrator for invitation changes. Ordinary team API keys cannot create or change invitations. Invitation recipient identity is verified on accept/decline; current inviter authority and expiry are checked again. Reuses a pending invitation for the same team/email. send_email defaults to true; false creates without delivery. Tokens and acceptance URLs are never returned. An email failure is represented by delivery.status=failed; it does not erase the invitation. Administrator role creation on this direct route returns 403 account_approval_required. Prepare team.invitations.create_admin through account approvals instead.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 320
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin",
                      "editor",
                      "viewer"
                    ],
                    "default": "viewer"
                  },
                  "send_email": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AccountInvitation"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "required": [
                        "id",
                        "email",
                        "role",
                        "status",
                        "delivery"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "admin",
                            "editor",
                            "viewer"
                          ]
                        },
                        "team_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending",
                            "accepted",
                            "declined",
                            "revoked",
                            "expired"
                          ]
                        },
                        "created_at": {
                          "type": "number",
                          "nullable": true
                        },
                        "expires_at": {
                          "type": "number",
                          "nullable": true
                        },
                        "created_by": {
                          "type": "string",
                          "nullable": true
                        },
                        "delivery": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": [
                                "not_requested",
                                "pending",
                                "sent",
                                "failed"
                              ]
                            },
                            "attempted_at": {
                              "type": "number",
                              "nullable": true
                            }
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/invitations/{inviteId}": {
      "get": {
        "operationId": "getTeamInvitation",
        "tags": [
          "Teams"
        ],
        "summary": "Get team invitation",
        "description": "Read a single invitation without its secret token. Requires administrator authority.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AccountInvitation"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      },
      "delete": {
        "operationId": "revokeTeamInvitation",
        "tags": [
          "Teams"
        ],
        "summary": "Revoke team invitation",
        "description": "Requires a current user-scoped team/account administrator for invitation changes. Ordinary team API keys cannot create or change invitations. Invitation recipient identity is verified on accept/decline; current inviter authority and expiry are checked again. Revocation is idempotent; an accepted invitation cannot be revoked.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AccountInvitation"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/{id}/invitations/{inviteId}/resend": {
      "post": {
        "operationId": "resendTeamInvitation",
        "tags": [
          "Teams"
        ],
        "summary": "Resend invitation email",
        "description": "Requires a current user-scoped team/account administrator for invitation changes. Ordinary team API keys cannot create or change invitations. Invitation recipient identity is verified on accept/decline; current inviter authority and expiry are checked again. Requires a pending unexpired invitation. Does not extend expiry. Inspect delivery.status; reconcile ambiguous outcomes before resending. Administrator invitations return account_invitation_delivery_required; use the owner-scoped /users/me/account-invitations/{id}/resend route. It validates approval proof and handles uncertain prior delivery explicitly.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AccountInvitation"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/invitations/inbox": {
      "get": {
        "operationId": "listRecipientInvitations",
        "tags": [
          "Teams"
        ],
        "summary": "List current recipient invitation inbox",
        "description": "Read pending metadata addressed to the current independently verified Auth email. Firebase recipients need no app profile/team; user-scoped MCP credentials must retain current source custody. Ordinary unverified email is allowed. No email/team override, token, approval proof, automatic join or profile provisioning. IDs are hints, not resource authority. Cursor binds current recipient UID, email, incarnation and pending status; empty filtered pages may still have more. Admin acceptance separately requires verified email and owner approval.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 1024
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe recipient metadata page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "id",
                          "email",
                          "emailOwner",
                          "rol",
                          "status",
                          "accepted",
                          "type",
                          "expiring",
                          "timestamp",
                          "teamId",
                          "teamName",
                          "billingId",
                          "billingName",
                          "approval_required",
                          "team"
                        ],
                        "properties": {
                          "id": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9_-]{1,128}$"
                          },
                          "email": {
                            "type": "string"
                          },
                          "emailOwner": {
                            "type": "string",
                            "nullable": true
                          },
                          "rol": {
                            "type": "string",
                            "enum": [
                              "admin",
                              "editor",
                              "viewer"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending"
                            ]
                          },
                          "accepted": {
                            "type": "boolean",
                            "enum": [
                              false
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "team",
                              "billingAccount"
                            ]
                          },
                          "expiring": {
                            "type": "number"
                          },
                          "timestamp": {
                            "type": "number",
                            "nullable": true
                          },
                          "teamId": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9_-]{1,128}$",
                            "nullable": true
                          },
                          "teamName": {
                            "type": "string",
                            "nullable": true
                          },
                          "billingId": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9_-]{1,128}$"
                          },
                          "billingName": {
                            "type": "string",
                            "nullable": true
                          },
                          "approval_required": {
                            "type": "boolean"
                          },
                          "team": {
                            "type": "object",
                            "nullable": true,
                            "additionalProperties": false,
                            "required": [
                              "id",
                              "alias",
                              "logo",
                              "primaryColor",
                              "billingAccount",
                              "members"
                            ],
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9_-]{1,128}$"
                              },
                              "alias": {
                                "type": "string",
                                "nullable": true
                              },
                              "logo": {
                                "type": "string",
                                "nullable": true
                              },
                              "primaryColor": {
                                "type": "string",
                                "nullable": true
                              },
                              "billingAccount": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9_-]{1,128}$"
                              },
                              "members": {
                                "type": "integer",
                                "minimum": 0
                              }
                            }
                          }
                        }
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true,
                      "maxLength": 1024
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query/cursor"
          },
          "401": {
            "description": "Invalid or revoked original user credential"
          },
          "403": {
            "description": "Inactive profile or credential scope"
          },
          "503": {
            "description": "Read unavailable; never interpret as empty inbox"
          }
        }
      }
    },
    "/teams/invitations/accept": {
      "post": {
        "operationId": "acceptTeamInvitation",
        "tags": [
          "Teams"
        ],
        "summary": "Accept team invitation",
        "description": "Requires the invited user, authenticated with a verified Firebase ID token (no existing team required) or a signed user-scoped MCP token. Ordinary API/OAuth keys are refused. Tokens remain secret and must come from the invitation link. Administrator acceptance requires completed owner approval bound to this invitation and current owner authority. The recipient must have a current active Auth account with matching email; administrator acceptance requires verified email. Missing approval returns account_approval_required; request owner recovery with existing_invitation_id.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 16384
                  }
                },
                "required": [
                  "token"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128,
                          "pattern": "^[^/]+$"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "accepted"
                          ]
                        },
                        "team_id": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/teams/invitations/decline": {
      "post": {
        "operationId": "declineTeamInvitation",
        "tags": [
          "Teams"
        ],
        "summary": "Decline team invitation",
        "description": "Requires the invited user, authenticated with a verified Firebase ID token (no existing team required) or a signed user-scoped MCP token. Ordinary API/OAuth keys are refused. Tokens remain secret and must come from the invitation link.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 16384
                  }
                },
                "required": [
                  "token"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation completed; inspect data for the persisted state and external delivery status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128,
                          "pattern": "^[^/]+$"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "declined"
                          ]
                        },
                        "team_id": {
                          "type": "string",
                          "nullable": true
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "Resource not found or outside authorized account"
          },
          "409": {
            "description": "State conflict; retrieve the current resource before retrying"
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        }
      }
    },
    "/journeys": {
      "get": {
        "operationId": "listJourneys",
        "tags": [
          "Journeys"
        ],
        "summary": "List journeys",
        "description": "Requires member authority within the selected team. The credential selects the source data mode.\n\nquery limit,next,order_by,sort,order_direction,created,status,triggerType",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            },
            "description": "Maximum results per page."
          },
          {
            "name": "next",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next token from the previous response; keep filters and ordering unchanged."
          },
          {
            "name": "order_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Firestore ordering field; defaults to timestamp."
          },
          {
            "name": "order_direction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            },
            "description": "Ordering direction; defaults to desc."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact equality filter."
          },
          {
            "name": "triggerType",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Catalog trigger key."
          },
          {
            "name": "created[gt]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Creation timestamp bound (epoch milliseconds or ISO date)."
          },
          {
            "name": "created[gte]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Creation timestamp bound (epoch milliseconds or ISO date)."
          },
          {
            "name": "created[lt]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Creation timestamp bound (epoch milliseconds or ISO date)."
          },
          {
            "name": "created[lte]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Creation timestamp bound (epoch milliseconds or ISO date)."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiPublicJourney"
                      }
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "next": {
                      "type": "string",
                      "nullable": true
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "total_results": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp",
                    "next",
                    "has_more",
                    "total_results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      },
      "post": {
        "operationId": "createJourney",
        "tags": [
          "Journeys"
        ],
        "summary": "Create a draft journey",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JourneyInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicJourney"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journeys/catalog": {
      "get": {
        "operationId": "getJourneyCatalog",
        "tags": [
          "Journeys"
        ],
        "summary": "Get the journey node catalog",
        "description": "Requires member authority within the selected team. The credential selects the source data mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/JourneyCatalog"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journeys/{id}": {
      "get": {
        "operationId": "getJourney",
        "tags": [
          "Journeys"
        ],
        "summary": "Get a journey",
        "description": "Requires member authority within the selected team. The credential selects the source data mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicJourney"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      },
      "put": {
        "operationId": "updateJourney",
        "tags": [
          "Journeys"
        ],
        "summary": "Update a journey draft",
        "description": "**Partial update:** send only the fields you want to change; omitted fields keep their current values.\n`name` is still required on every update, and a `graph` you send replaces the whole draft graph.\n\nRequires admin authority within the selected team. The credential selects the source data mode.\n\nDraft fields only; never changes published snapshot",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JourneyUpdateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicJourney"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      },
      "delete": {
        "operationId": "deleteJourney",
        "tags": [
          "Journeys"
        ],
        "summary": "Delete a draft or archived journey",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.\n\nOnly draft/archived",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "deleted": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "deleted"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journeys/{id}/runs": {
      "get": {
        "operationId": "listJourneyRuns",
        "tags": [
          "Journeys"
        ],
        "summary": "List the latest journey runs",
        "description": "Requires member authority within the selected team. The credential selects the source data mode.\n\nLatest 50; no cursor; graphSnapshot is never returned",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiPublicJourneyRun"
                      }
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "total_results": {
                      "type": "number"
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp",
                    "total_results",
                    "has_more"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journeys/{id}/publish": {
      "post": {
        "operationId": "publishJourney",
        "tags": [
          "Journeys"
        ],
        "summary": "Publish a journey",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicJourney"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journeys/{id}/pause": {
      "post": {
        "operationId": "pauseJourney",
        "tags": [
          "Journeys"
        ],
        "summary": "Pause a journey",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiPublicJourney"
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journeys/{id}/clone": {
      "post": {
        "operationId": "cloneJourney",
        "tags": [
          "Journeys"
        ],
        "summary": "Clone a journey",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.\n\nSource team/environment checked. targetLivemode selects COPY environment; cloned as draft.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JourneyCloneInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "journey": {
                          "$ref": "#/components/schemas/ApiPublicJourney"
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "crossEnvironment": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "journey",
                        "warnings",
                        "crossEnvironment"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journeys/{id}/test": {
      "post": {
        "operationId": "testJourney",
        "tags": [
          "Journeys"
        ],
        "summary": "Queue a journey dry-run",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.\n\nExactly one source_id or source_snapshot; queues a dry-run",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JourneyTestInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "run_id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "run_id"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journey-groups": {
      "get": {
        "operationId": "listJourneyGroups",
        "tags": [
          "Journey Groups"
        ],
        "summary": "List journey groups",
        "description": "Requires member authority within the selected team. The credential selects the source data mode.\n\nquery limit,next,order_by,sort,order_direction,created,createdFrom",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            },
            "description": "Maximum results per page."
          },
          {
            "name": "next",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Opaque next token from the previous response; keep filters and ordering unchanged."
          },
          {
            "name": "order_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Firestore ordering field; defaults to timestamp."
          },
          {
            "name": "order_direction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            },
            "description": "Ordering direction; defaults to desc."
          },
          {
            "name": "createdFrom",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Exact equality filter."
          },
          {
            "name": "created[gt]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Creation timestamp bound (epoch milliseconds or ISO date)."
          },
          {
            "name": "created[gte]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Creation timestamp bound (epoch milliseconds or ISO date)."
          },
          {
            "name": "created[lt]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Creation timestamp bound (epoch milliseconds or ISO date)."
          },
          {
            "name": "created[lte]",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Creation timestamp bound (epoch milliseconds or ISO date)."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/ApiPublicJourneyGroup"
                          },
                          {
                            "type": "object",
                            "properties": {
                              "journeysCount": {
                                "type": "number"
                              },
                              "publishedCount": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "journeysCount",
                              "publishedCount"
                            ]
                          }
                        ]
                      }
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "next": {
                      "type": "string",
                      "nullable": true
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "total_results": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp",
                    "next",
                    "has_more",
                    "total_results"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      },
      "post": {
        "operationId": "createJourneyGroup",
        "tags": [
          "Journey Groups"
        ],
        "summary": "Create a journey group",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JourneyGroupInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "group": {
                          "$ref": "#/components/schemas/ApiPublicJourneyGroup"
                        },
                        "journeys": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/ApiPublicJourney"
                          }
                        }
                      },
                      "required": [
                        "group",
                        "journeys"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journey-groups/{id}": {
      "get": {
        "operationId": "getJourneyGroup",
        "tags": [
          "Journey Groups"
        ],
        "summary": "Get a journey group",
        "description": "Requires member authority within the selected team. The credential selects the source data mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ApiPublicJourneyGroup"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "journeys": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/ApiPublicJourney"
                              }
                            }
                          },
                          "required": [
                            "journeys"
                          ]
                        }
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      },
      "put": {
        "operationId": "updateJourneyGroup",
        "tags": [
          "Journey Groups"
        ],
        "summary": "Update the final membership of a journey group",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.\n\njourneys is entire final membership; omitted journeys archived; expectedLastUpdated mandatory unless empty group. 409 group_changed on stale token or child changes",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JourneyGroupUpdateInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "group": {
                          "$ref": "#/components/schemas/ApiPublicJourneyGroup"
                        },
                        "journeys": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/ApiPublicJourney"
                          }
                        },
                        "results": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/JourneyGroupOutcome"
                          }
                        },
                        "revisionId": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "group",
                        "journeys",
                        "results",
                        "revisionId"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journey-groups/{id}/clone": {
      "post": {
        "operationId": "cloneJourneyGroup",
        "tags": [
          "Journey Groups"
        ],
        "summary": "Clone a journey group",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JourneyCloneInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "group": {
                          "$ref": "#/components/schemas/ApiPublicJourneyGroup"
                        },
                        "journeys": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/ApiPublicJourney"
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "crossEnvironment": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "group",
                        "journeys",
                        "warnings",
                        "crossEnvironment"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journey-groups/{id}/revert": {
      "post": {
        "operationId": "revertJourneyGroup",
        "tags": [
          "Journey Groups"
        ],
        "summary": "Revert the latest group edit",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.\n\nexpectedLastUpdated from GET last_updated mandatory unless empty group; 409 group_changed",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JourneyGroupRevertInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "results": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/JourneyGroupOutcome"
                          }
                        },
                        "revisionId": {
                          "type": "string"
                        },
                        "revertedTo": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "results",
                        "revisionId",
                        "revertedTo"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journey-groups/{id}/publish": {
      "post": {
        "operationId": "publishJourneyGroup",
        "tags": [
          "Journey Groups"
        ],
        "summary": "Publish journeys in a group",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.\n\nIndependent per journey. HTTP200 can include status failed; inspect every result.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "results": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/JourneyGroupOutcome"
                          }
                        }
                      },
                      "required": [
                        "results"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/journey-groups/{id}/pause": {
      "post": {
        "operationId": "pauseJourneyGroup",
        "tags": [
          "Journey Groups"
        ],
        "summary": "Pause journeys in a group",
        "description": "Requires admin authority within the selected team. The credential selects the source data mode.\n\nIndependent per journey. HTTP200 can include status failed; inspect every result.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identifier returned by the matching list or create operation."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "results": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/JourneyGroupOutcome"
                          }
                        }
                      },
                      "required": [
                        "results"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets": {
      "get": {
        "operationId": "getSheetsConnection",
        "tags": [
          "Google Sheets"
        ],
        "summary": "Get Google Sheets connection status",
        "description": "Requires member authority within the selected team. The credential selects the source data mode.\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "service_account_email": {
                          "type": "string"
                        },
                        "connection": {
                          "type": "object",
                          "properties": {
                            "spreadsheet_id": {
                              "type": "string"
                            },
                            "spreadsheet_name": {
                              "type": "string"
                            },
                            "spreadsheet_url": {
                              "type": "string",
                              "format": "uri"
                            },
                            "sheet_name": {
                              "type": "string"
                            },
                            "header_row": {
                              "type": "number"
                            },
                            "headers": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "mapping": {
                              "type": "object",
                              "properties": {
                                "target": {
                                  "type": "string",
                                  "enum": [
                                    "payment",
                                    "invoice"
                                  ]
                                },
                                "fields": {
                                  "type": "object",
                                  "additionalProperties": {
                                    "type": "object",
                                    "properties": {
                                      "column": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "value": {}
                                    }
                                  }
                                }
                              },
                              "required": [
                                "target",
                                "fields"
                              ],
                              "nullable": true
                            },
                            "enabled": {
                              "type": "boolean"
                            },
                            "poll_interval_minutes": {
                              "type": "number"
                            },
                            "connected_by_email": {
                              "type": "string"
                            },
                            "connected_at": {
                              "type": "number"
                            },
                            "last_sync_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_polled_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_sync_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "last_activity_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_activity_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "totals": {
                              "type": "object",
                              "properties": {
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "imported",
                                "adopted",
                                "failed",
                                "review"
                              ]
                            },
                            "sync_error": {
                              "type": "string",
                              "nullable": true
                            }
                          },
                          "required": [
                            "spreadsheet_id",
                            "spreadsheet_name",
                            "spreadsheet_url",
                            "sheet_name",
                            "header_row",
                            "headers",
                            "livemode",
                            "mapping",
                            "enabled",
                            "poll_interval_minutes",
                            "connected_by_email",
                            "connected_at",
                            "last_sync_at",
                            "last_polled_at",
                            "last_sync_summary",
                            "last_activity_at",
                            "last_activity_summary",
                            "totals",
                            "sync_error"
                          ],
                          "nullable": true
                        },
                        "other_connection": {
                          "type": "object",
                          "properties": {
                            "livemode": {
                              "type": "boolean"
                            },
                            "spreadsheet_name": {
                              "type": "string"
                            },
                            "sheet_name": {
                              "type": "string"
                            },
                            "target": {
                              "type": "string",
                              "enum": [
                                "payment",
                                "invoice",
                                null
                              ],
                              "nullable": true
                            },
                            "mapped": {
                              "type": "boolean"
                            },
                            "enabled": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "livemode",
                            "spreadsheet_name",
                            "sheet_name",
                            "target",
                            "mapped",
                            "enabled"
                          ],
                          "nullable": true
                        }
                      },
                      "required": [
                        "service_account_email",
                        "connection",
                        "other_connection"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      },
      "delete": {
        "operationId": "disconnectSheets",
        "deprecated": true,
        "tags": [
          "Google Sheets"
        ],
        "summary": "Disconnect Google Sheets (deprecated DELETE)",
        "description": "**Deprecated:** use [`POST /sheets/disconnect`](/reference/disconnectGoogleSheets), which runs the same handler. It pairs with `POST /sheets/connect`, and every integration disconnects with `POST …/disconnect`.\nThis route keeps working; its responses carry `Deprecation: true` and `Link: </v2/sheets/disconnect>; rel=\"successor-version\"`, with the\nconcrete ID in place of each path parameter.\n\nRequires editor authority within the selected team. The credential selects the source data mode.\n\nGoogle Sheets access and existing account restrictions still apply.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "disconnected": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "disconnected"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/disconnect": {
      "post": {
        "operationId": "disconnectGoogleSheets",
        "tags": [
          "Google Sheets"
        ],
        "summary": "Disconnect Google Sheets",
        "description": "Requires editor authority within the selected team. The credential selects the source data mode.\n\nGoogle Sheets access and existing account restrictions still apply.\n\nReplaces the deprecated [`DELETE /sheets`](/reference/disconnectSheets), which runs the same handler. It pairs with `POST /sheets/connect`, and every integration disconnects with `POST …/disconnect`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "disconnected": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "disconnected"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/fields": {
      "get": {
        "operationId": "getSheetsFields",
        "tags": [
          "Google Sheets"
        ],
        "summary": "List mappable Google Sheets fields",
        "description": "Requires member authority within the selected team. The credential selects the source data mode.\n\nquery target=payment|invoice\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "target",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "payment",
                "invoice"
              ]
            },
            "description": "Import target to inspect."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "target": {
                          "type": "string"
                        },
                        "endpoint": {
                          "type": "string"
                        },
                        "fields": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "path": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "string",
                                  "number",
                                  "boolean",
                                  "enum",
                                  "date",
                                  "string_list"
                                ]
                              },
                              "required": {
                                "type": "boolean"
                              },
                              "columnOnly": {
                                "type": "boolean"
                              },
                              "values": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "description": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "path",
                              "type",
                              "required"
                            ]
                          }
                        },
                        "open_objects": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "required_containers": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      },
                      "required": [
                        "target",
                        "endpoint",
                        "fields",
                        "open_objects",
                        "required_containers"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/headers": {
      "get": {
        "operationId": "refreshSheetsHeaders",
        "tags": [
          "Google Sheets"
        ],
        "summary": "Refresh Google Sheets headers",
        "description": "Requires editor authority within the selected team. The credential selects the source data mode.\n\nMutates cached headers and timestamp; reads Google sheet\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "headers": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "sample_rows": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "row_number": {
                                "type": "number"
                              },
                              "cells": {
                                "type": "array",
                                "items": {}
                              }
                            },
                            "required": [
                              "row_number",
                              "cells"
                            ]
                          }
                        }
                      },
                      "required": [
                        "headers",
                        "sample_rows"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/rows": {
      "get": {
        "operationId": "listSheetsRows",
        "tags": [
          "Google Sheets"
        ],
        "summary": "List the latest Google Sheets row outcomes",
        "description": "Requires editor authority within the selected team. The credential selects the source data mode.\n\nquery status comma-separated error,review,imported,processing; latest 50, no cursor\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated error,review,imported,processing. Returns at most 50 rows, without a cursor."
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "gigstack_id": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "error",
                                  "review",
                                  "imported",
                                  "processing"
                                ]
                              },
                              "row_number": {
                                "type": "number"
                              },
                              "target": {
                                "type": "string",
                                "enum": [
                                  "payment",
                                  "invoice"
                                ]
                              },
                              "result_id": {
                                "type": "string",
                                "nullable": true
                              },
                              "error": {
                                "type": "string",
                                "nullable": true
                              },
                              "attempts": {
                                "type": "number"
                              },
                              "updated_at": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "gigstack_id",
                              "status",
                              "row_number",
                              "target",
                              "result_id",
                              "error",
                              "attempts",
                              "updated_at"
                            ]
                          }
                        }
                      },
                      "required": [
                        "rows"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/connect": {
      "post": {
        "operationId": "connectSheets",
        "tags": [
          "Google Sheets"
        ],
        "summary": "Connect a Google spreadsheet",
        "description": "Requires editor + verified Firebase/MCP user authority within the selected team. The credential selects the source data mode.\n\nDirect Drive owner/editor required; API/OAuth denied; cross-tenant spreadsheet claims forbidden\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SheetsConnectInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "connection": {
                          "type": "object",
                          "properties": {
                            "spreadsheet_id": {
                              "type": "string"
                            },
                            "spreadsheet_name": {
                              "type": "string"
                            },
                            "spreadsheet_url": {
                              "type": "string",
                              "format": "uri"
                            },
                            "sheet_name": {
                              "type": "string"
                            },
                            "header_row": {
                              "type": "number"
                            },
                            "headers": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "mapping": {
                              "type": "object",
                              "properties": {
                                "target": {
                                  "type": "string",
                                  "enum": [
                                    "payment",
                                    "invoice"
                                  ]
                                },
                                "fields": {
                                  "type": "object",
                                  "additionalProperties": {
                                    "type": "object",
                                    "properties": {
                                      "column": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "value": {}
                                    }
                                  }
                                }
                              },
                              "required": [
                                "target",
                                "fields"
                              ],
                              "nullable": true
                            },
                            "enabled": {
                              "type": "boolean"
                            },
                            "poll_interval_minutes": {
                              "type": "number"
                            },
                            "connected_by_email": {
                              "type": "string"
                            },
                            "connected_at": {
                              "type": "number"
                            },
                            "last_sync_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_polled_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_sync_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "last_activity_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_activity_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "totals": {
                              "type": "object",
                              "properties": {
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "imported",
                                "adopted",
                                "failed",
                                "review"
                              ]
                            },
                            "sync_error": {
                              "type": "string",
                              "nullable": true
                            }
                          },
                          "required": [
                            "spreadsheet_id",
                            "spreadsheet_name",
                            "spreadsheet_url",
                            "sheet_name",
                            "header_row",
                            "headers",
                            "livemode",
                            "mapping",
                            "enabled",
                            "poll_interval_minutes",
                            "connected_by_email",
                            "connected_at",
                            "last_sync_at",
                            "last_polled_at",
                            "last_sync_summary",
                            "last_activity_at",
                            "last_activity_summary",
                            "totals",
                            "sync_error"
                          ],
                          "nullable": true
                        },
                        "copied_from_other": {
                          "type": "boolean"
                        },
                        "tabs": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "sample_rows": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "row_number": {
                                "type": "number"
                              },
                              "cells": {
                                "type": "array",
                                "items": {}
                              }
                            },
                            "required": [
                              "row_number",
                              "cells"
                            ]
                          }
                        }
                      },
                      "required": [
                        "connection",
                        "copied_from_other",
                        "tabs",
                        "sample_rows"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/mapping": {
      "put": {
        "operationId": "updateSheetsMapping",
        "tags": [
          "Google Sheets"
        ],
        "summary": "Save a Google Sheets import mapping",
        "description": "Requires editor + target module editor authority within the selected team. The credential selects the source data mode.\n\nPauses connection and rotates generation; field paths/catalog validated\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SheetsMappingInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "connection": {
                          "type": "object",
                          "properties": {
                            "spreadsheet_id": {
                              "type": "string"
                            },
                            "spreadsheet_name": {
                              "type": "string"
                            },
                            "spreadsheet_url": {
                              "type": "string",
                              "format": "uri"
                            },
                            "sheet_name": {
                              "type": "string"
                            },
                            "header_row": {
                              "type": "number"
                            },
                            "headers": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "mapping": {
                              "type": "object",
                              "properties": {
                                "target": {
                                  "type": "string",
                                  "enum": [
                                    "payment",
                                    "invoice"
                                  ]
                                },
                                "fields": {
                                  "type": "object",
                                  "additionalProperties": {
                                    "type": "object",
                                    "properties": {
                                      "column": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "value": {}
                                    }
                                  }
                                }
                              },
                              "required": [
                                "target",
                                "fields"
                              ],
                              "nullable": true
                            },
                            "enabled": {
                              "type": "boolean"
                            },
                            "poll_interval_minutes": {
                              "type": "number"
                            },
                            "connected_by_email": {
                              "type": "string"
                            },
                            "connected_at": {
                              "type": "number"
                            },
                            "last_sync_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_polled_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_sync_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "last_activity_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_activity_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "totals": {
                              "type": "object",
                              "properties": {
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "imported",
                                "adopted",
                                "failed",
                                "review"
                              ]
                            },
                            "sync_error": {
                              "type": "string",
                              "nullable": true
                            }
                          },
                          "required": [
                            "spreadsheet_id",
                            "spreadsheet_name",
                            "spreadsheet_url",
                            "sheet_name",
                            "header_row",
                            "headers",
                            "livemode",
                            "mapping",
                            "enabled",
                            "poll_interval_minutes",
                            "connected_by_email",
                            "connected_at",
                            "last_sync_at",
                            "last_polled_at",
                            "last_sync_summary",
                            "last_activity_at",
                            "last_activity_summary",
                            "totals",
                            "sync_error"
                          ],
                          "nullable": true
                        }
                      },
                      "required": [
                        "connection"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/preview": {
      "post": {
        "operationId": "previewSheets",
        "tags": [
          "Google Sheets"
        ],
        "summary": "Preview a Google Sheets import",
        "description": "Requires editor authority within the selected team. The credential selects the source data mode.\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SheetsPreviewInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "mapping_error": {
                          "type": "string",
                          "nullable": true
                        },
                        "pending_only": {
                          "type": "boolean"
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "row_number": {
                                "type": "number"
                              },
                              "gigstack_id": {},
                              "body": {
                                "type": "object",
                                "additionalProperties": true
                              },
                              "errors": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            },
                            "required": [
                              "row_number",
                              "gigstack_id",
                              "body",
                              "errors"
                            ]
                          }
                        }
                      },
                      "required": [
                        "mapping_error",
                        "pending_only",
                        "rows"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/enable": {
      "post": {
        "operationId": "enableSheets",
        "tags": [
          "Google Sheets"
        ],
        "summary": "Enable Google Sheets imports",
        "description": "Requires editor + target module editor authority within the selected team. The credential selects the source data mode.\n\nAPI/OAuth preserve existing connecting user; background imports still reauthorize that user\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "connection": {
                          "type": "object",
                          "properties": {
                            "spreadsheet_id": {
                              "type": "string"
                            },
                            "spreadsheet_name": {
                              "type": "string"
                            },
                            "spreadsheet_url": {
                              "type": "string",
                              "format": "uri"
                            },
                            "sheet_name": {
                              "type": "string"
                            },
                            "header_row": {
                              "type": "number"
                            },
                            "headers": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "mapping": {
                              "type": "object",
                              "properties": {
                                "target": {
                                  "type": "string",
                                  "enum": [
                                    "payment",
                                    "invoice"
                                  ]
                                },
                                "fields": {
                                  "type": "object",
                                  "additionalProperties": {
                                    "type": "object",
                                    "properties": {
                                      "column": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "value": {}
                                    }
                                  }
                                }
                              },
                              "required": [
                                "target",
                                "fields"
                              ],
                              "nullable": true
                            },
                            "enabled": {
                              "type": "boolean"
                            },
                            "poll_interval_minutes": {
                              "type": "number"
                            },
                            "connected_by_email": {
                              "type": "string"
                            },
                            "connected_at": {
                              "type": "number"
                            },
                            "last_sync_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_polled_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_sync_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "last_activity_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_activity_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "totals": {
                              "type": "object",
                              "properties": {
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "imported",
                                "adopted",
                                "failed",
                                "review"
                              ]
                            },
                            "sync_error": {
                              "type": "string",
                              "nullable": true
                            }
                          },
                          "required": [
                            "spreadsheet_id",
                            "spreadsheet_name",
                            "spreadsheet_url",
                            "sheet_name",
                            "header_row",
                            "headers",
                            "livemode",
                            "mapping",
                            "enabled",
                            "poll_interval_minutes",
                            "connected_by_email",
                            "connected_at",
                            "last_sync_at",
                            "last_polled_at",
                            "last_sync_summary",
                            "last_activity_at",
                            "last_activity_summary",
                            "totals",
                            "sync_error"
                          ],
                          "nullable": true
                        }
                      },
                      "required": [
                        "connection"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/pause": {
      "post": {
        "operationId": "pauseSheets",
        "tags": [
          "Google Sheets"
        ],
        "summary": "Pause Google Sheets imports",
        "description": "Requires editor authority within the selected team. The credential selects the source data mode.\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Operation result. Inspect per-item outcomes where present.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "connection": {
                          "type": "object",
                          "properties": {
                            "spreadsheet_id": {
                              "type": "string"
                            },
                            "spreadsheet_name": {
                              "type": "string"
                            },
                            "spreadsheet_url": {
                              "type": "string",
                              "format": "uri"
                            },
                            "sheet_name": {
                              "type": "string"
                            },
                            "header_row": {
                              "type": "number"
                            },
                            "headers": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "livemode": {
                              "type": "boolean"
                            },
                            "mapping": {
                              "type": "object",
                              "properties": {
                                "target": {
                                  "type": "string",
                                  "enum": [
                                    "payment",
                                    "invoice"
                                  ]
                                },
                                "fields": {
                                  "type": "object",
                                  "additionalProperties": {
                                    "type": "object",
                                    "properties": {
                                      "column": {
                                        "type": "string",
                                        "nullable": true
                                      },
                                      "value": {}
                                    }
                                  }
                                }
                              },
                              "required": [
                                "target",
                                "fields"
                              ],
                              "nullable": true
                            },
                            "enabled": {
                              "type": "boolean"
                            },
                            "poll_interval_minutes": {
                              "type": "number"
                            },
                            "connected_by_email": {
                              "type": "string"
                            },
                            "connected_at": {
                              "type": "number"
                            },
                            "last_sync_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_polled_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_sync_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "last_activity_at": {
                              "type": "number",
                              "nullable": true
                            },
                            "last_activity_summary": {
                              "type": "object",
                              "properties": {
                                "read": {
                                  "type": "number"
                                },
                                "claimed": {
                                  "type": "number"
                                },
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                },
                                "skipped": {
                                  "type": "number"
                                },
                                "remaining": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "read",
                                "claimed",
                                "imported",
                                "adopted",
                                "failed",
                                "review",
                                "skipped",
                                "remaining"
                              ],
                              "nullable": true
                            },
                            "totals": {
                              "type": "object",
                              "properties": {
                                "imported": {
                                  "type": "number"
                                },
                                "adopted": {
                                  "type": "number"
                                },
                                "failed": {
                                  "type": "number"
                                },
                                "review": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "imported",
                                "adopted",
                                "failed",
                                "review"
                              ]
                            },
                            "sync_error": {
                              "type": "string",
                              "nullable": true
                            }
                          },
                          "required": [
                            "spreadsheet_id",
                            "spreadsheet_name",
                            "spreadsheet_url",
                            "sheet_name",
                            "header_row",
                            "headers",
                            "livemode",
                            "mapping",
                            "enabled",
                            "poll_interval_minutes",
                            "connected_by_email",
                            "connected_at",
                            "last_sync_at",
                            "last_polled_at",
                            "last_sync_summary",
                            "last_activity_at",
                            "last_activity_summary",
                            "totals",
                            "sync_error"
                          ],
                          "nullable": true
                        }
                      },
                      "required": [
                        "connection"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/sheets/sync": {
      "post": {
        "operationId": "syncSheets",
        "tags": [
          "Google Sheets"
        ],
        "summary": "Queue a Google Sheets sync",
        "description": "Requires editor authority within the selected team. The credential selects the source data mode.\n\nGoogle Sheets access and existing account restrictions still apply.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "202": {
            "description": "Sync queued; inspect connection and row outcomes for completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "queued": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "queued"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request fields or pagination parameters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AuthForbidden"
          },
          "404": {
            "description": "The resource was not found in the selected team and data mode."
          },
          "409": {
            "description": "Conflicting state, stale group revision, or spreadsheet ownership conflict. Read current state before proposing another write."
          },
          "500": {
            "description": "Internal failure; a write may have completed. Reconcile before retrying."
          }
        }
      }
    },
    "/users/me": {
      "get": {
        "operationId": "getSelfProfile",
        "tags": [
          "Your Account"
        ],
        "summary": "Read your account profile",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SelfProfile"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      },
      "patch": {
        "operationId": "updateSelfProfile",
        "tags": [
          "Your Account"
        ],
        "summary": "Update your account profile",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SelfProfileInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SelfProfile"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      }
    },
    "/users/me/preferences/{teamId}": {
      "get": {
        "operationId": "getSelfPreferences",
        "tags": [
          "Your Account"
        ],
        "summary": "Read your team preferences",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,256}$"
            },
            "description": "A team where you currently have active membership."
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SelfPreferences"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      },
      "patch": {
        "operationId": "updateSelfPreferences",
        "tags": [
          "Your Account"
        ],
        "summary": "Update your team preferences",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "teamId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,256}$"
            },
            "description": "A team where you currently have active membership."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SelfPreferencesInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SelfPreferences"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      }
    },
    "/users/me/active-context": {
      "post": {
        "operationId": "selectSelfActiveContext",
        "tags": [
          "Your Account"
        ],
        "summary": "Select your active team or billing account",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SelfContextInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "active_team_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "active_billing_account_id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "active_team_id",
                        "active_billing_account_id"
                      ]
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      }
    },
    "/users/me/notifications": {
      "get": {
        "operationId": "listSelfNotifications",
        "tags": [
          "Your Account"
        ],
        "summary": "List your notifications",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.\n\nDismissed entries are excluded. Ordered by delivery date and recipient ID descending. Follow next_cursor until has_more is false.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Opaque next_cursor returned by the previous page; bound to this user."
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SelfNotification"
                      }
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp",
                    "has_more",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      }
    },
    "/users/me/notifications/unread-count": {
      "get": {
        "operationId": "countSelfUnreadNotifications",
        "tags": [
          "Your Account"
        ],
        "summary": "Count your unread notifications",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.\n\nDismissed entries are excluded from the count.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "count"
                      ]
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      }
    },
    "/users/me/notifications/read-all": {
      "post": {
        "operationId": "markSelfNotificationsRead",
        "tags": [
          "Your Account"
        ],
        "summary": "Mark your notifications as read",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.\n\nMarks the initial unread set, including dismissed entries, matching the existing account action. Recipient and parent read counters are updated transactionally.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "updated_count": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "updated_count"
                      ]
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      }
    },
    "/users/me/notifications/{notificationId}/read": {
      "post": {
        "operationId": "markSelfNotificationRead",
        "tags": [
          "Your Account"
        ],
        "summary": "Mark one notification as read",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "notificationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,256}$"
            },
            "description": "Recipient record ID from data[].id."
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SelfNotification"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      }
    },
    "/users/me/notifications/{notificationId}": {
      "delete": {
        "operationId": "dismissSelfNotification",
        "tags": [
          "Your Account"
        ],
        "summary": "Dismiss a notification",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "notificationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,256}$"
            },
            "description": "Recipient record ID from data[].id."
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SelfNotification"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      }
    },
    "/users/me/mcp-tokens": {
      "get": {
        "operationId": "listSelfMcpTokens",
        "tags": [
          "Your Account"
        ],
        "summary": "List your MCP token metadata",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.\n\nMetadata only, including revoked tokens; no JWTs or signer material. The collection is filtered to the authenticated owner.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SelfMcpToken"
                      }
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      },
      "post": {
        "operationId": "createSelfMcpToken",
        "tags": [
          "Your Account"
        ],
        "summary": "Retired: Create a personal MCP token",
        "description": "Direct credential issuance is retired. Returns HTTP 403 account_approval_required without generating credentials. Prepare an action through POST /users/me/account-approvals with a persisted UUIDv4, then let the initiating person review and confirm in the authenticated browser. Existing list and revocation operations remain available.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "403": {
            "description": "account_approval_required: use the credential approval handoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountApprovalRequired"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "account_approval_required",
                    "message": "Prepare and confirm this credential action through an account approval"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          }
        },
        "deprecated": true
      }
    },
    "/users/me/mcp-tokens/{keyId}": {
      "delete": {
        "operationId": "revokeSelfMcpToken",
        "tags": [
          "Your Account"
        ],
        "summary": "Revoke a personal MCP token",
        "description": "Requires a verified Firebase ID token or signed, active personal MCP token. Team API keys and OAuth client credentials cannot act as their creator. Firebase callers may access their own identity before joining a team. MCP callers remain subject to current credential/team authorization. Authentication is verified in the backend, including when requests pass through the API gateway.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,256}$"
            },
            "description": "Personal MCP token keyid."
          }
        ],
        "responses": {
          "200": {
            "description": "Persisted account state or action result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SelfMcpToken"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, empty patch, or invalid cursor."
          },
          "401": {
            "description": "A valid Firebase or personal MCP credential is required."
          },
          "403": {
            "description": "Disabled account, blocked membership, or insufficient account authority."
          },
          "404": {
            "description": "Resource not found within your authorized scope."
          },
          "409": {
            "description": "Context mismatch, changed membership, or personal token limit reached."
          },
          "500": {
            "description": "Internal failure. Reconcile current state before retrying a write."
          }
        }
      }
    },
    "/api-keys": {
      "get": {
        "operationId": "listApiCredentials",
        "tags": [
          "API Credentials"
        ],
        "summary": "List API credential metadata",
        "description": "Requires a verified Firebase or personal MCP user credential and current team administrator/owner or billing-account administrator authority. A team API key or OAuth token cannot act as its creator. Select the team with the team query parameter. For v2 plans, issuance requires apiAndWebhooks; legacy issuance behavior is preserved. Metadata and revocation remain available after a downgrade.\n\nLists API keys only, never stored JWTs. Empty filtered pages can still have next_cursor; continue until has_more is false.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_revoked",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Credential lifecycle result. Responses are not cacheable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiCredentialMetadata"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, team, filter or pagination."
          },
          "401": {
            "description": "Verified user credential required."
          },
          "403": {
            "description": "Current account authority or issuance entitlement required."
          },
          "404": {
            "description": "Credential or team not found in the authorized scope."
          },
          "409": {
            "description": "Active keys already exist, concurrent keys_changed conflict, or revocation in progress."
          },
          "500": {
            "description": "Credential operation failed; reconcile metadata before retrying. No signer details are returned."
          }
        }
      },
      "post": {
        "operationId": "createApiCredentials",
        "tags": [
          "API Credentials"
        ],
        "summary": "Retired: Create live and test API credentials",
        "description": "Direct credential issuance is retired. Returns HTTP 403 account_approval_required without generating credentials. Prepare an action through POST /users/me/account-approvals with a persisted UUIDv4, then let the initiating person review and confirm in the authenticated browser. Existing list and revocation operations remain available.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "403": {
            "description": "account_approval_required: use the credential approval handoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountApprovalRequired"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "account_approval_required",
                    "message": "Prepare and confirm this credential action through an account approval"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          }
        },
        "deprecated": true
      }
    },
    "/api-keys/rotate": {
      "post": {
        "operationId": "rotateApiCredentials",
        "tags": [
          "API Credentials"
        ],
        "summary": "Retired: Rotate live and test API credentials",
        "description": "Direct credential issuance is retired. Returns HTTP 403 account_approval_required without generating credentials. Prepare an action through POST /users/me/account-approvals with a persisted UUIDv4, then let the initiating person review and confirm in the authenticated browser. Existing list and revocation operations remain available.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "403": {
            "description": "account_approval_required: use the credential approval handoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountApprovalRequired"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "account_approval_required",
                    "message": "Prepare and confirm this credential action through an account approval"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          }
        },
        "deprecated": true
      }
    },
    "/api-keys/{keyId}": {
      "delete": {
        "operationId": "revokeApiCredential",
        "tags": [
          "API Credentials"
        ],
        "summary": "Revoke an API credential",
        "description": "Requires a verified Firebase or personal MCP user credential and current team administrator/owner or billing-account administrator authority. A team API key or OAuth token cannot act as its creator. Select the team with the team query parameter. For v2 plans, issuance requires apiAndWebhooks; legacy issuance behavior is preserved. Metadata and revocation remain available after a downgrade.\n\nReturns the revoked metadata, including when already revoked. Foreign keys and personal MCP token IDs return 404.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Credential lifecycle result. Responses are not cacheable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiCredentialMetadata"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, team, filter or pagination."
          },
          "401": {
            "description": "Verified user credential required."
          },
          "403": {
            "description": "Current account authority or issuance entitlement required."
          },
          "404": {
            "description": "Credential or team not found in the authorized scope."
          },
          "409": {
            "description": "Active keys already exist, concurrent keys_changed conflict, or revocation in progress."
          },
          "500": {
            "description": "Credential operation failed; reconcile metadata before retrying. No signer details are returned."
          }
        }
      }
    },
    "/api-keys/emergency-revoke": {
      "post": {
        "operationId": "emergencyRevokeApiCredentials",
        "tags": [
          "API Credentials"
        ],
        "summary": "Revoke legacy team API and MCP credentials",
        "description": "Requires a verified Firebase or personal MCP user credential and current team administrator/owner or billing-account administrator authority. A team API key or OAuth token cannot act as its creator. Select the team with the team query parameter. For v2 plans, issuance requires apiAndWebhooks; legacy issuance behavior is preserved. Metadata and revocation remain available after a downgrade.\n\nRevokes active legacy API and personal MCP credentials associated with the selected team, potentially including the calling legacy token. Named scoped keys, malformed scoped-marker records and OAuth credentials are untouched. The historical team_api_and_mcp_keys result label describes this legacy operation only. Batched revocation resumes its durable fence after interruption.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Credential lifecycle result. Responses are not cacheable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "revoked_count": {
                          "type": "number"
                        },
                        "scope": {
                          "type": "string",
                          "enum": [
                            "team_api_and_mcp_keys"
                          ]
                        },
                        "oauth_revoked": {
                          "type": "boolean",
                          "enum": [
                            false
                          ]
                        }
                      },
                      "required": [
                        "revoked_count",
                        "scope",
                        "oauth_revoked"
                      ]
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, team, filter or pagination."
          },
          "401": {
            "description": "Verified user credential required."
          },
          "403": {
            "description": "Current account authority or issuance entitlement required."
          },
          "404": {
            "description": "Credential or team not found in the authorized scope."
          },
          "409": {
            "description": "Active keys already exist, concurrent keys_changed conflict, or revocation in progress."
          },
          "500": {
            "description": "Credential operation failed; reconcile metadata before retrying. No signer details are returned."
          }
        }
      }
    },
    "/teams/{id}/integrations/catalog": {
      "get": {
        "operationId": "listAccountIntegrations",
        "tags": [
          "Account Integrations"
        ],
        "summary": "List account integration capabilities",
        "description": "Reads current stored configuration; completed does not establish current provider health. The catalog distinguishes dashboard actions from implemented API actions. Region and installation eligibility mirror existing web rules. Settings affect the team across credential data modes. Current authorized members can read; mutations recheck current team/owning-account administrator authority for user credentials. API keys retain their current team scope.\n\nSafe metadata and allowlisted settings only; provider credentials are never returned.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stored integration state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "team_id": {
                          "type": "string"
                        },
                        "providers": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/AccountIntegrationState"
                          }
                        }
                      },
                      "required": [
                        "team_id",
                        "providers"
                      ]
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, field, empty patch, bank identity, or CLABE; provider requires its dedicated settings workflow."
          },
          "401": {
            "description": "Authentication required."
          },
          "403": {
            "description": "Current role or existing installation entitlement required."
          },
          "404": {
            "description": "Team or provider not found in authorized scope."
          },
          "409": {
            "description": "Integration is not configured or team is pending deletion."
          }
        }
      }
    },
    "/teams/{id}/integrations/{provider}": {
      "get": {
        "operationId": "getAccountIntegration",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Read stored integration settings",
        "description": "Reads current stored configuration; completed does not establish current provider health. The catalog distinguishes dashboard actions from implemented API actions. Region and installation eligibility mirror existing web rules. Settings affect the team across credential data modes. Current authorized members can read; mutations recheck current team/owning-account administrator authority for user credentials. API keys retain their current team scope.\n\nSafe metadata and allowlisted settings only; provider credentials are never returned.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "stripe",
                "adyen",
                "paypal",
                "zettle",
                "conekta",
                "openpay",
                "clip",
                "clockpms",
                "pagoralia",
                "dlocal",
                "woocommerce",
                "mercadopago",
                "mercadolibre",
                "airtable",
                "shopify",
                "bank",
                "sheets",
                "netsuite",
                "whatsapp",
                "zapier",
                "whmcs",
                "hilos",
                "sat",
                "sat_download",
                "factus"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stored integration state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountIntegrationDetail"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, field, empty patch, bank identity, or CLABE; provider requires its dedicated settings workflow."
          },
          "401": {
            "description": "Authentication required."
          },
          "403": {
            "description": "Current role or existing installation entitlement required."
          },
          "404": {
            "description": "Team or provider not found in authorized scope."
          },
          "409": {
            "description": "Integration is not configured or team is pending deletion."
          }
        }
      }
    },
    "/teams/{id}/integrations/{provider}/settings": {
      "patch": {
        "operationId": "updateAccountIntegrationSettings",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Update provider settings",
        "description": "Reads current stored configuration; completed does not establish current provider health. The catalog distinguishes dashboard actions from implemented API actions. Region and installation eligibility mirror existing web rules. Settings affect the team across credential data modes. Current authorized members can read; mutations recheck current team/owning-account administrator authority for user credentials. API keys retain their current team scope.\n\nOnly fields for the selected provider are accepted. Existing non-bank connection required. Bank instructions require country and holder name, plus a valid CLABE for MEX; saving marks them configured without verifying bank ownership. Existing installation limit applies to first bank configuration. No credentials or worker state are replaced.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "stripe",
                "adyen",
                "paypal",
                "zettle",
                "conekta",
                "openpay",
                "clip",
                "clockpms",
                "pagoralia",
                "dlocal",
                "woocommerce",
                "mercadopago",
                "mercadolibre",
                "airtable",
                "shopify",
                "bank",
                "sheets",
                "netsuite",
                "whatsapp",
                "zapier",
                "whmcs",
                "hilos",
                "sat",
                "sat_download",
                "factus"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/IntegrationStripeSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationAdyenSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationPaypalSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationConektaSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationOpenpaySettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationClipSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationClockpmsSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationPagoraliaSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationDlocalSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationWoocommerceSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationMercadopagoSettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationShopifySettingsInput"
                  },
                  {
                    "$ref": "#/components/schemas/IntegrationBankSettingsInput"
                  }
                ]
              },
              "examples": {
                "disableStripeAutomation": {
                  "summary": "For provider=stripe",
                  "value": {
                    "automatic_invoicing": false
                  }
                },
                "bankInstructions": {
                  "summary": "For provider=bank",
                  "value": {
                    "country": "MEX",
                    "holder_name": "Example Company",
                    "clabe": "032180000118359719"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stored integration state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountIntegrationDetail"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, field, empty patch, bank identity, or CLABE; provider requires its dedicated settings workflow."
          },
          "401": {
            "description": "Authentication required."
          },
          "403": {
            "description": "Current role or existing installation entitlement required."
          },
          "404": {
            "description": "Team or provider not found in authorized scope."
          },
          "409": {
            "description": "Integration is not configured or team is pending deletion."
          }
        }
      }
    },
    "/teams/{id}/fiscal-upload-sessions": {
      "post": {
        "operationId": "createFiscalUploadSession",
        "tags": [
          "Fiscal Handoff"
        ],
        "summary": "Create a secure fiscal upload session",
        "description": "Requires a verified Firebase or active signed personal MCP identity and current team owner authority. Team API keys and OAuth cannot impersonate their creator. Fiscal configuration is shared across live/test credential modes. FIEL/PFX provider calls use production even on staging; CSD affects shared future invoice configuration. The browser displays actual provider_environment and requires explicit consent.\n\nCreates a 15-minute session bound to the actual user, team, purpose and credential mode. Returns a fixed authenticated browser URL. Manifest consent text and hash are frozen at creation. At most five pending sessions per owner/team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Safe fiscal state. HTTP success alone does not establish provider completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/FiscalUploadSession"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, purpose, consent, identifier or upload."
          },
          "401": {
            "description": "Verified user credential required."
          },
          "403": {
            "description": "Current owner or browser identity required."
          },
          "404": {
            "description": "Session or team not found for current identity/mode."
          },
          "409": {
            "description": "Session expired, operation started, another upload is active, or recovery deadline has not elapsed."
          },
          "503": {
            "description": "Nonproduction browser origin is not safely configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FiscalUploadSessionInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/fiscal-upload-sessions/{sessionId}": {
      "get": {
        "operationId": "getFiscalUploadSession",
        "tags": [
          "Fiscal Handoff"
        ],
        "summary": "Read a fiscal upload session",
        "description": "Requires a verified Firebase or active signed personal MCP identity and current team owner authority. Team API keys and OAuth cannot impersonate their creator. Fiscal configuration is shared across live/test credential modes. FIEL/PFX provider calls use production even on staging; CSD affects shared future invoice configuration. The browser displays actual provider_environment and requires explicit consent.\n\nCurrent owner can inspect a prior-owner session after ownership transfer. Submission remains restricted to the original creator while still owner. Read after a lost connection; never automatically resubmit.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe fiscal state. HTTP success alone does not establish provider completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/FiscalUploadSession"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, purpose, consent, identifier or upload."
          },
          "401": {
            "description": "Verified user credential required."
          },
          "403": {
            "description": "Current owner or browser identity required."
          },
          "404": {
            "description": "Session or team not found for current identity/mode."
          },
          "409": {
            "description": "Session expired, operation started, another upload is active, or recovery deadline has not elapsed."
          },
          "503": {
            "description": "Nonproduction browser origin is not safely configured."
          }
        }
      },
      "delete": {
        "operationId": "cancelFiscalUploadSession",
        "tags": [
          "Fiscal Handoff"
        ],
        "summary": "Cancel a pending fiscal upload session",
        "description": "Requires a verified Firebase or active signed personal MCP identity and current team owner authority. Team API keys and OAuth cannot impersonate their creator. Fiscal configuration is shared across live/test credential modes. FIEL/PFX provider calls use production even on staging; CSD affects shared future invoice configuration. The browser displays actual provider_environment and requires explicit consent.\n\nCancellation is allowed only while pending and does not remove existing fiscal configuration. Started operations return 409 operation_started.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe fiscal state. HTTP success alone does not establish provider completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/FiscalUploadSession"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, purpose, consent, identifier or upload."
          },
          "401": {
            "description": "Verified user credential required."
          },
          "403": {
            "description": "Current owner or browser identity required."
          },
          "404": {
            "description": "Session or team not found for current identity/mode."
          },
          "409": {
            "description": "Session expired, operation started, another upload is active, or recovery deadline has not elapsed."
          },
          "503": {
            "description": "Nonproduction browser origin is not safely configured."
          }
        }
      }
    },
    "/teams/{id}/fiscal-status": {
      "get": {
        "operationId": "getTeamFiscalStatus",
        "tags": [
          "Fiscal Handoff"
        ],
        "summary": "Read safe team fiscal status",
        "description": "Requires a verified Firebase or active signed personal MCP identity and current team owner authority. Team API keys and OAuth cannot impersonate their creator. Fiscal configuration is shared across live/test credential modes. FIEL/PFX provider calls use production even on staging; CSD affects shared future invoice configuration. The browser displays actual provider_environment and requires explicit consent.\n\nSafe stored metadata only. Reads do not contact providers, finalize a manifest, or send email. blocking_session_id identifies a pending recovery for the current owner.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe fiscal state. HTTP success alone does not establish provider completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/FiscalAccountStatus"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, purpose, consent, identifier or upload."
          },
          "401": {
            "description": "Verified user credential required."
          },
          "403": {
            "description": "Current owner or browser identity required."
          },
          "404": {
            "description": "Session or team not found for current identity/mode."
          },
          "409": {
            "description": "Session expired, operation started, another upload is active, or recovery deadline has not elapsed."
          },
          "503": {
            "description": "Nonproduction browser origin is not safely configured."
          }
        }
      }
    },
    "/teams/{id}/fiscal-upload-sessions/{sessionId}/reconcile": {
      "post": {
        "operationId": "reconcileFiscalUploadSession",
        "tags": [
          "Fiscal Handoff"
        ],
        "summary": "Reconcile a fiscal upload outcome",
        "description": "Requires a verified Firebase or active signed personal MCP identity and current team owner authority. Team API keys and OAuth cannot impersonate their creator. Fiscal configuration is shared across live/test credential modes. FIEL/PFX provider calls use production even on staging; CSD affects shared future invoice configuration. The browser displays actual provider_environment and requires explicit consent.\n\nChecks exact locally persisted session/attempt markers. Does not contact a provider or replay files. A match can establish completion; missing evidence preserves outcome_unknown.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe fiscal state. HTTP success alone does not establish provider completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/FiscalUploadSession"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid fields, purpose, consent, identifier or upload."
          },
          "401": {
            "description": "Verified user credential required."
          },
          "403": {
            "description": "Current owner or browser identity required."
          },
          "404": {
            "description": "Session or team not found for current identity/mode."
          },
          "409": {
            "description": "Session expired, operation started, another upload is active, or recovery deadline has not elapsed."
          },
          "503": {
            "description": "Nonproduction browser origin is not safely configured."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {}
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/zettle/status": {
      "get": {
        "operationId": "accountZettleStatus",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Get Zettle connection status",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nReturns stored connection metadata and at most 20 review purchases, not complete review history.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "zettle"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "status"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountZettleStatusResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        }
      }
    },
    "/teams/{id}/integrations/zettle/connection-settings": {
      "patch": {
        "operationId": "accountZettleSettings",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Update Zettle connection settings",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nBoth settings are required. Current admin/editor or owning billing administrator authority and the configured connection mode are required. An active sync lease can return sync_busy.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "zettle"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "settings"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountZettleSettingsResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountZettleSettingsInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/zettle/sync": {
      "post": {
        "operationId": "accountZettleSync",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Run a Zettle sync",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nHTTP 202 with queued true confirms durable enqueue only. Test imports still read real merchant purchases. Use status to inspect progress.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "zettle"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "sync"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountZettleSyncResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountZettleSyncInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/zettle/connection": {
      "delete": {
        "operationId": "accountZettleDisconnect",
        "deprecated": true,
        "tags": [
          "Account Integrations"
        ],
        "summary": "Disconnect Zettle (deprecated DELETE)",
        "description": "**Deprecated:** use [`POST /teams/{id}/integrations/zettle/disconnect`](/reference/disconnectZettle), which runs the same handler and takes the same body. Every integration disconnects with `POST …/disconnect`.\nThis route keeps working; its responses carry `Deprecation: true` and `Link: </v2/teams/{id}/integrations/zettle/disconnect>; rel=\"successor-version\"`, with the\nconcrete ID in place of each path parameter.\n\nRequires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nStops and fences local work, removes local credentials, and attempts remote subscription cleanup. partial_cleanup true means remote removal failed. remote_removed null means no remote attempt; do not claim confirmed remote cleanup.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "zettle"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "disconnect"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountZettleDisconnectResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountZettleDisconnectInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/zettle/disconnect": {
      "post": {
        "operationId": "disconnectZettle",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Disconnect Zettle",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nStops and fences local work, removes local credentials, and attempts remote subscription cleanup. partial_cleanup true means remote removal failed. remote_removed null means no remote attempt; do not claim confirmed remote cleanup.\n\nReplaces the deprecated [`DELETE /teams/{id}/integrations/zettle/connection`](/reference/accountZettleDisconnect), which runs the same handler and takes the same body. Every integration disconnects with `POST …/disconnect`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "zettle"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "disconnect"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountZettleDisconnectResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountZettleDisconnectInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/status": {
      "get": {
        "operationId": "accountNetsuiteStatus",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Get NetSuite connection status",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nReports both live and test metadata and at most 20 safe recent syncs. It is not a mode-filtered complete history.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "status"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteStatusResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/ping": {
      "post": {
        "operationId": "accountNetsuitePing",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Test the NetSuite connection",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nContacts the selected provider environment; returns safe connection metadata.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "ping"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuitePingResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountNetsuitePingInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/connection": {
      "delete": {
        "operationId": "accountNetsuiteDisconnect",
        "deprecated": true,
        "tags": [
          "Account Integrations"
        ],
        "summary": "Disconnect NetSuite (deprecated DELETE)",
        "description": "**Deprecated:** use [`POST /teams/{id}/integrations/netsuite/disconnect`](/reference/disconnectNetsuite), which runs the same handler and takes the same body. Every integration disconnects with `POST …/disconnect`.\nThis route keeps working; its responses carry `Deprecation: true` and `Link: </v2/teams/{id}/integrations/netsuite/disconnect>; rel=\"successor-version\"`, with the\nconcrete ID in place of each path parameter.\n\nRequires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nDisables only the selected mode. credentials_retained true means encrypted provider secrets remain stored, matching the existing dashboard behavior.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "disconnect"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteDisconnectResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountNetsuiteDisconnectInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/disconnect": {
      "post": {
        "operationId": "disconnectNetsuite",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Disconnect NetSuite",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nDisables only the selected mode. credentials_retained true means encrypted provider secrets remain stored, matching the existing dashboard behavior.\n\nReplaces the deprecated [`DELETE /teams/{id}/integrations/netsuite/connection`](/reference/accountNetsuiteDisconnect), which runs the same handler and takes the same body. Every integration disconnects with `POST …/disconnect`.\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "disconnect"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteDisconnectResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountNetsuiteDisconnectInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/invoices/{invoiceId}/sync": {
      "post": {
        "operationId": "accountNetsuiteSync",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Sync an invoice to NetSuite",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nChecks invoice team and mode, resets local sync steps and enqueues processing. An enqueue failure may leave local state changed. Do not automatically replay after timeout.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "sync"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteSyncResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountNetsuiteSyncInput"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "accountNetsuiteSyncStatus",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Get an invoice NetSuite sync status",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nSafe allowlisted sync state. Raw upstream errors are redacted; diagnosis retains selected actionable fields. Missing sync returns 404.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "sync_status"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteSyncStatusResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/invoices/{invoiceId}/resync": {
      "post": {
        "operationId": "accountNetsuiteResync",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Resync an invoice to NetSuite",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nOn a paid invoice this can delete and recreate the applied NetSuite customer payment for its current total. Requires explicit operator intent. Enqueued does not mean completed; inspect individual sync status before retry.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "resync"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteResyncResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountNetsuiteResyncInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/syncs": {
      "get": {
        "operationId": "accountNetsuiteSyncs",
        "tags": [
          "Account Integrations"
        ],
        "summary": "List NetSuite syncs",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nExisting attention scan is bounded to at most 1000 rows per source query, with 50-item pages. Preserve truncated true and nextBefore; do not describe this as complete history.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^\\d+_[A-Za-z0-9_-]+$"
            },
            "description": "Use nextBefore from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "syncs"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteSyncsResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/items": {
      "get": {
        "operationId": "accountNetsuiteItemsConfig",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Get NetSuite item settings",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nReads team-shared mapping configuration, independent of credential mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "items_config"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteItemsConfigResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/items/preview": {
      "post": {
        "operationId": "accountNetsuiteItemsPreview",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Preview a NetSuite item rule",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nUses the shared mapping configuration and a live provider lookup even with a test credential. Returns previewToken and requiresConfirmation for the current configuration.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "items_preview"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteItemsPreviewResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountNetsuiteItemsPreviewInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/netsuite/items/rules": {
      "post": {
        "operationId": "accountNetsuiteItemsRule",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Save a NetSuite item rule",
        "description": "Requires a verified Firebase or active signed personal MCP user. Team API keys/OAuth cannot impersonate their creator. Current role, credential mode and target team are rechecked by the provider service; blocked users are refused. Response data carries provider, operation, livemode, effect_scope and the safe provider result.\n\nRequires a current previewToken. If preview changes existing lines, confirmChanges true is separately required. Stale previews return 409 state_changed. Mapping is team-shared and lookup is live even with test credentials.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Provider operation result; inspect queued, partial_cleanup, truncated and effect_scope before claiming completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "timestamp",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "timestamp": {
                      "type": "number"
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "provider",
                        "operation",
                        "livemode",
                        "effect_scope",
                        "data"
                      ],
                      "properties": {
                        "provider": {
                          "type": "string",
                          "enum": [
                            "netsuite"
                          ]
                        },
                        "operation": {
                          "type": "string",
                          "enum": [
                            "items_rule"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "effect_scope": {
                          "type": "string",
                          "enum": [
                            "team_shared",
                            "team_shared_live_lookup",
                            "team_shared_status",
                            "connection_mode",
                            "credential_mode"
                          ]
                        },
                        "data": {
                          "$ref": "#/components/schemas/AccountNetsuiteItemsRuleResult"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or provider configuration."
          },
          "401": {
            "description": "Verified personal user credential required."
          },
          "403": {
            "description": "Current provider action permission or matching connection/invoice mode required."
          },
          "404": {
            "description": "Team, invoice, connection or sync not found in the authorized scope."
          },
          "409": {
            "description": "Active sync lease, changed connection/configuration or stale preview. Read state and preview again."
          },
          "503": {
            "description": "Explicit environment or signed internal service authorization is unavailable."
          },
          "504": {
            "description": "outcome_unknown: no provider result arrived. Inspect current state before deciding whether to retry; no automatic replay occurred."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountNetsuiteItemsRuleInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/summary": {
      "get": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingSummary",
        "summary": "Read account subscription and usage",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Subscriptions are bounded to 100 with subscriptions_has_more. Null usage means unavailable, not zero.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingSummary"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        }
      }
    },
    "/teams/{id}/billing/prices": {
      "get": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingPrices",
        "summary": "Read Pricing v3 prices",
        "description": "What each add-on, monthly fee and document costs, from the billing catalog, in MXN before IVA. The public GET /pricing list for Mexico, where gigstack bills every account, plus the items not `listed` there, so an account offered an add-on not on the public page sees its price. Read-only and cached up to a minute; any team credential may read it. Nothing account-specific: the account's own early-billing threshold is in the summary's credits.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The price list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PriceList"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "The billing catalog is not set up in this environment (prices_unavailable)."
          },
          "503": {
            "description": "Prices could not be read; retry shortly (prices_unavailable)."
          }
        }
      }
    },
    "/pricing": {
      "get": {
        "tags": [
          "Pricing"
        ],
        "operationId": "getPublicPrices",
        "summary": "Read the public price list",
        "description": "The Pricing v3 price list without authentication, for price pages and plan comparisons: add-ons, monthly fees, the document scale, welcome credits and the early-billing threshold, from the billing catalog, in MXN before IVA. Public prices only: items the catalog does not mark `listed` (features not launched yet) are left out, and nothing is per account. Any origin may read it (Access-Control-Allow-Origin *). Cacheable for five minutes. Keep a fallback for when it is unreachable, and hide a price the list does not carry.",
        "security": [],
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "Issuing country, ISO 3166-1 alpha-3. Defaults to MEX.",
            "schema": {
              "type": "string",
              "enum": [
                "MEX",
                "COL"
              ],
              "default": "MEX"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The price list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PriceList"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown country (invalid_country)."
          },
          "404": {
            "description": "The country has no catalog yet (prices_unavailable)."
          },
          "503": {
            "description": "Prices could not be read; retry shortly (prices_unavailable)."
          }
        }
      }
    },
    "/teams/{id}/billing/plans": {
      "get": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingPlans",
        "summary": "List eligible legacy account plans",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Preserves hidden-plan and team-volume visibility rules. Prices are minor units. Never supply provider price IDs.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingPlans"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        }
      }
    },
    "/teams/{id}/billing/history": {
      "get": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingHistory",
        "summary": "List account billing invoices",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Use data.cursor for the next page. Cursor is scoped to the billing account, provider environment and customer. Invoice dates are Unix seconds; amounts are minor units. Hosted URLs are sensitive handoffs.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingHistory"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        }
      }
    },
    "/teams/{id}/billing/fiscal": {
      "get": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingFiscalGet",
        "summary": "Read account fiscal details",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. This read does not heal the fiscal mirror or synchronize Stripe. stripe_synced null means no sync was attempted.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingFiscal"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        }
      },
      "patch": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingFiscalUpdate",
        "summary": "Update account fiscal details",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Writes the account billing fiscal profile and attempts Stripe synchronization. Inspect stripe_synced: false preserves a partial local save. Existing SAT validation applies.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action. On `billing_operation_pending`, `error.details.operation_id` names the operation holding the lock: reconcile it, then retry. A Checkout already paid or expired no longer holds the lock."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingFiscalInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/checkout": {
      "post": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingCheckout",
        "summary": "Start legacy account plan checkout",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. A UUID v4 operation_id is required. An identical repeated request reads the prior operation without replay. Changed parameters conflict. Checkout keeps an account lock until completion or expiry is observed. A hosted link is not a completed purchase. Current pricing-version and trial eligibility rules apply; legacy checkout refuses pricing v3.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action. On `billing_operation_pending`, `error.details.operation_id` names the operation holding the lock: reconcile it, then retry. A Checkout already paid or expired no longer holds the lock."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingCheckoutInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/upgrade": {
      "post": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingUpgrade",
        "summary": "Upgrade legacy account subscription",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Requires exactly one manageable subscription. Existing proration applies. Read the operation before retrying after a timeout. Legacy upgrade refuses pricing v3.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action. On `billing_operation_pending`, `error.details.operation_id` names the operation holding the lock: reconcile it, then retry. A Checkout already paid or expired no longer holds the lock."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingUpgradeInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/portal": {
      "post": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingPortal",
        "summary": "Open account billing portal",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Creates a hosted Stripe handoff. Neither cancellation nor payment-method update is complete when the link is created. Portal handoff creation releases the account lock.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action. On `billing_operation_pending`, `error.details.operation_id` names the operation holding the lock: reconcile it, then retry. A Checkout already paid or expired no longer holds the lock."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingPortalInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/go-live": {
      "post": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingGoLive",
        "summary": "Take a team live (pricing v3)",
        "description": "Pricing v3 accounts only (409 go_live_v3_only otherwise). Marks the team live so it can stamp with its CSD (409 csd_required without one; 409 csd_test_only while it still has a SAT test CSD, as an agent sandbox does; 409 csd_invalid when the CSD is incomplete or was not saved by a validated upload; 409 csd_expired when it is expired or expires within a day; 409 manifest_required when the RFC has not signed the SAT manifest, which Prodigia needs to stamp). If the billing account has no usage subscription yet, returns a hosted Stripe Checkout handoff (status handoff_ready) to add a card; nothing is charged at checkout, and the team goes live with the one-time credit grant once the subscription is active. After Checkout, reconcile the operation: that also finishes the go-live when Stripe reports the subscription active or trialing. Otherwise the team is live immediately (status completed). Requires a billing-account administrator.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action. On `billing_operation_pending`, `error.details.operation_id` names the operation holding the lock: reconcile it, then retry. A Checkout already paid or expired no longer holds the lock."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingGoLiveInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/features": {
      "post": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingFeatureActivate",
        "summary": "Turn a feature on for a team (pricing v3)",
        "description": "Pricing v3 accounts only (409 features_v3_only). The team must be live, with its usage subscription (409 go_live_required). Adds the feature to that subscription without proration, so it shows on the same monthly invoice and is first charged at the next cut (free until then: `result.free_until`), at the catalog price plus IVA. Several teams of one account share one item whose quantity is the number of teams with the feature. 409 feature_unavailable for free, unpriced or other account-level features. When it completes, the feature is on for the team (`result.kind: feature`, `result.scope: team`). Repeating it for a team already counted changes nothing in Stripe. A feature the price list shows with `charged: false` is free: it is turned on with no subscription item (`result.charged: false`, `subscription_item_id: null`) and stays free while on. Requires a billing-account administrator.\n\n`feature: connect` turns gigstack Connect on for the whole billing account (`result.scope: billing_account`), from any team of it once the account has its usage subscription. One item of quantity 1, with no free period: it is prorated from today onto the next invoice (`result.prorated: true`, `result.free_until: null`). `result.connect` is the account's Connect state (`state` `on`). 409 feature_already_enabled when gigstack staff turned it on.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action. On `billing_operation_pending`, `error.details.operation_id` names the operation holding the lock: reconcile it, then retry. A Checkout already paid or expired no longer holds the lock."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingFeatureActivateInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/features/deactivate": {
      "post": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingFeatureDeactivate",
        "summary": "Turn a feature off for a team (pricing v3)",
        "description": "Pricing v3 accounts only (409 features_v3_only), for a feature turned on from the app (409 feature_not_subscribed otherwise). Takes the team's seat off the usage subscription now, without proration: nothing is refunded and nothing more is charged. The feature stays on until the next cut, which the period already billed covers (`result.kind: feature_off`, `result.ends_at`), and gigstack turns it off then. Turning it on again before that only puts the seat back. Repeating it returns the same end. A feature turned on free is off at once (`result.ends_at: null`). Requires a billing-account administrator.\n\n`feature: connect`: the item leaves the subscription now and Connect stays on for the whole account until the cut (`result.connect.state: ending`, `result.ends_at`); then operating on other teams, creating teams and keys scoped to several teams answer 403. Each team keeps being billed until it is deleted (`DELETE /teams/{id}` does not need Connect for a billing admin). A Connect turned on by gigstack staff cannot be turned off here (409 feature_not_subscribed).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action. On `billing_operation_pending`, `error.details.operation_id` names the operation holding the lock: reconcile it, then retry. A Checkout already paid or expired no longer holds the lock."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingFeatureActivateInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/operations/{operationId}": {
      "get": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingOperationGet",
        "summary": "Read billing operation",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Operation timestamps are milliseconds. failed and outcome_unknown are unsuccessful results even with HTTP 200. Never treat an unknown result as safe to repeat.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        }
      }
    },
    "/teams/{id}/billing/operations/{operationId}/reconcile": {
      "post": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingReconcile",
        "summary": "Reconcile billing operation",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Reads exact local/provider markers and never replays a write. Checkout can remain handoff_ready while the session is open. For a go-live whose Checkout completed, it also finishes the go-live once Stripe reports the v3 subscription active or trialing (pending teams with a valid CSD go live, the welcome credits are pinned once); read the team afterwards. Safe to repeat.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingReconcileInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/operations/{operationId}/cancel": {
      "post": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingCheckoutCancel",
        "summary": "Cancel an open account checkout",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Requires a NEW operation_id to expire the exact original checkout. The cancellation has its own durable readback. Confirmed expiry cancels the original and releases the lock. Already completed checkout cannot be cancelled and requires subscription management. Unknown expiry retains the cancellation lock; read/reconcile its new ID rather than replaying.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  },
                  "expired": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "11ea635b-3261-4f6c-b127-7a806b3db91c",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout.cancel",
                        "status": "completed",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": {
                          "kind": "checkout_cancellation",
                          "checkout_operation_id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                          "session_id": "cs_test_synthetic",
                          "status": "expired"
                        },
                        "error": null,
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action. On `billing_operation_pending`, `error.details.operation_id` names the operation holding the lock: reconcile it, then retry. A Checkout already paid or expired no longer holds the lock."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingCancelInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/billing/operations/{operationId}/resolve": {
      "post": {
        "tags": [
          "Account Billing"
        ],
        "operationId": "accountBillingResolve",
        "summary": "Release uncertain billing operation",
        "description": "Requires a verified Firebase or signed personal MCP user with current unblocked team membership. Team API keys and OAuth tokens cannot act as their creator. Writes and operation readback/recovery require a current billing-account administrator. Effects are shared by the billing account. Staging always uses sandbox billing; credential livemode does not choose billing environment. Requires a signed-in Firebase billing administrator and acknowledge_unconfirmed_effects true after ten minutes. Releases the lock for a NEW operation while preserving the previous unknown outcome. It does not cancel or undo provider effects.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inspect the returned state before reporting completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBillingOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                },
                "examples": {
                  "unknown": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "c03839fa-20e3-4b56-86ba-d41d92e67f19",
                        "team_id": "team_example",
                        "billing_account_id": "account_example",
                        "effect_scope": "billing_account_shared",
                        "provider_environment": "sandbox",
                        "action": "checkout",
                        "status": "outcome_unknown",
                        "created_at": 1791500000000,
                        "updated_at": 1791500000000,
                        "recovery_available_at": 1791500600000,
                        "result": null,
                        "error": {
                          "code": "billing_result_unconfirmed",
                          "message": "Read the original operation before retrying",
                          "retryable": false
                        },
                        "resolution": null
                      },
                      "timestamp": 1791500000000
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, cursor or fiscal fields."
          },
          "401": {
            "description": "Verified Firebase or personal MCP identity required."
          },
          "403": {
            "description": "Current membership or billing administrator authority required."
          },
          "404": {
            "description": "Team, plan, or operation not found in scope."
          },
          "409": {
            "description": "Account lock, changed operation parameters, ambiguous customer or incompatible plan state. Read current state before deciding the next action."
          },
          "502": {
            "description": "Billing result unconfirmed or upstream unavailable. Read the original operation ID before retrying."
          },
          "503": {
            "description": "Runtime project, application origin or internal service authorization is not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBillingResolveInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/customer-portal": {
      "get": {
        "tags": [
          "Account Branding"
        ],
        "operationId": "accountPortalGet",
        "summary": "Read customer portal registration",
        "description": "Requires a verified Firebase or signed personal MCP user and current unblocked membership or billing-administrator access, or a plain (unscoped) API key of exactly this team (claimed agent sandbox test keys included). A team key never acts as its creator. Effects are shared across live/test modes. Returns the canonical top-level registered slug, link and current can_register/can_rename permissions.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current persisted state or explicitly unsaved analysis.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountPortal"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, identifier, file or slug."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current administrator required for this action."
          },
          "404": {
            "description": "Team not found or inaccessible."
          },
          "409": {
            "description": "Slug taken, expected slug changed, rename not confirmed, or team pending deletion."
          },
          "500": {
            "description": "Operation or model analysis could not be confirmed. Read current state before retrying a write."
          }
        }
      },
      "put": {
        "tags": [
          "Account Branding"
        ],
        "operationId": "accountPortalSet",
        "summary": "Register or rename customer portal",
        "description": "Requires a verified Firebase or signed personal MCP user and current unblocked membership or billing-administrator access, or a plain (unscoped) API key of exactly this team (claimed agent sandbox test keys included). A team key never acts as its creator and is audited as the credential only. Effects are shared across live/test modes. Initial registration permits a current member or a team key; re-sending the current slug is a no-op for any of them. Rename requires a current signed- in administrator (never a team key), expected_slug matching current state and confirm_existing_links_change true. Renaming changes existing customer links. Slugs are 1-128 ASCII letters/digits and normalized lowercase; uniqueness is fenced across public and legacy web writers. No unregister operation is provided.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current persisted state or explicitly unsaved analysis.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountPortal"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, identifier, file or slug."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current administrator required for this action."
          },
          "404": {
            "description": "Team not found or inaccessible."
          },
          "409": {
            "description": "Slug taken, expected slug changed, rename not confirmed, or team pending deletion."
          },
          "500": {
            "description": "Operation or model analysis could not be confirmed. Read current state before retrying a write."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountPortalInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/brand": {
      "get": {
        "tags": [
          "Account Branding"
        ],
        "operationId": "accountBrandGet",
        "summary": "Read team branding",
        "description": "Requires a verified Firebase or signed personal MCP user and current unblocked membership or billing-administrator access. Team API/OAuth keys cannot impersonate their creator. Effects are shared across live/test modes. Returns canonical stored brand alias, colors, logo and voice; missing or cleared values are null.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current persisted state or explicitly unsaved analysis.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBrand"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, identifier, file or slug."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current administrator required for this action."
          },
          "404": {
            "description": "Team not found or inaccessible."
          },
          "409": {
            "description": "Slug taken, expected slug changed, rename not confirmed, or team pending deletion."
          },
          "500": {
            "description": "Operation or model analysis could not be confirmed. Read current state before retrying a write."
          }
        }
      },
      "patch": {
        "tags": [
          "Account Branding"
        ],
        "operationId": "accountBrandUpdate",
        "summary": "Update supplied team branding fields",
        "description": "Requires a verified Firebase or signed personal MCP user and current unblocked membership or billing-administrator access. Team API/OAuth keys cannot impersonate their creator. Effects are shared across live/test modes. Current administrator required. Supplied fields only; null or empty clears the leaf. Persisting voice is separate from analysis. Unknown fields rejected.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current persisted state or explicitly unsaved analysis.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBrand"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, identifier, file or slug."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current administrator required for this action."
          },
          "404": {
            "description": "Team not found or inaccessible."
          },
          "409": {
            "description": "Slug taken, expected slug changed, rename not confirmed, or team pending deletion."
          },
          "500": {
            "description": "Operation or model analysis could not be confirmed. Read current state before retrying a write."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBrandInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/brand/logo": {
      "post": {
        "tags": [
          "Account Branding"
        ],
        "operationId": "accountBrandLogoUpload",
        "summary": "Upload team logo",
        "description": "Requires a verified Firebase or signed personal MCP user and current unblocked membership or billing-administrator access. Team API/OAuth keys cannot impersonate their creator. Effects are shared across live/test modes. Current administrator checked before Storage and attachment. One PNG/JPEG file up to 10 MiB. Upload uses a unique team-owned private object and download-token URL. storage_cleanup retained means the previous object was left in storage; do not claim deletion.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current persisted state or explicitly unsaved analysis.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBrandLogoResult"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, identifier, file or slug."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current administrator required for this action."
          },
          "404": {
            "description": "Team not found or inaccessible."
          },
          "409": {
            "description": "Slug taken, expected slug changed, rename not confirmed, or team pending deletion."
          },
          "500": {
            "description": "Operation or model analysis could not be confirmed. Read current state before retrying a write."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Account Branding"
        ],
        "operationId": "accountBrandLogoDelete",
        "summary": "Remove team logo",
        "description": "Requires a verified Firebase or signed personal MCP user and current unblocked membership or billing-administrator access. Team API/OAuth keys cannot impersonate their creator. Effects are shared across live/test modes. Current administrator required. Clears stored logo and deletes only managed team files/logos objects. Historical or arbitrary paths remain in storage with storage_cleanup retained. An ambiguous commit never triggers unsafe deletion.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current persisted state or explicitly unsaved analysis.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBrandLogoResult"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, identifier, file or slug."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current administrator required for this action."
          },
          "404": {
            "description": "Team not found or inaccessible."
          },
          "409": {
            "description": "Slug taken, expected slug changed, rename not confirmed, or team pending deletion."
          },
          "500": {
            "description": "Operation or model analysis could not be confirmed. Read current state before retrying a write."
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {}
              }
            }
          }
        }
      }
    },
    "/teams/{id}/brand/analyze-voice": {
      "post": {
        "tags": [
          "Account Branding"
        ],
        "operationId": "accountBrandAnalyzeVoice",
        "summary": "Analyze website brand voice without saving",
        "description": "Requires a verified Firebase or signed personal MCP user and current unblocked membership or billing-administrator access. Team API/OAuth keys cannot impersonate their creator. Effects are shared across live/test modes. Current administrator required. Reads a public website through DNS/redirect SSRF guards and uses model compute. Never saves the result: saved is false. Review the analysis, then PATCH voice separately if desired.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current persisted state or explicitly unsaved analysis.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountBrandAnalysis"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, identifier, file or slug."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current administrator required for this action."
          },
          "404": {
            "description": "Team not found or inaccessible."
          },
          "409": {
            "description": "Slug taken, expected slug changed, rename not confirmed, or team pending deletion."
          },
          "500": {
            "description": "Operation or model analysis could not be confirmed. Read current state before retrying a write."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountBrandAnalysisInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integration-connection-sessions": {
      "post": {
        "tags": [
          "Provider Setup"
        ],
        "operationId": "integrationSetupCreate",
        "summary": "Create provider browser setup session",
        "description": "Requires a verified personal Firebase/MCP credential and current provider configuration authority. Also accepts a plain (unscoped) API key of exactly this team (claimed agent sandbox test keys included) to start, read, cancel and reconcile; the key never acts as its creator. A session started by a team key has no person until a signed-in member with the provider role (admin for NetSuite) opens completion_url and claims it; submit and resolve always require that signed-in Firebase browser. Test import mode does not isolate real provider accounts; read effect_scope and disclosures. Creates a session and completion_url for a signed-in person: it stays pending for 24 hours when started by a team API key (so the person can open the link later) and ten minutes when started by a person; expires_at reports the deadline. A claimed attempt keeps its ten-minute in-flight deadline. Read disclosures and credential_schema in the browser before consent. One pending/in-flight/unknown session per team/provider; an expired pending session is superseded by the next create. Initial providers only: Airtable, MercadoLibre, NetSuite and Zettle.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Setup session state, not a generic connection-success assertion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/IntegrationSetupSession"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, unsupported provider or missing explicit consent."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current provider configuration authority, entitlement or browser identity required."
          },
          "404": {
            "description": "Team or session inaccessible."
          },
          "409": {
            "description": "Setup locked, session changed, cannot cancel or recovery not yet available."
          },
          "503": {
            "description": "Explicit runtime environment or matching browser origin not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationSetupCreateInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integration-connection-sessions/{sessionId}": {
      "get": {
        "tags": [
          "Provider Setup"
        ],
        "operationId": "integrationSetupGet",
        "summary": "Read provider setup outcome",
        "description": "Requires a verified personal Firebase/MCP credential and current provider configuration authority. Also accepts a plain (unscoped) API key of exactly this team (claimed agent sandbox test keys included) to start, read, cancel and reconcile; the key never acts as its creator. A session started by a team key has no person until a signed-in member with the provider role (admin for NetSuite) opens completion_url and claims it; submit and resolve always require that signed-in Firebase browser. Test import mode does not isolate real provider accounts; read effect_scope and disclosures. Returns current status and allowlisted result, never stored secrets or OAuth state. completed confirms this attempt; pending/awaiting_oauth/outcome_unknown do not. result.connected false never proves a previous connection is disconnected.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Setup session state, not a generic connection-success assertion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/IntegrationSetupSession"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, unsupported provider or missing explicit consent."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current provider configuration authority, entitlement or browser identity required."
          },
          "404": {
            "description": "Team or session inaccessible."
          },
          "409": {
            "description": "Setup locked, session changed, cannot cancel or recovery not yet available."
          },
          "503": {
            "description": "Explicit runtime environment or matching browser origin not configured."
          }
        }
      },
      "delete": {
        "tags": [
          "Provider Setup"
        ],
        "operationId": "integrationSetupCancel",
        "summary": "Cancel pending provider setup",
        "description": "Requires a verified personal Firebase/MCP credential and current provider configuration authority. Also accepts a plain (unscoped) API key of exactly this team (claimed agent sandbox test keys included) to start, read, cancel and reconcile; the key never acts as its creator. A session started by a team key has no person until a signed-in member with the provider role (admin for NetSuite) opens completion_url and claims it; submit and resolve always require that signed-in Firebase browser. Test import mode does not isolate real provider accounts; read effect_scope and disclosures. Cancels pending/expired setup only. It never disconnects an established provider.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Setup session state, not a generic connection-success assertion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/IntegrationSetupSession"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, unsupported provider or missing explicit consent."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current provider configuration authority, entitlement or browser identity required."
          },
          "404": {
            "description": "Team or session inaccessible."
          },
          "409": {
            "description": "Setup locked, session changed, cannot cancel or recovery not yet available."
          },
          "503": {
            "description": "Explicit runtime environment or matching browser origin not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationSetupEmptyInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integration-connection-sessions/{sessionId}/reconcile": {
      "post": {
        "tags": [
          "Provider Setup"
        ],
        "operationId": "integrationSetupReconcile",
        "summary": "Reconcile an existing provider attempt",
        "description": "Requires a verified personal Firebase/MCP credential and current provider configuration authority. Also accepts a plain (unscoped) API key of exactly this team (claimed agent sandbox test keys included) to start, read, cancel and reconcile; the key never acts as its creator. A session started by a team key has no person until a signed-in member with the provider role (admin for NetSuite) opens completion_url and claims it; submit and resolve always require that signed-in Firebase browser. Test import mode does not isolate real provider accounts; read effect_scope and disclosures. Read-only exact-attempt reconciliation. No provider write or replay. Same-name/current provider state cannot prove this attempt completed.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Setup session state, not a generic connection-success assertion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/IntegrationSetupSession"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, unsupported provider or missing explicit consent."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current provider configuration authority, entitlement or browser identity required."
          },
          "404": {
            "description": "Team or session inaccessible."
          },
          "409": {
            "description": "Setup locked, session changed, cannot cancel or recovery not yet available."
          },
          "503": {
            "description": "Explicit runtime environment or matching browser origin not configured."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationSetupEmptyInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/email-domain": {
      "get": {
        "tags": [
          "Email Domain"
        ],
        "operationId": "emailDomainGet",
        "summary": "Read custom email domain and DNS state",
        "description": "Verified personal Firebase/MCP credential required. Team API/OAuth creator identity is not accepted. Scope is shared across live/test; staging may use the same configured SendGrid account. Test mode does not isolate provider effects. Current unblocked members can read domain/DNS state. configured does not mean DNS valid. Missing values are null. full_domain retains the historical subdomain@domain display format. ownership_status is verified or migration_required; unverified legacy records return can_manage false and require operator-verified migration.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current domain or durable operation state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountEmailDomainState"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, UUID or DNS name."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current unblocked administrator required."
          },
          "404": {
            "description": "Team or operation inaccessible."
          },
          "409": {
            "description": "Active operation, conflicting retry or recovery not yet available."
          },
          "503": {
            "description": "Explicit runtime environment or internal service identity unavailable."
          }
        }
      },
      "put": {
        "tags": [
          "Email Domain"
        ],
        "operationId": "emailDomainSet",
        "summary": "Set custom email domain",
        "description": "Verified personal Firebase/MCP credential required. Team API/OAuth creator identity is not accepted. Scope is shared across live/test; staging may use the same configured SendGrid account. Test mode does not isolate provider effects. Current administrator required. Caller saves UUIDv4 operation_id before submitting. Domain/subdomain normalized lowercase/IDNA with strict DNS labels. Replacing local configuration retains the previous provider domain and reports that fact. Completed setup can still require customer DNS changes. Set, validate, remove and reconciliation reject unverified legacy ownership with 409 domain_migration_required; the server does not migrate ownership from a client-writable provider identifier.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current domain or durable operation state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountEmailDomainOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, UUID or DNS name."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current unblocked administrator required."
          },
          "404": {
            "description": "Team or operation inaccessible."
          },
          "409": {
            "description": "Active operation, conflicting retry, recovery unavailable, or domain_migration_required for unverified provider ownership."
          },
          "503": {
            "description": "Explicit runtime environment or internal service identity unavailable."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountEmailDomainSetInput"
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Email Domain"
        ],
        "operationId": "emailDomainRemove",
        "summary": "Remove current custom email domain",
        "description": "Verified personal Firebase/MCP credential required. Team API/OAuth creator identity is not accepted. Scope is shared across live/test; staging may use the same configured SendGrid account. Test mode does not isolate provider effects. Current administrator required. New caller-saved UUIDv4 operation_id. Removes the exact stored provider domain and clears local configuration only after confirmation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current domain or durable operation state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountEmailDomainOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, UUID or DNS name."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current unblocked administrator required."
          },
          "404": {
            "description": "Team or operation inaccessible."
          },
          "409": {
            "description": "Active operation, conflicting retry, recovery unavailable, or domain_migration_required for unverified provider ownership."
          },
          "503": {
            "description": "Explicit runtime environment or internal service identity unavailable."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountEmailDomainOperationInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/email-domain/validate": {
      "post": {
        "tags": [
          "Email Domain"
        ],
        "operationId": "emailDomainValidate",
        "summary": "Validate custom email DNS",
        "description": "Verified personal Firebase/MCP credential required. Team API/OAuth creator identity is not accepted. Scope is shared across live/test; staging may use the same configured SendGrid account. Test mode does not isolate provider effects. Current administrator required. New caller-saved UUIDv4 operation_id. Invokes provider DNS validation; inspect result.domain.valid instead of equating completed operation with valid DNS.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current domain or durable operation state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountEmailDomainOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, UUID or DNS name."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current unblocked administrator required."
          },
          "404": {
            "description": "Team or operation inaccessible."
          },
          "409": {
            "description": "Active operation, conflicting retry, recovery unavailable, or domain_migration_required for unverified provider ownership."
          },
          "503": {
            "description": "Explicit runtime environment or internal service identity unavailable."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountEmailDomainOperationInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/email-domain/operations/{operationId}": {
      "get": {
        "tags": [
          "Email Domain"
        ],
        "operationId": "emailDomainOperationGet",
        "summary": "Read email-domain operation",
        "description": "Verified personal Firebase/MCP credential required. Team API/OAuth creator identity is not accepted. Scope is shared across live/test; staging may use the same configured SendGrid account. Test mode does not isolate provider effects. Current administrator required. Read original operation after timeout; failed/outcome_unknown are unsuccessful even with HTTP200.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current domain or durable operation state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountEmailDomainOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, UUID or DNS name."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current unblocked administrator required."
          },
          "404": {
            "description": "Team or operation inaccessible."
          },
          "409": {
            "description": "Active operation, conflicting retry or recovery not yet available."
          },
          "503": {
            "description": "Explicit runtime environment or internal service identity unavailable."
          }
        }
      }
    },
    "/teams/{id}/email-domain/operations/{operationId}/reconcile": {
      "post": {
        "tags": [
          "Email Domain"
        ],
        "operationId": "emailDomainOperationReconcile",
        "summary": "Reconcile email-domain operation without replay",
        "description": "Verified personal Firebase/MCP credential required. Team API/OAuth creator identity is not accepted. Scope is shared across live/test; staging may use the same configured SendGrid account. Test mode does not isolate provider effects. Current administrator required. Exact-attempt read-only reconciliation, no provider writes. Optional observation is current provider state with attempt_confirmed false, not proof of original attempt completion.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current domain or durable operation state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountEmailDomainReconciled"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, UUID or DNS name."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current unblocked administrator required."
          },
          "404": {
            "description": "Team or operation inaccessible."
          },
          "409": {
            "description": "Active operation, conflicting retry, recovery unavailable, or domain_migration_required for unverified provider ownership."
          },
          "503": {
            "description": "Explicit runtime environment or internal service identity unavailable."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountEmailDomainEmptyInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/email-domain/operations/{operationId}/resolve": {
      "post": {
        "tags": [
          "Email Domain"
        ],
        "operationId": "emailDomainOperationResolve",
        "summary": "Release unresolved email-domain operation",
        "description": "Verified personal Firebase/MCP credential required. Team API/OAuth creator identity is not accepted. Scope is shared across live/test; staging may use the same configured SendGrid account. Test mode does not isolate provider effects. Current administrator required, after ten minutes, with explicit acknowledge_unconfirmed_effects true. Releases the team lock for a NEW operation and preserves old unknown outcome. No rollback, provider cleanup or automatic retry.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current domain or durable operation state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountEmailDomainOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, UUID or DNS name."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current unblocked administrator required."
          },
          "404": {
            "description": "Team or operation inaccessible."
          },
          "409": {
            "description": "Active operation, conflicting retry, recovery unavailable, or domain_migration_required for unverified provider ownership."
          },
          "503": {
            "description": "Explicit runtime environment or internal service identity unavailable."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountEmailDomainResolveInput"
              }
            }
          }
        }
      }
    },
    "/users/me/account-approvals": {
      "post": {
        "operationId": "prepareAccountApproval",
        "tags": [
          "Account Approvals"
        ],
        "summary": "Prepare an account approval",
        "description": "Requires a verified personal Firebase or MCP identity and current action authority. Team API/OAuth keys cannot prepare approvals. Reads and cancellation bind the creator and originating MCP credential/mode. Browser confirmation rechecks current authority, credential validity and relevant account state. Preparation never issues a credential or accepts terms.\n\nPersist a UUIDv4 operation_id before the first call. After a timeout, repeat only the exact action, scope and normalized payload with the same ID; it retrieves the existing intent. Changed input returns 409 operation_conflict. API actions require an empty payload; MCP creation requires a trimmed name and explicit livemode. Open review_url in the authenticated browser to review and confirm. The selected MCP team is initial context, not a user-access security ceiling. Select an authorized current team with the team query parameter for authentication context; preparation should use the same team as body.team_id. This does not alter the originating credential or mode.\n\nMembership actions require the current team owner. Prepare a transfer with payload {new_owner_id}, or an admin promotion/addition with payload {member_id}. The browser reviews the frozen target identity, current role and account-wide consequences. Team membership is shared across production and test: requested_modes is empty for these actions, not a sandbox-only promise. The old owner remains an administrator after transfer; billing-account ownership is unchanged. Membership execution returns no credentials. Ordinary editor/viewer changes and permissions-only patches retain their existing direct routes and authority.\n\nAdministrator invitations require team.invitations.create_admin with team_id, or billing_account.invitations.create_admin with billing_account_id and no team_id. Payload must contain email and an explicit send_email boolean. Only the current canonical scope owner can approve; billing administrators or team owners do not substitute for the billing-account owner. Account-wide membership applies across live and test. To recover an existing unexpired pending admin invitation, supply existing_invitation_id and send_email:false. Review freezes the recipient address, scope, role, expiry and delivery choice. Completed means recorded, not emailed or joined. Read the receipt invitation through /users/me/account-invitations/{id} for delivery status. Missing canonical owner returns 409 canonical_owner_required and requires support recovery.\nManaged administrator creation uses managed_users.create_admin with team_id and an email/profile payload. Both canonical team and billing owners must be the initiating person. The first browser execution creates a disabled identity and its bootstrap records; a second fresh browser review is required to grant membership and activate it. No credentials or email are delivered. Unknown outcomes require reconcile, never another creation or activation attempt. Where owners differ, create a nonadmin managed user then use owner-reviewed promotion.\n\nManaged session actions use managed_users.issue_session or managed_users.revoke_sessions with team_id and exactly {user_id}. The current canonical owner of the billing account and every reachable team must be the initiating person. Private provenance and current Auth incarnation are required; historical API labels alone are insufficient. The frozen managed_session_change includes inherited grants and exact prior issuance/revocation attempts. Access spans live and test (requested_modes:[]), with no lifetime tenant ceiling. Only a separately reviewed browser action can issue access or revoke refresh tokens. Unknown attempts are never automatically replayed. A custom_token_expires_at deadline limits exchange, not a redeemed Firebase session. Revocation does not invalidate an outstanding custom token or necessarily already-issued ID tokens; prior unknown issuance remains unknown. Session preparation is disabled by default and always unavailable in production until an authoritative reverse-index strategy exists. Only explicit staging prototype configuration enables bounded projected scans. Unavailable or incomplete scope returns 503 without issuance. This contract does not establish deployment availability.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Safe approval state only. Cache-Control: no-store. Preparation is not issuance; GET and cancellation never return secrets or challenges.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountApproval"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "operation_id": "00000000-0000-4000-8000-000000000001",
                    "action": "api_keys.generate",
                    "team": {
                      "id": "team_example",
                      "legal_name": null,
                      "tax_id": null
                    },
                    "billing_account_id": "billing_example",
                    "payload": {},
                    "requested_modes": [
                      true,
                      false
                    ],
                    "effect_scope": "team_credentials",
                    "status": "pending",
                    "created_at": 1700000000000,
                    "expires_at": 1700000600000,
                    "completed_at": null,
                    "review_url": "https://app.gigstack.pro/account/approvals/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "can_cancel": true,
                    "disclosure_version": "credential-approval-v1",
                    "existing_key_ids": [],
                    "terms": null,
                    "receipt": null,
                    "error": null,
                    "membership_change": null,
                    "invitation_change": null,
                    "managed_identity_change": null,
                    "managed_identity_execution": null,
                    "managed_session_change": null,
                    "managed_session_execution": null
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown fields, or action-specific payload mismatch."
          },
          "401": {
            "description": "Verified personal identity required."
          },
          "403": {
            "description": "Current authority, origin credential and mode, or enabled account checks failed."
          },
          "404": {
            "description": "Approval or account not found in authorized scope."
          },
          "409": {
            "description": "operation_conflict, changed account state, expired/cancelled approval, or active key conflict."
          },
          "500": {
            "description": "Preparation or state read failed. Preserve the operation ID and exact input; do not generate a replacement as an automatic retry."
          },
          "503": {
            "description": "managed_session_scope_unavailable: the strategy is disabled or production is unsupported. managed_session_scope_limit: a staging limit+1 scan detected incomplete scope. No session is issued; do not retry with new operation IDs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/AccountApprovalInput"
                  },
                  {
                    "oneOf": [
                      {
                        "properties": {
                          "action": {
                            "enum": [
                              "api_keys.generate",
                              "api_keys.rotate"
                            ]
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {}
                          }
                        },
                        "required": [
                          "team_id"
                        ],
                        "not": {
                          "required": [
                            "billing_account_id"
                          ]
                        }
                      },
                      {
                        "properties": {
                          "action": {
                            "enum": [
                              "mcp_tokens.create"
                            ]
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64
                              },
                              "livemode": {
                                "type": "boolean"
                              },
                              "environments": {
                                "type": "string",
                                "enum": [
                                  "both"
                                ],
                                "description": "`both` mints a test and a live MCP token together and returns them as one connection key (`gsc_…`) in `secrets.mcp_token`; `livemode` must then be false (test is the default environment). Counts as two tokens against the limit of ten."
                              }
                            },
                            "required": [
                              "name",
                              "livemode"
                            ]
                          }
                        },
                        "required": [
                          "team_id"
                        ],
                        "not": {
                          "required": [
                            "billing_account_id"
                          ]
                        }
                      },
                      {
                        "properties": {
                          "action": {
                            "enum": [
                              "team.ownership.transfer"
                            ]
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "new_owner_id": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9_-]{1,128}$"
                              }
                            },
                            "required": [
                              "new_owner_id"
                            ]
                          }
                        },
                        "required": [
                          "team_id"
                        ],
                        "not": {
                          "required": [
                            "billing_account_id"
                          ]
                        }
                      },
                      {
                        "properties": {
                          "action": {
                            "enum": [
                              "team.members.promote_admin",
                              "team.members.add_admin"
                            ]
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "member_id": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9_-]{1,128}$"
                              }
                            },
                            "required": [
                              "member_id"
                            ]
                          }
                        },
                        "required": [
                          "team_id"
                        ],
                        "not": {
                          "required": [
                            "billing_account_id"
                          ]
                        }
                      },
                      {
                        "required": [
                          "team_id"
                        ],
                        "not": {
                          "required": [
                            "billing_account_id"
                          ]
                        },
                        "properties": {
                          "action": {
                            "enum": [
                              "team.invitations.create_admin"
                            ]
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "email": {
                                "type": "string",
                                "format": "email",
                                "maxLength": 320
                              },
                              "send_email": {
                                "type": "boolean"
                              },
                              "existing_invitation_id": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9_-]{1,128}$"
                              }
                            },
                            "required": [
                              "email",
                              "send_email"
                            ],
                            "not": {
                              "required": [
                                "existing_invitation_id"
                              ],
                              "properties": {
                                "send_email": {
                                  "enum": [
                                    true
                                  ]
                                }
                              }
                            }
                          }
                        }
                      },
                      {
                        "required": [
                          "billing_account_id"
                        ],
                        "not": {
                          "required": [
                            "team_id"
                          ]
                        },
                        "properties": {
                          "action": {
                            "enum": [
                              "billing_account.invitations.create_admin"
                            ]
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "email": {
                                "type": "string",
                                "format": "email",
                                "maxLength": 320
                              },
                              "send_email": {
                                "type": "boolean"
                              },
                              "existing_invitation_id": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9_-]{1,128}$"
                              }
                            },
                            "required": [
                              "email",
                              "send_email"
                            ],
                            "not": {
                              "required": [
                                "existing_invitation_id"
                              ],
                              "properties": {
                                "send_email": {
                                  "enum": [
                                    true
                                  ]
                                }
                              }
                            }
                          }
                        }
                      },
                      {
                        "required": [
                          "team_id"
                        ],
                        "not": {
                          "required": [
                            "billing_account_id"
                          ]
                        },
                        "properties": {
                          "action": {
                            "enum": [
                              "managed_users.create_admin"
                            ]
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "email": {
                                "type": "string",
                                "maxLength": 320,
                                "format": "email"
                              },
                              "first_name": {
                                "type": "string",
                                "nullable": true,
                                "maxLength": 100
                              },
                              "last_name": {
                                "type": "string",
                                "nullable": true,
                                "maxLength": 100
                              },
                              "phone": {
                                "type": "string",
                                "nullable": true,
                                "pattern": "^\\+[1-9]\\d{7,14}$"
                              },
                              "company_role": {
                                "type": "string",
                                "nullable": true,
                                "maxLength": 100
                              },
                              "address": {
                                "type": "object",
                                "additionalProperties": false,
                                "properties": {
                                  "country": {
                                    "type": "string",
                                    "nullable": true,
                                    "maxLength": 250
                                  },
                                  "street": {
                                    "type": "string",
                                    "nullable": true,
                                    "maxLength": 250
                                  },
                                  "zip": {
                                    "type": "string",
                                    "nullable": true,
                                    "maxLength": 250
                                  },
                                  "city": {
                                    "type": "string",
                                    "nullable": true,
                                    "maxLength": 250
                                  },
                                  "state": {
                                    "type": "string",
                                    "nullable": true,
                                    "maxLength": 250
                                  },
                                  "exterior": {
                                    "type": "string",
                                    "nullable": true,
                                    "maxLength": 250
                                  },
                                  "municipality": {
                                    "type": "string",
                                    "nullable": true,
                                    "maxLength": 250
                                  },
                                  "neighborhood": {
                                    "type": "string",
                                    "nullable": true,
                                    "maxLength": 250
                                  }
                                },
                                "nullable": true
                              }
                            },
                            "required": [
                              "email"
                            ]
                          }
                        }
                      },
                      {
                        "required": [
                          "team_id"
                        ],
                        "not": {
                          "required": [
                            "billing_account_id"
                          ]
                        },
                        "properties": {
                          "action": {
                            "enum": [
                              "managed_users.issue_session",
                              "managed_users.revoke_sessions"
                            ]
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "user_id": {
                                "type": "string",
                                "pattern": "^[A-Za-z0-9_-]{1,128}$"
                              }
                            },
                            "required": [
                              "user_id"
                            ]
                          }
                        }
                      }
                    ]
                  }
                ]
              },
              "examples": {
                "apiKeys": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000001",
                    "action": "api_keys.generate",
                    "team_id": "team_example",
                    "payload": {}
                  }
                },
                "mcpToken": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000001",
                    "action": "mcp_tokens.create",
                    "team_id": "team_example",
                    "payload": {
                      "name": "Local agent",
                      "livemode": false
                    }
                  }
                },
                "mcpConnectionKey": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000001",
                    "action": "mcp_tokens.create",
                    "team_id": "team_example",
                    "payload": {
                      "name": "Claude",
                      "livemode": false,
                      "environments": "both"
                    }
                  }
                },
                "transferOwnership": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000002",
                    "action": "team.ownership.transfer",
                    "team_id": "team_example",
                    "payload": {
                      "new_owner_id": "user_example"
                    }
                  }
                },
                "promoteAdmin": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000003",
                    "action": "team.members.promote_admin",
                    "team_id": "team_example",
                    "payload": {
                      "member_id": "user_example"
                    }
                  }
                },
                "teamAdminInvitation": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000004",
                    "action": "team.invitations.create_admin",
                    "team_id": "team_example",
                    "payload": {
                      "email": "member@example.com",
                      "send_email": false
                    }
                  }
                },
                "billingAdminInvitation": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000005",
                    "action": "billing_account.invitations.create_admin",
                    "billing_account_id": "billing_example",
                    "payload": {
                      "email": "member@example.com",
                      "send_email": true
                    }
                  }
                },
                "recoverAdminInvitation": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000006",
                    "action": "team.invitations.create_admin",
                    "team_id": "team_example",
                    "payload": {
                      "email": "member@example.com",
                      "send_email": false,
                      "existing_invitation_id": "inv_example"
                    }
                  }
                },
                "managedSession": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000007",
                    "action": "managed_users.issue_session",
                    "team_id": "team_example",
                    "payload": {
                      "user_id": "managed_example"
                    }
                  }
                },
                "revokeManagedSessions": {
                  "value": {
                    "operation_id": "00000000-0000-4000-8000-000000000008",
                    "action": "managed_users.revoke_sessions",
                    "team_id": "team_example",
                    "payload": {
                      "user_id": "managed_example"
                    }
                  }
                }
              }
            }
          },
          "required": true
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ]
      }
    },
    "/users/me/account-approvals/{id}": {
      "get": {
        "operationId": "getAccountApproval",
        "tags": [
          "Account Approvals"
        ],
        "summary": "Read an account approval",
        "description": "Requires a verified personal Firebase or MCP identity and current action authority. Team API/OAuth keys cannot prepare approvals. Reads and cancellation bind the creator and originating MCP credential/mode. Browser confirmation rechecks current authority, credential validity and relevant account state. Preparation never issues a credential or accepts terms.\n\nRead safe state and a metadata receipt. Pending requests need human browser confirmation. Completed requests never reveal secrets, even if their browser response was lost. There is no secret retrieval route. Select an authorized current team with the team query parameter for authentication context; preparation should use the same team as body.team_id. This does not alter the originating credential or mode.\n\nMembership actions require the current team owner. Prepare a transfer with payload {new_owner_id}, or an admin promotion/addition with payload {member_id}. The browser reviews the frozen target identity, current role and account-wide consequences. Team membership is shared across production and test: requested_modes is empty for these actions, not a sandbox-only promise. The old owner remains an administrator after transfer; billing-account ownership is unchanged. Membership execution returns no credentials. Ordinary editor/viewer changes and permissions-only patches retain their existing direct routes and authority. Managed session processing/unknown states are safe metadata only. A completed issued receipt does not prove delivery or sign-in. custom_token_expires_at is an exchange deadline, not session expiry. Read status after a lost response; never replay issuance or start a replacement solely because this deadline elapsed. A new intent requires a new explicit human review of the frozen prior attempts.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "required": true
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Safe approval state only. Cache-Control: no-store. Preparation is not issuance; GET and cancellation never return secrets or challenges.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountApproval"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "operation_id": "00000000-0000-4000-8000-000000000001",
                    "action": "managed_users.issue_session",
                    "team": {
                      "id": "team_example",
                      "legal_name": null,
                      "tax_id": null
                    },
                    "billing_account_id": "billing_example",
                    "payload": {
                      "user_id": "managed_example"
                    },
                    "requested_modes": [],
                    "effect_scope": "managed_session",
                    "status": "unknown",
                    "created_at": 1700000000000,
                    "expires_at": 1700000600000,
                    "completed_at": null,
                    "review_url": "https://app.gigstack.pro/account/approvals/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "can_cancel": false,
                    "disclosure_version": "managed-session-v1",
                    "existing_key_ids": [],
                    "terms": null,
                    "receipt": null,
                    "error": null,
                    "membership_change": null,
                    "invitation_change": null,
                    "managed_identity_change": null,
                    "managed_identity_execution": null,
                    "managed_session_change": {
                      "user_id": "managed_example",
                      "email": "managed@example.test",
                      "auth_creation_time": "2026-01-01T00:00:00Z",
                      "billing_account_id": "billing_example",
                      "teams": [
                        {
                          "id": "team_example",
                          "role": "editor"
                        }
                      ],
                      "billing_accounts": [
                        {
                          "id": "billing_example",
                          "role": "member"
                        }
                      ],
                      "delivery": "browser_once",
                      "session_scope": "firebase_identity",
                      "prior_attempts": []
                    },
                    "managed_session_execution": {
                      "phase": "unknown",
                      "attempted_at": 1700000000000,
                      "custom_token_expires_at": 1700003600000,
                      "delivery": "not_observable"
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown fields, or action-specific payload mismatch."
          },
          "401": {
            "description": "Verified personal identity required."
          },
          "403": {
            "description": "Current authority, origin credential and mode, or enabled account checks failed."
          },
          "404": {
            "description": "Approval or account not found in authorized scope."
          },
          "409": {
            "description": "operation_conflict, changed account state, expired/cancelled approval, or active key conflict."
          },
          "500": {
            "description": "Preparation or state read failed. Preserve the operation ID and exact input; do not generate a replacement as an automatic retry."
          }
        }
      },
      "delete": {
        "operationId": "cancelAccountApproval",
        "tags": [
          "Account Approvals"
        ],
        "summary": "Cancel a pending account approval",
        "description": "Requires a verified personal Firebase or MCP identity and current action authority. Team API/OAuth keys cannot prepare approvals. Reads and cancellation bind the creator and originating MCP credential/mode. Browser confirmation rechecks current authority, credential validity and relevant account state. Preparation never issues a credential or accepts terms.\n\nCancel this exact pending request. Cancellation neither revokes issued credentials nor reverses a completed action. No automatic replacement approval is created. Select an authorized current team with the team query parameter for authentication context; preparation should use the same team as body.team_id. This does not alter the originating credential or mode.\n\nMembership actions require the current team owner. Prepare a transfer with payload {new_owner_id}, or an admin promotion/addition with payload {member_id}. The browser reviews the frozen target identity, current role and account-wide consequences. Team membership is shared across production and test: requested_modes is empty for these actions, not a sandbox-only promise. The old owner remains an administrator after transfer; billing-account ownership is unchanged. Membership execution returns no credentials. Ordinary editor/viewer changes and permissions-only patches retain their existing direct routes and authority.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "required": true
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Safe approval state only. Cache-Control: no-store. Preparation is not issuance; GET and cancellation never return secrets or challenges.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountApproval"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "operation_id": "00000000-0000-4000-8000-000000000001",
                    "action": "api_keys.generate",
                    "team": {
                      "id": "team_example",
                      "legal_name": null,
                      "tax_id": null
                    },
                    "billing_account_id": "billing_example",
                    "payload": {},
                    "requested_modes": [
                      true,
                      false
                    ],
                    "effect_scope": "team_credentials",
                    "status": "cancelled",
                    "created_at": 1700000000000,
                    "expires_at": 1700000600000,
                    "completed_at": null,
                    "review_url": "https://app.gigstack.pro/account/approvals/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "can_cancel": false,
                    "disclosure_version": "credential-approval-v1",
                    "existing_key_ids": [],
                    "terms": null,
                    "receipt": null,
                    "error": null,
                    "membership_change": null,
                    "invitation_change": null,
                    "managed_identity_change": null,
                    "managed_identity_execution": null,
                    "managed_session_change": null,
                    "managed_session_execution": null
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown fields, or action-specific payload mismatch."
          },
          "401": {
            "description": "Verified personal identity required."
          },
          "403": {
            "description": "Current authority, origin credential and mode, or enabled account checks failed."
          },
          "404": {
            "description": "Approval or account not found in authorized scope."
          },
          "409": {
            "description": "operation_conflict, changed account state, expired/cancelled approval, or active key conflict."
          },
          "500": {
            "description": "Preparation or state read failed. Preserve the operation ID and exact input; do not generate a replacement as an automatic retry."
          }
        }
      }
    },
    "/users/me/account-invitations/{id}": {
      "get": {
        "operationId": "getAccountInvitation",
        "tags": [
          "Account Approvals"
        ],
        "summary": "Read an account invitation",
        "description": "Requires an active personal Firebase or MCP identity and the current canonical owner of the stored invitation scope. Scope comes from the stored invitation; caller cannot substitute a team or billing account. Configuration applies across live and test. approval_required reports missing proof metadata; a false value does not guarantee current approval validity. No token or acceptance URL is returned. Read delivery and revocation state separately from approval completion.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Safe invitation metadata only; no invitation token or acceptance URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountInvitation"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "inv_example",
                    "email": "member@example.com",
                    "role": "admin",
                    "team_id": "team_example",
                    "type": "team",
                    "billing_account_id": "billing_example",
                    "approval_required": false,
                    "status": "pending",
                    "created_at": 1700000000000,
                    "expires_at": 1700604800000,
                    "created_by": "user_owner",
                    "delivery": {
                      "status": "not_requested",
                      "attempted_at": null
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid invitation ID or body."
          },
          "401": {
            "description": "Active personal identity required."
          },
          "403": {
            "description": "Current canonical scope owner or completed approval required."
          },
          "404": {
            "description": "Invitation or scope not found."
          },
          "409": {
            "description": "Invitation is no longer pending, delivery_in_progress, or delivery_outcome_unknown. Inspect current state before taking another action."
          },
          "500": {
            "description": "Outcome is not established. Read invitation state; do not automatically repeat a resend."
          }
        }
      },
      "delete": {
        "operationId": "revokeAccountInvitation",
        "tags": [
          "Account Approvals"
        ],
        "summary": "Revoke an account invitation",
        "description": "Requires an active personal Firebase or MCP identity and the current canonical owner of the stored invitation scope. Scope comes from the stored invitation; caller cannot substitute a team or billing account. Configuration applies across live and test. approval_required reports missing proof metadata; a false value does not guarantee current approval validity. No token or acceptance URL is returned. Revokes a pending invitation. Repeating revocation returns the revoked state. Revocation does not retract an email already sent.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {}
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Safe invitation metadata only; no invitation token or acceptance URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountInvitation"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "inv_example",
                    "email": "member@example.com",
                    "role": "admin",
                    "team_id": "team_example",
                    "type": "team",
                    "billing_account_id": "billing_example",
                    "approval_required": false,
                    "status": "pending",
                    "created_at": 1700000000000,
                    "expires_at": 1700604800000,
                    "created_by": "user_owner",
                    "delivery": {
                      "status": "not_requested",
                      "attempted_at": null
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid invitation ID or body."
          },
          "401": {
            "description": "Active personal identity required."
          },
          "403": {
            "description": "Current canonical scope owner or completed approval required."
          },
          "404": {
            "description": "Invitation or scope not found."
          },
          "409": {
            "description": "Invitation is no longer pending, delivery_in_progress, or delivery_outcome_unknown. Inspect current state before taking another action."
          },
          "500": {
            "description": "Outcome is not established. Read invitation state; do not automatically repeat a resend."
          }
        }
      }
    },
    "/users/me/account-invitations/{id}/resend": {
      "post": {
        "operationId": "resendAccountInvitation",
        "tags": [
          "Account Approvals"
        ],
        "summary": "Resend an account invitation",
        "description": "Requires an active personal Firebase or MCP identity and the current canonical owner of the stored invitation scope. Scope comes from the stored invitation; caller cannot substitute a team or billing account. Configuration applies across live and test. approval_required reports missing proof metadata; a false value does not guarantee current approval validity. No token or acceptance URL is returned. An explicit send attempt. Completed administrator approval and its original owner authority are revalidated. Active five-minute delivery leases return delivery_in_progress. Failed, unknown or expired-lease delivery requires acknowledge_unconfirmed_delivery:true, which acknowledges possible duplicate email. Provider errors persist delivery.status=unknown. There is no automatic retry or lease takeover. Repeating a successful resend can send another email; inspect GET first.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "acknowledge_unconfirmed_delivery": {
                    "type": "boolean"
                  }
                }
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Safe invitation metadata only; no invitation token or acceptance URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountInvitation"
                    },
                    "timestamp": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "inv_example",
                    "email": "member@example.com",
                    "role": "admin",
                    "team_id": "team_example",
                    "type": "team",
                    "billing_account_id": "billing_example",
                    "approval_required": false,
                    "status": "pending",
                    "created_at": 1700000000000,
                    "expires_at": 1700604800000,
                    "created_by": "user_owner",
                    "delivery": {
                      "status": "not_requested",
                      "attempted_at": null
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid invitation ID or body."
          },
          "401": {
            "description": "Active personal identity required."
          },
          "403": {
            "description": "Current canonical scope owner or completed approval required."
          },
          "404": {
            "description": "Invitation or scope not found."
          },
          "409": {
            "description": "Invitation is no longer pending, delivery_in_progress, or delivery_outcome_unknown. Inspect current state before taking another action."
          },
          "500": {
            "description": "Outcome is not established. Read invitation state; do not automatically repeat a resend."
          }
        }
      }
    },
    "/teams/{id}/api-logs": {
      "get": {
        "operationId": "listApiLogs",
        "tags": [
          "Teams"
        ],
        "summary": "List API logs",
        "description": "Read retained logs for the authorized target team and credential mode. Firebase/MCP callers need current viewer-or-higher access; team API/OAuth credentials remain subject to target/sibling-team authorization. Signed API, MCP and OAuth credentials keep their issued mode. Output excludes raw bodies, headers, credentials, signed URLs and arbitrary provider text. This is a metadata/structure view, not a complete original-payload export. A filtered page can be empty while has_more is true. Continue with next_cursor until null; cursor includes timestamp and ID so deleting the anchor does not restart pagination. Unsupported stored cursor timestamps return log_pagination_unavailable rather than falsely claiming the history ended. Logs use the same teamId field as the web API-log view; legacy records using only another team field are not silently merged. Existing retention applies. The browser may supply livemode only with an independently reverified Firebase ID token; the selector must equal the authenticated request mode. Signed API, MCP and OAuth credentials cannot use this selector, even to repeat their own mode. API details additionally retain allowlisted fiscal amounts, flags and catalog values with explicit redaction/truncation markers. Requests revalidate the original credential and current account/team/mode after asynchronous reads.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "description": "Maximum rows scanned, not number of matching results."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Use next_cursor with the same team, credential mode and all filters, including limit."
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Inclusive epoch milliseconds."
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Inclusive epoch milliseconds."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "2xx",
                "3xx",
                "4xx",
                "5xx"
              ]
            },
            "description": "Result filter applied within each bounded scan."
          },
          {
            "name": "method",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "GET",
                "POST",
                "PUT",
                "PATCH",
                "DELETE",
                "OPTIONS",
                "HEAD"
              ]
            },
            "description": "HTTP method."
          },
          {
            "name": "endpoint",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^/[A-Za-z0-9_/:.-]{0,255}$"
            },
            "description": "Prefix of the redacted route; variable segments are :id. Current and historical leading-slash forms are normalized."
          },
          {
            "name": "livemode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Firebase browser transport only: select live (true) or test (false) history. The original Firebase token is reverified, including revocation, and the selected mode must match its authenticated request context. Omit for API, MCP and OAuth credentials; they use their issued mode."
          }
        ],
        "responses": {
          "200": {
            "description": "Redacted log metadata and documented pagination/detail structure.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AccountApiLog"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "scanned_count": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "livemode": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "has_more",
                    "next_cursor",
                    "scanned_count",
                    "livemode"
                  ]
                },
                "example": {
                  "success": true,
                  "data": [
                    {
                      "id": "log_example",
                      "timestamp": 1700000000000,
                      "method": "POST",
                      "endpoint": "/v2/invoices/:id",
                      "status_code": 400,
                      "livemode": false,
                      "redaction": "metadata_and_body_shape",
                      "team_id": "team_example"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null,
                  "scanned_count": 1,
                  "livemode": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid ID, mode_required, invalid_filter or invalid_cursor. Filters must be single values; duplicate/array values are rejected."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Current team read authority is missing, blocked, inactive or ambiguous."
          },
          "404": {
            "description": "Team/log not found in the authorized team and credential mode."
          },
          "409": {
            "description": "log_pagination_unavailable: a stored cursor timestamp cannot safely be used. This does not prove the history is exhausted. mode_changed: the Firebase browser selector differs from the authenticated request mode. Refresh context before reading again."
          },
          "500": {
            "description": "log_read_failed. No provider action was attempted."
          }
        }
      }
    },
    "/teams/{id}/api-logs/{logId}": {
      "get": {
        "operationId": "getApiLog",
        "tags": [
          "Teams"
        ],
        "summary": "Read one API log",
        "description": "Read retained logs for the authorized target team and credential mode. Firebase/MCP callers need current viewer-or-higher access; team API/OAuth credentials remain subject to target/sibling-team authorization. Signed API, MCP and OAuth credentials keep their issued mode. Output excludes raw bodies, headers, credentials, signed URLs and arbitrary provider text. This is a metadata/structure view, not a complete original-payload export. Detail returns bounded body shapes; arbitrary values and property names are redacted. Logs use the same teamId field as the web API-log view; legacy records using only another team field are not silently merged. Existing retention applies. The browser may supply livemode only with an independently reverified Firebase ID token; the selector must equal the authenticated request mode. Signed API, MCP and OAuth credentials cannot use this selector, even to repeat their own mode. API details additionally retain allowlisted fiscal amounts, flags and catalog values with explicit redaction/truncation markers. Requests revalidate the original credential and current account/team/mode after asynchronous reads.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "logId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "livemode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Firebase browser transport only: select live (true) or test (false) history. The original Firebase token is reverified, including revocation, and the selected mode must match its authenticated request context. Omit for API, MCP and OAuth credentials; they use their issued mode."
          }
        ],
        "responses": {
          "200": {
            "description": "Redacted log metadata and documented pagination/detail structure.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountApiLogDetail"
                    },
                    "timestamp": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "log_example",
                    "timestamp": 1700000000000,
                    "method": "POST",
                    "endpoint": "/v2/invoices/:id",
                    "status_code": 400,
                    "livemode": false,
                    "redaction": "metadata_and_body_shape",
                    "request_shape": {
                      "data": "[string]"
                    },
                    "query_shape": {},
                    "response_shape": {
                      "error": "[string]"
                    },
                    "team_id": "team_example",
                    "payload_redaction": "allowlisted_structured_values_v1",
                    "request_payload": {
                      "items": [
                        {
                          "quantity": 1,
                          "unit_price": 100
                        }
                      ],
                      "client": {
                        "document_type": "31",
                        "legal_name": {
                          "$redacted": "value_not_allowlisted"
                        }
                      }
                    },
                    "query_payload": null,
                    "response_payload": {
                      "success": true,
                      "data": {
                        "total": 116,
                        "currency": "COP"
                      }
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid ID, mode_required, invalid_filter or invalid_cursor. Filters must be single values; duplicate/array values are rejected."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Current team read authority is missing, blocked, inactive or ambiguous."
          },
          "404": {
            "description": "Team/log not found in the authorized team and credential mode."
          },
          "409": {
            "description": "log_pagination_unavailable: a stored cursor timestamp cannot safely be used. This does not prove the history is exhausted. mode_changed: the Firebase browser selector differs from the authenticated request mode. Refresh context before reading again."
          },
          "500": {
            "description": "log_read_failed. No provider action was attempted."
          }
        }
      }
    },
    "/teams/{id}/webhook-deliveries": {
      "get": {
        "operationId": "listWebhookDeliveryLogs",
        "tags": [
          "Teams"
        ],
        "summary": "List webhook delivery logs",
        "description": "Read retained logs for the authorized target team and credential mode. Firebase/MCP callers need current viewer-or-higher access; team API/OAuth credentials remain subject to target/sibling-team authorization. Signed API, MCP and OAuth credentials keep their issued mode. Output excludes raw bodies, headers, credentials, signed URLs and arbitrary provider text. This is a metadata/structure view, not a complete original-payload export. A filtered page can be empty while has_more is true. Continue with next_cursor until null; cursor includes timestamp and ID so deleting the anchor does not restart pagination. Unsupported stored cursor timestamps return log_pagination_unavailable rather than falsely claiming the history ended. These are the customer-visible logs records, not internal delivery-attempt IDs. pending does not mean delivered; retry_requested is only a request flag. Rows without a provable matching payload mode are excluded. This route never sends or retries a webhook. Retrying means another delivery attempt may run; it is not a terminal failure. resource_id is a historical selection hint, and every resource action checks current access. Attempts and latency can be null for older records. Receiver text and destination URLs are never returned. The browser may supply livemode only with an independently reverified Firebase ID token; the selector must equal the authenticated request mode. Signed API, MCP and OAuth credentials cannot use this selector, even to repeat their own mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "description": "Maximum rows scanned, not number of matching results."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Use next_cursor with the same team, credential mode and all filters, including limit."
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Inclusive epoch milliseconds."
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Inclusive epoch milliseconds."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "processing",
                "retrying",
                "succeeded",
                "failed",
                "unknown"
              ]
            },
            "description": "Result filter applied within each bounded scan."
          },
          {
            "name": "event",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "payment.created",
                "payment.updated",
                "payment.succeeded",
                "payment.canceled",
                "payment.deleted",
                "payment.upcoming_due_date",
                "invoice.created",
                "invoice.canceled",
                "invoice.failed",
                "invoice_batch.completed",
                "payment_batch.completed",
                "receipt.created",
                "receipt.updated",
                "receipt.completed",
                "receipt.deleted",
                "customer.created",
                "customer.updated",
                "customer.deleted",
                "service.created",
                "service.updated",
                "service.deleted",
                "sat.invoice.synced",
                "teams.created",
                "teams.sat.completed",
                "teams.stripe.completed",
                "teams.openpay.completed",
                "teams.sat.manifest.signed"
              ]
            },
            "description": "Webhook event name, for example invoice.created."
          },
          {
            "name": "livemode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Firebase browser transport only: select live (true) or test (false) history. The original Firebase token is reverified, including revocation, and the selected mode must match its authenticated request context. Omit for API, MCP and OAuth credentials; they use their issued mode."
          }
        ],
        "responses": {
          "200": {
            "description": "Redacted log metadata and documented pagination/detail structure.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AccountWebhookDeliveryLog"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "scanned_count": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "livemode": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "has_more",
                    "next_cursor",
                    "scanned_count",
                    "livemode"
                  ]
                },
                "example": {
                  "success": true,
                  "data": [
                    {
                      "id": "log_example",
                      "timestamp": 1700000000000,
                      "updated_at": null,
                      "webhook_id": "wh_example",
                      "event": "invoice.created",
                      "livemode": false,
                      "status": "pending",
                      "response_code": null,
                      "retry_requested": false,
                      "redaction": "metadata_and_body_shape",
                      "resource_id": null,
                      "attempts": null,
                      "latency_ms": null,
                      "error_category": null
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null,
                  "scanned_count": 1,
                  "livemode": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid ID, mode_required, invalid_filter or invalid_cursor. Filters must be single values; duplicate/array values are rejected."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Current team read authority is missing, blocked, inactive or ambiguous."
          },
          "404": {
            "description": "Team/log not found in the authorized team and credential mode."
          },
          "409": {
            "description": "log_pagination_unavailable: a stored cursor timestamp cannot safely be used. This does not prove the history is exhausted. mode_changed: the Firebase browser selector differs from the authenticated request mode. Refresh context before reading again."
          },
          "500": {
            "description": "log_read_failed. No provider action was attempted."
          }
        }
      }
    },
    "/teams/{id}/webhook-deliveries/{logId}": {
      "get": {
        "operationId": "getWebhookDeliveryLog",
        "tags": [
          "Teams"
        ],
        "summary": "Read one webhook delivery log",
        "description": "Read retained logs for the authorized target team and credential mode. Firebase/MCP callers need current viewer-or-higher access; team API/OAuth credentials remain subject to target/sibling-team authorization. Signed API, MCP and OAuth credentials keep their issued mode. Output excludes raw bodies, headers, credentials, signed URLs and arbitrary provider text. This is a metadata/structure view, not a complete original-payload export. Detail returns bounded body shapes; arbitrary values and property names are redacted. These are the customer-visible logs records, not internal delivery-attempt IDs. pending does not mean delivered; retry_requested is only a request flag. Rows without a provable matching payload mode are excluded. This route never sends or retries a webhook. Retrying means another delivery attempt may run; it is not a terminal failure. resource_id is a historical selection hint, and every resource action checks current access. Attempts and latency can be null for older records. Receiver text and destination URLs are never returned. The browser may supply livemode only with an independently reverified Firebase ID token; the selector must equal the authenticated request mode. Signed API, MCP and OAuth credentials cannot use this selector, even to repeat their own mode.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "logId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          },
          {
            "name": "livemode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "Firebase browser transport only: select live (true) or test (false) history. The original Firebase token is reverified, including revocation, and the selected mode must match its authenticated request context. Omit for API, MCP and OAuth credentials; they use their issued mode."
          }
        ],
        "responses": {
          "200": {
            "description": "Redacted log metadata and documented pagination/detail structure.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountWebhookDeliveryLogDetail"
                    },
                    "timestamp": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "log_example",
                    "timestamp": 1700000000000,
                    "updated_at": null,
                    "webhook_id": "wh_example",
                    "event": "invoice.created",
                    "livemode": false,
                    "status": "pending",
                    "response_code": null,
                    "retry_requested": false,
                    "redaction": "metadata_and_body_shape",
                    "payload_shape": {
                      "data": {
                        "id": "[string]"
                      }
                    },
                    "response_shape": null,
                    "resource_id": null,
                    "attempts": null,
                    "latency_ms": null,
                    "error_category": null
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid ID, mode_required, invalid_filter or invalid_cursor. Filters must be single values; duplicate/array values are rejected."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Current team read authority is missing, blocked, inactive or ambiguous."
          },
          "404": {
            "description": "Team/log not found in the authorized team and credential mode."
          },
          "409": {
            "description": "log_pagination_unavailable: a stored cursor timestamp cannot safely be used. This does not prove the history is exhausted. mode_changed: the Firebase browser selector differs from the authenticated request mode. Refresh context before reading again."
          },
          "500": {
            "description": "log_read_failed. No provider action was attempted."
          }
        }
      }
    },
    "/users/me/account-approvals/{id}/reconcile": {
      "post": {
        "operationId": "reconcileAccountApproval",
        "tags": [
          "Account Approvals"
        ],
        "summary": "Reconcile managed identity provisioning evidence",
        "description": "Using the originating personal Firebase/MCP credential, read Auth by the reserved user ID and update this managed creation receipt. No creation, activation, membership grant, email or credential issuance occurs. Missing identity after a timeout remains unknown. activation_required means return to the private browser for a new review; only completed confirms enabled Auth and the recorded membership grant. API/OAuth team keys cannot use this personal account operation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "required": true
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Safe approval state only. Cache-Control: no-store. Preparation is not issuance; GET and cancellation never return secrets or challenges.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountApproval"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "operation_id": "00000000-0000-4000-8000-000000000001",
                    "action": "managed_users.create_admin",
                    "team": {
                      "id": "team_example",
                      "legal_name": null,
                      "tax_id": null
                    },
                    "billing_account_id": "billing_example",
                    "payload": {
                      "email": "managed@example.test"
                    },
                    "requested_modes": [],
                    "effect_scope": "managed_identity",
                    "status": "activation_required",
                    "created_at": 1700000000000,
                    "expires_at": 1700000600000,
                    "completed_at": null,
                    "review_url": "https://app.gigstack.pro/account/approvals/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                    "can_cancel": false,
                    "disclosure_version": "managed-identity-v1",
                    "existing_key_ids": [],
                    "terms": null,
                    "receipt": null,
                    "error": null,
                    "membership_change": null,
                    "invitation_change": null,
                    "managed_identity_change": {
                      "user_id": "managed_example",
                      "email": "managed@example.test",
                      "profile": {},
                      "team_id": "team_example",
                      "billing_account_id": "billing_example",
                      "role": "admin",
                      "auto_join": true,
                      "credential_delivery": "none",
                      "initial_auth_state": "disabled",
                      "bootstrap_effects": [
                        "profile_initialization",
                        "membership_usage_initialization",
                        "support_identity_claims"
                      ]
                    },
                    "managed_identity_execution": {
                      "phase": "activation_required",
                      "auth_state": "disabled",
                      "membership_granted": false,
                      "started_at": 1700000000000,
                      "updated_at": 1700000000100,
                      "error_code": null
                    },
                    "managed_session_change": null,
                    "managed_session_execution": null
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid input, unknown fields, or action-specific payload mismatch."
          },
          "401": {
            "description": "Verified personal identity required."
          },
          "403": {
            "description": "Current authority, origin credential and mode, or enabled account checks failed."
          },
          "404": {
            "description": "Approval or account not found in authorized scope."
          },
          "409": {
            "description": "operation_conflict, changed account state, expired/cancelled approval, or active key conflict."
          },
          "500": {
            "description": "Preparation or state read failed. Preserve the operation ID and exact input; do not generate a replacement as an automatic retry."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {}
              },
              "example": {}
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/airtable/bases": {
      "get": {
        "operationId": "listAirtableBases",
        "tags": [
          "Account Integrations"
        ],
        "summary": "List Airtable bases",
        "description": "Requires a verified Firebase person or signed personal MCP credential and current team authority. Airtable uses one shared production connection; gigstack live/test mode controls imported payment records. This reads scoped metadata; it does not change provider state. HTTP 200 may contain processing or outcome_unknown; inspect data.status. See the Airtable lifecycle guide for pagination, shared effects and reviewed OAuth recovery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped result. Operation status determines completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AirtableBases"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "data": [],
                    "has_more": false,
                    "next_cursor": null,
                    "effect_scope": "shared_connection",
                    "provider_environment": "production"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, mapping, mode assertion or acknowledgment."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current account, membership or provider authority refused."
          },
          "404": {
            "description": "Resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode changed, setup/lifecycle locked, or uncertain recovery requires review."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Result unknown. Keep operation_id and read the receipt; do not automatically repeat provider effects."
          }
        }
      }
    },
    "/teams/{id}/integrations/airtable/bases/{baseId}/tables": {
      "get": {
        "operationId": "listAirtableTables",
        "tags": [
          "Account Integrations"
        ],
        "summary": "List Airtable tables and fields",
        "description": "Requires a verified Firebase person or signed personal MCP credential and current team authority. Airtable uses one shared production connection; gigstack live/test mode controls imported payment records. This reads scoped metadata; it does not change provider state. HTTP 200 may contain processing or outcome_unknown; inspect data.status. See the Airtable lifecycle guide for pagination, shared effects and reviewed OAuth recovery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "baseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped result. Operation status determines completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AirtableTables"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "data": [],
                    "has_more": false,
                    "next_cursor": null,
                    "effect_scope": "shared_connection",
                    "provider_environment": "production"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, mapping, mode assertion or acknowledgment."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current account, membership or provider authority refused."
          },
          "404": {
            "description": "Resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode changed, setup/lifecycle locked, or uncertain recovery requires review."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Result unknown. Keep operation_id and read the receipt; do not automatically repeat provider effects."
          }
        }
      }
    },
    "/teams/{id}/integrations/airtable/webhooks": {
      "get": {
        "operationId": "listAirtableWebhooks",
        "tags": [
          "Account Integrations"
        ],
        "summary": "List Airtable import mappings",
        "description": "Requires a verified Firebase person or signed personal MCP credential and current team authority. Airtable uses one shared production connection; gigstack live/test mode controls imported payment records. This reads scoped metadata; it does not change provider state. HTTP 200 may contain processing or outcome_unknown; inspect data.status. See the Airtable lifecycle guide for pagination, shared effects and reviewed OAuth recovery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "mode",
                "shared"
              ]
            }
          },
          {
            "name": "base_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 250,
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "expired",
                "disabled"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped result. Operation status determines completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AirtableWebhooks"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "data": [],
                    "has_more": false,
                    "next_cursor": null,
                    "scope": "mode",
                    "livemode": false,
                    "provider_environment": "production",
                    "can_manage": true,
                    "can_recover_registration": true,
                    "blocking_operation_id": null,
                    "connection": {
                      "connected": false,
                      "restricted": false,
                      "recovery_session_id": null,
                      "identity_verification": null,
                      "effect_scope": "shared_connection",
                      "oauth_credentials_retained": true
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, mapping, mode assertion or acknowledgment."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current account, membership or provider authority refused."
          },
          "404": {
            "description": "Resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode changed, setup/lifecycle locked, or uncertain recovery requires review."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Result unknown. Keep operation_id and read the receipt; do not automatically repeat provider effects."
          }
        }
      },
      "post": {
        "operationId": "registerAirtableWebhook",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Register an Airtable import mapping",
        "description": "Requires a verified Firebase person or signed personal MCP credential and current team authority. Airtable uses one shared production connection; gigstack live/test mode controls imported payment records. Persist operation_id before sending. Repeat only the same UUID and identical confirmed payload; uncertain attempts are never automatically replayed. expected_livemode asserts the reviewed mode and cannot override authenticated mode.  HTTP 200 may contain processing or outcome_unknown; inspect data.status. See the Airtable lifecycle guide for pagination, shared effects and reviewed OAuth recovery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped result. Operation status determines completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AirtableOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "11111111-1111-4111-8111-111111111111",
                    "team_id": "team_example",
                    "action": "disconnect",
                    "livemode": false,
                    "effect_scope": "shared_connection",
                    "status": "outcome_unknown",
                    "created_at": 1700000000000,
                    "updated_at": 1700000000000,
                    "snapshot_complete": true,
                    "target_count": 1,
                    "processed_count": 1,
                    "local_disabled_count": 1,
                    "remote_deleted_count": 0,
                    "unknown_count": 1,
                    "error_code": null,
                    "webhook_id": null,
                    "recovery_operation_id": null,
                    "cleanup_operation_id": null,
                    "recovery_session_id": null,
                    "provider_environment": "production",
                    "oauth_credentials_retained": true,
                    "continuation_required": false,
                    "partial_cleanup": true,
                    "targets": {
                      "data": [
                        {
                          "id": "ach_example",
                          "base_id": "app_example",
                          "local_disabled": true,
                          "remote_status": "unknown"
                        }
                      ],
                      "has_more": false,
                      "next_cursor": null
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, mapping, mode assertion or acknowledgment."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current account, membership or provider authority refused."
          },
          "404": {
            "description": "Resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode changed, setup/lifecycle locked, or uncertain recovery requires review."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Result unknown. Keep operation_id and read the receipt; do not automatically repeat provider effects."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AirtableRegisterInput"
              },
              "example": {
                "operation_id": "11111111-1111-4111-8111-111111111111",
                "expected_livemode": false,
                "base_id": "app_example",
                "table_id": "tbl_example",
                "field_map": {
                  "amount": "fld_amount"
                },
                "confirmed": true
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/airtable/bases/{baseId}/webhooks/remote": {
      "get": {
        "operationId": "listAirtableRemoteWebhooks",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Inspect remote Airtable webhooks",
        "description": "Requires a verified Firebase person or signed personal MCP credential and current team authority. Airtable uses one shared production connection; gigstack live/test mode controls imported payment records. This reads scoped metadata; it does not change provider state. HTTP 200 may contain processing or outcome_unknown; inspect data.status. See the Airtable lifecycle guide for pagination, shared effects and reviewed OAuth recovery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "baseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped result. Operation status determines completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AirtableRemoteWebhooks"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "data": [],
                    "has_more": false,
                    "next_cursor": null,
                    "effect_scope": "shared_connection",
                    "provider_environment": "production"
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, mapping, mode assertion or acknowledgment."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current account, membership or provider authority refused."
          },
          "404": {
            "description": "Resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode changed, setup/lifecycle locked, or uncertain recovery requires review."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Result unknown. Keep operation_id and read the receipt; do not automatically repeat provider effects."
          }
        }
      }
    },
    "/teams/{id}/integrations/airtable/webhooks/{webhookId}": {
      "delete": {
        "operationId": "unregisterAirtableWebhook",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Remove an Airtable import mapping",
        "description": "Requires a verified Firebase person or signed personal MCP credential and current team authority. Airtable uses one shared production connection; gigstack live/test mode controls imported payment records. Persist operation_id before sending. Repeat only the same UUID and identical confirmed payload; uncertain attempts are never automatically replayed. expected_livemode asserts the reviewed mode and cannot override authenticated mode.  HTTP 200 may contain processing or outcome_unknown; inspect data.status. See the Airtable lifecycle guide for pagination, shared effects and reviewed OAuth recovery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "webhookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped result. Operation status determines completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AirtableOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "11111111-1111-4111-8111-111111111111",
                    "team_id": "team_example",
                    "action": "disconnect",
                    "livemode": false,
                    "effect_scope": "shared_connection",
                    "status": "outcome_unknown",
                    "created_at": 1700000000000,
                    "updated_at": 1700000000000,
                    "snapshot_complete": true,
                    "target_count": 1,
                    "processed_count": 1,
                    "local_disabled_count": 1,
                    "remote_deleted_count": 0,
                    "unknown_count": 1,
                    "error_code": null,
                    "webhook_id": null,
                    "recovery_operation_id": null,
                    "cleanup_operation_id": null,
                    "recovery_session_id": null,
                    "provider_environment": "production",
                    "oauth_credentials_retained": true,
                    "continuation_required": false,
                    "partial_cleanup": true,
                    "targets": {
                      "data": [
                        {
                          "id": "ach_example",
                          "base_id": "app_example",
                          "local_disabled": true,
                          "remote_status": "unknown"
                        }
                      ],
                      "has_more": false,
                      "next_cursor": null
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, mapping, mode assertion or acknowledgment."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current account, membership or provider authority refused."
          },
          "404": {
            "description": "Resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode changed, setup/lifecycle locked, or uncertain recovery requires review."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Result unknown. Keep operation_id and read the receipt; do not automatically repeat provider effects."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AirtableUnregisterInput"
              },
              "example": {
                "operation_id": "11111111-1111-4111-8111-111111111111",
                "expected_livemode": false,
                "confirmed": true
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/airtable/disconnect": {
      "post": {
        "operationId": "disconnectAirtable",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Disconnect Airtable imports across modes",
        "description": "Requires a verified Firebase person or signed personal MCP credential and current team authority. Airtable uses one shared production connection; gigstack live/test mode controls imported payment records. Persist operation_id before sending. Repeat only the same UUID and identical confirmed payload; uncertain attempts are never automatically replayed. expected_livemode asserts the reviewed mode and cannot override authenticated mode.  HTTP 200 may contain processing or outcome_unknown; inspect data.status. See the Airtable lifecycle guide for pagination, shared effects and reviewed OAuth recovery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped result. Operation status determines completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AirtableOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "11111111-1111-4111-8111-111111111111",
                    "team_id": "team_example",
                    "action": "disconnect",
                    "livemode": false,
                    "effect_scope": "shared_connection",
                    "status": "outcome_unknown",
                    "created_at": 1700000000000,
                    "updated_at": 1700000000000,
                    "snapshot_complete": true,
                    "target_count": 1,
                    "processed_count": 1,
                    "local_disabled_count": 1,
                    "remote_deleted_count": 0,
                    "unknown_count": 1,
                    "error_code": null,
                    "webhook_id": null,
                    "recovery_operation_id": null,
                    "cleanup_operation_id": null,
                    "recovery_session_id": null,
                    "provider_environment": "production",
                    "oauth_credentials_retained": true,
                    "continuation_required": false,
                    "partial_cleanup": true,
                    "targets": {
                      "data": [
                        {
                          "id": "ach_example",
                          "base_id": "app_example",
                          "local_disabled": true,
                          "remote_status": "unknown"
                        }
                      ],
                      "has_more": false,
                      "next_cursor": null
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, mapping, mode assertion or acknowledgment."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current account, membership or provider authority refused."
          },
          "404": {
            "description": "Resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode changed, setup/lifecycle locked, or uncertain recovery requires review."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Result unknown. Keep operation_id and read the receipt; do not automatically repeat provider effects."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AirtableDisconnectInput"
              },
              "example": {
                "operation_id": "11111111-1111-4111-8111-111111111111",
                "expected_livemode": false,
                "confirmed": true,
                "acknowledge_shared_connection": true
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/airtable/operations/{operationId}": {
      "get": {
        "operationId": "getAirtableOperation",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Read an Airtable operation",
        "description": "Requires a verified Firebase person or signed personal MCP credential and current team authority. Airtable uses one shared production connection; gigstack live/test mode controls imported payment records. This reads scoped metadata; it does not change provider state. HTTP 200 may contain processing or outcome_unknown; inspect data.status. See the Airtable lifecycle guide for pagination, shared effects and reviewed OAuth recovery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 250,
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 8192
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped result. Operation status determines completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AirtableOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "11111111-1111-4111-8111-111111111111",
                    "team_id": "team_example",
                    "action": "disconnect",
                    "livemode": false,
                    "effect_scope": "shared_connection",
                    "status": "outcome_unknown",
                    "created_at": 1700000000000,
                    "updated_at": 1700000000000,
                    "snapshot_complete": true,
                    "target_count": 1,
                    "processed_count": 1,
                    "local_disabled_count": 1,
                    "remote_deleted_count": 0,
                    "unknown_count": 1,
                    "error_code": null,
                    "webhook_id": null,
                    "recovery_operation_id": null,
                    "cleanup_operation_id": null,
                    "recovery_session_id": null,
                    "provider_environment": "production",
                    "oauth_credentials_retained": true,
                    "continuation_required": false,
                    "partial_cleanup": true,
                    "targets": {
                      "data": [
                        {
                          "id": "ach_example",
                          "base_id": "app_example",
                          "local_disabled": true,
                          "remote_status": "unknown"
                        }
                      ],
                      "has_more": false,
                      "next_cursor": null
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, mapping, mode assertion or acknowledgment."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current account, membership or provider authority refused."
          },
          "404": {
            "description": "Resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode changed, setup/lifecycle locked, or uncertain recovery requires review."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Result unknown. Keep operation_id and read the receipt; do not automatically repeat provider effects."
          }
        }
      }
    },
    "/teams/{id}/integrations/airtable/operations/{operationId}/reconcile": {
      "post": {
        "operationId": "reconcileAirtableOperation",
        "tags": [
          "Account Integrations"
        ],
        "summary": "Reconcile Airtable without replaying writes",
        "description": "Requires a verified Firebase person or signed personal MCP credential and current team authority. Airtable uses one shared production connection; gigstack live/test mode controls imported payment records. Reconciliation reads provider evidence without repeating an uncertain POST or DELETE. HTTP 200 may contain processing or outcome_unknown; inspect data.status. See the Airtable lifecycle guide for pagination, shared effects and reviewed OAuth recovery.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 250,
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe scoped result. Operation status determines completion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/AirtableOperation"
                    },
                    "timestamp": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ]
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "11111111-1111-4111-8111-111111111111",
                    "team_id": "team_example",
                    "action": "disconnect",
                    "livemode": false,
                    "effect_scope": "shared_connection",
                    "status": "outcome_unknown",
                    "created_at": 1700000000000,
                    "updated_at": 1700000000000,
                    "snapshot_complete": true,
                    "target_count": 1,
                    "processed_count": 1,
                    "local_disabled_count": 1,
                    "remote_deleted_count": 0,
                    "unknown_count": 1,
                    "error_code": null,
                    "webhook_id": null,
                    "recovery_operation_id": null,
                    "cleanup_operation_id": null,
                    "recovery_session_id": null,
                    "provider_environment": "production",
                    "oauth_credentials_retained": true,
                    "continuation_required": false,
                    "partial_cleanup": true,
                    "targets": {
                      "data": [
                        {
                          "id": "ach_example",
                          "base_id": "app_example",
                          "local_disabled": true,
                          "remote_status": "unknown"
                        }
                      ],
                      "has_more": false,
                      "next_cursor": null
                    }
                  },
                  "timestamp": 1700000000000
                }
              }
            }
          },
          "400": {
            "description": "Invalid identifier, mapping, mode assertion or acknowledgment."
          },
          "401": {
            "description": "Verified personal credential required."
          },
          "403": {
            "description": "Current account, membership or provider authority refused."
          },
          "404": {
            "description": "Resource unavailable in authorized scope."
          },
          "409": {
            "description": "Mode changed, setup/lifecycle locked, or uncertain recovery requires review."
          },
          "503": {
            "description": "Runtime environment or internal service authorization unavailable."
          },
          "504": {
            "description": "Result unknown. Keep operation_id and read the receipt; do not automatically repeat provider effects."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AirtableReconcileInput"
              },
              "example": {}
            }
          }
        }
      }
    },
    "/payments/links": {
      "get": {
        "operationId": "listPaymentLinks",
        "tags": [
          "Payments"
        ],
        "summary": "List reusable payment links",
        "description": "Reusable link configuration is a mode-specific resource. Saving does not create a payment, charge a provider, or stamp an invoice. Later payer use can create payments and run configured invoice automation. Current original credentials and payment-module authority are checked. Source/offline contract; no live provider validation is claimed. Follow next_cursor with identical filters. Database predicates exclude opposite/unknown modes.",
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Selected authorized team; Firebase must match current authenticated team. Mode is current persisted preference or immutable credential mode."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "deleted"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Bounded timestamp/document-ID page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data",
                    "has_more",
                    "next_cursor",
                    "livemode"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PaymentLink"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "livemode": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid typed input, identifier or cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Original credential could not be verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Current role, credential scope or account denied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource or operation is not readable in selected team/mode.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Mode, revision, deleted resource or operation conflict; review current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Outcome unconfirmed. Read the same operation UUID; no automatic write replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createPaymentLink",
        "tags": [
          "Payments"
        ],
        "summary": "Create reusable payment link",
        "description": "Reusable link configuration is a mode-specific resource. Saving does not create a payment, charge a provider, or stamp an invoice. Later payer use can create payments and run configured invoice automation. Current original credentials and payment-module authority are checked. Source/offline contract; no live provider validation is claimed. Persist operation_id before the request. expected_livemode asserts the selected mode; it does not override it. Update/delete require the latest GET revision. Lost acknowledgments are recovered by reading the same operation. Delete is allowed after use and retains generated payment/invoice history. Short URL may be null; use the full URL.",
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Selected authorized team; Firebase must match current authenticated team. Mode is current persisted preference or immutable credential mode."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentLinkCreateInput"
              },
              "example": {
                "operation_id": "11111111-1111-4111-8111-111111111111",
                "expected_livemode": false,
                "currency": "MXN",
                "items": [
                  {
                    "total": 100,
                    "quantity": 1
                  }
                ],
                "custom_method_types": [
                  {
                    "id": "bank"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Atomic durable receipt and current link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLinkMutationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid typed input, identifier or cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Original credential could not be verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Current role, credential scope or account denied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource or operation is not readable in selected team/mode.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Mode, revision, deleted resource or operation conflict; review current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Outcome unconfirmed. Read the same operation UUID; no automatic write replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/payments/links/{linkId}": {
      "patch": {
        "operationId": "updatePaymentLink",
        "tags": [
          "Payments"
        ],
        "summary": "Update reusable payment link",
        "description": "Reusable link configuration is a mode-specific resource. Saving does not create a payment, charge a provider, or stamp an invoice. Later payer use can create payments and run configured invoice automation. Current original credentials and payment-module authority are checked. Source/offline contract; no live provider validation is claimed. Persist operation_id before the request. expected_livemode asserts the selected mode; it does not override it. Update/delete require the latest GET revision. Lost acknowledgments are recovered by reading the same operation. Delete is allowed after use and retains generated payment/invoice history. Short URL may be null; use the full URL.",
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Selected authorized team; Firebase must match current authenticated team. Mode is current persisted preference or immutable credential mode."
          },
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^plink[A-Za-z0-9_-]{1,155}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentLinkUpdateInput"
              },
              "example": {
                "operation_id": "11111111-1111-4111-8111-111111111111",
                "expected_livemode": false,
                "expected_revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                "description": "Updated reference"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Atomic durable receipt and current link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLinkMutationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid typed input, identifier or cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Original credential could not be verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Current role, credential scope or account denied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource or operation is not readable in selected team/mode.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Mode, revision, deleted resource or operation conflict; review current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Outcome unconfirmed. Read the same operation UUID; no automatic write replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deletePaymentLink",
        "tags": [
          "Payments"
        ],
        "summary": "Delete reusable payment link",
        "description": "Reusable link configuration is a mode-specific resource. Saving does not create a payment, charge a provider, or stamp an invoice. Later payer use can create payments and run configured invoice automation. Current original credentials and payment-module authority are checked. Source/offline contract; no live provider validation is claimed. Persist operation_id before the request. expected_livemode asserts the selected mode; it does not override it. Update/delete require the latest GET revision. Lost acknowledgments are recovered by reading the same operation. Delete is allowed after use and retains generated payment/invoice history. Short URL may be null; use the full URL.",
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Selected authorized team; Firebase must match current authenticated team. Mode is current persisted preference or immutable credential mode."
          },
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^plink[A-Za-z0-9_-]{1,155}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentLinkDeleteInput"
              },
              "example": {
                "operation_id": "11111111-1111-4111-8111-111111111111",
                "expected_livemode": false,
                "expected_revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Atomic durable receipt and current link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLinkMutationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid typed input, identifier or cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Original credential could not be verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Current role, credential scope or account denied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource or operation is not readable in selected team/mode.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Mode, revision, deleted resource or operation conflict; review current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Outcome unconfirmed. Read the same operation UUID; no automatic write replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "getPaymentLink",
        "tags": [
          "Payments"
        ],
        "summary": "Get reusable payment link",
        "description": "Reusable link configuration is a mode-specific resource. Saving does not create a payment, charge a provider, or stamp an invoice. Later payer use can create payments and run configured invoice automation. Current original credentials and payment-module authority are checked. Source/offline contract; no live provider validation is claimed. The actual Firestore document ID identifies historical rows, not a stored id alias.",
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Selected authorized team; Firebase must match current authenticated team. Mode is current persisted preference or immutable credential mode."
          },
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^plink[A-Za-z0-9_-]{1,155}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current link and revision.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/PaymentLink"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid typed input, identifier or cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Original credential could not be verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Current role, credential scope or account denied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource or operation is not readable in selected team/mode.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Mode, revision, deleted resource or operation conflict; review current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Outcome unconfirmed. Read the same operation UUID; no automatic write replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/payments/links/{linkId}/history/{resourceType}/{resourceId}": {
      "get": {
        "operationId": "getPaymentLinkHistoryV2",
        "tags": [
          "Payments"
        ],
        "summary": "Read an authorized historical invoice or receipt",
        "description": "Independently rechecks the original credential, current payment-link and target module viewing permission, exact document ID, team and current mode. Saved and nested references grant no authority. Current runtime project bucket and exact invoice/files-subdocument storage path are enforced. No document generation, download-token minting, Storage metadata writes or provider writes occur. Current authority and document/files snapshots are checked again after read-only Storage awaits. Returns the entire mapped public invoice/receipt DTO. files.pdf and files.xml are existing safe HTTPS URLs or null; file_status separately reports existing file availability. Ordinary history reads never return inline bytes.",
        "parameters": [
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resourceType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "invoices",
                "receipts"
              ]
            }
          },
          {
            "name": "resourceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Full independently authorized public document projection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLinkHistoryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid kind or identifier"
          },
          "403": {
            "description": "Current credential or module permission refused"
          },
          "404": {
            "description": "Missing or out-of-scope link, saved reference or resource"
          },
          "409": {
            "description": "Resource, files or selected mode changed while reading"
          },
          "503": {
            "description": "Read unconfirmed"
          }
        }
      }
    },
    "/payments/links/{linkId}/history/{resourceType}/{resourceId}/files/{fileType}": {
      "get": {
        "operationId": "getPaymentLinkHistoryFileV2",
        "tags": [
          "Payments"
        ],
        "summary": "Read an existing authorized historical PDF or XML",
        "description": "Independently rechecks the original credential, current payment-link and target module viewing permission, exact document ID, team and current mode. Saved and nested references grant no authority. Current runtime project bucket and exact invoice/files-subdocument storage path are enforced. No document generation, download-token minting, Storage metadata writes or provider writes occur. Current authority and document/files snapshots are checked again after read-only Storage awaits. Returns existing inline/offloaded bytes only on this explicit file-read request; absent or unreadable files return available:false and file:null without retry. Filename and MIME type are pinned to the authorized resource and selected PDF/XML kind.",
        "parameters": [
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resourceType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "invoices",
                "receipts"
              ]
            }
          },
          {
            "name": "resourceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "fileType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "pdf",
                "xml"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/TeamParameter"
          }
        ],
        "responses": {
          "200": {
            "description": "Existing authorized file bytes or truthful unavailability",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLinkHistoryFileResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid kind or identifier"
          },
          "403": {
            "description": "Current credential or module permission refused"
          },
          "404": {
            "description": "Missing or out-of-scope link, saved reference or resource"
          },
          "409": {
            "description": "Resource, files or selected mode changed while reading"
          },
          "503": {
            "description": "Read unconfirmed"
          }
        }
      }
    },
    "/payments/links/operations/{operationId}": {
      "get": {
        "operationId": "getPaymentLinkOperation",
        "tags": [
          "Payments"
        ],
        "summary": "Read payment-link operation",
        "description": "Reusable link configuration is a mode-specific resource. Saving does not create a payment, charge a provider, or stamp an invoice. Later payer use can create payments and run configured invoice automation. Current original credentials and payment-module authority are checked. Source/offline contract; no live provider validation is claimed. Read-only recovery. Historical completed receipt can have data:null. A 404 only means no matching receipt is currently readable; it is not proof a concurrent request never ran.",
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Selected authorized team; Firebase must match current authenticated team. Mode is current persisted preference or immutable credential mode."
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Committed operation with current resource.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLinkMutationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid typed input, identifier or cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Original credential could not be verified.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Current role, credential scope or account denied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource or operation is not readable in selected team/mode.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Mode, revision, deleted resource or operation conflict; review current state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Outcome unconfirmed. Read the same operation UUID; no automatic write replay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/payments/{paymentId}/reminders": {
      "get": {
        "operationId": "getPaymentReminderConfiguration",
        "tags": [
          "Payments"
        ],
        "summary": "Get payment reminder configuration",
        "description": "Canonical payment-mode reminder lifecycle. Config revision and durable UUID prevent stale writes. Read the same UUID after an uncertain result. Reconciliation is read-only; continuation consumes only untouched queue steps. Unknown consumed sends require freshly reviewed browser supersession, explicit duplicate-email acknowledgement and no active send claim. Empty reminders can enable team defaults. Production test data mode can send real email. Source implementation; no deployment or live email proof.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current reminder configuration, operation receipt or private review; email acceptance does not prove delivery."
          },
          "409": {
            "description": "Stale revision, generation, scope or active occurrence; review current state."
          },
          "503": {
            "description": "Outcome unconfirmed; read durable UUID, do not replay attempted effects."
          }
        }
      },
      "put": {
        "operationId": "replacePaymentReminderConfiguration",
        "tags": [
          "Payments"
        ],
        "summary": "Replace payment reminder configuration",
        "description": "Canonical payment-mode reminder lifecycle. Config revision and durable UUID prevent stale writes. Read the same UUID after an uncertain result. Reconciliation is read-only; continuation consumes only untouched queue steps. Unknown consumed sends require freshly reviewed browser supersession, explicit duplicate-email acknowledgement and no active send claim. Empty reminders can enable team defaults. Production test data mode can send real email. Source implementation; no deployment or live email proof.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current reminder configuration, operation receipt or private review; email acceptance does not prove delivery."
          },
          "409": {
            "description": "Stale revision, generation, scope or active occurrence; review current state."
          },
          "503": {
            "description": "Outcome unconfirmed; read durable UUID, do not replay attempted effects."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentReminderConfigurationRequest"
              }
            }
          }
        }
      }
    },
    "/payments/{paymentId}/reminder-operations/{operationId}": {
      "get": {
        "operationId": "getPaymentReminderOperation",
        "tags": [
          "Payments"
        ],
        "summary": "Get a payment reminder operation",
        "description": "Canonical payment-mode reminder lifecycle. Config revision and durable UUID prevent stale writes. Read the same UUID after an uncertain result. Reconciliation is read-only; continuation consumes only untouched queue steps. Unknown consumed sends require freshly reviewed browser supersession, explicit duplicate-email acknowledgement and no active send claim. Empty reminders can enable team defaults. Production test data mode can send real email. Source implementation; no deployment or live email proof.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current reminder configuration, operation receipt or private review; email acceptance does not prove delivery."
          },
          "409": {
            "description": "Stale revision, generation, scope or active occurrence; review current state."
          },
          "503": {
            "description": "Outcome unconfirmed; read durable UUID, do not replay attempted effects."
          }
        }
      }
    },
    "/payments/{paymentId}/reminder-operations/{operationId}/reconcile": {
      "post": {
        "operationId": "reconcilePaymentReminderOperation",
        "tags": [
          "Payments"
        ],
        "summary": "Reconcile a payment reminder operation",
        "description": "Canonical payment-mode reminder lifecycle. Config revision and durable UUID prevent stale writes. Read the same UUID after an uncertain result. Reconciliation is read-only; continuation consumes only untouched queue steps. Unknown consumed sends require freshly reviewed browser supersession, explicit duplicate-email acknowledgement and no active send claim. Empty reminders can enable team defaults. Production test data mode can send real email. Source implementation; no deployment or live email proof.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current reminder configuration, operation receipt or private review; email acceptance does not prove delivery."
          },
          "409": {
            "description": "Stale revision, generation, scope or active occurrence; review current state."
          },
          "503": {
            "description": "Outcome unconfirmed; read durable UUID, do not replay attempted effects."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentReminderEmptyRequest"
              }
            }
          }
        }
      }
    },
    "/payments/{paymentId}/reminder-operations/{operationId}/continue": {
      "post": {
        "operationId": "continuePaymentReminderOperation",
        "tags": [
          "Payments"
        ],
        "summary": "Continue a payment reminder operation",
        "description": "Canonical payment-mode reminder lifecycle. Config revision and durable UUID prevent stale writes. Read the same UUID after an uncertain result. Reconciliation is read-only; continuation consumes only untouched queue steps. Unknown consumed sends require freshly reviewed browser supersession, explicit duplicate-email acknowledgement and no active send claim. Empty reminders can enable team defaults. Production test data mode can send real email. Source implementation; no deployment or live email proof.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current reminder configuration, operation receipt or private review; email acceptance does not prove delivery."
          },
          "409": {
            "description": "Stale revision, generation, scope or active occurrence; review current state."
          },
          "503": {
            "description": "Outcome unconfirmed; read durable UUID, do not replay attempted effects."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentReminderEmptyRequest"
              }
            }
          }
        }
      }
    },
    "/payments/{paymentId}/reminder-recoveries": {
      "post": {
        "operationId": "preparePaymentReminderRecovery",
        "tags": [
          "Payments"
        ],
        "summary": "Prepare a payment reminder recovery",
        "description": "Canonical payment-mode reminder lifecycle. Config revision and durable UUID prevent stale writes. Read the same UUID after an uncertain result. Reconciliation is read-only; continuation consumes only untouched queue steps. Unknown consumed sends require freshly reviewed browser supersession, explicit duplicate-email acknowledgement and no active send claim. Empty reminders can enable team defaults. Production test data mode can send real email. Source implementation; no deployment or live email proof.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          },
          {
            "name": "team",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,160}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current reminder configuration, operation receipt or private review; email acceptance does not prove delivery."
          },
          "409": {
            "description": "Stale revision, generation, scope or active occurrence; review current state."
          },
          "503": {
            "description": "Outcome unconfirmed; read durable UUID, do not replay attempted effects."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentReminderRecoveryRequest"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/stripe/standard-accounts": {
      "post": {
        "operationId": "createStripeStandardAccountV2",
        "tags": [
          "Teams"
        ],
        "summary": "Create a Standard Stripe account",
        "description": "Creates one selected-mode Standard account with the current team email and team ID. Save operation UUID before transport. Current original machine grant or personal editor; historical key creator is never impersonated. Returns safe account ID and browser handoff, never a provider account object or onboarding URL. Unknown provider results require read-only UUID reconciliation and never automatic account creation replay. Creating the account does not establish onboarding or charges activation.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current safe metadata or explicitly private ephemeral browser result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "operation_id",
                        "team_id",
                        "billing_account_id",
                        "requester",
                        "method",
                        "livemode",
                        "expected_generation",
                        "generation",
                        "status",
                        "created_at",
                        "expires_at",
                        "updated_at",
                        "steps",
                        "provider_revocation",
                        "provider_webhook_removal",
                        "browser_handoff_url"
                      ],
                      "properties": {
                        "operation_id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
                        },
                        "team_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "billing_account_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9_-]{1,128}$"
                        },
                        "requester": {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "credential_kind",
                            "source_team_id",
                            "credential_id",
                            "person_id"
                          ],
                          "properties": {
                            "credential_kind": {
                              "type": "string",
                              "enum": [
                                "firebase",
                                "mcp",
                                "api",
                                "oauth"
                              ]
                            },
                            "source_team_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$"
                            },
                            "credential_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$",
                              "nullable": true
                            },
                            "person_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9_-]{1,128}$",
                              "nullable": true
                            }
                          }
                        },
                        "method": {
                          "type": "string",
                          "enum": [
                            "oauth",
                            "manual_key",
                            "connect_webhooks",
                            "account_onboarding",
                            "platform_account_create"
                          ]
                        },
                        "livemode": {
                          "type": "boolean"
                        },
                        "expected_generation": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "generation": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991,
                          "nullable": true
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending",
                            "expired",
                            "awaiting_oauth",
                            "in_progress",
                            "completed",
                            "outcome_unknown",
                            "cancelled"
                          ]
                        },
                        "created_at": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "expires_at": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "updated_at": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "steps": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "oauth_exchange": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "account_verification": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "manual_webhook": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "connect_webhook": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "transfer_webhook": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "credential_commit": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "account_onboarding_link": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            },
                            "platform_account_create": {
                              "type": "object",
                              "additionalProperties": false,
                              "required": [
                                "status"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "not_started",
                                    "in_progress",
                                    "completed",
                                    "outcome_unknown"
                                  ]
                                },
                                "remote_id": {
                                  "type": "string",
                                  "maxLength": 160
                                }
                              }
                            }
                          }
                        },
                        "provider_revocation": {
                          "type": "string",
                          "enum": [
                            "not_performed"
                          ]
                        },
                        "provider_webhook_removal": {
                          "type": "string",
                          "enum": [
                            "not_performed"
                          ]
                        },
                        "browser_handoff_url": {
                          "type": "string",
                          "format": "uri"
                        },
                        "provider_account_id": {
                          "type": "string",
                          "pattern": "^acct_[A-Za-z0-9]+$"
                        }
                      }
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Unknown result: read saved UUID; never replay a provider effect.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StripeStandardAccountCreateInput"
              }
            }
          }
        }
      }
    },
    "/teams/{id}/integrations/stripe/standard-accounts/{accountId}/refresh": {
      "post": {
        "operationId": "refreshStripeStandardAccountV2",
        "tags": [
          "Teams"
        ],
        "summary": "Refresh Standard Stripe account activation",
        "description": "Read-only provider account retrieval with exact current team, owner, billing account, selected mode, account ID and expected generation checked before and after asynchronous work. Persists safe activation flags only. A browser return from onboarding is not proof of completion. This does not create or replay provider effects.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^acct_[A-Za-z0-9]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current safe metadata or explicitly private ephemeral browser result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/StripeStandardAccountActivation"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Invalid, stale or unreviewed current original scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Unknown result: read saved UUID; never replay a provider effect.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StandardErrorResponse"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StripeStandardAccountRefreshInput"
              }
            }
          }
        }
      }
    },
    "/users/me/scoped-api-keys": {
      "get": {
        "operationId": "listScopedApiKeys",
        "tags": [
          "Api Keys"
        ],
        "summary": "List named and legacy key metadata",
        "description": "[Small working example](/guides/api-credentials)\n\n**Integration note:** Requires current personal identity and billing-account/per-key ACLs. API keys never manage credentials. Safe metadata only; private browser approval alone reveals a new secret once. Legacy keys remain valid; no forced migration. See [API credentials](/guides/api-credentials).\n\nRequires an active personal Firebase/MCP identity and current billing-account/per-key management authority. API keys, including legacy keys, cannot manage credentials. Readback contains metadata only, never stored tokens, secret-once browser execution data or reviewer challenges. Follow non-null next_cursor including empty pages. New routes do not inherit key scope permission.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "billing_account_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string",
                  "description": "Numeric string accepted by the request validator."
                }
              ],
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe server-authorized lifecycle result; does not reveal a credential.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ScopedApiKeyList"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Personal identity/current management authority required; machine credentials are refused."
          },
          "404": {
            "description": "Key is absent or outside current management authority."
          },
          "409": {
            "description": "State or immutable operation intent changed; read the saved operation/key before further action."
          }
        }
      }
    },
    "/users/me/scoped-api-keys/policy": {
      "get": {
        "operationId": "getScopedApiKeyPolicy",
        "tags": [
          "Api Keys"
        ],
        "summary": "Read eligible exact team/action/manager policy",
        "description": "[Small working example](/guides/api-credentials)\n\n**Integration note:** Requires current personal identity and billing-account/per-key ACLs. API keys never manage credentials. Safe metadata only; private browser approval alone reveals a new secret once. Legacy keys remain valid; no forced migration. See [API credentials](/guides/api-credentials).\n\nRequires an active personal Firebase/MCP identity and current billing-account/per-key management authority. API keys, including legacy keys, cannot manage credentials. Readback contains metadata only, never stored tokens, secret-once browser execution data or reviewer challenges. Follow non-null next_cursor including empty pages. New routes do not inherit key scope permission.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "billing_account_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe server-authorized lifecycle result; does not reveal a credential.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ScopedApiKeyPolicy"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Personal identity/current management authority required; machine credentials are refused."
          },
          "404": {
            "description": "Key is absent or outside current management authority."
          },
          "409": {
            "description": "State or immutable operation intent changed; read the saved operation/key before further action."
          }
        }
      }
    },
    "/users/me/scoped-api-keys/{keyId}": {
      "get": {
        "operationId": "getScopedApiKey",
        "tags": [
          "Api Keys"
        ],
        "summary": "Read exact safe key scope and permissions",
        "description": "[Small working example](/guides/api-credentials)\n\n**Integration note:** Requires current personal identity and billing-account/per-key ACLs. API keys never manage credentials. Safe metadata only; private browser approval alone reveals a new secret once. Legacy keys remain valid; no forced migration. See [API credentials](/guides/api-credentials).\n\nRequires an active personal Firebase/MCP identity and current billing-account/per-key management authority. API keys, including legacy keys, cannot manage credentials. Readback contains metadata only, never stored tokens, secret-once browser execution data or reviewer challenges. Follow non-null next_cursor including empty pages. New routes do not inherit key scope permission.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "billing_account_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe server-authorized lifecycle result; does not reveal a credential.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ScopedApiKeyMetadata"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Personal identity/current management authority required; machine credentials are refused."
          },
          "404": {
            "description": "Key is absent or outside current management authority."
          },
          "409": {
            "description": "State or immutable operation intent changed; read the saved operation/key before further action."
          }
        }
      },
      "delete": {
        "operationId": "revokeScopedApiKey",
        "tags": [
          "Api Keys"
        ],
        "summary": "Revoke only one authorized key with a persisted operation UUID",
        "description": "[Small working example](/guides/api-credentials)\n\n**Integration note:** Requires current personal identity and billing-account/per-key ACLs. API keys never manage credentials. Safe metadata only; private browser approval alone reveals a new secret once. Legacy keys remain valid; no forced migration. See [API credentials](/guides/api-credentials).\n\nRequires an active personal Firebase/MCP identity and current billing-account/per-key management authority. API keys, including legacy keys, cannot manage credentials. Readback contains metadata only, never stored tokens, secret-once browser execution data or reviewer challenges. Follow non-null next_cursor including empty pages. New routes do not inherit key scope permission.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "billing_account_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScopedApiKeyRevokeInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Safe server-authorized lifecycle result; does not reveal a credential.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ScopedApiKeyRevokeReceipt"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Personal identity/current management authority required; machine credentials are refused."
          },
          "404": {
            "description": "Key is absent or outside current management authority."
          },
          "409": {
            "description": "State or immutable operation intent changed; read the saved operation/key before further action."
          }
        }
      }
    },
    "/users/me/scoped-api-keys/{keyId}/audit": {
      "get": {
        "operationId": "listScopedApiKeyAudit",
        "tags": [
          "Api Keys"
        ],
        "summary": "Read safe per-key lifecycle audit",
        "description": "[Small working example](/guides/api-credentials)\n\n**Integration note:** Requires current personal identity and billing-account/per-key ACLs. API keys never manage credentials. Safe metadata only; private browser approval alone reveals a new secret once. Legacy keys remain valid; no forced migration. See [API credentials](/guides/api-credentials).\n\nRequires an active personal Firebase/MCP identity and current billing-account/per-key management authority. API keys, including legacy keys, cannot manage credentials. Readback contains metadata only, never stored tokens, secret-once browser execution data or reviewer challenges. Follow non-null next_cursor including empty pages. New routes do not inherit key scope permission.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "billing_account_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "oneOf": [
                {
                  "type": "number"
                },
                {
                  "type": "string",
                  "description": "Numeric string accepted by the request validator."
                }
              ],
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe server-authorized lifecycle result; does not reveal a credential.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ScopedApiKeyAudit"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Personal identity/current management authority required; machine credentials are refused."
          },
          "404": {
            "description": "Key is absent or outside current management authority."
          },
          "409": {
            "description": "State or immutable operation intent changed; read the saved operation/key before further action."
          }
        }
      }
    },
    "/users/me/scoped-api-keys/emergency-revoke": {
      "post": {
        "operationId": "emergencyRevokeScopedApiKeys",
        "tags": [
          "Api Keys"
        ],
        "summary": "Revoke all billing-account scoped keys with a saved operation UUID",
        "description": "[Small working example](/guides/api-credentials)\n\n**Integration note:** Requires the current personal billing-account owner; delegated credential administrators, per-key managers and all API keys are refused. Revokes scoped keys across both modes, without affecting legacy API, MCP or OAuth credentials. Persist the operation UUID before POST. Read GET after an uncertain response; repeating POST with that same UUID deliberately resumes the saved operation. Never automatically create a fresh UUID or infer completion from request acceptance. processing exposes partial revoked_count and completed_at:null; completed has the final count and completion timestamp. Invalidates pending scoped create/rotate approvals. No credential secrets are returned.\n\nRequires the current personal billing-account owner; delegated credential administrators, per-key managers and all API keys are refused. Revokes scoped keys across both modes, without affecting legacy API, MCP or OAuth credentials. Persist the operation UUID before POST. Read GET after an uncertain response; repeating POST with that same UUID deliberately resumes the saved operation. Never automatically create a fresh UUID or infer completion from request acceptance. processing exposes partial revoked_count and completed_at:null; completed has the final count and completion timestamp. Invalidates pending scoped create/rotate approvals. No credential secrets are returned.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "billing_account_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScopedApiKeyEmergencyInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Safe server-authorized lifecycle result; does not reveal a credential.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ScopedApiKeyEmergencyReceipt"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Personal identity/current management authority required; machine credentials are refused."
          },
          "404": {
            "description": "Key is absent or outside current management authority."
          },
          "409": {
            "description": "State or immutable operation intent changed; read the saved operation/key before further action."
          }
        }
      }
    },
    "/users/me/scoped-api-keys/emergency-revocations/{operationId}": {
      "get": {
        "operationId": "getScopedApiKeyEmergencyRevocation",
        "tags": [
          "Api Keys"
        ],
        "summary": "Read saved owner scoped-key emergency status",
        "description": "[Small working example](/guides/api-credentials)\n\n**Integration note:** Requires the current personal billing-account owner; delegated credential administrators, per-key managers and all API keys are refused. Revokes scoped keys across both modes, without affecting legacy API, MCP or OAuth credentials. Persist the operation UUID before POST. Read GET after an uncertain response; repeating POST with that same UUID deliberately resumes the saved operation. Never automatically create a fresh UUID or infer completion from request acceptance. processing exposes partial revoked_count and completed_at:null; completed has the final count and completion timestamp. Invalidates pending scoped create/rotate approvals. No credential secrets are returned.\n\nRequires the current personal billing-account owner; delegated credential administrators, per-key managers and all API keys are refused. Revokes scoped keys across both modes, without affecting legacy API, MCP or OAuth credentials. Persist the operation UUID before POST. Read GET after an uncertain response; repeating POST with that same UUID deliberately resumes the saved operation. Never automatically create a fresh UUID or infer completion from request acceptance. processing exposes partial revoked_count and completed_at:null; completed has the final count and completion timestamp. Invalidates pending scoped create/rotate approvals. No credential secrets are returned.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "billing_account_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{1,128}$"
            }
          },
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Safe server-authorized lifecycle result; does not reveal a credential.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "no-store"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/ScopedApiKeyEmergencyReceipt"
                    },
                    "timestamp": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Personal identity/current management authority required; machine credentials are refused."
          },
          "404": {
            "description": "Key is absent or outside current management authority."
          },
          "409": {
            "description": "State or immutable operation intent changed; read the saved operation/key before further action."
          }
        }
      }
    }
  }
}
