{
  "openapi": "3.0.1",
  "info": {
    "title": "Partners Dashboard API",
    "description": "\n\n## Partner webhooks\nUse a partner bearer token from `POST /api/Partner/Login`. These routes do not require an `Api-Version` header. Save one public HTTPS callback for all your EGS units in each environment. Every invoice notification includes `egsUnitId` and your original `clientRequestId`.\n\n| Event | When it is sent | Sequence |\n| --- | --- | --- |\n| `invoice.reporting.delayed` | Reporting is still unresolved one hour after AVTax received the invoice. Read `lastProblem`, `nextZatcaRetryAtUtc`, and `reportingRequiresAttention`. | 1 |\n| `invoice.reporting.completed` | ZATCA accepted the invoice, accepted it with warnings, or rejected it. | 2 |\n| `webhook.test` | You request an endpoint test. No invoice is involved. | 0 |\n\nThe callback body follows **InvoiceWebhookPayload** in Schemas. Verify the `webhook-id`, `webhook-timestamp`, and `webhook-signature` headers using your signing secret and the exact raw request body. Return any `2xx` within 10 seconds to acknowledge receipt. Failed callbacks retry for up to 72 hours. Store event IDs to handle duplicates, and never let a delayed event replace a completed result received earlier.\n\nNotifications can be viewed and resent for 30 days. Resend preserves the original event ID and body, works after invoice XML deletion, and does not send the invoice to ZATCA again. [Setup and signature verification guide](https://zatca.avtax.net/Docs/Webhooks).",
    "version": "v2"
  },
  "paths": {
    "/api/EgsUnits/me/profile": {
      "get": {
        "tags": [
          "EgsUnitProfile"
        ],
        "summary": "Reads this EGS unit's profile: the logo, stamp, bank details and default PDF layout its PDFs use.",
        "description": "The ETag header carries the profile's version. Send it back as If-Match when you change the profile, so a change\r\nthe partner made in the meantime isn't overwritten.",
        "responses": {
          "200": {
            "description": "The profile. A unit that never saved one gets version 0 and empty fields.",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileView"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileView"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileView"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "EgsUnitProfile"
        ],
        "summary": "Changes this EGS unit's profile. Send only what changes; everything else stays as it is.",
        "description": "Send multipart/form-data (application/x-www-form-urlencoded also works when there's no image):\r\n            \r\n- Text fields: bankName, accountName, accountNumber, iban, pdfTemplate. Sent empty, a field is cleared.\r\n- Files: logo and stamp, PNG or JPEG, up to 2 MB each. They're re-encoded without their metadata and scaled to\r\n  at most 1000 pixels on the longer side.\r\n- removeLogo=true or removeStamp=true removes an image.\r\n            \r\nThe change is saved whole or not at all. Every PDF of this unit then uses the profile, unless the PDF request\r\nsends its own logo, stamp, bank details or layout. Re-rendering an older invoice also uses the current profile.\r\nThe profile never changes the signed XML.",
        "parameters": [
          {
            "name": "If-Match",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "BankName": {
                    "type": "string",
                    "description": "The bank's name, up to 100 characters."
                  },
                  "AccountName": {
                    "type": "string",
                    "description": "The account holder's name, up to 100 characters."
                  },
                  "AccountNumber": {
                    "type": "string",
                    "description": "The account number, up to 34 letters, digits, spaces or dashes."
                  },
                  "Iban": {
                    "type": "string",
                    "description": "The IBAN, checked with its check digits. A Saudi IBAN is SA and 22 digits; spaces are removed."
                  },
                  "PdfTemplate": {
                    "type": "string",
                    "description": "The PDF layout used when a PDF request doesn't name one, such as ModernTemplate. Empty: the default."
                  },
                  "Logo": {
                    "type": "string",
                    "description": "A PNG or JPEG of up to 2 MB, printed at the top of the PDF.",
                    "format": "binary"
                  },
                  "Stamp": {
                    "type": "string",
                    "description": "A PNG or JPEG of up to 2 MB, printed as the stamp or signature at the bottom of the PDF.",
                    "format": "binary"
                  },
                  "RemoveLogo": {
                    "type": "string",
                    "description": "true removes the saved logo."
                  },
                  "RemoveStamp": {
                    "type": "string",
                    "description": "true removes the saved stamp."
                  }
                }
              },
              "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner.",
              "encoding": {
                "BankName": {
                  "style": "form"
                },
                "AccountName": {
                  "style": "form"
                },
                "AccountNumber": {
                  "style": "form"
                },
                "Iban": {
                  "style": "form"
                },
                "PdfTemplate": {
                  "style": "form"
                },
                "Logo": {
                  "style": "form"
                },
                "Stamp": {
                  "style": "form"
                },
                "RemoveLogo": {
                  "style": "form"
                },
                "RemoveStamp": {
                  "style": "form"
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "BankName": {
                    "type": "string",
                    "description": "The bank's name, up to 100 characters."
                  },
                  "AccountName": {
                    "type": "string",
                    "description": "The account holder's name, up to 100 characters."
                  },
                  "AccountNumber": {
                    "type": "string",
                    "description": "The account number, up to 34 letters, digits, spaces or dashes."
                  },
                  "Iban": {
                    "type": "string",
                    "description": "The IBAN, checked with its check digits. A Saudi IBAN is SA and 22 digits; spaces are removed."
                  },
                  "PdfTemplate": {
                    "type": "string",
                    "description": "The PDF layout used when a PDF request doesn't name one, such as ModernTemplate. Empty: the default."
                  },
                  "Logo": {
                    "type": "string",
                    "description": "A PNG or JPEG of up to 2 MB, printed at the top of the PDF.",
                    "format": "binary"
                  },
                  "Stamp": {
                    "type": "string",
                    "description": "A PNG or JPEG of up to 2 MB, printed as the stamp or signature at the bottom of the PDF.",
                    "format": "binary"
                  },
                  "RemoveLogo": {
                    "type": "string",
                    "description": "true removes the saved logo."
                  },
                  "RemoveStamp": {
                    "type": "string",
                    "description": "true removes the saved stamp."
                  }
                }
              },
              "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner.",
              "encoding": {
                "BankName": {
                  "style": "form"
                },
                "AccountName": {
                  "style": "form"
                },
                "AccountNumber": {
                  "style": "form"
                },
                "Iban": {
                  "style": "form"
                },
                "PdfTemplate": {
                  "style": "form"
                },
                "Logo": {
                  "style": "form"
                },
                "Stamp": {
                  "style": "form"
                },
                "RemoveLogo": {
                  "style": "form"
                },
                "RemoveStamp": {
                  "style": "form"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved. The answer is the whole profile, with the new ETag.",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileView"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileView"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileView"
                }
              }
            }
          },
          "400": {
            "description": "A field can't be saved (each one is listed in errors), or nothing was sent.",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          },
          "409": {
            "description": "The unit is retired, revoked or archived.",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              }
            }
          },
          "412": {
            "description": "If-Match was sent and the profile has changed since; load it again.",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              }
            }
          }
        }
      }
    },
    "/api/EgsUnits/CreateNewEgsUnit": {
      "post": {
        "tags": [
          "EgsUnits"
        ],
        "summary": "Initiates the creation of a new Egs Unit.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-AVTax-Owner-Reference",
            "in": "header",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-AVTax-Checkout-Reference",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The command to create a new company.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNewEgsUnitCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNewEgsUnitCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNewEgsUnitCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateNewEgsUnitResponse"
                },
                "example": {"clientId":"32ad76eb-b449-4ec0-8c63-61d8e2c4447a","clientSecret":"ffec4244-cf6c-48c6-8e1e-6fef901fc1ad","egsUnitId":"cfeebf33-e7a7-44fe-b048-06dc8c469ce5","lifecycleStatus":"Active","certificateExpiresAtUtc":"2028-11-17T23:12:53.7916941Z","invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"isProduction":true}
              },
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/CreateNewEgsUnitResponse"
                },
                "example": {"clientId":"32ad76eb-b449-4ec0-8c63-61d8e2c4447a","clientSecret":"ffec4244-cf6c-48c6-8e1e-6fef901fc1ad","egsUnitId":"cfeebf33-e7a7-44fe-b048-06dc8c469ce5","lifecycleStatus":"Active","certificateExpiresAtUtc":"2028-11-17T23:12:53.7916941Z","invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"isProduction":true}
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          }
        }
      }
    },
    "/api/EgsUnits/GetEgsUnits": {
      "get": {
        "tags": [
          "EgsUnits"
        ],
        "summary": "Retrieves the list of Egs Units associated with the current user.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnits"
                },
                "example": [{"clientId":"b819854c-1639-48a4-8b82-0e3d840b245f","clientSecret":"5a42d4a0-1496-487e-b42d-dc4c383c7319","egsUnitId":"67cc404e-075d-4360-a989-73e077f6f088","organizationName":"Company Name 1","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8003813Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null},{"clientId":"976e2968-023b-4fb0-b224-e4e5842b2971","clientSecret":"48d00443-b225-4ed3-a772-aeccf16a8258","egsUnitId":"110fc3e6-304a-42f6-a81a-66ff569b1be8","organizationName":"Company Name 2","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8005882Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null},{"clientId":"4a9ce4d4-cc6d-4d8a-9b14-d489ad3bc0d3","clientSecret":"eb7d97cf-93ed-4f5b-9a1d-ce527e43fc69","egsUnitId":"4aac9eaf-837e-4643-aeed-2db16c8017fd","organizationName":"Company Name 3","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8005893Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null},{"clientId":"c1447f9c-6a84-47a9-a2d5-bfc23d56a2ff","clientSecret":"d6783066-11ff-402e-9c44-c4859a9a66e1","egsUnitId":"e401d4cf-1511-44ad-a5d6-ac11fa242037","organizationName":"Company Name 4","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8005903Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null},{"clientId":"267ecae5-c428-4a59-93be-59f43da40cae","clientSecret":"8d61948b-c65a-4d95-a2a2-6b6c31f603e7","egsUnitId":"3b04087c-87d1-44a8-85d1-e0a821f9a097","organizationName":"Company Name 5","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8005908Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null}]
              },
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnits"
                },
                "example": [{"clientId":"b819854c-1639-48a4-8b82-0e3d840b245f","clientSecret":"5a42d4a0-1496-487e-b42d-dc4c383c7319","egsUnitId":"67cc404e-075d-4360-a989-73e077f6f088","organizationName":"Company Name 1","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8003813Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null},{"clientId":"976e2968-023b-4fb0-b224-e4e5842b2971","clientSecret":"48d00443-b225-4ed3-a772-aeccf16a8258","egsUnitId":"110fc3e6-304a-42f6-a81a-66ff569b1be8","organizationName":"Company Name 2","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8005882Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null},{"clientId":"4a9ce4d4-cc6d-4d8a-9b14-d489ad3bc0d3","clientSecret":"eb7d97cf-93ed-4f5b-9a1d-ce527e43fc69","egsUnitId":"4aac9eaf-837e-4643-aeed-2db16c8017fd","organizationName":"Company Name 3","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8005893Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null},{"clientId":"c1447f9c-6a84-47a9-a2d5-bfc23d56a2ff","clientSecret":"d6783066-11ff-402e-9c44-c4859a9a66e1","egsUnitId":"e401d4cf-1511-44ad-a5d6-ac11fa242037","organizationName":"Company Name 4","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8005903Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null},{"clientId":"267ecae5-c428-4a59-93be-59f43da40cae","clientSecret":"8d61948b-c65a-4d95-a2a2-6b6c31f603e7","egsUnitId":"3b04087c-87d1-44a8-85d1-e0a821f9a097","organizationName":"Company Name 5","vatNumber":"3000000000003","additionalIDSchemeID":"None","schemeIDName":"Commercial Registration Number","additionalID":"1221356","isProduction":true,"maximumNumberOfInvoicesPerMonth":10000,"rateLimitPerMinute":50,"serialNumber":"1-Avtax|2-ZatcaConnector|3-ABC123456","createdAt":"2026-11-17T23:12:53.8005908Z","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false,"replacedByEgsUnitId":null,"isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null}]
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          }
        }
      }
    },
    "/api/EgsUnits/{egsUnitId}/revoke": {
      "post": {
        "tags": [
          "EgsUnits"
        ],
        "summary": "Revokes the secret associated with a specific Egs Unit.",
        "description": "This endpoint allows the partner to revoke the secret key for an Egs Unit identified by its ID.\r\nRevoking the secret will invalidate the current key, preventing further access using that key.\r\n\r\nThe user must be authenticated and authorized as a partner to perform this operation.",
        "parameters": [
          {
            "name": "egsUnitId",
            "in": "path",
            "description": "The unique identifier of the Egs Unit for which the secret should be revoked.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RevokeEgsSecretResponse"
                },
                "example": {"clientSecret":"new-client-secret-12345","egsUnitId":"egsunit-id-67890"}
              },
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/RevokeEgsSecretResponse"
                },
                "example": {"clientSecret":"new-client-secret-12345","egsUnitId":"egsunit-id-67890"}
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          }
        }
      }
    },
    "/api/EgsUnits/{egsUnitId}/suspend": {
      "post": {
        "tags": [
          "EgsUnits"
        ],
        "summary": "Suspends an Egs Unit so it stops accepting new invoices.",
        "description": "While the unit is suspended, new invoices submitted with it through Invoice API v1 and v2 are refused with\r\n403 (code egs_unit_suspended on v2), and nothing is sent to ZATCA. Everything else keeps working: the client ID\r\nand secret stay the same, status checks and statistics remain available, and invoices already issued keep\r\nbeing reported to ZATCA.\r\n            \r\nSuspending a unit that is already suspended keeps the original suspension time and replaces the note.",
        "parameters": [
          {
            "name": "egsUnitId",
            "in": "path",
            "description": "The unique identifier of the Egs Unit to suspend.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Optional. A note of up to 200 characters explaining why; only you see it.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SuspendEgsUnitRequest"
              },
              "example": {"note":"Branch closed for renovation"}
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/SuspendEgsUnitRequest"
              },
              "example": {"note":"Branch closed for renovation"}
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/SuspendEgsUnitRequest"
              },
              "example": {"note":"Branch closed for renovation"}
            }
          }
        },
        "responses": {
          "200": {
            "description": "The unit is suspended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitSuspensionResponse"
                },
                "example": {"egsUnitId":"egsunit-id-67890","isSuspended":true,"suspendedAtUtc":"2026-10-06T09:30:00Z","suspensionNote":"Branch closed for renovation"}
              },
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitSuspensionResponse"
                },
                "example": {"egsUnitId":"egsunit-id-67890","isSuspended":true,"suspendedAtUtc":"2026-10-06T09:30:00Z","suspensionNote":"Branch closed for renovation"}
              }
            }
          },
          "400": {
            "description": "The note is longer than 200 characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {"errors":["The client ID or client secret you entered is incorrect. Please check and try again."]}
              },
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {"errors":["The client ID or client secret you entered is incorrect. Please check and try again."]}
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          },
          "404": {
            "description": "No Egs Unit with this ID belongs to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {"errors":["The client ID or client secret you entered is incorrect. Please check and try again."]}
              },
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {"errors":["The client ID or client secret you entered is incorrect. Please check and try again."]}
              }
            }
          }
        }
      }
    },
    "/api/EgsUnits/{egsUnitId}/unsuspend": {
      "post": {
        "tags": [
          "EgsUnits"
        ],
        "summary": "Unsuspends an Egs Unit so it accepts new invoices again.",
        "description": "New invoices are accepted again on the next request. Invoices refused while the unit was suspended aren't\r\nresubmitted for you: send them again (Invoice API v2 requests can reuse their Idempotency-Key).\r\nUnsuspending a unit that isn't suspended changes nothing.",
        "parameters": [
          {
            "name": "egsUnitId",
            "in": "path",
            "description": "The unique identifier of the Egs Unit to unsuspend.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The unit accepts new invoices.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitSuspensionResponse"
                },
                "example": {"egsUnitId":"egsunit-id-67890","isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null}
              },
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitSuspensionResponse"
                },
                "example": {"egsUnitId":"egsunit-id-67890","isSuspended":false,"suspendedAtUtc":null,"suspensionNote":null}
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          },
          "404": {
            "description": "No Egs Unit with this ID belongs to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {"errors":["The client ID or client secret you entered is incorrect. Please check and try again."]}
              },
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {"errors":["The client ID or client secret you entered is incorrect. Please check and try again."]}
              }
            }
          }
        }
      }
    },
    "/api/EgsUnits/{egsUnitId}/profile": {
      "get": {
        "tags": [
          "EgsUnits"
        ],
        "summary": "Reads an Egs Unit's profile: the logo, stamp, bank details and default PDF layout its PDFs use.",
        "description": "The ETag header carries the profile's version. Send it back as If-Match when you change the profile, so a change\r\nthe unit made in the meantime with its own token isn't overwritten.",
        "parameters": [
          {
            "name": "egsUnitId",
            "in": "path",
            "description": "The unique identifier of one of your Egs Units.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The profile. A unit that never saved one gets version 0 and empty fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileView"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          },
          "404": {
            "description": "No Egs Unit with this ID belongs to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "EgsUnits"
        ],
        "summary": "Changes an Egs Unit's profile. Send only what changes; everything else stays as it is.",
        "description": "Send multipart/form-data (application/x-www-form-urlencoded also works when there's no image):\r\n            \r\n- Text fields: bankName, accountName, accountNumber, iban, pdfTemplate. Sent empty, a field is cleared.\r\n- Files: logo and stamp, PNG or JPEG, up to 2 MB each. They're re-encoded without their metadata and scaled to\r\n  at most 1000 pixels on the longer side.\r\n- removeLogo=true or removeStamp=true removes an image.\r\n            \r\nThe change is saved whole or not at all. Every PDF of the unit then uses the profile, unless the PDF request\r\nsends its own logo, stamp, bank details or layout. Re-rendering an older invoice also uses the current profile.\r\nThe profile never changes the signed XML. The unit can change its own profile too, at /api/EgsUnits/me/profile.",
        "parameters": [
          {
            "name": "egsUnitId",
            "in": "path",
            "description": "The unique identifier of one of your Egs Units.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "BankName": {
                    "type": "string",
                    "description": "The bank's name, up to 100 characters."
                  },
                  "AccountName": {
                    "type": "string",
                    "description": "The account holder's name, up to 100 characters."
                  },
                  "AccountNumber": {
                    "type": "string",
                    "description": "The account number, up to 34 letters, digits, spaces or dashes."
                  },
                  "Iban": {
                    "type": "string",
                    "description": "The IBAN, checked with its check digits. A Saudi IBAN is SA and 22 digits; spaces are removed."
                  },
                  "PdfTemplate": {
                    "type": "string",
                    "description": "The PDF layout used when a PDF request doesn't name one, such as ModernTemplate. Empty: the default."
                  },
                  "Logo": {
                    "type": "string",
                    "description": "A PNG or JPEG of up to 2 MB, printed at the top of the PDF.",
                    "format": "binary"
                  },
                  "Stamp": {
                    "type": "string",
                    "description": "A PNG or JPEG of up to 2 MB, printed as the stamp or signature at the bottom of the PDF.",
                    "format": "binary"
                  },
                  "RemoveLogo": {
                    "type": "string",
                    "description": "true removes the saved logo."
                  },
                  "RemoveStamp": {
                    "type": "string",
                    "description": "true removes the saved stamp."
                  }
                }
              },
              "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner.",
              "encoding": {
                "BankName": {
                  "style": "form"
                },
                "AccountName": {
                  "style": "form"
                },
                "AccountNumber": {
                  "style": "form"
                },
                "Iban": {
                  "style": "form"
                },
                "PdfTemplate": {
                  "style": "form"
                },
                "Logo": {
                  "style": "form"
                },
                "Stamp": {
                  "style": "form"
                },
                "RemoveLogo": {
                  "style": "form"
                },
                "RemoveStamp": {
                  "style": "form"
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "BankName": {
                    "type": "string",
                    "description": "The bank's name, up to 100 characters."
                  },
                  "AccountName": {
                    "type": "string",
                    "description": "The account holder's name, up to 100 characters."
                  },
                  "AccountNumber": {
                    "type": "string",
                    "description": "The account number, up to 34 letters, digits, spaces or dashes."
                  },
                  "Iban": {
                    "type": "string",
                    "description": "The IBAN, checked with its check digits. A Saudi IBAN is SA and 22 digits; spaces are removed."
                  },
                  "PdfTemplate": {
                    "type": "string",
                    "description": "The PDF layout used when a PDF request doesn't name one, such as ModernTemplate. Empty: the default."
                  },
                  "Logo": {
                    "type": "string",
                    "description": "A PNG or JPEG of up to 2 MB, printed at the top of the PDF.",
                    "format": "binary"
                  },
                  "Stamp": {
                    "type": "string",
                    "description": "A PNG or JPEG of up to 2 MB, printed as the stamp or signature at the bottom of the PDF.",
                    "format": "binary"
                  },
                  "RemoveLogo": {
                    "type": "string",
                    "description": "true removes the saved logo."
                  },
                  "RemoveStamp": {
                    "type": "string",
                    "description": "true removes the saved stamp."
                  }
                }
              },
              "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner.",
              "encoding": {
                "BankName": {
                  "style": "form"
                },
                "AccountName": {
                  "style": "form"
                },
                "AccountNumber": {
                  "style": "form"
                },
                "Iban": {
                  "style": "form"
                },
                "PdfTemplate": {
                  "style": "form"
                },
                "Logo": {
                  "style": "form"
                },
                "Stamp": {
                  "style": "form"
                },
                "RemoveLogo": {
                  "style": "form"
                },
                "RemoveStamp": {
                  "style": "form"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved. The answer is the whole profile, with the new ETag.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileView"
                }
              }
            }
          },
          "400": {
            "description": "A field can't be saved (each one is listed in errors), or nothing was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          },
          "404": {
            "description": "No Egs Unit with this ID belongs to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              }
            }
          },
          "409": {
            "description": "The unit is retired, revoked or archived.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              }
            }
          },
          "412": {
            "description": "If-Match was sent and the profile has changed since; load it again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EgsUnitProfileError"
                }
              }
            }
          }
        }
      }
    },
    "/api/EgsUnits/{egsUnitId}/renew": {
      "post": {
        "tags": [
          "EgsUnits"
        ],
        "summary": "Renews the ZATCA production certificate for a specific Egs Unit.",
        "description": "This endpoint generates a fresh CSR/key pair for the EGS unit identified by its ID,\r\nsubmits it to ZATCA to renew the existing production certificate, and stores the\r\nnewly issued certificate against the unit.\r\n            \r\nThe user must be authenticated and authorized as a partner, and the EGS unit must\r\nalready have an active production certificate.",
        "parameters": [
          {
            "name": "egsUnitId",
            "in": "path",
            "description": "The unique identifier of the Egs Unit whose certificate should be renewed.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The renewal request containing the OTP generated from the Fatoora portal.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenewEgsUnitCertificateCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/RenewEgsUnitCertificateCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/RenewEgsUnitCertificateCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RenewEgsUnitCertificateResponse"
                },
                "example": {"egsUnitId":"egsunit-id-67890","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false}
              },
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/RenewEgsUnitCertificateResponse"
                },
                "example": {"egsUnitId":"egsunit-id-67890","lifecycleStatus":"Active","certificateExpiresAtUtc":null,"invoiceAcceptanceStopsAtUtc":null,"newInvoiceSubmissionAllowed":false}
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          }
        }
      }
    },
    "/api/Partner/CreateAccount": {
      "post": {
        "tags": [
          "Partner"
        ],
        "summary": "Creates a new user and returns a JWT upon successful creation.",
        "requestBody": {
          "description": "The Request body containing the details of the new user.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNewUserCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNewUserCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNewUserCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/Partner/Login": {
      "post": {
        "tags": [
          "Partner"
        ],
        "summary": "Endpoint for Partner Account Authentication",
        "description": "This endpoint, `Login`, is specifically designed for partner accounts. It provides a secure method for partners to authenticate themselves and gain access to the system.\r\n            \r\nAs a partner, you are required to provide your registered email and password. Upon successful authentication, you will be able to access the `EgsUnits` endpoints.\r\n            \r\nPlease note that the security of your account is paramount. Ensure that your credentials are kept confidential and secure.\r\n            \r\nAn unknown email and a wrong password get the same 401. After 5 wrong passwords for one email, or 20 in all, from one\r\nnetwork in 15 minutes, the answer is 429 with Retry-After.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/LoginCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/Partner/ChangePassword": {
      "post": {
        "tags": [
          "Partner"
        ],
        "summary": "Endpoint for Changing Partner Account Password",
        "description": "This `ChangePassword` endpoint is designed to provide a secure method for partners to change their account password. \r\n            \r\nAs a partner, you are required to be authenticated and authorized to access this endpoint. Once authenticated, you can use this endpoint to change your password, enhancing the security of your account.\r\n            \r\nPlease note that it's important to choose a strong password and keep it confidential to protect your account.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangePasswordCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangePasswordCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ChangePasswordCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/Partner/ResetPassword": {
      "post": {
        "tags": [
          "Partner"
        ],
        "summary": "Endpoint for Resetting User Password",
        "description": "This `ResetPassword` endpoint allows partners to reset their password by providing their email address. \r\nA reset link will be sent to the provided email if it exists in our system.\r\n            \r\nThe answer is the same 200 whether or not a partner account uses the email, and the email is sent shortly after.\r\nThe link opens the partner portal, works once and expires after 24 hours. An account gets at most one reset\r\nemail every 5 minutes and 5 a day. One network can send 10 requests an hour; after that the answer is 429 with Retry-After.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResetPasswordCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ResetPasswordCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ResetPasswordCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/Partner/FinalizePasswordReset": {
      "post": {
        "tags": [
          "Partner"
        ],
        "summary": "Endpoint for Finalizing Password Reset",
        "description": "This `FinalizePasswordReset` endpoint allows users to finalize their password reset by providing their email,\r\nreset token, and new password.\r\n            \r\nA wrong email and a wrong, used or expired token both get 400 with \"Invalid token.\". After 10 of those from one\r\nnetwork in 15 minutes, the answer is 429 with Retry-After.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FinalizePasswordResetCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/FinalizePasswordResetCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/FinalizePasswordResetCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/Partner/GetEgsUnitStatistics": {
      "get": {
        "tags": [
          "Partner"
        ],
        "summary": "Endpoint for retrieving statistics on EgsUnits and their invoices.",
        "description": "This endpoint returns the number of submitted EgsUnits along with the count of \r\nSimplified and Standard invoices for each EgsUnit.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EgsUnitStatisticsDto"
                  }
                },
                "example": [{"egsUnitId":"egs-unit-1","egsUnitName":"Example EGS Unit 1","simplifiedInvoiceCount":5,"standardInvoiceCount":10,"totalInvoices":15,"totalAmountInvoiced":1500.00,"averageInvoiceAmount":150.00,"lastInvoiceDate":"2026-11-12T23:12:53.8388742Z","isProduction":true},{"egsUnitId":"egs-unit-2","egsUnitName":"Example EGS Unit 2","simplifiedInvoiceCount":3,"standardInvoiceCount":7,"totalInvoices":10,"totalAmountInvoiced":800.00,"averageInvoiceAmount":114.29,"lastInvoiceDate":"2026-11-07T23:12:53.8389791Z","isProduction":false}]
              },
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EgsUnitStatisticsDto"
                  }
                },
                "example": [{"egsUnitId":"egs-unit-1","egsUnitName":"Example EGS Unit 1","simplifiedInvoiceCount":5,"standardInvoiceCount":10,"totalInvoices":15,"totalAmountInvoiced":1500.00,"averageInvoiceAmount":150.00,"lastInvoiceDate":"2026-11-12T23:12:53.8388742Z","isProduction":true},{"egsUnitId":"egs-unit-2","egsUnitName":"Example EGS Unit 2","simplifiedInvoiceCount":3,"standardInvoiceCount":7,"totalInvoices":10,"totalAmountInvoiced":800.00,"averageInvoiceAmount":114.29,"lastInvoiceDate":"2026-11-07T23:12:53.8389791Z","isProduction":false}]
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          }
        }
      }
    },
    "/api/Partner/GetEgsUnitMonthlyInvoiceStatistics/egsunit/{egsUnitId}/monthly-statistics": {
      "get": {
        "tags": [
          "Partner"
        ],
        "summary": "Get monthly invoice statistics for an EgsUnit.",
        "description": "This endpoint returns the count of invoices and total amounts grouped by month for a given EgsUnit.",
        "parameters": [
          {
            "name": "egsUnitId",
            "in": "path",
            "description": "The ID of the EgsUnit.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MonthlyInvoiceStatisticsDto"
                  }
                },
                "example": [{"year":2024,"month":1,"invoiceCount":120,"totalAmount":50000},{"year":2024,"month":2,"invoiceCount":95,"totalAmount":45000}]
              },
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MonthlyInvoiceStatisticsDto"
                  }
                },
                "example": [{"year":2024,"month":1,"invoiceCount":120,"totalAmount":50000},{"year":2024,"month":2,"invoiceCount":95,"totalAmount":45000}]
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              },
              "text/plain": {
                "schema": {
                  "type": "string"
                },
                "example": "You must login using https://zatcaapi.avtax.net/api/UserAuthentication/LoginAsEgsUnit if you are an EGS unit, or https://zatcaapi.avtax.net/api/UserAuthentication/Login as partner."
              }
            }
          }
        }
      }
    },
    "/api/Partner/webhooks/{environment}": {
      "get": {
        "tags": [
          "PartnerWebhooks"
        ],
        "summary": "Get your callback settings.",
        "description": "Returns the settings for all your EGS units in the selected environment.\r\nIf you have not configured a callback, url and updatedAtUtc are null and enabled is false.\r\nThis endpoint never returns a signing secret. Save the secret when creating the endpoint or rotating it.\r\nThese routes do not require an Api-Version header.",
        "operationId": "PartnerWebhooks_Get",
        "parameters": [
          {
            "name": "environment",
            "in": "path",
            "description": "Use simulation for testing or production for live invoices. Use lowercase values.",
            "required": true,
            "schema": {
              "enum": [
                "simulation",
                "production"
              ],
              "type": "string"
            },
            "example": "simulation"
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid environment, callback URL, request body, or filter. Webhook errors use code and message; unreadable bodies or filters use errors. Omit Api-Version for these version-neutral routes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Partner bearer token missing, invalid, or expired. Sign in through POST /api/Partner/Login. An authentication failure is not a webhook code/message response."
          },
          "403": {
            "description": "The token does not authorize a partner account. EGS-unit tokens cannot manage partner webhooks."
          },
          "200": {
            "description": "Current settings, including an unconfigured state when no callback has been saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSettingsResponse"
                },
                "examples": {
                  "configured": {
                    "summary": "Notifications enabled",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": true,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  },
                  "paused": {
                    "summary": "Notifications paused",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": false,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  },
                  "not-configured": {
                    "summary": "No callback saved yet",
                    "value": {
                      "environment": "simulation",
                      "url": null,
                      "enabled": false,
                      "updatedAtUtc": null,
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSettingsResponse"
                },
                "examples": {
                  "configured": {
                    "summary": "Notifications enabled",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": true,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  },
                  "paused": {
                    "summary": "Notifications paused",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": false,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  },
                  "not-configured": {
                    "summary": "No callback saved yet",
                    "value": {
                      "environment": "simulation",
                      "url": null,
                      "enabled": false,
                      "updatedAtUtc": null,
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "PartnerWebhooks"
        ],
        "summary": "Save your callback URL and enable or pause invoice notifications.",
        "description": "Save the full public HTTPS URL that should receive updates. Every event identifies its EGS unit;\r\nyou do not need a separate callback URL for each unit. Redirects are not followed.\r\nCreating the endpoint returns its signing secret once. Updating settings keeps the existing secret.\r\nSet enabled to false to stop new invoice notifications and pause pending delivery.\r\nRe-enabling resumes retained deliveries whose retry window has not ended.\r\nA URL change applies to subsequent attempts, including retries of existing notifications.\r\nInvoice reporting to ZATCA continues independently of this setting.",
        "operationId": "PartnerWebhooks_Save",
        "parameters": [
          {
            "name": "environment",
            "in": "path",
            "description": "Use simulation for testing or production for live invoices. Use lowercase values.",
            "required": true,
            "schema": {
              "enum": [
                "simulation",
                "production"
              ],
              "type": "string"
            },
            "example": "simulation"
          }
        ],
        "requestBody": {
          "description": "The callback URL and whether invoice notifications should be enabled.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookSettingsRequest"
              },
              "examples": {
                "enable": {
                  "summary": "Enable notifications",
                  "value": {
                    "url": "https://partner.example.com/webhooks/avtax",
                    "enabled": true
                  }
                },
                "pause": {
                  "summary": "Pause invoice notifications",
                  "value": {
                    "url": "https://partner.example.com/webhooks/avtax",
                    "enabled": false
                  }
                }
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookSettingsRequest"
              },
              "examples": {
                "enable": {
                  "summary": "Enable notifications",
                  "value": {
                    "url": "https://partner.example.com/webhooks/avtax",
                    "enabled": true
                  }
                },
                "pause": {
                  "summary": "Pause invoice notifications",
                  "value": {
                    "url": "https://partner.example.com/webhooks/avtax",
                    "enabled": false
                  }
                }
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookSettingsRequest"
              },
              "examples": {
                "enable": {
                  "summary": "Enable notifications",
                  "value": {
                    "url": "https://partner.example.com/webhooks/avtax",
                    "enabled": true
                  }
                },
                "pause": {
                  "summary": "Pause invoice notifications",
                  "value": {
                    "url": "https://partner.example.com/webhooks/avtax",
                    "enabled": false
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "400": {
            "description": "Invalid environment, callback URL, request body, or filter. Webhook errors use code and message; unreadable bodies or filters use errors. Omit Api-Version for these version-neutral routes.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/WebhookErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  },
                  "invalid-url": {
                    "summary": "Callback URL is not allowed",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Enter a public HTTPS callback URL without embedded credentials or a fragment."
                    }
                  },
                  "private-address": {
                    "summary": "Callback resolves to a private address",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "The callback host must resolve exclusively to public internet addresses."
                    }
                  },
                  "dns-failed": {
                    "summary": "Callback hostname cannot be resolved",
                    "value": {
                      "code": "webhook_dns_failed",
                      "message": "The callback host could not be resolved. Check the URL and try again."
                    }
                  },
                  "dns-timeout": {
                    "summary": "Callback validation timed out",
                    "value": {
                      "code": "webhook_validation_timeout",
                      "message": "The callback host could not be validated in time. Try again."
                    }
                  },
                  "unreadable-body": {
                    "summary": "Missing request body",
                    "value": {
                      "errors": [
                        "A non-empty request body is required."
                      ]
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/WebhookErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  },
                  "invalid-url": {
                    "summary": "Callback URL is not allowed",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Enter a public HTTPS callback URL without embedded credentials or a fragment."
                    }
                  },
                  "private-address": {
                    "summary": "Callback resolves to a private address",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "The callback host must resolve exclusively to public internet addresses."
                    }
                  },
                  "dns-failed": {
                    "summary": "Callback hostname cannot be resolved",
                    "value": {
                      "code": "webhook_dns_failed",
                      "message": "The callback host could not be resolved. Check the URL and try again."
                    }
                  },
                  "dns-timeout": {
                    "summary": "Callback validation timed out",
                    "value": {
                      "code": "webhook_validation_timeout",
                      "message": "The callback host could not be validated in time. Try again."
                    }
                  },
                  "unreadable-body": {
                    "summary": "Missing request body",
                    "value": {
                      "errors": [
                        "A non-empty request body is required."
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Partner bearer token missing, invalid, or expired. Sign in through POST /api/Partner/Login. An authentication failure is not a webhook code/message response."
          },
          "403": {
            "description": "The token does not authorize a partner account. EGS-unit tokens cannot manage partner webhooks."
          },
          "200": {
            "description": "Settings saved. signingSecret is populated only when the endpoint is first created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSettingsResponse"
                },
                "examples": {
                  "created": {
                    "summary": "First save: keep this signing secret",
                    "description": "The secret shown here is a fictional example. Your real secret is returned only on creation or rotation.",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": true,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": "whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
                      "previousSecretExpiresAtUtc": null
                    }
                  },
                  "updated": {
                    "summary": "Existing settings updated: secret unchanged",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": true,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  },
                  "paused": {
                    "summary": "Invoice notifications paused",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": false,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSettingsResponse"
                },
                "examples": {
                  "created": {
                    "summary": "First save: keep this signing secret",
                    "description": "The secret shown here is a fictional example. Your real secret is returned only on creation or rotation.",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": true,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": "whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
                      "previousSecretExpiresAtUtc": null
                    }
                  },
                  "updated": {
                    "summary": "Existing settings updated: secret unchanged",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": true,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  },
                  "paused": {
                    "summary": "Invoice notifications paused",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": false,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": null,
                      "previousSecretExpiresAtUtc": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The settings changed during this request. Refresh them before trying again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "concurrent-change": {
                    "summary": "Refresh after a concurrent change",
                    "value": {
                      "code": "webhook_changed",
                      "message": "The webhook changed during this request. Refresh and try again."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "concurrent-change": {
                    "summary": "Refresh after a concurrent change",
                    "value": {
                      "code": "webhook_changed",
                      "message": "The webhook changed during this request. Refresh and try again."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/Partner/webhooks/{environment}/rotate-secret": {
      "post": {
        "tags": [
          "PartnerWebhooks"
        ],
        "summary": "Create a new webhook signing secret.",
        "description": "Save the returned signingSecret securely and update your receiver.\r\nFor the next 24 hours, requests include signatures made with both the new and previous secrets,\r\nso your receiver can switch without interrupting delivery. previousSecretExpiresAtUtc gives the exact deadline.\r\nThe new secret is shown only in this response. Another rotation is blocked during the overlap period.\r\nThis changes the webhook signing secret, not your partner login or EGS credentials.",
        "operationId": "PartnerWebhooks_Rotate",
        "parameters": [
          {
            "name": "environment",
            "in": "path",
            "description": "The environment whose signing secret you want to rotate: simulation or production.",
            "required": true,
            "schema": {
              "enum": [
                "simulation",
                "production"
              ],
              "type": "string"
            },
            "example": "simulation"
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid environment, callback URL, request body, or filter. Webhook errors use code and message; unreadable bodies or filters use errors. Omit Api-Version for these version-neutral routes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Partner bearer token missing, invalid, or expired. Sign in through POST /api/Partner/Login. An authentication failure is not a webhook code/message response."
          },
          "403": {
            "description": "The token does not authorize a partner account. EGS-unit tokens cannot manage partner webhooks."
          },
          "200": {
            "description": "The new signing secret and the previous secret's overlap deadline.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSettingsResponse"
                },
                "examples": {
                  "rotated": {
                    "summary": "New secret with a 24-hour overlap",
                    "description": "Store the new secret securely and update your receiver before previousSecretExpiresAtUtc.",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": true,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": "whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
                      "previousSecretExpiresAtUtc": "2026-09-29T12:00:00Z"
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSettingsResponse"
                },
                "examples": {
                  "rotated": {
                    "summary": "New secret with a 24-hour overlap",
                    "description": "Store the new secret securely and update your receiver before previousSecretExpiresAtUtc.",
                    "value": {
                      "environment": "simulation",
                      "url": "https://partner.example.com/webhooks/avtax",
                      "enabled": true,
                      "updatedAtUtc": "2026-09-28T12:00:00Z",
                      "signingSecret": "whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=",
                      "previousSecretExpiresAtUtc": "2026-09-29T12:00:00Z"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No callback has been configured for this partner and environment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "not-found": {
                    "summary": "Unavailable or expired notification, or missing endpoint",
                    "value": {
                      "code": "webhook_not_found",
                      "message": "The webhook or retained notification was not found."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "not-found": {
                    "summary": "Unavailable or expired notification, or missing endpoint",
                    "value": {
                      "code": "webhook_not_found",
                      "message": "The webhook or retained notification was not found."
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "A previous rotation is still in its 24-hour overlap, or the settings changed concurrently.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "concurrent-change": {
                    "summary": "Refresh after a concurrent change",
                    "value": {
                      "code": "webhook_changed",
                      "message": "The webhook changed during this request. Refresh and try again."
                    }
                  },
                  "rotation-overlap": {
                    "summary": "A rotation is already in progress",
                    "value": {
                      "code": "webhook_conflict",
                      "message": "A secret rotation is already in its 24-hour overlap period."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "concurrent-change": {
                    "summary": "Refresh after a concurrent change",
                    "value": {
                      "code": "webhook_changed",
                      "message": "The webhook changed during this request. Refresh and try again."
                    }
                  },
                  "rotation-overlap": {
                    "summary": "A rotation is already in progress",
                    "value": {
                      "code": "webhook_conflict",
                      "message": "A secret rotation is already in its 24-hour overlap period."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/Partner/webhooks/{environment}/test": {
      "post": {
        "tags": [
          "PartnerWebhooks"
        ],
        "summary": "Send a signed test notification to your saved callback.",
        "description": "Queues a webhook.test event, even while invoice notifications are paused.\r\nThe callback payload has egsUnitId and data set to null and sequence set to 0.\r\nNo invoice is created or submitted to ZATCA.\r\nA 202 response means the test is queued, not that your receiver has acknowledged it.\r\nUse the returned eventId with GET deliveries/{eventId} to check the result.\r\nYou can create one test notification per minute for each environment; earlier requests return 409.",
        "operationId": "PartnerWebhooks_Test",
        "parameters": [
          {
            "name": "environment",
            "in": "path",
            "description": "The environment of the saved callback to test: simulation or production.",
            "required": true,
            "schema": {
              "enum": [
                "simulation",
                "production"
              ],
              "type": "string"
            },
            "example": "simulation"
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid environment, callback URL, request body, or filter. Webhook errors use code and message; unreadable bodies or filters use errors. Omit Api-Version for these version-neutral routes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Partner bearer token missing, invalid, or expired. Sign in through POST /api/Partner/Login. An authentication failure is not a webhook code/message response."
          },
          "403": {
            "description": "The token does not authorize a partner account. EGS-unit tokens cannot manage partner webhooks."
          },
          "202": {
            "description": "The test notification has been queued. Check delivery details using the returned eventId.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookAcceptedResponse"
                },
                "examples": {
                  "queued": {
                    "summary": "Test queued; receipt not yet confirmed",
                    "value": {
                      "eventId": "da2a4d14-919a-464c-a37c-1ad53161ac1f"
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookAcceptedResponse"
                },
                "examples": {
                  "queued": {
                    "summary": "Test queued; receipt not yet confirmed",
                    "value": {
                      "eventId": "da2a4d14-919a-464c-a37c-1ad53161ac1f"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Save a callback URL for this environment before sending a test.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "not-found": {
                    "summary": "Unavailable or expired notification, or missing endpoint",
                    "value": {
                      "code": "webhook_not_found",
                      "message": "The webhook or retained notification was not found."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "not-found": {
                    "summary": "Unavailable or expired notification, or missing endpoint",
                    "value": {
                      "code": "webhook_not_found",
                      "message": "The webhook or retained notification was not found."
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Wait one minute before another test, or refresh settings after a concurrent change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "concurrent-change": {
                    "summary": "Refresh after a concurrent change",
                    "value": {
                      "code": "webhook_changed",
                      "message": "The webhook changed during this request. Refresh and try again."
                    }
                  },
                  "test-limit": {
                    "summary": "Wait one minute between tests",
                    "value": {
                      "code": "webhook_conflict",
                      "message": "Wait one minute before sending another test notification."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "concurrent-change": {
                    "summary": "Refresh after a concurrent change",
                    "value": {
                      "code": "webhook_changed",
                      "message": "The webhook changed during this request. Refresh and try again."
                    }
                  },
                  "test-limit": {
                    "summary": "Wait one minute between tests",
                    "value": {
                      "code": "webhook_conflict",
                      "message": "Wait one minute before sending another test notification."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/Partner/webhooks/{environment}/deliveries": {
      "get": {
        "tags": [
          "PartnerWebhooks"
        ],
        "summary": "List your recent notifications and delivery results.",
        "description": "Lists retained notifications for this partner and environment, newest first.\r\nNotifications are retained for 30 days. Filters are combined; no matches returns an empty items array.\r\nDelivery status tells you whether your callback received the notification, not whether ZATCA accepted the invoice.\r\nDates filter notification creation time and must be supplied in UTC, with a Z suffix.\r\nExpired notifications are omitted, even if their history has not yet been cleaned up.",
        "operationId": "PartnerWebhooks_List",
        "parameters": [
          {
            "name": "environment",
            "in": "path",
            "description": "The notification environment: simulation or production.",
            "required": true,
            "schema": {
              "enum": [
                "simulation",
                "production"
              ],
              "type": "string"
            },
            "example": "simulation"
          },
          {
            "name": "EgsUnitId",
            "in": "query",
            "description": "Show only notifications for this EGS unit. Omit to include all your units in the selected environment.",
            "schema": {
              "type": "string"
            },
            "example": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314"
          },
          {
            "name": "Status",
            "in": "query",
            "description": "Filter callback delivery state: Pending, Delivering, Delivered, or Failed. Omit for all states. An unrecognized value returns no matches.",
            "schema": {
              "enum": [
                "Pending",
                "Delivering",
                "Delivered",
                "Failed"
              ],
              "type": "string"
            }
          },
          {
            "name": "Invoice",
            "in": "query",
            "description": "An exact invoice number (documentId), invoice UUID, or original Idempotency-Key (clientRequestId). Partial searches are not supported.",
            "schema": {
              "type": "string"
            },
            "example": "INV-2026-000184"
          },
          {
            "name": "FromUtc",
            "in": "query",
            "description": "Include notifications created at or after this UTC time, for example 2026-09-28T00:00:00Z. Filters notification creation time, not the invoice issue date.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-09-28T00:00:00Z"
          },
          {
            "name": "ToUtc",
            "in": "query",
            "description": "Include notifications created at or before this UTC time. If it is earlier than fromUtc, no notifications match.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-09-28T23:59:59Z"
          },
          {
            "name": "Page",
            "in": "query",
            "description": "Page number, starting at 1. Defaults to 1; values outside 1 through 100000 are adjusted to the nearest limit.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 1
            }
          },
          {
            "name": "PageSize",
            "in": "query",
            "description": "Maximum notifications per page. Defaults to 25; values outside 1 through 100 are adjusted to the nearest limit.",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 25
            }
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid environment, callback URL, request body, or filter. Webhook errors use code and message; unreadable bodies or filters use errors. Omit Api-Version for these version-neutral routes.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/WebhookErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  },
                  "invalid-date": {
                    "summary": "Date filter cannot be read",
                    "value": {
                      "errors": [
                        "The value 'not-a-date' is not valid for FromUtc."
                      ]
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/WebhookErrorResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  },
                  "invalid-date": {
                    "summary": "Date filter cannot be read",
                    "value": {
                      "errors": [
                        "The value 'not-a-date' is not valid for FromUtc."
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Partner bearer token missing, invalid, or expired. Sign in through POST /api/Partner/Login. An authentication failure is not a webhook code/message response."
          },
          "403": {
            "description": "The token does not authorize a partner account. EGS-unit tokens cannot manage partner webhooks."
          },
          "200": {
            "description": "A page of matching notifications, or an empty page when there are no matches.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryPage"
                },
                "examples": {
                  "notifications": {
                    "summary": "Recent notifications",
                    "value": {
                      "items": [
                        {
                          "eventId": "da2a4d14-919a-464c-a37c-1ad53161ac1f",
                          "eventType": "webhook.test",
                          "egsUnitId": null,
                          "clientRequestId": null,
                          "invoiceUuid": null,
                          "documentId": null,
                          "deliveryStatus": "Delivered",
                          "occurredAtUtc": "2026-09-28T12:05:00Z",
                          "expiresAtUtc": "2026-10-28T12:05:00Z",
                          "attemptCount": 2,
                          "nextAttemptAtUtc": null,
                          "lastHttpStatusCode": 204,
                          "lastError": null
                        },
                        {
                          "eventId": "7a05b0d6-e14a-4625-9e79-277ca52e1198",
                          "eventType": "invoice.reporting.completed",
                          "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                          "clientRequestId": "pos-2026-000184",
                          "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                          "documentId": "INV-2026-000184",
                          "deliveryStatus": "Delivered",
                          "occurredAtUtc": "2026-09-28T12:00:00Z",
                          "expiresAtUtc": "2026-10-28T12:00:00Z",
                          "attemptCount": 2,
                          "nextAttemptAtUtc": null,
                          "lastHttpStatusCode": 204,
                          "lastError": null
                        },
                        {
                          "eventId": "99b05a11-fb62-4913-98c2-61926aeb97ea",
                          "eventType": "invoice.reporting.delayed",
                          "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                          "clientRequestId": "pos-2026-000184",
                          "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                          "documentId": "INV-2026-000184",
                          "deliveryStatus": "Pending",
                          "occurredAtUtc": "2026-09-28T11:00:00Z",
                          "expiresAtUtc": "2026-10-28T11:00:00Z",
                          "attemptCount": 1,
                          "nextAttemptAtUtc": "2026-09-28T11:01:00Z",
                          "lastHttpStatusCode": 503,
                          "lastError": "The callback returned HTTP 503."
                        }
                      ],
                      "page": 1,
                      "pageSize": 25,
                      "total": 3
                    }
                  },
                  "empty": {
                    "summary": "No matching notifications",
                    "value": {
                      "items": [ ],
                      "page": 1,
                      "pageSize": 25,
                      "total": 0
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryPage"
                },
                "examples": {
                  "notifications": {
                    "summary": "Recent notifications",
                    "value": {
                      "items": [
                        {
                          "eventId": "da2a4d14-919a-464c-a37c-1ad53161ac1f",
                          "eventType": "webhook.test",
                          "egsUnitId": null,
                          "clientRequestId": null,
                          "invoiceUuid": null,
                          "documentId": null,
                          "deliveryStatus": "Delivered",
                          "occurredAtUtc": "2026-09-28T12:05:00Z",
                          "expiresAtUtc": "2026-10-28T12:05:00Z",
                          "attemptCount": 2,
                          "nextAttemptAtUtc": null,
                          "lastHttpStatusCode": 204,
                          "lastError": null
                        },
                        {
                          "eventId": "7a05b0d6-e14a-4625-9e79-277ca52e1198",
                          "eventType": "invoice.reporting.completed",
                          "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                          "clientRequestId": "pos-2026-000184",
                          "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                          "documentId": "INV-2026-000184",
                          "deliveryStatus": "Delivered",
                          "occurredAtUtc": "2026-09-28T12:00:00Z",
                          "expiresAtUtc": "2026-10-28T12:00:00Z",
                          "attemptCount": 2,
                          "nextAttemptAtUtc": null,
                          "lastHttpStatusCode": 204,
                          "lastError": null
                        },
                        {
                          "eventId": "99b05a11-fb62-4913-98c2-61926aeb97ea",
                          "eventType": "invoice.reporting.delayed",
                          "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                          "clientRequestId": "pos-2026-000184",
                          "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                          "documentId": "INV-2026-000184",
                          "deliveryStatus": "Pending",
                          "occurredAtUtc": "2026-09-28T11:00:00Z",
                          "expiresAtUtc": "2026-10-28T11:00:00Z",
                          "attemptCount": 1,
                          "nextAttemptAtUtc": "2026-09-28T11:01:00Z",
                          "lastHttpStatusCode": 503,
                          "lastError": "The callback returned HTTP 503."
                        }
                      ],
                      "page": 1,
                      "pageSize": 25,
                      "total": 3
                    }
                  },
                  "empty": {
                    "summary": "No matching notifications",
                    "value": {
                      "items": [ ],
                      "page": 1,
                      "pageSize": 25,
                      "total": 0
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/Partner/webhooks/{environment}/deliveries/{eventId}": {
      "get": {
        "tags": [
          "PartnerWebhooks"
        ],
        "summary": "View a notification, its original JSON, and recent delivery attempts.",
        "description": "Returns the stored notification body as the payloadJson string and up to 200 callback attempts, newest first.\r\nThe JSON is a snapshot from when the event was created; use invoice status polling for the latest reporting state.\r\nThis request does not read invoice XML or contact ZATCA. An event from another partner or environment,\r\nor one past its 30-day retention period, returns 404.",
        "operationId": "PartnerWebhooks_Detail",
        "parameters": [
          {
            "name": "environment",
            "in": "path",
            "description": "The environment in which the notification was created: simulation or production.",
            "required": true,
            "schema": {
              "enum": [
                "simulation",
                "production"
              ],
              "type": "string"
            },
            "example": "simulation"
          },
          {
            "name": "eventId",
            "in": "path",
            "description": "The notification's eventId UUID, from a callback, test response, or delivery list.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "7a05b0d6-e14a-4625-9e79-277ca52e1198"
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid environment, callback URL, request body, or filter. Webhook errors use code and message; unreadable bodies or filters use errors. Omit Api-Version for these version-neutral routes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Partner bearer token missing, invalid, or expired. Sign in through POST /api/Partner/Login. An authentication failure is not a webhook code/message response."
          },
          "403": {
            "description": "The token does not authorize a partner account. EGS-unit tokens cannot manage partner webhooks."
          },
          "200": {
            "description": "The notification snapshot and its current callback delivery history.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryDetail"
                },
                "examples": {
                  "completed": {
                    "summary": "Invoice accepted; callback delivery recovered",
                    "value": {
                      "delivery": {
                        "eventId": "7a05b0d6-e14a-4625-9e79-277ca52e1198",
                        "eventType": "invoice.reporting.completed",
                        "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                        "clientRequestId": "pos-2026-000184",
                        "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                        "documentId": "INV-2026-000184",
                        "deliveryStatus": "Delivered",
                        "occurredAtUtc": "2026-09-28T12:00:00Z",
                        "expiresAtUtc": "2026-10-28T12:00:00Z",
                        "attemptCount": 2,
                        "nextAttemptAtUtc": null,
                        "lastHttpStatusCode": 204,
                        "lastError": null
                      },
                      "payloadJson": "{\"eventId\":\"7a05b0d6-e14a-4625-9e79-277ca52e1198\",\"eventType\":\"invoice.reporting.completed\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T12:00:00Z\",\"environment\":\"simulation\",\"egsUnitId\":\"55d8edcb-4d1b-48a7-b58c-fd60e7edb314\",\"sequence\":2,\"data\":{\"clientRequestId\":\"pos-2026-000184\",\"invoiceUuid\":\"524881de-8ca0-461a-9460-f4b3b3c831dc\",\"documentId\":\"INV-2026-000184\",\"documentType\":\"SimplifiedTaxInvoice\",\"invoiceIssuanceStatus\":\"LocallyIssued\",\"zatcaSubmissionStatus\":\"Accepted\",\"zatcaSubmissionAttempts\":3,\"validation\":{\"status\":\"PASS\",\"info\":[{\"severity\":\"INFO\",\"code\":\"XSD_ZATCA_VALID\",\"category\":\"XSD validation\",\"message\":\"Complied with UBL 2.1 standards in line with ZATCA specifications\"}],\"warnings\":[],\"errors\":[]},\"nextZatcaRetryAtUtc\":null,\"lastProblem\":null,\"reportingRequiresAttention\":false}}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T12:01:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 204,
                          "durationMilliseconds": 125,
                          "error": null
                        },
                        {
                          "attemptedAtUtc": "2026-09-28T12:00:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  },
                  "callback-retrying": {
                    "summary": "Invoice accepted; callback retry scheduled",
                    "description": "A failed callback does not change the Accepted invoice result inside payloadJson.",
                    "value": {
                      "delivery": {
                        "eventId": "7a05b0d6-e14a-4625-9e79-277ca52e1198",
                        "eventType": "invoice.reporting.completed",
                        "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                        "clientRequestId": "pos-2026-000184",
                        "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                        "documentId": "INV-2026-000184",
                        "deliveryStatus": "Pending",
                        "occurredAtUtc": "2026-09-28T12:00:00Z",
                        "expiresAtUtc": "2026-10-28T12:00:00Z",
                        "attemptCount": 1,
                        "nextAttemptAtUtc": "2026-09-28T12:01:00Z",
                        "lastHttpStatusCode": 503,
                        "lastError": "The callback returned HTTP 503."
                      },
                      "payloadJson": "{\"eventId\":\"7a05b0d6-e14a-4625-9e79-277ca52e1198\",\"eventType\":\"invoice.reporting.completed\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T12:00:00Z\",\"environment\":\"simulation\",\"egsUnitId\":\"55d8edcb-4d1b-48a7-b58c-fd60e7edb314\",\"sequence\":2,\"data\":{\"clientRequestId\":\"pos-2026-000184\",\"invoiceUuid\":\"524881de-8ca0-461a-9460-f4b3b3c831dc\",\"documentId\":\"INV-2026-000184\",\"documentType\":\"SimplifiedTaxInvoice\",\"invoiceIssuanceStatus\":\"LocallyIssued\",\"zatcaSubmissionStatus\":\"Accepted\",\"zatcaSubmissionAttempts\":3,\"validation\":{\"status\":\"PASS\",\"info\":[{\"severity\":\"INFO\",\"code\":\"XSD_ZATCA_VALID\",\"category\":\"XSD validation\",\"message\":\"Complied with UBL 2.1 standards in line with ZATCA specifications\"}],\"warnings\":[],\"errors\":[]},\"nextZatcaRetryAtUtc\":null,\"lastProblem\":null,\"reportingRequiresAttention\":false}}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T12:00:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  },
                  "reporting-delayed": {
                    "summary": "Reporting delayed; automatic retries continue",
                    "value": {
                      "delivery": {
                        "eventId": "99b05a11-fb62-4913-98c2-61926aeb97ea",
                        "eventType": "invoice.reporting.delayed",
                        "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                        "clientRequestId": "pos-2026-000184",
                        "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                        "documentId": "INV-2026-000184",
                        "deliveryStatus": "Delivered",
                        "occurredAtUtc": "2026-09-28T11:00:00Z",
                        "expiresAtUtc": "2026-10-28T11:00:00Z",
                        "attemptCount": 2,
                        "nextAttemptAtUtc": null,
                        "lastHttpStatusCode": 204,
                        "lastError": null
                      },
                      "payloadJson": "{\"eventId\":\"99b05a11-fb62-4913-98c2-61926aeb97ea\",\"eventType\":\"invoice.reporting.delayed\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T11:00:00Z\",\"environment\":\"simulation\",\"egsUnitId\":\"55d8edcb-4d1b-48a7-b58c-fd60e7edb314\",\"sequence\":1,\"data\":{\"clientRequestId\":\"pos-2026-000184\",\"invoiceUuid\":\"524881de-8ca0-461a-9460-f4b3b3c831dc\",\"documentId\":\"INV-2026-000184\",\"documentType\":\"SimplifiedTaxInvoice\",\"invoiceIssuanceStatus\":\"LocallyIssued\",\"zatcaSubmissionStatus\":\"Unknown\",\"zatcaSubmissionAttempts\":2,\"validation\":{\"status\":\"UNKNOWN\",\"info\":[],\"warnings\":[],\"errors\":[]},\"nextZatcaRetryAtUtc\":\"2026-09-28T11:05:00Z\",\"lastProblem\":{\"source\":\"transport\",\"code\":\"zatca_timeout\",\"message\":\"The reporting request timed out or was interrupted. The outcome is unknown; this does not establish that ZATCA is unavailable.\",\"httpStatusCode\":null,\"observedAtUtc\":\"2026-09-28T10:59:00Z\"},\"reportingRequiresAttention\":false}}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T11:01:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 204,
                          "durationMilliseconds": 125,
                          "error": null
                        },
                        {
                          "attemptedAtUtc": "2026-09-28T11:00:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  },
                  "support-required": {
                    "summary": "Reporting delayed; contact support",
                    "value": {
                      "delivery": {
                        "eventId": "99b05a11-fb62-4913-98c2-61926aeb97ea",
                        "eventType": "invoice.reporting.delayed",
                        "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                        "clientRequestId": "pos-2026-000184",
                        "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                        "documentId": "INV-2026-000184",
                        "deliveryStatus": "Delivered",
                        "occurredAtUtc": "2026-09-28T11:00:00Z",
                        "expiresAtUtc": "2026-10-28T11:00:00Z",
                        "attemptCount": 2,
                        "nextAttemptAtUtc": null,
                        "lastHttpStatusCode": 204,
                        "lastError": null
                      },
                      "payloadJson": "{\"eventId\":\"99b05a11-fb62-4913-98c2-61926aeb97ea\",\"eventType\":\"invoice.reporting.delayed\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T11:00:00Z\",\"environment\":\"simulation\",\"egsUnitId\":\"55d8edcb-4d1b-48a7-b58c-fd60e7edb314\",\"sequence\":1,\"data\":{\"clientRequestId\":\"pos-2026-000184\",\"invoiceUuid\":\"524881de-8ca0-461a-9460-f4b3b3c831dc\",\"documentId\":\"INV-2026-000184\",\"documentType\":\"SimplifiedTaxInvoice\",\"invoiceIssuanceStatus\":\"LocallyIssued\",\"zatcaSubmissionStatus\":\"Unknown\",\"zatcaSubmissionAttempts\":2,\"validation\":{\"status\":\"UNKNOWN\",\"info\":[],\"warnings\":[],\"errors\":[]},\"nextZatcaRetryAtUtc\":null,\"lastProblem\":{\"source\":\"credentials_or_configuration\",\"code\":\"egs_reporting_credentials_unavailable\",\"message\":\"The existing invoice cannot be reported with this EGS unit\\u0027s current credentials or lifecycle state. Contact support; the original invoice has been preserved.\",\"httpStatusCode\":null,\"observedAtUtc\":\"2026-09-28T10:59:00Z\"},\"reportingRequiresAttention\":true}}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T11:01:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 204,
                          "durationMilliseconds": 125,
                          "error": null
                        },
                        {
                          "attemptedAtUtc": "2026-09-28T11:00:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  },
                  "test": {
                    "summary": "Endpoint test; no invoice",
                    "value": {
                      "delivery": {
                        "eventId": "da2a4d14-919a-464c-a37c-1ad53161ac1f",
                        "eventType": "webhook.test",
                        "egsUnitId": null,
                        "clientRequestId": null,
                        "invoiceUuid": null,
                        "documentId": null,
                        "deliveryStatus": "Delivered",
                        "occurredAtUtc": "2026-09-28T12:05:00Z",
                        "expiresAtUtc": "2026-10-28T12:05:00Z",
                        "attemptCount": 2,
                        "nextAttemptAtUtc": null,
                        "lastHttpStatusCode": 204,
                        "lastError": null
                      },
                      "payloadJson": "{\"eventId\":\"da2a4d14-919a-464c-a37c-1ad53161ac1f\",\"eventType\":\"webhook.test\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T12:05:00Z\",\"environment\":\"simulation\",\"egsUnitId\":null,\"sequence\":0,\"data\":null}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T12:06:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 204,
                          "durationMilliseconds": 125,
                          "error": null
                        },
                        {
                          "attemptedAtUtc": "2026-09-28T12:05:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryDetail"
                },
                "examples": {
                  "completed": {
                    "summary": "Invoice accepted; callback delivery recovered",
                    "value": {
                      "delivery": {
                        "eventId": "7a05b0d6-e14a-4625-9e79-277ca52e1198",
                        "eventType": "invoice.reporting.completed",
                        "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                        "clientRequestId": "pos-2026-000184",
                        "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                        "documentId": "INV-2026-000184",
                        "deliveryStatus": "Delivered",
                        "occurredAtUtc": "2026-09-28T12:00:00Z",
                        "expiresAtUtc": "2026-10-28T12:00:00Z",
                        "attemptCount": 2,
                        "nextAttemptAtUtc": null,
                        "lastHttpStatusCode": 204,
                        "lastError": null
                      },
                      "payloadJson": "{\"eventId\":\"7a05b0d6-e14a-4625-9e79-277ca52e1198\",\"eventType\":\"invoice.reporting.completed\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T12:00:00Z\",\"environment\":\"simulation\",\"egsUnitId\":\"55d8edcb-4d1b-48a7-b58c-fd60e7edb314\",\"sequence\":2,\"data\":{\"clientRequestId\":\"pos-2026-000184\",\"invoiceUuid\":\"524881de-8ca0-461a-9460-f4b3b3c831dc\",\"documentId\":\"INV-2026-000184\",\"documentType\":\"SimplifiedTaxInvoice\",\"invoiceIssuanceStatus\":\"LocallyIssued\",\"zatcaSubmissionStatus\":\"Accepted\",\"zatcaSubmissionAttempts\":3,\"validation\":{\"status\":\"PASS\",\"info\":[{\"severity\":\"INFO\",\"code\":\"XSD_ZATCA_VALID\",\"category\":\"XSD validation\",\"message\":\"Complied with UBL 2.1 standards in line with ZATCA specifications\"}],\"warnings\":[],\"errors\":[]},\"nextZatcaRetryAtUtc\":null,\"lastProblem\":null,\"reportingRequiresAttention\":false}}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T12:01:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 204,
                          "durationMilliseconds": 125,
                          "error": null
                        },
                        {
                          "attemptedAtUtc": "2026-09-28T12:00:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  },
                  "callback-retrying": {
                    "summary": "Invoice accepted; callback retry scheduled",
                    "description": "A failed callback does not change the Accepted invoice result inside payloadJson.",
                    "value": {
                      "delivery": {
                        "eventId": "7a05b0d6-e14a-4625-9e79-277ca52e1198",
                        "eventType": "invoice.reporting.completed",
                        "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                        "clientRequestId": "pos-2026-000184",
                        "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                        "documentId": "INV-2026-000184",
                        "deliveryStatus": "Pending",
                        "occurredAtUtc": "2026-09-28T12:00:00Z",
                        "expiresAtUtc": "2026-10-28T12:00:00Z",
                        "attemptCount": 1,
                        "nextAttemptAtUtc": "2026-09-28T12:01:00Z",
                        "lastHttpStatusCode": 503,
                        "lastError": "The callback returned HTTP 503."
                      },
                      "payloadJson": "{\"eventId\":\"7a05b0d6-e14a-4625-9e79-277ca52e1198\",\"eventType\":\"invoice.reporting.completed\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T12:00:00Z\",\"environment\":\"simulation\",\"egsUnitId\":\"55d8edcb-4d1b-48a7-b58c-fd60e7edb314\",\"sequence\":2,\"data\":{\"clientRequestId\":\"pos-2026-000184\",\"invoiceUuid\":\"524881de-8ca0-461a-9460-f4b3b3c831dc\",\"documentId\":\"INV-2026-000184\",\"documentType\":\"SimplifiedTaxInvoice\",\"invoiceIssuanceStatus\":\"LocallyIssued\",\"zatcaSubmissionStatus\":\"Accepted\",\"zatcaSubmissionAttempts\":3,\"validation\":{\"status\":\"PASS\",\"info\":[{\"severity\":\"INFO\",\"code\":\"XSD_ZATCA_VALID\",\"category\":\"XSD validation\",\"message\":\"Complied with UBL 2.1 standards in line with ZATCA specifications\"}],\"warnings\":[],\"errors\":[]},\"nextZatcaRetryAtUtc\":null,\"lastProblem\":null,\"reportingRequiresAttention\":false}}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T12:00:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  },
                  "reporting-delayed": {
                    "summary": "Reporting delayed; automatic retries continue",
                    "value": {
                      "delivery": {
                        "eventId": "99b05a11-fb62-4913-98c2-61926aeb97ea",
                        "eventType": "invoice.reporting.delayed",
                        "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                        "clientRequestId": "pos-2026-000184",
                        "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                        "documentId": "INV-2026-000184",
                        "deliveryStatus": "Delivered",
                        "occurredAtUtc": "2026-09-28T11:00:00Z",
                        "expiresAtUtc": "2026-10-28T11:00:00Z",
                        "attemptCount": 2,
                        "nextAttemptAtUtc": null,
                        "lastHttpStatusCode": 204,
                        "lastError": null
                      },
                      "payloadJson": "{\"eventId\":\"99b05a11-fb62-4913-98c2-61926aeb97ea\",\"eventType\":\"invoice.reporting.delayed\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T11:00:00Z\",\"environment\":\"simulation\",\"egsUnitId\":\"55d8edcb-4d1b-48a7-b58c-fd60e7edb314\",\"sequence\":1,\"data\":{\"clientRequestId\":\"pos-2026-000184\",\"invoiceUuid\":\"524881de-8ca0-461a-9460-f4b3b3c831dc\",\"documentId\":\"INV-2026-000184\",\"documentType\":\"SimplifiedTaxInvoice\",\"invoiceIssuanceStatus\":\"LocallyIssued\",\"zatcaSubmissionStatus\":\"Unknown\",\"zatcaSubmissionAttempts\":2,\"validation\":{\"status\":\"UNKNOWN\",\"info\":[],\"warnings\":[],\"errors\":[]},\"nextZatcaRetryAtUtc\":\"2026-09-28T11:05:00Z\",\"lastProblem\":{\"source\":\"transport\",\"code\":\"zatca_timeout\",\"message\":\"The reporting request timed out or was interrupted. The outcome is unknown; this does not establish that ZATCA is unavailable.\",\"httpStatusCode\":null,\"observedAtUtc\":\"2026-09-28T10:59:00Z\"},\"reportingRequiresAttention\":false}}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T11:01:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 204,
                          "durationMilliseconds": 125,
                          "error": null
                        },
                        {
                          "attemptedAtUtc": "2026-09-28T11:00:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  },
                  "support-required": {
                    "summary": "Reporting delayed; contact support",
                    "value": {
                      "delivery": {
                        "eventId": "99b05a11-fb62-4913-98c2-61926aeb97ea",
                        "eventType": "invoice.reporting.delayed",
                        "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
                        "clientRequestId": "pos-2026-000184",
                        "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
                        "documentId": "INV-2026-000184",
                        "deliveryStatus": "Delivered",
                        "occurredAtUtc": "2026-09-28T11:00:00Z",
                        "expiresAtUtc": "2026-10-28T11:00:00Z",
                        "attemptCount": 2,
                        "nextAttemptAtUtc": null,
                        "lastHttpStatusCode": 204,
                        "lastError": null
                      },
                      "payloadJson": "{\"eventId\":\"99b05a11-fb62-4913-98c2-61926aeb97ea\",\"eventType\":\"invoice.reporting.delayed\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T11:00:00Z\",\"environment\":\"simulation\",\"egsUnitId\":\"55d8edcb-4d1b-48a7-b58c-fd60e7edb314\",\"sequence\":1,\"data\":{\"clientRequestId\":\"pos-2026-000184\",\"invoiceUuid\":\"524881de-8ca0-461a-9460-f4b3b3c831dc\",\"documentId\":\"INV-2026-000184\",\"documentType\":\"SimplifiedTaxInvoice\",\"invoiceIssuanceStatus\":\"LocallyIssued\",\"zatcaSubmissionStatus\":\"Unknown\",\"zatcaSubmissionAttempts\":2,\"validation\":{\"status\":\"UNKNOWN\",\"info\":[],\"warnings\":[],\"errors\":[]},\"nextZatcaRetryAtUtc\":null,\"lastProblem\":{\"source\":\"credentials_or_configuration\",\"code\":\"egs_reporting_credentials_unavailable\",\"message\":\"The existing invoice cannot be reported with this EGS unit\\u0027s current credentials or lifecycle state. Contact support; the original invoice has been preserved.\",\"httpStatusCode\":null,\"observedAtUtc\":\"2026-09-28T10:59:00Z\"},\"reportingRequiresAttention\":true}}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T11:01:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 204,
                          "durationMilliseconds": 125,
                          "error": null
                        },
                        {
                          "attemptedAtUtc": "2026-09-28T11:00:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  },
                  "test": {
                    "summary": "Endpoint test; no invoice",
                    "value": {
                      "delivery": {
                        "eventId": "da2a4d14-919a-464c-a37c-1ad53161ac1f",
                        "eventType": "webhook.test",
                        "egsUnitId": null,
                        "clientRequestId": null,
                        "invoiceUuid": null,
                        "documentId": null,
                        "deliveryStatus": "Delivered",
                        "occurredAtUtc": "2026-09-28T12:05:00Z",
                        "expiresAtUtc": "2026-10-28T12:05:00Z",
                        "attemptCount": 2,
                        "nextAttemptAtUtc": null,
                        "lastHttpStatusCode": 204,
                        "lastError": null
                      },
                      "payloadJson": "{\"eventId\":\"da2a4d14-919a-464c-a37c-1ad53161ac1f\",\"eventType\":\"webhook.test\",\"schemaVersion\":\"1.0\",\"occurredAtUtc\":\"2026-09-28T12:05:00Z\",\"environment\":\"simulation\",\"egsUnitId\":null,\"sequence\":0,\"data\":null}",
                      "attempts": [
                        {
                          "attemptedAtUtc": "2026-09-28T12:06:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 204,
                          "durationMilliseconds": 125,
                          "error": null
                        },
                        {
                          "attemptedAtUtc": "2026-09-28T12:05:00Z",
                          "destinationUrl": "https://partner.example.com/webhooks/avtax",
                          "httpStatusCode": 503,
                          "durationMilliseconds": 180,
                          "error": "The callback returned HTTP 503."
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The notification is unavailable, expired, or does not belong to this partner and environment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "not-found": {
                    "summary": "Unavailable or expired notification, or missing endpoint",
                    "value": {
                      "code": "webhook_not_found",
                      "message": "The webhook or retained notification was not found."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "not-found": {
                    "summary": "Unavailable or expired notification, or missing endpoint",
                    "value": {
                      "code": "webhook_not_found",
                      "message": "The webhook or retained notification was not found."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/Partner/webhooks/{environment}/deliveries/{eventId}/replay": {
      "post": {
        "tags": [
          "PartnerWebhooks"
        ],
        "summary": "Resend a retained notification to your current callback URL.",
        "description": "Sends the same eventId and exact original JSON again, with a fresh delivery timestamp and signature.\r\nThis does not resubmit the invoice to ZATCA and still works after the temporary invoice XML has been deleted.\r\nThe callback must be enabled. If the notification is already Pending or Delivering, this returns 202\r\nwithout adding another delivery cycle. Otherwise, failed delivery is retried for up to 72 hours,\r\nlimited by the notification's original 30-day expiry. Resending never extends that expiry.\r\nA 202 response confirms acceptance of the resend request, not receipt by your callback.",
        "operationId": "PartnerWebhooks_Replay",
        "parameters": [
          {
            "name": "environment",
            "in": "path",
            "description": "The notification's environment: simulation or production.",
            "required": true,
            "schema": {
              "enum": [
                "simulation",
                "production"
              ],
              "type": "string"
            },
            "example": "simulation"
          },
          {
            "name": "eventId",
            "in": "path",
            "description": "The eventId UUID of the retained notification to send again.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "7a05b0d6-e14a-4625-9e79-277ca52e1198"
          }
        ],
        "responses": {
          "400": {
            "description": "Invalid environment, callback URL, request body, or filter. Webhook errors use code and message; unreadable bodies or filters use errors. Omit Api-Version for these version-neutral routes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "invalid-environment": {
                    "summary": "Use simulation or production",
                    "value": {
                      "code": "invalid_webhook_request",
                      "message": "Environment must be production or simulation."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Partner bearer token missing, invalid, or expired. Sign in through POST /api/Partner/Login. An authentication failure is not a webhook code/message response."
          },
          "403": {
            "description": "The token does not authorize a partner account. EGS-unit tokens cannot manage partner webhooks."
          },
          "202": {
            "description": "Resend queued, or the notification is already waiting to be delivered. The original eventId is returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookAcceptedResponse"
                },
                "examples": {
                  "accepted": {
                    "summary": "Resend accepted; original event ID retained",
                    "description": "The same response is returned if the event is already Pending or Delivering; another active cycle is not created.",
                    "value": {
                      "eventId": "7a05b0d6-e14a-4625-9e79-277ca52e1198"
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookAcceptedResponse"
                },
                "examples": {
                  "accepted": {
                    "summary": "Resend accepted; original event ID retained",
                    "description": "The same response is returned if the event is already Pending or Delivering; another active cycle is not created.",
                    "value": {
                      "eventId": "7a05b0d6-e14a-4625-9e79-277ca52e1198"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The notification or callback is unavailable, expired, or belongs to another partner or environment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "not-found": {
                    "summary": "Unavailable or expired notification, or missing endpoint",
                    "value": {
                      "code": "webhook_not_found",
                      "message": "The webhook or retained notification was not found."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "not-found": {
                    "summary": "Unavailable or expired notification, or missing endpoint",
                    "value": {
                      "code": "webhook_not_found",
                      "message": "The webhook or retained notification was not found."
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Enable the callback before resending, or refresh settings after a concurrent change.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "concurrent-change": {
                    "summary": "Refresh after a concurrent change",
                    "value": {
                      "code": "webhook_changed",
                      "message": "The webhook changed during this request. Refresh and try again."
                    }
                  },
                  "endpoint-paused": {
                    "summary": "Enable notifications before resending",
                    "value": {
                      "code": "webhook_conflict",
                      "message": "Enable the webhook endpoint before resending notifications."
                    }
                  }
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookErrorResponse"
                },
                "examples": {
                  "concurrent-change": {
                    "summary": "Refresh after a concurrent change",
                    "value": {
                      "code": "webhook_changed",
                      "message": "The webhook changed during this request. Refresh and try again."
                    }
                  },
                  "endpoint-paused": {
                    "summary": "Enable notifications before resending",
                    "value": {
                      "code": "webhook_conflict",
                      "message": "Enable the webhook endpoint before resending notifications."
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AdditionalIDScheme": {
        "enum": [
          "None",
          "CRN",
          "MOM",
          "MLS",
          "Number700",
          "SAG",
          "OTH",
          "TIN",
          "NAT",
          "IQA",
          "PAS",
          "GCC"
        ],
        "type": "string"
      },
      "ChangePasswordCommand": {
        "type": "object",
        "properties": {
          "currrentPassword": {
            "type": "string",
            "nullable": true
          },
          "newPassword": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CreateNewEgsUnitCommand": {
        "required": [
          "address"
        ],
        "type": "object",
        "properties": {
          "commonName": {
            "type": "string",
            "description": "Provided by the Taxpayer for each Solution unit: Unique Name or Asset Tracking Number of the Solution Unit",
            "default": "Default Common Name",
            "nullable": true
          },
          "organizationName": {
            "type": "string",
            "default": "Default Organization Name",
            "nullable": true
          },
          "organizationUnitName": {
            "type": "string",
            "default": "Default Organization Unit Name",
            "nullable": true
          },
          "serialNumber": {
            "type": "string",
            "default": "1-Manufacturer or Solution Provider Name|2-Model or Version|3-SerialNumber",
            "nullable": true
          },
          "vatNumber": {
            "type": "string",
            "default": "300075588700003",
            "nullable": true
          },
          "additionalID": {
            "type": "string",
            "nullable": true
          },
          "additionalIDSchemeID": {
            "$ref": "#/components/schemas/AdditionalIDScheme"
          },
          "invoiceType": {
            "type": "string",
            "default": "1100",
            "nullable": true
          },
          "industry": {
            "type": "string",
            "default": "Default Industry",
            "nullable": true
          },
          "isProduction": {
            "type": "boolean",
            "default": false
          },
          "address": {
            "$ref": "#/components/schemas/PartyPostalAddress"
          },
          "otp": {
            "type": "string",
            "default": "537888",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CreateNewEgsUnitResponse": {
        "type": "object",
        "properties": {
          "clientId": {
            "type": "string",
            "nullable": true
          },
          "clientSecret": {
            "type": "string",
            "nullable": true
          },
          "egsUnitId": {
            "type": "string",
            "nullable": true
          },
          "lifecycleStatus": {
            "$ref": "#/components/schemas/EgsUnitLifecycleStatus"
          },
          "certificateExpiresAtUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "invoiceAcceptanceStopsAtUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "newInvoiceSubmissionAllowed": {
            "type": "boolean"
          },
          "isProduction": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CreateNewUserCommand": {
        "type": "object",
        "properties": {
          "fullName": {
            "type": "string",
            "default": "John Doe",
            "nullable": true
          },
          "email": {
            "type": "string",
            "default": "johndoe@example.com",
            "nullable": true
          },
          "phoneNumber": {
            "type": "string",
            "default": "+1234567890",
            "nullable": true
          },
          "password": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EgsUnitLifecycleStatus": {
        "enum": [
          "Active",
          "Expiring",
          "Expired",
          "Retired",
          "Revoked",
          "Archived"
        ],
        "type": "string",
        "description": "Operational lifecycle of an EGS unit. Historical units are retained so their\r\ninvoices and chain remain auditable even after credentials can no longer be used."
      },
      "EgsUnitProfileEditor": {
        "enum": [
          "Partner",
          "EgsUnit"
        ],
        "type": "string",
        "description": "Who saved an EGS unit profile: the partner that owns the unit, or the unit with its own token."
      },
      "EgsUnitProfileError": {
        "type": "object",
        "properties": {
          "traceId": {
            "type": "string",
            "nullable": true
          },
          "code": {
            "type": "string",
            "description": "invalid_profile, nothing_to_change, egs_unit_not_found, egs_unit_closed or profile_changed.",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "nullable": true
            },
            "description": "For invalid_profile: each refused field and what to change.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A refused profile call."
      },
      "EgsUnitProfileImage": {
        "type": "object",
        "properties": {
          "contentType": {
            "type": "string",
            "nullable": true
          },
          "width": {
            "type": "integer",
            "format": "int32"
          },
          "height": {
            "type": "integer",
            "format": "int32"
          },
          "bytes": {
            "type": "integer",
            "format": "int32"
          },
          "sha256": {
            "type": "string",
            "nullable": true
          },
          "dataUrl": {
            "type": "string",
            "description": "The image itself, ready for an img tag: data:image/png;base64,...",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "EgsUnitProfileView": {
        "type": "object",
        "properties": {
          "egsUnitId": {
            "type": "string",
            "nullable": true
          },
          "bankName": {
            "type": "string",
            "nullable": true
          },
          "accountName": {
            "type": "string",
            "nullable": true
          },
          "accountNumber": {
            "type": "string",
            "nullable": true
          },
          "iban": {
            "type": "string",
            "nullable": true
          },
          "pdfTemplate": {
            "$ref": "#/components/schemas/PdfA3Templete"
          },
          "logo": {
            "$ref": "#/components/schemas/EgsUnitProfileImage"
          },
          "stamp": {
            "$ref": "#/components/schemas/EgsUnitProfileImage"
          },
          "version": {
            "type": "integer",
            "description": "0 until the profile is first saved. Also sent as the ETag header.",
            "format": "int32"
          },
          "updatedAtUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "updatedBy": {
            "$ref": "#/components/schemas/EgsUnitProfileEditor"
          }
        },
        "additionalProperties": false,
        "description": "The profile as GET and PATCH return it."
      },
      "EgsUnitStatisticsDto": {
        "type": "object",
        "properties": {
          "egsUnitId": {
            "type": "string",
            "description": "Unique identifier for the EgsUnit.",
            "nullable": true
          },
          "egsUnitName": {
            "type": "string",
            "description": "Name or description of the EgsUnit.",
            "nullable": true
          },
          "simplifiedInvoiceCount": {
            "type": "integer",
            "description": "Count of Simplified invoices.",
            "format": "int32"
          },
          "standardInvoiceCount": {
            "type": "integer",
            "description": "Count of Standard invoices.",
            "format": "int32"
          },
          "totalInvoices": {
            "type": "integer",
            "description": "Total number of invoices for this EgsUnit, calculated as the sum of \r\nSimplifiedInvoiceCount and StandardInvoiceCount.",
            "format": "int32",
            "readOnly": true
          },
          "totalAmountInvoiced": {
            "type": "number",
            "description": "Total amount invoiced for both Simplified and Standard invoices.",
            "format": "double"
          },
          "averageInvoiceAmount": {
            "type": "number",
            "description": "Average amount per invoice, calculated as TotalAmountInvoiced divided by TotalInvoices.",
            "format": "double"
          },
          "lastInvoiceDate": {
            "type": "string",
            "description": "Date when the last invoice was submitted for this EgsUnit.",
            "format": "date-time",
            "nullable": true
          },
          "isProduction": {
            "type": "boolean",
            "description": "Indicates whether this EgsUnit is in production."
          }
        },
        "additionalProperties": false,
        "description": "Represents the statistics for a single EgsUnit, including details about its invoices."
      },
      "EgsUnitSuspensionResponse": {
        "type": "object",
        "properties": {
          "egsUnitId": {
            "type": "string",
            "nullable": true
          },
          "isSuspended": {
            "type": "boolean",
            "description": "True while new v1 and v2 invoice submissions are refused."
          },
          "suspendedAtUtc": {
            "type": "string",
            "description": "When the unit was suspended, in UTC. Suspending it again keeps this time.",
            "format": "date-time",
            "nullable": true
          },
          "suspensionNote": {
            "type": "string",
            "description": "Your note on why the unit is suspended, if you added one.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Whether an EGS unit currently accepts new invoices through Invoice API v1 and v2."
      },
      "EgsUnits": {
        "type": "object",
        "properties": {
          "clientId": {
            "type": "string",
            "nullable": true
          },
          "clientSecret": {
            "type": "string",
            "nullable": true
          },
          "egsUnitId": {
            "type": "string",
            "nullable": true
          },
          "organizationName": {
            "type": "string",
            "nullable": true
          },
          "vatNumber": {
            "type": "string",
            "nullable": true
          },
          "additionalIDSchemeID": {
            "type": "string",
            "nullable": true
          },
          "schemeIDName": {
            "type": "string",
            "nullable": true
          },
          "additionalID": {
            "type": "string",
            "nullable": true
          },
          "isProduction": {
            "type": "boolean"
          },
          "maximumNumberOfInvoicesPerMonth": {
            "type": "integer",
            "format": "int32"
          },
          "rateLimitPerMinute": {
            "type": "integer",
            "format": "int32"
          },
          "serialNumber": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lifecycleStatus": {
            "$ref": "#/components/schemas/EgsUnitLifecycleStatus"
          },
          "certificateExpiresAtUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "invoiceAcceptanceStopsAtUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "newInvoiceSubmissionAllowed": {
            "type": "boolean",
            "description": "Whether the unit's certificate still allows new invoices. Suspension is reported separately in IsSuspended."
          },
          "replacedByEgsUnitId": {
            "type": "string",
            "nullable": true
          },
          "isSuspended": {
            "type": "boolean",
            "description": "True while you have suspended the unit. New v1 and v2 invoices are refused even when NewInvoiceSubmissionAllowed is true."
          },
          "suspendedAtUtc": {
            "type": "string",
            "description": "When you suspended the unit, in UTC. Null when it isn't suspended.",
            "format": "date-time",
            "nullable": true
          },
          "suspensionNote": {
            "type": "string",
            "description": "Your note on why the unit is suspended, if any.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Problems with the request or requested operation. Correct any invalid or missing values before retrying.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Explanations of why a request could not be completed."
      },
      "FinalizePasswordResetCommand": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "nullable": true
          },
          "token": {
            "type": "string",
            "nullable": true
          },
          "newPassword": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "InvoiceKind": {
        "enum": [
          "TaxInvoiceCreditNote",
          "SimplifiedCreditNote",
          "TaxInvoiceDebitNote",
          "SimplifiedDebitNote",
          "PrepaymentTaxInvoice",
          "PrepaymentSimplifiedTaxInvoice",
          "TaxInvoice",
          "SimplifiedTaxInvoice"
        ],
        "type": "string"
      },
      "InvoiceV2IssuanceStatus": {
        "enum": [
          "Validated",
          "LocallyIssued",
          "Cleared"
        ],
        "type": "string"
      },
      "InvoiceV2Problem": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "description": "Where the problem was observed: zatca_response (an authority response), transport (a connection failure or timeout), storage (AVTax invoice storage), credentials_or_configuration (a setup problem requiring attention), or unknown. A transport failure does not prove ZATCA is down.",
            "nullable": true
          },
          "code": {
            "type": "string",
            "description": "A short problem identifier your integration can record or share with support.",
            "nullable": true
          },
          "message": {
            "type": "string",
            "description": "A safe explanation of what happened, without credentials or raw external response bodies.",
            "nullable": true
          },
          "httpStatusCode": {
            "type": "integer",
            "description": "HTTP status associated with the problem, when one was received. Null for failures with no HTTP response.",
            "format": "int32",
            "nullable": true
          },
          "observedAtUtc": {
            "type": "string",
            "description": "When this problem was recorded, in UTC. This can be earlier than the notification's creation or delivery time.",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "The last observed reporting problem, not an inferred cause of an outage.",
        "example": {
          "source": "transport",
          "code": "zatca_timeout",
          "message": "The reporting request timed out or was interrupted. The outcome is unknown; this does not establish that ZATCA is unavailable.",
          "httpStatusCode": null,
          "observedAtUtc": "2026-09-28T10:59:00Z"
        }
      },
      "InvoiceV2SubmissionOutcome": {
        "enum": [
          "Pending",
          "Submitting",
          "Accepted",
          "AcceptedWithWarnings",
          "Rejected",
          "Unknown"
        ],
        "type": "string"
      },
      "InvoiceV2ValidationMessage": {
        "type": "object",
        "properties": {
          "severity": {
            "type": "string",
            "description": "The message severity reported by the validator, such as INFO, WARNING, or ERROR.",
            "nullable": true
          },
          "code": {
            "type": "string",
            "description": "The validator's machine-readable rule or result code.",
            "nullable": true
          },
          "category": {
            "type": "string",
            "description": "The validation source or rule category.",
            "nullable": true
          },
          "message": {
            "type": "string",
            "description": "The human-readable validation detail.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "InvoiceV2ValidationSummary": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "description": "The overall validation result reported by the API or ZATCA, such as PASS, ERROR, or UNKNOWN.",
            "nullable": true
          },
          "info": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceV2ValidationMessage"
            },
            "description": "Informational validation messages that do not require a correction.",
            "nullable": true
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceV2ValidationMessage"
            },
            "description": "Validation warnings that should be reviewed but did not prevent issuance.",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceV2ValidationMessage"
            },
            "description": "Validation errors that prevented or rejected the requested operation.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "InvoiceWebhookData": {
        "type": "object",
        "properties": {
          "clientRequestId": {
            "type": "string",
            "description": "The Idempotency-Key used when submitting the invoice. Use it to match the update to your original request or poll the invoice status.",
            "nullable": true
          },
          "invoiceUuid": {
            "type": "string",
            "description": "The UUID assigned to the signed invoice. It stays the same across reporting attempts.",
            "nullable": true
          },
          "documentId": {
            "type": "string",
            "description": "Your invoice number, supplied as documentId when submitting the invoice.",
            "nullable": true
          },
          "documentType": {
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceKind"
              }
            ],
            "description": "The kind of simplified invoice or note, such as SimplifiedTaxInvoice or SimplifiedCreditNote."
          },
          "invoiceIssuanceStatus": {
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceV2IssuanceStatus"
              }
            ],
            "description": "Whether AVTax has issued the invoice locally. LocallyIssued does not, by itself, mean ZATCA has accepted it."
          },
          "zatcaSubmissionStatus": {
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceV2SubmissionOutcome"
              }
            ],
            "description": "The reporting result. Completed events use Accepted, AcceptedWithWarnings, or Rejected. Delayed events remain Pending or Unknown."
          },
          "zatcaSubmissionAttempts": {
            "type": "integer",
            "description": "Number of recorded reporting attempts for this invoice when the event was created. This is separate from callback delivery attempts.",
            "format": "int32"
          },
          "validation": {
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceV2ValidationSummary"
              }
            ],
            "description": "Validation information, warnings, and errors recorded for the invoice. Review warnings even when reporting succeeds."
          },
          "nextZatcaRetryAtUtc": {
            "type": "string",
            "description": "When AVTax plans to retry reporting, in UTC. Null when no retry is scheduled, including final results and cases that require support.",
            "format": "date-time",
            "nullable": true
          },
          "lastProblem": {
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceV2Problem"
              }
            ],
            "description": "The last recorded reporting problem and when it was observed. Null when none is recorded. Read its source rather than assuming ZATCA is unavailable.",
            "nullable": true
          },
          "reportingRequiresAttention": {
            "type": "boolean",
            "description": "True when support must resolve a problem, such as unavailable XML or unusable credentials, before reporting can continue. Contact support; do not issue a replacement invoice for the same request."
          }
        },
        "additionalProperties": false,
        "description": "Invoice identifiers and reporting results. This snapshot contains no invoice XML, QR payload, or credentials.",
        "example": {
          "clientRequestId": "pos-2026-000184",
          "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
          "documentId": "INV-2026-000184",
          "documentType": "SimplifiedTaxInvoice",
          "invoiceIssuanceStatus": "LocallyIssued",
          "zatcaSubmissionStatus": "Accepted",
          "zatcaSubmissionAttempts": 3,
          "validation": {
            "status": "PASS",
            "info": [
              {
                "severity": "INFO",
                "code": "XSD_ZATCA_VALID",
                "category": "XSD validation",
                "message": "Complied with UBL 2.1 standards in line with ZATCA specifications"
              }
            ],
            "warnings": [ ],
            "errors": [ ]
          },
          "nextZatcaRetryAtUtc": null,
          "lastProblem": null,
          "reportingRequiresAttention": false
        }
      },
      "InvoiceWebhookPayload": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string",
            "description": "Unique notification ID. Store it to detect duplicates; retries and manual resends keep the same ID.",
            "format": "uuid"
          },
          "eventType": {
            "type": "string",
            "description": "What happened: invoice.reporting.delayed, invoice.reporting.completed, or webhook.test.",
            "nullable": true
          },
          "schemaVersion": {
            "type": "string",
            "description": "Version of this notification's JSON structure. Currently 1.0.",
            "nullable": true
          },
          "occurredAtUtc": {
            "type": "string",
            "description": "When AVTax created this notification, in UTC. This stays unchanged when the notification is resent.",
            "format": "date-time"
          },
          "environment": {
            "type": "string",
            "description": "The environment this notification belongs to: simulation or production.",
            "nullable": true
          },
          "egsUnitId": {
            "type": "string",
            "description": "The EGS unit that issued the invoice. Use it to route updates when one callback serves many units. Null for webhook.test.",
            "nullable": true
          },
          "sequence": {
            "type": "integer",
            "description": "Order within one invoice operation: 1 for delayed, 2 for completed. A completed event can arrive without a delayed event. Test events use 0. Do not replace a completed result with a delayed result received later.",
            "format": "int32"
          },
          "data": {
            "allOf": [
              {
                "$ref": "#/components/schemas/InvoiceWebhookData"
              }
            ],
            "description": "The invoice's state when this notification was created. Null for webhook.test.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A signed notification sent to your saved callback URL.",
        "example": {
          "eventId": "7a05b0d6-e14a-4625-9e79-277ca52e1198",
          "eventType": "invoice.reporting.completed",
          "schemaVersion": "1.0",
          "occurredAtUtc": "2026-09-28T12:00:00Z",
          "environment": "simulation",
          "egsUnitId": "55d8edcb-4d1b-48a7-b58c-fd60e7edb314",
          "sequence": 2,
          "data": {
            "clientRequestId": "pos-2026-000184",
            "invoiceUuid": "524881de-8ca0-461a-9460-f4b3b3c831dc",
            "documentId": "INV-2026-000184",
            "documentType": "SimplifiedTaxInvoice",
            "invoiceIssuanceStatus": "LocallyIssued",
            "zatcaSubmissionStatus": "Accepted",
            "zatcaSubmissionAttempts": 3,
            "validation": {
              "status": "PASS",
              "info": [
                {
                  "severity": "INFO",
                  "code": "XSD_ZATCA_VALID",
                  "category": "XSD validation",
                  "message": "Complied with UBL 2.1 standards in line with ZATCA specifications"
                }
              ],
              "warnings": [ ],
              "errors": [ ]
            },
            "nextZatcaRetryAtUtc": null,
            "lastProblem": null,
            "reportingRequiresAttention": false
          }
        }
      },
      "LoginCommand": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "nullable": true
          },
          "password": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "MonthlyInvoiceStatisticsDto": {
        "type": "object",
        "properties": {
          "year": {
            "type": "integer",
            "format": "int32"
          },
          "month": {
            "type": "integer",
            "format": "int32"
          },
          "invoiceCount": {
            "type": "integer",
            "format": "int32"
          },
          "totalAmount": {
            "type": "number",
            "format": "double"
          }
        },
        "additionalProperties": false
      },
      "PartyPostalAddress": {
        "type": "object",
        "properties": {
          "streetName": {
            "maxLength": 127,
            "minLength": 1,
            "type": "string",
            "description": "The street name of the address.",
            "default": "شارع الأمير محمد بن عبد العزيز",
            "nullable": true
          },
          "additionalStreetName": {
            "type": "string",
            "description": "Any additional information about the street name.",
            "default": "الرياض",
            "nullable": true
          },
          "buildingNumber": {
            "type": "string",
            "description": "The building number of the address.",
            "default": "1234",
            "nullable": true
          },
          "plotIdentification": {
            "type": "string",
            "description": "The plot identification number of the address.",
            "default": "5678",
            "nullable": true
          },
          "citySubdivisionName": {
            "type": "string",
            "description": "The subdivision name of the city for the address.",
            "default": "الرياض",
            "nullable": true
          },
          "cityName": {
            "type": "string",
            "description": "The city name of the address.",
            "default": "الرياض",
            "nullable": true
          },
          "postalZone": {
            "maxLength": 5,
            "type": "string",
            "description": "The postal zone (or zip code) of the address.",
            "default": "11564",
            "nullable": true
          },
          "countrySubentity": {
            "type": "string",
            "description": "The subentity of the country for the address.",
            "default": "منطقة الرياض",
            "nullable": true
          },
          "country": {
            "maxLength": 2,
            "type": "string",
            "description": "The country of the address. This property accepts only ISO 3166-1 alpha-2 country codes (e.g., \"SA\" for Saudi Arabia).",
            "default": "SA",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PdfA3Templete": {
        "enum": [
          "ZatcaTemplate",
          "SimplifiedTemplate",
          "SimplifiedTemplateAr",
          "CustomTemplate",
          "ModernTemplate",
          "ModernTemplateAr",
          "SimplifiedMixedTemplate"
        ],
        "type": "string"
      },
      "RenewEgsUnitCertificateCommand": {
        "type": "object",
        "properties": {
          "otp": {
            "type": "string",
            "description": "The one time password generated from the Fatoora portal.",
            "default": "537888",
            "nullable": true
          },
          "commonName": {
            "type": "string",
            "description": "Optional. Overrides the stored Common Name when provided.",
            "nullable": true
          },
          "organizationIdentifier": {
            "type": "string",
            "description": "Optional. Overrides the stored VAT / Organization Identifier when provided.",
            "nullable": true
          },
          "organizationUnitName": {
            "type": "string",
            "description": "Optional. Overrides the stored Organization Unit Name when provided.",
            "nullable": true
          },
          "organizationName": {
            "type": "string",
            "description": "Optional. Overrides the stored Organization Name when provided.",
            "nullable": true
          },
          "invoiceType": {
            "type": "string",
            "description": "Optional. Overrides the stored Invoice Type when provided.",
            "nullable": true
          },
          "locationAddress": {
            "type": "string",
            "description": "Optional. Overrides the stored Location Address when provided.",
            "nullable": true
          },
          "industry": {
            "type": "string",
            "description": "Optional. Overrides the stored Industry when provided.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Command to renew the ZATCA production certificate of an EGS unit owned by a partner.\r\n\r\n\r\nAny CSR identity field left null reuses the value currently stored for the EGS unit.\r\nSupplying a value overrides it and persists the new value against the unit.\r\n"
      },
      "RenewEgsUnitCertificateResponse": {
        "type": "object",
        "properties": {
          "egsUnitId": {
            "type": "string",
            "description": "The unique identifier of the EGS unit whose certificate was renewed. The signing\r\ncredential remains server-side and is never returned to the partner.",
            "nullable": true
          },
          "lifecycleStatus": {
            "$ref": "#/components/schemas/EgsUnitLifecycleStatus"
          },
          "certificateExpiresAtUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "invoiceAcceptanceStopsAtUtc": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "newInvoiceSubmissionAllowed": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ResetPasswordCommand": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "RevokeEgsSecretResponse": {
        "type": "object",
        "properties": {
          "clientSecret": {
            "type": "string",
            "description": "The newly generated client secret.",
            "nullable": true
          },
          "egsUnitId": {
            "type": "string",
            "description": "The unique identifier of the Egs Unit.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SuspendEgsUnitRequest": {
        "type": "object",
        "properties": {
          "note": {
            "type": "string",
            "description": "Why the unit is suspended, up to 200 characters, for example \"Branch closed for renovation\".\r\nOnly you see it; it isn't sent to anyone submitting invoices with the unit.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Optional details for suspending an EGS unit."
      },
      "WebhookAcceptedResponse": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string",
            "description": "The notification ID. Use it with GET deliveries/{eventId} to check delivery. Resending an existing notification returns its original ID.",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "Confirms that a notification is queued or already waiting to be delivered. It does not confirm receipt by your callback."
      },
      "WebhookAttemptResponse": {
        "type": "object",
        "properties": {
          "attemptedAtUtc": {
            "type": "string",
            "description": "When this callback attempt started, in UTC.",
            "format": "date-time"
          },
          "destinationUrl": {
            "type": "string",
            "description": "The callback URL used for this attempt. Query parameters are omitted from history. Earlier attempts may show an older URL if your settings changed.",
            "nullable": true
          },
          "httpStatusCode": {
            "type": "integer",
            "description": "The HTTP status your callback returned. Any 2xx acknowledges receipt. Null when no HTTP response was received.",
            "format": "int32",
            "nullable": true
          },
          "durationMilliseconds": {
            "type": "integer",
            "description": "Time spent attempting delivery, in milliseconds. A callback request has a 10-second timeout.",
            "format": "int64"
          },
          "error": {
            "type": "string",
            "description": "Explanation of this attempt's failure. Null for a successful delivery. Callback response bodies are not included.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "The result of one attempt to send a notification to your callback."
      },
      "WebhookDeliveryDetail": {
        "type": "object",
        "properties": {
          "delivery": {
            "allOf": [
              {
                "$ref": "#/components/schemas/WebhookDeliverySummary"
              }
            ],
            "description": "Current callback delivery state and invoice identifiers."
          },
          "payloadJson": {
            "type": "string",
            "description": "The exact original notification JSON, returned here as a string. Parse it to inspect the event; do not mistake it for an additional nested object in the callback body. Retries and resends use these same bytes.",
            "nullable": true
          },
          "attempts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookAttemptResponse"
            },
            "description": "Up to 200 most recent callback attempts, newest first. Empty before the first attempt. delivery.attemptCount is the total across all attempts.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A retained notification's delivery state, original JSON, and recent callback attempts."
      },
      "WebhookDeliveryPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookDeliverySummary"
            },
            "description": "Notifications on this page. Empty when no retained notifications match the filters.",
            "nullable": true
          },
          "page": {
            "type": "integer",
            "description": "The page returned, starting at 1. The requested value is limited to 1 through 100000.",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "description": "Maximum notifications per page, limited to 1 through 100. The default is 25.",
            "format": "int32"
          },
          "total": {
            "type": "integer",
            "description": "Total retained notifications matching the filters across all pages, not just this page.",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "A page of retained notifications, ordered from newest to oldest."
      },
      "WebhookDeliverySummary": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string",
            "description": "Unique notification ID. Use it to view details, resend the notification, and deduplicate received events.",
            "format": "uuid"
          },
          "eventType": {
            "type": "string",
            "description": "The notification type: invoice.reporting.delayed, invoice.reporting.completed, or webhook.test.",
            "nullable": true
          },
          "egsUnitId": {
            "type": "string",
            "description": "The invoice's EGS unit ID. Null for an endpoint test.",
            "nullable": true
          },
          "clientRequestId": {
            "type": "string",
            "description": "The Idempotency-Key of the invoice request. Null for an endpoint test.",
            "nullable": true
          },
          "invoiceUuid": {
            "type": "string",
            "description": "The signed invoice's UUID. Null for an endpoint test.",
            "nullable": true
          },
          "documentId": {
            "type": "string",
            "description": "Your invoice number. Null for an endpoint test.",
            "nullable": true
          },
          "deliveryStatus": {
            "type": "string",
            "description": "Callback delivery state: Pending (queued, awaiting retry, or paused), Delivering, Delivered (your callback returned any 2xx), or Failed (the retry window ended). This is not the invoice's ZATCA result.",
            "nullable": true
          },
          "occurredAtUtc": {
            "type": "string",
            "description": "When this notification was created, in UTC. Retrying or resending does not change it.",
            "format": "date-time"
          },
          "expiresAtUtc": {
            "type": "string",
            "description": "When the notification's 30-day retention ends, in UTC. After this time it can no longer be viewed or resent and returns 404.",
            "format": "date-time"
          },
          "attemptCount": {
            "type": "integer",
            "description": "Total recorded callback delivery attempts, including automatic retries and manual resends. This does not count ZATCA reporting attempts.",
            "format": "int32"
          },
          "nextAttemptAtUtc": {
            "type": "string",
            "description": "The next planned callback attempt, in UTC. Null when none is scheduled. A pending invoice notification remains paused while the endpoint is disabled.",
            "format": "date-time",
            "nullable": true
          },
          "lastHttpStatusCode": {
            "type": "integer",
            "description": "HTTP status returned by your callback on the latest recorded attempt, such as 204 or 503. Null before the first attempt or when no HTTP response was received.",
            "format": "int32",
            "nullable": true
          },
          "lastError": {
            "type": "string",
            "description": "Explanation of the latest callback delivery failure. Null when no error is recorded. This describes notification delivery, not invoice validation.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A notification and the current state of attempts to deliver it to your callback."
      },
      "WebhookErrorResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "A short error identifier your integration can check, such as webhook_not_found or webhook_conflict.",
            "nullable": true
          },
          "message": {
            "type": "string",
            "description": "A plain-language explanation of the problem and, when available, what to do next.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A webhook-management request that could not be completed."
      },
      "WebhookSettingsRequest": {
        "required": [
          "url"
        ],
        "type": "object",
        "properties": {
          "url": {
            "maxLength": 2048,
            "type": "string",
            "description": "The full public HTTPS URL that receives notifications, including your callback path, up to 2048 characters. One URL handles all your EGS units in this environment. Private network addresses, embedded credentials, fragments, and redirects are not supported."
          },
          "enabled": {
            "type": "boolean",
            "description": "True to create and deliver invoice notifications. False stops new invoice notifications and pauses pending ones; unexpired deliveries within their retry window resume when enabled again. Explicit test notifications can still be sent while paused.",
            "default": false
          }
        },
        "additionalProperties": false,
        "description": "The callback settings to save for one partner and environment."
      },
      "WebhookSettingsResponse": {
        "type": "object",
        "properties": {
          "environment": {
            "type": "string",
            "description": "The environment these settings apply to: simulation or production.",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "Your saved HTTPS callback URL. Null when no endpoint has been configured.",
            "nullable": true
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether invoice notifications are enabled. False when no endpoint is configured. This flag does not change invoice reporting to ZATCA."
          },
          "updatedAtUtc": {
            "type": "string",
            "description": "When these settings last changed, in UTC. Null when no endpoint is configured.",
            "format": "date-time",
            "nullable": true
          },
          "signingSecret": {
            "type": "string",
            "description": "The secret used to verify webhook signatures. Returned only when the endpoint is first created or its secret is rotated. Save it securely at that time; later reads and ordinary settings updates return null.",
            "nullable": true
          },
          "previousSecretExpiresAtUtc": {
            "type": "string",
            "description": "When the previous signing secret stops being included in delivery signatures, in UTC. Null when no previous secret is retained. Compare with the current time to see whether the 24-hour overlap is still active.",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Your saved callback settings. Production and Simulation have separate URLs and signing secrets."
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "apiKey",
        "description": "Bearer token from POST /api/UserAuthentication/LoginAsEgsUnit or POST /api/Partner/Login. Partner tokens also require EgsUnitClientId and EgsUnitClientSecret.",
        "name": "Authorization",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ]
    }
  ],
  "tags": [
    {
      "name": "EgsUnitProfile",
      "description": "An EGS unit's own profile, with the unit's token. It only ever reaches the unit named in the token: there's no\r\nunit ID to choose. Partners change any unit they own at /api/EgsUnits/{egsUnitId}/profile."
    },
    {
      "name": "PartnerWebhooks",
      "description": "Manage callback settings and notification delivery history for your partner account."
    }
  ]
}