{
  "openapi": "3.1.1",
  "info": {
    "title": "Simplify Accounting External POS API",
    "version": "1.0.0",
    "description": "Submit finalized sales and refunds for accounting review. Neither acknowledgment nor review posts accounting entries, creates payments or contacts, changes stock, or issues fiscal receipts."
  },
  "externalDocs": {
    "description": "Quickstart, payload rules, and retry guidance",
    "url": "https://accounting.pointsimplify.com/developers/pos/v1/"
  },
  "servers": [
    {
      "url": "https://accounting.pointsimplify.com/api/integrations/pos/sandbox/v1",
      "description": "Sandbox. Separate connection keys and synthetic data only."
    },
    {
      "url": "https://accounting.pointsimplify.com/api/integrations/pos/v1",
      "description": "Production review-only intake. When the deployment enables it, use a separate production key issued by an accountant for the selected company."
    }
  ],
  "security": [{ "PosConnectionKey": [] }],
  "paths": {
    "/connection": {
      "get": {
        "operationId": "getPosConnection",
        "summary": "Verify a connection key and its environment",
        "responses": {
          "200": {
            "description": "Authenticated connection",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Connection" },
                "example": { "environment": "sandbox", "mode": "review_only" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/InvalidToken" },
          "429": { "$ref": "#/components/responses/RateLimited" },
          "503": { "$ref": "#/components/responses/ProductionDisabled" }
        }
      }
    },
    "/events": {
      "post": {
        "operationId": "receivePosEvent",
        "summary": "Send one finalized sale or refund",
        "description": "Send uncompressed UTF-8 JSON up to 128 KiB. The same event ID and content return the original acknowledgment, including after review. JSON object key order is ignored; values and array order are significant. Reusing an event ID with different content, or a transaction ID with a different event ID, is a conflict. VAT is validated per refund line; reconcile any source rounding remainder with the accountant rather than altering the finalized figures.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/Event" },
              "examples": {
                "sale": {
                  "summary": "Synthetic two-line sale with split tender",
                  "externalValue": "https://accounting.pointsimplify.com/developers/pos/v1/sale.json"
                },
                "refund": {
                  "summary": "Synthetic partial refund referencing that sale",
                  "externalValue": "https://accounting.pointsimplify.com/developers/pos/v1/refund.json"
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Event durably received; not a review or posting",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Acknowledgment" },
                "example": { "event_id": "demo-event-sale-001", "status": "received" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/InvalidToken" },
          "409": {
            "description": "Event content conflict, transaction ID conflict, or sandbox limit (event_conflict, transaction_conflict, sandbox_limit)",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          },
          "413": {
            "description": "Uncompressed JSON exceeds 128 KiB (payload_too_large)",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          },
          "415": {
            "description": "Unsupported media type, charset, or content encoding (unsupported_media_type)",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          },
          "429": { "$ref": "#/components/responses/RateLimited" },
          "503": { "$ref": "#/components/responses/ProductionDisabled" }
        }
      }
    },
    "/events/{event_id}": {
      "parameters": [
        {
          "name": "event_id",
          "in": "path",
          "required": true,
          "description": "URL-encoded event ID from the submission.",
          "schema": { "$ref": "#/components/schemas/ExternalId" }
        }
      ],
      "get": {
        "operationId": "getPosEventStatus",
        "summary": "Get the review status of an event on this connection",
        "responses": {
          "200": {
            "description": "Current review status",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/EventStatus" },
                "example": {
                  "event_id": "demo-event-refund-001",
                  "status": "needs_review",
                  "review_reason": "original_sale_not_reviewed",
                  "received_at": "2026-10-20T09:45:01Z",
                  "reviewed_at": null
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/InvalidToken" },
          "404": {
            "description": "No such event on the authenticated connection (not_found)",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          },
          "429": { "$ref": "#/components/responses/RateLimited" },
          "503": { "$ref": "#/components/responses/ProductionDisabled" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "PosConnectionKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Opaque key issued in Accounting by a company accountant for one POS connection and environment. Use HTTPS from your backend; no user credentials or PointSimplify tokens."
      }
    },
    "responses": {
      "InvalidRequest": {
        "description": "Invalid request or event (invalid_request, invalid_event)",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "InvalidToken": {
        "description": "Missing, invalid, rotated, revoked, or wrong-environment POS key (invalid_token)",
        "headers": {
          "WWW-Authenticate": { "schema": { "type": "string" }, "example": "Bearer realm=\"external-pos\"" }
        },
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "RateLimited": {
        "description": "Connection or ingress rate limit. Back off and honor Retry-After when present.",
        "headers": {
          "Retry-After": { "schema": { "type": "integer", "minimum": 1 }, "description": "Seconds before the next attempt." }
        },
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "ProductionDisabled": {
        "description": "Production intake not enabled (production_disabled)",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      }
    },
    "schemas": {
      "ExternalId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 80,
        "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,79}$",
        "description": "Case-sensitive source identifier. Do not put personal, card or credential data in identifiers."
      },
      "NonnegativeCents": { "type": "integer", "minimum": 0, "maximum": 1000000000 },
      "PositiveCents": { "type": "integer", "minimum": 1, "maximum": 1000000000 },
      "Event": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "event_id", "type", "sale_id", "occurred_at", "business_date",
          "location_id", "currency", "lines", "payments", "total_cents"
        ],
        "properties": {
          "event_id": {
            "$ref": "#/components/schemas/ExternalId",
            "description": "Stable event ID, unique within the connection. Reuse it for retries."
          },
          "type": { "type": "string", "enum": ["sale", "refund"] },
          "sale_id": {
            "$ref": "#/components/schemas/ExternalId",
            "description": "Stable identifier for this transaction, including a refund; unique within the connection."
          },
          "original_sale_id": {
            "$ref": "#/components/schemas/ExternalId",
            "description": "Required on refunds, forbidden on sales. Must reference a different sale_id on the same connection."
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d{1,3})?(?:Z|[+-](?:[01]\\d|2[0-3]):[0-5]\\d)$",
            "description": "Gregorian timestamp with seconds and an explicit offset or Z."
          },
          "business_date": {
            "type": "string", "format": "date", "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "POS business date; can differ from the clock date on overnight shifts."
          },
          "location_id": { "$ref": "#/components/schemas/ExternalId" },
          "currency": { "type": "string", "const": "EUR" },
          "fiscal_receipt_reference": {
            "$ref": "#/components/schemas/ExternalId",
            "description": "Optional existing receipt reference; does not cause a new fiscal receipt to be issued."
          },
          "lines": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": { "$ref": "#/components/schemas/Line" },
            "description": "Line IDs must be unique within the event."
          },
          "payments": {
            "type": "array", "minItems": 1, "maxItems": 10,
            "items": { "$ref": "#/components/schemas/Payment" }
          },
          "total_cents": {
            "$ref": "#/components/schemas/PositiveCents",
            "description": "EUR cents. Must equal both the sum of net and VAT and the sum of payments."
          }
        },
        "if": { "properties": { "type": { "const": "refund" } } },
        "then": { "required": ["original_sale_id"] },
        "else": { "not": { "required": ["original_sale_id"] } }
      },
      "Line": {
        "type": "object",
        "additionalProperties": false,
        "required": ["line_id", "sku", "quantity", "tax_treatment", "vat_rate", "net_cents", "vat_cents"],
        "properties": {
          "line_id": {
            "$ref": "#/components/schemas/ExternalId",
            "description": "For a refund, use the original sale's line ID."
          },
          "sku": { "$ref": "#/components/schemas/ExternalId" },
          "quantity": {
            "type": "string",
            "pattern": "^(?:0|[1-9]\\d{0,5})(?:\\.\\d{1,6})?$",
            "not": { "pattern": "^0(?:\\.0{1,6})?$" },
            "description": "Positive exact decimal string; up to six integer and six fractional digits."
          },
          "tax_treatment": { "type": "string", "enum": ["standard", "exempt", "zero_rated"] },
          "vat_rate": { "type": "integer", "enum": [0, 8, 18] },
          "net_cents": { "$ref": "#/components/schemas/NonnegativeCents" },
          "vat_cents": {
            "$ref": "#/components/schemas/NonnegativeCents",
            "description": "Line net cents times VAT rate divided by 100, rounded half up to whole cents."
          }
        },
        "if": { "properties": { "tax_treatment": { "const": "standard" } } },
        "then": { "properties": { "vat_rate": { "enum": [8, 18] } } },
        "else": { "properties": { "vat_rate": { "const": 0 } } }
      },
      "Payment": {
        "type": "object",
        "additionalProperties": false,
        "required": ["method", "amount_cents"],
        "properties": {
          "method": { "type": "string", "enum": ["cash", "card"] },
          "amount_cents": { "$ref": "#/components/schemas/PositiveCents" }
        }
      },
      "Connection": {
        "type": "object",
        "additionalProperties": false,
        "required": ["environment", "mode"],
        "properties": {
          "environment": { "type": "string", "enum": ["sandbox", "production"] },
          "mode": { "type": "string", "const": "review_only" }
        }
      },
      "Acknowledgment": {
        "type": "object",
        "additionalProperties": false,
        "required": ["event_id", "status"],
        "properties": {
          "event_id": { "$ref": "#/components/schemas/ExternalId" },
          "status": { "type": "string", "const": "received" }
        }
      },
      "EventStatus": {
        "type": "object",
        "additionalProperties": false,
        "required": ["event_id", "status", "review_reason", "received_at", "reviewed_at"],
        "properties": {
          "event_id": { "$ref": "#/components/schemas/ExternalId" },
          "status": { "type": "string", "enum": ["needs_review", "reviewed", "rejected"] },
          "review_reason": {
            "type": ["string", "null"],
            "enum": [
              null, "original_sale_pending", "original_sale_not_reviewed", "refund_location_mismatch",
              "refund_line_mismatch", "refund_exceeds_original"
            ],
            "description": "A refund blocker while it is awaiting review, otherwise null. Internal reviewer notes aren't exposed."
          },
          "received_at": { "type": "string", "format": "date-time", "description": "UTC timestamp." },
          "reviewed_at": {
            "type": ["string", "null"], "format": "date-time",
            "description": "UTC timestamp of the final review decision, or null."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "code": { "type": "string", "description": "Machine-readable error code when provided by the route." },
          "error": { "type": "string", "description": "Short human-readable error message." }
        }
      }
    }
  }
}
