{
  "openapi": "3.1.0",
  "info": {
    "title": "OSuite Billing API",
    "version": "1",
    "description": "Your OSuite’s own address: the cloud edition’s, or a desktop’s Remote access address. Calls go there directly; OfinIT is not in between. Authorization: Bearer <a billing token>. Make one under Your account › API tokens, choosing Bill through the Billing API, one per website. Keep it on your server: never in a browser or an app people download. A site on serverless hosting (Vercel, Netlify, AWS Lambda) calls from changing addresses: leave the token’s address list empty, and expect a note to the token’s owner about each new address."
  },
  "servers": [
    {
      "url": "https://YOUR-OSUITE",
      "description": "Your OSuite’s own address"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "A billing token (osk_…)"
      }
    },
    "schemas": {
      "CustomerInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Needed when no customer matches",
            "maxLength": 120
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "gstin": {
            "type": "string",
            "description": "A GSTIN in India; a TRN or VAT number elsewhere"
          },
          "stateCode": {
            "type": "string",
            "description": "Two digits, e.g. 27; 96 for a customer abroad",
            "pattern": "^\\d{2}$"
          },
          "street": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "pincode": {
            "type": "string"
          }
        }
      },
      "CustomerRef": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              }
            },
            "required": [
              "id"
            ],
            "additionalProperties": false
          },
          {
            "$ref": "#/components/schemas/CustomerInput"
          }
        ],
        "description": "A customer by the id OSuite gave, or their details to find or add them."
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "gstin": {
            "type": [
              "string",
              "null"
            ]
          },
          "stateCode": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "CustomerResult": {
        "type": "object",
        "properties": {
          "customer": {
            "$ref": "#/components/schemas/Customer"
          },
          "created": {
            "type": "boolean"
          }
        },
        "required": [
          "customer",
          "created"
        ]
      },
      "ItemDetails": {
        "type": "object",
        "properties": {
          "when": {
            "type": "string",
            "description": "A date and time, such as 14 Nov, 06:30",
            "maxLength": 60
          },
          "vehicle": {
            "type": "string",
            "description": "Vehicle",
            "maxLength": 60
          },
          "route": {
            "type": "string",
            "description": "Pickup and drop",
            "maxLength": 200
          },
          "measure": {
            "type": "string",
            "description": "Km, weight or volume",
            "maxLength": 60
          },
          "person": {
            "type": "string",
            "description": "A patient, student or guest",
            "maxLength": 120
          },
          "staff": {
            "type": "string",
            "description": "Served by",
            "maxLength": 120
          },
          "asset": {
            "type": "string",
            "description": "A device and serial number",
            "maxLength": 120
          },
          "booking": {
            "type": "string",
            "description": "A booking or PNR number",
            "maxLength": 60
          },
          "stay": {
            "type": "string",
            "description": "Room, guests and nights",
            "maxLength": 60
          },
          "own1": {
            "type": "string",
            "description": "The business’s own first detail, labelled as it named it in OSuite",
            "maxLength": 120
          },
          "own2": {
            "type": "string",
            "description": "Its second",
            "maxLength": 120
          },
          "own3": {
            "type": "string",
            "description": "Its third",
            "maxLength": 120
          }
        },
        "additionalProperties": false,
        "description": "Printed under the item’s description."
      },
      "ItemInput": {
        "type": "object",
        "properties": {
          "sku": {
            "type": "string",
            "description": "A product’s SKU in OSuite: fills the name, price, HSN, unit and GST"
          },
          "description": {
            "type": "string",
            "maxLength": 300
          },
          "qty": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "price": {
            "type": "number",
            "description": "Per unit, before tax, in the invoice’s currency"
          },
          "gstRate": {
            "type": "number",
            "description": "GST or VAT %"
          },
          "hsn": {
            "type": "string",
            "description": "HSN for goods, SAC for services (998315)",
            "maxLength": 10
          },
          "discountPct": {
            "type": "number",
            "description": "A percentage off the unit price",
            "minimum": 0,
            "maximum": 100
          },
          "unit": {
            "type": "string",
            "description": "A word: year, month, day, hour, session, visit, trip, km, user, gb, nos, or one of the business’s own"
          },
          "periodFrom": {
            "type": "string",
            "description": "The item’s own service period",
            "format": "date"
          },
          "periodTo": {
            "type": "string",
            "format": "date"
          },
          "details": {
            "$ref": "#/components/schemas/ItemDetails"
          }
        },
        "description": "An item: { sku }, or { description, qty, price, gstRate, … }."
      },
      "Instalment": {
        "type": "object",
        "properties": {
          "dueDate": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "number",
            "description": "0 for all to split the total evenly",
            "minimum": 0
          }
        },
        "required": [
          "dueDate"
        ]
      },
      "PaymentInput": {
        "type": "object",
        "properties": {
          "amount": {
            "type": "number",
            "description": "What is due when left out",
            "exclusiveMinimum": 0
          },
          "mode": {
            "type": "string",
            "enum": [
              "upi",
              "bank",
              "card",
              "cash",
              "cheque",
              "online"
            ]
          },
          "reference": {
            "type": "string",
            "maxLength": 60
          },
          "date": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "InvoiceItem": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "hsn": {
            "type": [
              "string",
              "null"
            ]
          },
          "qty": {
            "type": "number"
          },
          "price": {
            "type": "number"
          },
          "discountPct": {
            "type": "number"
          },
          "gstRate": {
            "type": "number"
          },
          "taxable": {
            "type": "number",
            "description": "In the business’s own currency"
          },
          "unit": {
            "type": [
              "string",
              "null"
            ]
          },
          "periodFrom": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "periodTo": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "details": {
            "$ref": "#/components/schemas/ItemDetails"
          }
        },
        "required": [
          "description",
          "qty",
          "price",
          "gstRate",
          "taxable"
        ]
      },
      "Foreign": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string"
          },
          "total": {
            "type": "number"
          },
          "due": {
            "type": "number"
          },
          "exchangeRate": {
            "type": "string",
            "description": "Rupees (the business’s currency) for one unit"
          }
        },
        "required": [
          "currency",
          "total",
          "exchangeRate"
        ],
        "description": "What a customer abroad sees and pays, in their currency."
      },
      "Invoice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "description": "OSuite’s number; null for a draft"
          },
          "test": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "due",
              "overdue",
              "paid",
              "cancelled",
              "test"
            ]
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "dueDate": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "customer": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "placeOfSupply": {
            "type": [
              "string",
              "null"
            ]
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceItem"
            }
          },
          "taxable": {
            "type": "number"
          },
          "tax": {
            "type": "number"
          },
          "total": {
            "type": "number",
            "description": "In the business’s own currency"
          },
          "paid": {
            "type": "number"
          },
          "due": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "foreign": {
            "$ref": "#/components/schemas/Foreign"
          },
          "exportType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "lut",
              "igst"
            ]
          },
          "periodFrom": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "periodTo": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "contractNo": {
            "type": [
              "string",
              "null"
            ]
          },
          "siteAddress": {
            "type": [
              "string",
              "null"
            ]
          },
          "jobNo": {
            "type": [
              "string",
              "null"
            ]
          },
          "consignmentNo": {
            "type": [
              "string",
              "null"
            ]
          },
          "matterNo": {
            "type": [
              "string",
              "null"
            ]
          },
          "instalments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Instalment"
            }
          },
          "viewUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "payUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null when nothing is due or no connected gateway takes the currency",
            "format": "uri"
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "The website (token name) that made it"
          }
        },
        "required": [
          "id",
          "number",
          "status",
          "date",
          "items",
          "total",
          "currency"
        ]
      },
      "InvoiceResult": {
        "type": "object",
        "properties": {
          "invoice": {
            "$ref": "#/components/schemas/Invoice"
          },
          "sent": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "email",
                "whatsapp",
                "sms"
              ]
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "invoice",
          "sent",
          "warnings"
        ]
      },
      "InvoiceList": {
        "type": "object",
        "properties": {
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Invoice"
            }
          }
        },
        "required": [
          "invoices"
        ]
      },
      "SendResult": {
        "type": "object",
        "properties": {
          "sent": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "email",
                "whatsapp",
                "sms"
              ]
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "sent",
          "warnings"
        ]
      },
      "PaymentResult": {
        "type": "object",
        "properties": {
          "paymentId": {
            "type": "integer"
          },
          "invoice": {
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "paymentId",
          "invoice"
        ]
      },
      "CreditNoteResult": {
        "type": "object",
        "properties": {
          "creditNote": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "number": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "date": {
                "type": "string",
                "format": "date"
              },
              "reason": {
                "type": "string",
                "enum": [
                  "return",
                  "rate",
                  "discount",
                  "other"
                ]
              },
              "total": {
                "type": "number"
              },
              "applied": {
                "type": "number"
              },
              "left": {
                "type": "number"
              }
            }
          },
          "invoice": {
            "$ref": "#/components/schemas/Invoice"
          }
        },
        "required": [
          "creditNote",
          "invoice"
        ]
      },
      "Proforma": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "description": "PF series; null for a test key’s"
          },
          "test": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "expired",
              "invoiced",
              "cancelled",
              "draft",
              "test"
            ]
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "validUntil": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "customer": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "placeOfSupply": {
            "type": [
              "string",
              "null"
            ]
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceItem"
            }
          },
          "taxable": {
            "type": "number"
          },
          "tax": {
            "type": "number"
          },
          "total": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "foreign": {
            "$ref": "#/components/schemas/Foreign"
          },
          "exportType": {
            "type": [
              "string",
              "null"
            ]
          },
          "invoiceId": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Its tax invoice, once paid"
          },
          "viewUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "payUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "While open, and a connected gateway takes its currency",
            "format": "uri"
          },
          "source": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "status",
          "date",
          "items",
          "total",
          "currency"
        ]
      },
      "ProformaResult": {
        "type": "object",
        "properties": {
          "proforma": {
            "$ref": "#/components/schemas/Proforma"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "proforma"
        ]
      },
      "ProformaInvoiced": {
        "type": "object",
        "properties": {
          "invoice": {
            "$ref": "#/components/schemas/Invoice"
          },
          "proforma": {
            "$ref": "#/components/schemas/Proforma"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "invoice",
          "proforma"
        ]
      },
      "UsageResult": {
        "type": "object",
        "properties": {
          "reading": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "recurring": {
                "type": "integer"
              },
              "meter": {
                "type": "string"
              },
              "quantity": {
                "type": "number"
              },
              "forDate": {
                "type": "string",
                "format": "date"
              },
              "billed": {
                "type": "boolean"
              }
            }
          }
        },
        "required": [
          "reading"
        ]
      },
      "Checkout": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "paid",
              "expired"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "invoice": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Invoice"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "status",
          "url",
          "expiresAt"
        ]
      },
      "CheckoutResult": {
        "type": "object",
        "properties": {
          "checkout": {
            "$ref": "#/components/schemas/Checkout"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "checkout"
        ]
      },
      "Deleted": {
        "type": "object",
        "properties": {
          "deleted": {
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "deleted"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "What is wrong, in words"
          },
          "fieldErrors": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Field name → what it needs"
          }
        },
        "required": [
          "error"
        ]
      },
      "WebhookLink": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "display": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "display"
        ],
        "description": "Another record: its id, and its name as OSuite shows it."
      },
      "WebhookInvoice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The invoice: fetch it with GET /api/v1/invoices/{id}"
          },
          "number": {
            "type": [
              "string",
              "null"
            ]
          },
          "previousNumber": {
            "type": "string",
            "description": "invoice.renumbered only: the number it had, to find the sale by"
          },
          "state": {
            "type": "string",
            "description": "posted or cancelled; draft for a test key’s, which sends no webhooks"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "As your website sent it; a proforma’s tax invoice takes the proforma’s"
          },
          "customerId": {
            "$ref": "#/components/schemas/WebhookLink"
          },
          "currency": {
            "type": "string"
          },
          "totalAmount": {
            "type": "string",
            "description": "A decimal as text, such as \"1416.00\""
          },
          "amountDue": {
            "type": "string",
            "description": "A decimal as text"
          },
          "paymentState": {
            "type": "string"
          },
          "apiSource": {
            "type": [
              "string",
              "null"
            ],
            "description": "The token’s name, for an invoice a website made"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {},
              "additionalProperties": true
            }
          }
        },
        "required": [
          "id",
          "number",
          "state",
          "customerId",
          "currency",
          "totalAmount"
        ],
        "additionalProperties": true,
        "description": "The invoice as OSuite holds it, with OSuite’s own field names. Only the fields named here are promised; others may come and go."
      },
      "WebhookPayment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The payment; it has no endpoint of its own"
          },
          "number": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "string",
            "description": "A decimal as text"
          },
          "mode": {
            "type": "string"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "partnerId": {
            "$ref": "#/components/schemas/WebhookLink"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "invoiceId": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/WebhookLink"
                    },
                    {
                      "type": "null"
                    }
                  ],
                  "description": "The invoice this part pays: fetch it with GET /api/v1/invoices/{invoiceId.id}"
                },
                "amount": {
                  "type": "string",
                  "description": "A decimal as text"
                }
              },
              "required": [
                "invoiceId",
                "amount"
              ],
              "additionalProperties": true
            }
          }
        },
        "required": [
          "id",
          "amount",
          "lines"
        ],
        "additionalProperties": true,
        "description": "The payment as OSuite holds it. Only the fields named here are promised."
      },
      "WebhookProforma": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The proforma: fetch it with GET /api/v1/proformas/{id}"
          },
          "number": {
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "type": "string"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "validUntil": {
            "type": "string",
            "format": "date"
          },
          "currency": {
            "type": "string"
          },
          "totalAmount": {
            "type": "string",
            "description": "A decimal as text"
          },
          "invoiceId": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/WebhookLink"
              },
              {
                "type": "null"
              }
            ],
            "description": "Its tax invoice: fetch it with GET /api/v1/invoices/{invoiceId.id}"
          }
        },
        "required": [
          "id",
          "invoiceId"
        ],
        "additionalProperties": true,
        "description": "The proforma as OSuite holds it. Only the fields named here are promised."
      },
      "WebhookCheckout": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The checkout id"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "paid",
              "expired"
            ]
          },
          "website": {
            "type": "string",
            "description": "The token’s name"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "invoiceId": {
            "type": "integer"
          },
          "invoiceNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null until paid"
          },
          "total": {
            "type": [
              "string",
              "null"
            ],
            "description": "A decimal as text"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "paidAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "status",
          "website",
          "reference",
          "invoiceId",
          "invoiceNumber",
          "total",
          "currency",
          "paidAt",
          "expiresAt"
        ],
        "additionalProperties": false
      },
      "InvoiceEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The same on every retry of one event: skip one already handled"
          },
          "event": {
            "type": "string",
            "enum": [
              "invoice.posted",
              "invoice.cancelled",
              "invoice.renumbered"
            ]
          },
          "occurredAt": {
            "type": "string",
            "description": "When it happened in OSuite; the same on every retry, so on a retry it can be long past. Judge a call’s age by X-OSuite-Timestamp, never by this",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/WebhookInvoice"
          }
        },
        "required": [
          "id",
          "event",
          "occurredAt",
          "data"
        ],
        "additionalProperties": false
      },
      "PaymentEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The same on every retry of one event: skip one already handled"
          },
          "event": {
            "type": "string",
            "enum": [
              "payment.received"
            ]
          },
          "occurredAt": {
            "type": "string",
            "description": "When it happened in OSuite; the same on every retry, so on a retry it can be long past. Judge a call’s age by X-OSuite-Timestamp, never by this",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/WebhookPayment"
          }
        },
        "required": [
          "id",
          "event",
          "occurredAt",
          "data"
        ],
        "additionalProperties": false
      },
      "ProformaEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The same on every retry of one event: skip one already handled"
          },
          "event": {
            "type": "string",
            "enum": [
              "proforma.invoiced"
            ]
          },
          "occurredAt": {
            "type": "string",
            "description": "When it happened in OSuite; the same on every retry, so on a retry it can be long past. Judge a call’s age by X-OSuite-Timestamp, never by this",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/WebhookProforma"
          }
        },
        "required": [
          "id",
          "event",
          "occurredAt",
          "data"
        ],
        "additionalProperties": false
      },
      "CheckoutEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The same on every retry of one event: skip one already handled"
          },
          "event": {
            "type": "string",
            "enum": [
              "checkout.paid",
              "checkout.expired"
            ]
          },
          "occurredAt": {
            "type": "string",
            "description": "When it happened in OSuite; the same on every retry, so on a retry it can be long past. Judge a call’s age by X-OSuite-Timestamp, never by this",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/WebhookCheckout"
          }
        },
        "required": [
          "id",
          "event",
          "occurredAt",
          "data"
        ],
        "additionalProperties": false
      },
      "WebhookPing": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ],
        "additionalProperties": false
      },
      "PingEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The same on every retry of one event: skip one already handled"
          },
          "event": {
            "type": "string",
            "enum": [
              "ping"
            ]
          },
          "occurredAt": {
            "type": "string",
            "description": "When it happened in OSuite; the same on every retry, so on a retry it can be long past. Judge a call’s age by X-OSuite-Timestamp, never by this",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/WebhookPing"
          }
        },
        "required": [
          "id",
          "event",
          "occurredAt",
          "data"
        ],
        "additionalProperties": false
      },
      "WebhookEvent": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/InvoiceEvent"
          },
          {
            "$ref": "#/components/schemas/PaymentEvent"
          },
          {
            "$ref": "#/components/schemas/ProformaEvent"
          },
          {
            "$ref": "#/components/schemas/CheckoutEvent"
          },
          {
            "$ref": "#/components/schemas/PingEvent"
          }
        ],
        "description": "Any of the events; the event field says which. ping is Send a test: answer it 2xx and do nothing."
      }
    }
  },
  "paths": {
    "/api/v1/customers": {
      "post": {
        "operationId": "upsert-customer",
        "summary": "Find or add a customer",
        "description": "Finds a customer by GSTIN, then email, then mobile number; adds one when none matches and a name is given. Answers 201 when added, 200 when found.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=<your order number>.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Needed when no customer matches; up to 120 characters."
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "description": "Matched without regard to case."
                  },
                  "phone": {
                    "type": "string",
                    "description": "Matched on its last 10 digits."
                  },
                  "gstin": {
                    "type": "string",
                    "description": "The customer’s tax number: a GSTIN in India (matched first; sets the state code), a TRN or VAT number elsewhere."
                  },
                  "stateCode": {
                    "type": "string",
                    "pattern": "^\\d{2}$",
                    "description": "Two digits, e.g. 27 for Maharashtra; sets the place of supply."
                  },
                  "street": {
                    "type": "string",
                    "description": "Address, for a new customer."
                  },
                  "city": {
                    "type": "string",
                    "description": "For a new customer."
                  },
                  "pincode": {
                    "type": "string",
                    "description": "For a new customer."
                  }
                }
              },
              "example": {
                "name": "Mehta Engineering",
                "email": "buy@mehta.in",
                "gstin": "24AABCM1234A1ZD"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ customer: { id, name, email, phone, gstin, stateCode }, created }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerResult"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/customers/{id}": {
      "get": {
        "operationId": "get-customer",
        "summary": "A customer",
        "description": "One customer by the id OSuite gave.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ id, name, email, phone, gstin, stateCode }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices": {
      "post": {
        "operationId": "create-invoice",
        "summary": "Make an invoice",
        "description": "Makes an invoice and posts it: OSuite works out the place of supply, GST, totals and the invoice number. With post: false it stays a draft: number is in the answer but null until it is posted, and its totals already include GST, the same as once posted. If no payment gateway the business connected takes its currency from this customer, the invoice is still made, with payUrl null and a warning saying so (only a checkout is refused for this). A total you send as expectTotal is checked against OSuite’s and a difference reported in warnings; OSuite’s is the invoice’s. Refused within the token’s limits (largest invoice, invoices a day). An invoice that cannot be posted (goods not in stock, say) leaves nothing behind.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=<your order number>.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "customer",
                  "items"
                ],
                "properties": {
                  "customer": {
                    "$ref": "#/components/schemas/CustomerRef",
                    "description": "{ id } of a customer, or the customer’s details to find or add them (as in POST /api/v1/customers)."
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ItemInput"
                    },
                    "minItems": 1,
                    "maxItems": 200,
                    "description": "Up to 200 items: { sku } of a product in OSuite, or { description, qty, price, gstRate, hsn?, discountPct?, unit?, periodFrom?, periodTo?, details? }. price is per unit before tax (GST or VAT is added on top, worked out by OSuite), in the invoice’s currency. discountPct is a percentage off that item’s unit price, so the same percentage off the item’s line; the tax is worked out on what is left. hsn takes HSN codes for goods and SAC codes for services (998315), printed in the HSN/SAC column. A SKU fills the name, price, HSN, unit and GST, which you may still give. unit is a word such as year, month, day, hour, session, visit, trip, km, user, gb or nos (or one of the business’s own units); a service with none is a lump sum. periodFrom and periodTo (YYYY-MM-DD) are the item’s own service period, printed under it. details prints under the item: any of when, vehicle, route, measure, person, staff, asset, booking, stay, and own1 to own3 for the business’s own details, such as { \"vehicle\": \"KA01AB1234\", \"route\": \"Airport to Indiranagar\" }."
                  },
                  "reference": {
                    "type": "string",
                    "description": "Your order number; printed on the invoice."
                  },
                  "date": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD; today when left out."
                  },
                  "dueDate": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD; or dueDays."
                  },
                  "dueDays": {
                    "type": "number",
                    "description": "Days after the date it is due."
                  },
                  "placeOfSupply": {
                    "type": "string",
                    "description": "Two-digit state code; the customer’s state when left out; 96 for a customer abroad."
                  },
                  "currency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$",
                    "description": "ISO code such as USD, EUR, GBP or AED for a customer abroad; item prices are then in it, and the customer pays in it. The business’s own currency when left out."
                  },
                  "exchangeRate": {
                    "type": "number",
                    "description": "How much of the business’s currency one unit is worth on the invoice date: for goods the CBIC customs rate (CGST rule 34(1)); for services a rate by generally accepted accounting principles for that date (rule 34(2)), such as the RBI reference rate. It sets the rupee value on the GST return. Left out, in India OSuite fills FBIL’s reference rate for the invoice date (the last business day’s at weekends and holidays), as OfinIT reads it each day from RBI’s site, and the invoice notes where it came from; for goods FBIL’s stands in for CBIC’s customs rate, which OSuite has no free source for. With no rate known within a week, the rate on the business’s latest invoice in that currency is used and warnings says so. Send exchangeRate yourself to use another rate, such as your bank’s: one rate a day, from one source you also price with, never a fixed figure."
                  },
                  "exportType": {
                    "type": "string",
                    "enum": [
                      "lut",
                      "igst"
                    ],
                    "description": "\"lut\" (export under LUT, no IGST) or \"igst\" (IGST paid). Needed in India when the place of supply is 96, another country."
                  },
                  "periodFrom": {
                    "type": "string",
                    "format": "date",
                    "description": "For services: YYYY-MM-DD, the first day the invoice bills; printed under the customer."
                  },
                  "periodTo": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD, the last day it bills."
                  },
                  "contractNo": {
                    "type": "string",
                    "description": "The contract or statement of work it bills under; printed under the customer."
                  },
                  "siteAddress": {
                    "type": "string",
                    "description": "The site or venue the work was done at; printed on the invoice."
                  },
                  "jobNo": {
                    "type": "string",
                    "description": "Job card or work order number; printed on the invoice."
                  },
                  "consignmentNo": {
                    "type": "string",
                    "description": "Consignment note or e-way bill number; printed on the invoice."
                  },
                  "matterNo": {
                    "type": "string",
                    "description": "Matter or case number; printed on the invoice."
                  },
                  "instalments": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Instalment"
                    },
                    "minItems": 2,
                    "maxItems": 24,
                    "description": "To be paid in parts: 2 to 24 of { dueDate, amount }. They add up to the total; send every amount as 0 to split the total evenly. The invoice is due on the first date, and each part is reminded on its own."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Printed on the invoice."
                  },
                  "post": {
                    "type": "boolean",
                    "description": "false keeps a draft to post later with /post."
                  },
                  "send": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "email",
                        "whatsapp",
                        "sms"
                      ]
                    },
                    "description": "Any of \"email\", \"whatsapp\", \"sms\": sent to the customer once posted. In Saudi Arabia and Malaysia it waits until ZATCA or LHDN has accepted the invoice, then goes by itself: warnings says so."
                  },
                  "expectTotal": {
                    "type": "number",
                    "description": "Your total, checked against OSuite’s to the paisa: any difference adds to warnings \"Your total X differs from OSuite’s Y…\", and OSuite’s is the invoice’s. With paise in it, the invoice keeps its paise, as exactTotal does."
                  },
                  "returnUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "https address the customer is offered once they have paid on payUrl, to go back to your site. For a proforma paid on its payUrl, it gets ?checkout=<id>&invoice=<id of the tax invoice> added."
                  },
                  "exactTotal": {
                    "type": "boolean",
                    "description": "true keeps the invoice to the paisa, with no rounding to the rupee: for what your website charged exactly."
                  }
                }
              },
              "example": {
                "customer": {
                  "name": "Mehta Engineering",
                  "email": "buy@mehta.in",
                  "stateCode": "24"
                },
                "reference": "Order 1001",
                "items": [
                  {
                    "sku": "LED-18",
                    "qty": 4
                  },
                  {
                    "description": "Installation",
                    "hsn": "9954",
                    "qty": 1,
                    "price": 1000,
                    "gstRate": 18
                  }
                ],
                "expectTotal": 3196,
                "send": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ invoice, sent, warnings }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceResult"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "list-invoices",
        "summary": "This website’s invoices",
        "description": "The invoices this token’s website made, newest first. Invoices made in OSuite itself or by another website are not listed.",
        "parameters": [
          {
            "name": "customer",
            "in": "query",
            "required": false,
            "description": "Only this customer’s.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "reference",
            "in": "query",
            "required": false,
            "description": "Only the one with this reference (your order number): check it before making an invoice again for an order whose first call got no answer.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "\"due\" or \"paid\".",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 100; 25 when left out.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ invoices: [invoice] }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceList"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}": {
      "get": {
        "operationId": "get-invoice",
        "summary": "An invoice",
        "description": "Its status (draft, due, overdue, paid, cancelled, test), items, totals, what is paid and due, and links to view and pay it. payUrl is how a customer pays an invoice already made: OSuite’s page for it, on the business’s own gateway. A payment made there is recorded by OSuite itself, and the payment.received webhook tells you; send the customer back with returnUrl. payUrl is null when no gateway the business connected takes the invoice’s currency from this customer (making it, warnings says so): take that payment on your own gateway. Each item has its unit, periodFrom, periodTo and details. A cancelled invoice was cancelled in OSuite, perhaps reissued under a new number: see the invoice.cancelled and invoice.renumbered webhooks.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ id, number, test, status, date, dueDate, reference, customer, placeOfSupply, items: [{ description, hsn, qty, price, discountPct, gstRate, taxable, unit, periodFrom, periodTo, details }], taxable, tax, total, paid, due, currency, foreign?: { currency, total, due, exchangeRate }, exportType, periodFrom, periodTo, contractNo, siteAddress, jobNo, consignmentNo, matterNo, instalments: [{ dueDate, amount }], viewUrl, payUrl, source }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete-invoice",
        "summary": "Delete a draft",
        "description": "Takes back a draft this website made with post: false and will not post (a basket the customer did not pay). It had no number and is in no return. A posted invoice is refused: correct it with a credit note. Drafts left unposted for 7 days are taken back by themselves.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ deleted: true }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}/pdf": {
      "get": {
        "operationId": "invoice-pdf",
        "summary": "The invoice as a PDF",
        "description": "The posted invoice as an A4 PDF, for your customer to download. OSuite’s invoice is the only invoice for a sale: give your customer this one, and never number or print one of your own. A test key’s invoices stay drafts and have no PDF.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "application/pdf",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}/post": {
      "post": {
        "operationId": "post-invoice",
        "summary": "Post a draft",
        "description": "Posts an invoice made with post: false. A test key’s invoices stay drafts.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}/send": {
      "post": {
        "operationId": "send-invoice",
        "summary": "Send an invoice",
        "description": "Sends a posted invoice by email, WhatsApp (through the business’s provider, with its invoice template) or SMS (its SMS provider). What could not be sent is said in warnings.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "channels": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "email",
                        "whatsapp",
                        "sms"
                      ]
                    },
                    "description": "Any of \"email\", \"whatsapp\", \"sms\"; [\"email\"] when left out."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ sent, warnings }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendResult"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}/payments": {
      "post": {
        "operationId": "record-payment",
        "summary": "Record a payment",
        "description": "A payment your website took itself (its own gateway, UPI or bank), set against the invoice as a posted receipt.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=<your order number>.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "amount": {
                    "type": "number",
                    "description": "What was received; what is due when left out. No more than is due."
                  },
                  "mode": {
                    "type": "string",
                    "enum": [
                      "upi",
                      "bank",
                      "card",
                      "cash",
                      "cheque",
                      "online"
                    ],
                    "description": "\"upi\", \"bank\", \"card\", \"cash\", \"cheque\" or \"online\" (a gateway or wallet); \"upi\" when left out. From Razorpay’s method: card → card, upi → upi, netbanking → bank, wallet → online."
                  },
                  "reference": {
                    "type": "string",
                    "description": "The gateway’s or bank’s reference."
                  },
                  "date": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD; today when left out."
                  }
                }
              },
              "example": {
                "amount": 3196,
                "mode": "upi",
                "reference": "pay_RZP123"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ paymentId, invoice }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentResult"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}/credit-notes": {
      "post": {
        "operationId": "create-credit-note",
        "summary": "Credit an invoice",
        "description": "A posted credit note against the invoice, for a refund, a return or a discount after the sale: the whole invoice when no items are sent, or only the items sent. It is in the invoice’s currency and reported in GST returns; it is set against what the invoice still owes, and any rest is left as the customer’s credit. Money you refund on your gateway is refunded there; this records it in the books.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=<your order number>.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "reason": {
                    "type": "string",
                    "enum": [
                      "return",
                      "rate",
                      "discount",
                      "other"
                    ],
                    "description": "\"return\", \"rate\" (a rate difference), \"discount\" or \"other\"; \"return\" when left out."
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ItemInput"
                    },
                    "minItems": 1,
                    "maxItems": 200,
                    "description": "What is credited, as for an invoice: [{ description, hsn, qty, price, gstRate }]. The whole invoice when left out."
                  },
                  "date": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD; today when left out."
                  }
                }
              },
              "example": {
                "reason": "return",
                "items": [
                  {
                    "description": "LED panel 18W",
                    "hsn": "9405",
                    "qty": 1,
                    "price": 450,
                    "gstRate": 12
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ creditNote: { id, number, date, reason, total, applied, left }, invoice }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditNoteResult"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proformas": {
      "post": {
        "operationId": "create-proforma",
        "summary": "Make a proforma",
        "description": "A bill before payment (a renewal, an advance), never a tax invoice: numbered in the PF series, in no GST return. It takes the same body as an invoice, plus validUntil (or validDays; 15 days when left out). Once the customer pays, make its tax invoice with /invoice, or let them pay on its payUrl (null, with a warning, when no connected gateway takes its currency). A proforma is not emailed when it is made: send it yourself with its viewUrl or PDF; send is kept for its tax invoice, emailed once paid. To change the price, cancel it and make a new one; both stay on record. OSuite sends no reminders for a proforma: remind the customer from your site until validUntil.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=<your order number>.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "customer",
                  "items"
                ],
                "properties": {
                  "customer": {
                    "$ref": "#/components/schemas/CustomerRef",
                    "description": "{ id } of a customer, or the customer’s details to find or add them (as in POST /api/v1/customers)."
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ItemInput"
                    },
                    "minItems": 1,
                    "maxItems": 200,
                    "description": "Up to 200 items: { sku } of a product in OSuite, or { description, qty, price, gstRate, hsn?, discountPct?, unit?, periodFrom?, periodTo?, details? }. price is per unit before tax (GST or VAT is added on top, worked out by OSuite), in the invoice’s currency. discountPct is a percentage off that item’s unit price, so the same percentage off the item’s line; the tax is worked out on what is left. hsn takes HSN codes for goods and SAC codes for services (998315), printed in the HSN/SAC column. A SKU fills the name, price, HSN, unit and GST, which you may still give. unit is a word such as year, month, day, hour, session, visit, trip, km, user, gb or nos (or one of the business’s own units); a service with none is a lump sum. periodFrom and periodTo (YYYY-MM-DD) are the item’s own service period, printed under it. details prints under the item: any of when, vehicle, route, measure, person, staff, asset, booking, stay, and own1 to own3 for the business’s own details, such as { \"vehicle\": \"KA01AB1234\", \"route\": \"Airport to Indiranagar\" }."
                  },
                  "reference": {
                    "type": "string",
                    "description": "Your order number; printed on the invoice."
                  },
                  "date": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD; today when left out."
                  },
                  "dueDate": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD; or dueDays."
                  },
                  "dueDays": {
                    "type": "number",
                    "description": "Days after the date it is due."
                  },
                  "placeOfSupply": {
                    "type": "string",
                    "description": "Two-digit state code; the customer’s state when left out; 96 for a customer abroad."
                  },
                  "currency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$",
                    "description": "ISO code such as USD, EUR, GBP or AED for a customer abroad; item prices are then in it, and the customer pays in it. The business’s own currency when left out."
                  },
                  "exchangeRate": {
                    "type": "number",
                    "description": "How much of the business’s currency one unit is worth on the invoice date: for goods the CBIC customs rate (CGST rule 34(1)); for services a rate by generally accepted accounting principles for that date (rule 34(2)), such as the RBI reference rate. It sets the rupee value on the GST return. Left out, in India OSuite fills FBIL’s reference rate for the invoice date (the last business day’s at weekends and holidays), as OfinIT reads it each day from RBI’s site, and the invoice notes where it came from; for goods FBIL’s stands in for CBIC’s customs rate, which OSuite has no free source for. With no rate known within a week, the rate on the business’s latest invoice in that currency is used and warnings says so. Send exchangeRate yourself to use another rate, such as your bank’s: one rate a day, from one source you also price with, never a fixed figure."
                  },
                  "exportType": {
                    "type": "string",
                    "enum": [
                      "lut",
                      "igst"
                    ],
                    "description": "\"lut\" (export under LUT, no IGST) or \"igst\" (IGST paid). Needed in India when the place of supply is 96, another country."
                  },
                  "periodFrom": {
                    "type": "string",
                    "format": "date",
                    "description": "For services: YYYY-MM-DD, the first day the invoice bills; printed under the customer."
                  },
                  "periodTo": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD, the last day it bills."
                  },
                  "contractNo": {
                    "type": "string",
                    "description": "The contract or statement of work it bills under; printed under the customer."
                  },
                  "siteAddress": {
                    "type": "string",
                    "description": "The site or venue the work was done at; printed on the invoice."
                  },
                  "jobNo": {
                    "type": "string",
                    "description": "Job card or work order number; printed on the invoice."
                  },
                  "consignmentNo": {
                    "type": "string",
                    "description": "Consignment note or e-way bill number; printed on the invoice."
                  },
                  "matterNo": {
                    "type": "string",
                    "description": "Matter or case number; printed on the invoice."
                  },
                  "instalments": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Instalment"
                    },
                    "minItems": 2,
                    "maxItems": 24,
                    "description": "To be paid in parts: 2 to 24 of { dueDate, amount }. They add up to the total; send every amount as 0 to split the total evenly. The invoice is due on the first date, and each part is reminded on its own."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Printed on the invoice."
                  },
                  "send": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "email",
                        "whatsapp",
                        "sms"
                      ]
                    },
                    "description": "Any of \"email\", \"whatsapp\", \"sms\": sent to the customer once posted. In Saudi Arabia and Malaysia it waits until ZATCA or LHDN has accepted the invoice, then goes by itself: warnings says so."
                  },
                  "expectTotal": {
                    "type": "number",
                    "description": "Your total, checked against OSuite’s to the paisa: any difference adds to warnings \"Your total X differs from OSuite’s Y…\", and OSuite’s is the invoice’s. With paise in it, the invoice keeps its paise, as exactTotal does."
                  },
                  "returnUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "https address the customer is offered once they have paid on payUrl, to go back to your site. For a proforma paid on its payUrl, it gets ?checkout=<id>&invoice=<id of the tax invoice> added."
                  },
                  "exactTotal": {
                    "type": "boolean",
                    "description": "true keeps the invoice to the paisa, with no rounding to the rupee: for what your website charged exactly."
                  },
                  "validUntil": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD it may be paid until. After it the proforma is expired: payUrl goes and it can no longer be paid on OSuite’s page. For a renewal with a grace period, make it the last day service may be restored."
                  },
                  "validDays": {
                    "type": "number",
                    "description": "Or how many days from its date."
                  }
                }
              },
              "example": {
                "customer": {
                  "id": 812
                },
                "reference": "Renewal ozero-4471",
                "validDays": 7,
                "items": [
                  {
                    "description": "Hosting renewal",
                    "hsn": "998315",
                    "qty": 1,
                    "unit": "year",
                    "price": 4800,
                    "gstRate": 18,
                    "periodFrom": "2026-12-01",
                    "periodTo": "2027-11-30",
                    "details": {
                      "own1": "shop.example.in"
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ proforma: { id, number, test, status, date, validUntil, reference, customer, items, taxable, tax, total, currency, foreign?, exportType, invoiceId, viewUrl, payUrl, source } }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProformaResult"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proformas/{id}": {
      "get": {
        "operationId": "get-proforma",
        "summary": "A proforma",
        "description": "Its status: open (may be paid), expired (past validUntil), invoiced (paid; invoiceId is its tax invoice), cancelled, draft or test.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "proforma",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Proforma"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proformas/{id}/pdf": {
      "get": {
        "operationId": "proforma-pdf",
        "summary": "The proforma as a PDF",
        "description": "The proforma as an A4 PDF, titled Proforma Invoice. A test key’s proformas stay drafts and have no PDF.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "application/pdf",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proformas/{id}/invoice": {
      "post": {
        "operationId": "invoice-proforma",
        "summary": "Invoice a paid proforma",
        "description": "The customer paid the proforma on your site: its tax invoice is made from it, dated today (or date), at the proforma’s exchange rate, posted, with the payment you send recorded against it, and sent as asked. It works after validUntil too, as the money is already taken. Once only: called again, it answers with the same invoice. Its tax invoice takes the proforma’s reference (Proforma <number> when it had none), so GET /api/v1/invoices?reference= finds it. A proforma being paid on OSuite’s page at that moment is refused with 409. The token’s daily limit does not apply: the money is already taken.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=<your order number>.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "payment": {
                    "$ref": "#/components/schemas/PaymentInput",
                    "description": "{ amount?, mode?, reference?, date? } as for POST /api/v1/invoices/{id}/payments: recorded against the new invoice."
                  },
                  "date": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD; today when left out."
                  },
                  "send": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "email",
                        "whatsapp",
                        "sms"
                      ]
                    },
                    "description": "Any of \"email\", \"whatsapp\", \"sms\"; as the proforma was made when left out."
                  }
                }
              },
              "example": {
                "payment": {
                  "mode": "upi",
                  "reference": "pay_RZP987"
                },
                "send": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ invoice, proforma, warnings }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProformaInvoiced"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/proformas/{id}/cancel": {
      "post": {
        "operationId": "cancel-proforma",
        "summary": "Cancel a proforma",
        "description": "A proforma not paid (a renewal that lapsed, a price that changed) is cancelled and stays on record. A paid one is refused: correct its invoice with a credit note.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "proforma",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Proforma"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/usage": {
      "post": {
        "operationId": "record-usage",
        "summary": "Send usage",
        "description": "A reading for a subscription’s metered line (storage, users, servers, calls): billed on its next recurring invoice, above what the line includes, at its rate. Name the subscription by the id you gave it in OSuite (Subscription id on the recurring invoice). Readings are added up; each is billed once.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=<your order number>.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "subscription",
                  "meter",
                  "quantity"
                ],
                "properties": {
                  "subscription": {
                    "type": "string",
                    "description": "Your id for the subscription, as on the recurring invoice."
                  },
                  "meter": {
                    "type": "string",
                    "description": "The meter, as on the line: such as storage_gb or users."
                  },
                  "quantity": {
                    "type": "number",
                    "description": "How much was used, 0 or more."
                  },
                  "date": {
                    "type": "string",
                    "format": "date",
                    "description": "YYYY-MM-DD the reading is for; the next invoice’s day when left out."
                  },
                  "unit": {
                    "type": "string",
                    "description": "The unit of the quantity, such as GB, Hours or Users: refused when the line bills in another unit. Left out, the line’s own."
                  }
                }
              },
              "example": {
                "subscription": "acme-hosting-01",
                "meter": "storage_gb",
                "quantity": 1250.5,
                "unit": "GB"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ reading: { id, recurring, meter, quantity, forDate, billed } }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageResult"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/checkout": {
      "post": {
        "operationId": "create-checkout",
        "summary": "Start a hosted checkout",
        "description": "A cart in, the address of OSuite’s pay page back. The cart is a draft invoice, its totals with GST but no number and in no return, until the customer pays on the business’s own gateway; then it is posted, the payment recorded, the invoice sent, and the customer taken to successUrl with ?checkout=<id>&invoice=<id>. A cart left unpaid for a day closes (status expired, webhook checkout.expired); its draft is kept a week, so a payment the bank confirms late is still billed (webhook checkout.paid), then taken back.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Calls that make something need an Idempotency-Key header, 8 to 100 characters, such as your order number. Sent again with the same key within 30 days (after a timeout, say), the call answers as the first time did, with Idempotent-Replayed: true, and makes nothing twice. Later than that, check first with GET /api/v1/invoices?reference=<your order number>.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "customer",
                  "items",
                  "successUrl"
                ],
                "properties": {
                  "customer": {
                    "$ref": "#/components/schemas/CustomerRef",
                    "description": "As for an invoice."
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ItemInput"
                    },
                    "minItems": 1,
                    "maxItems": 200,
                    "description": "Up to 200 items: { sku } of a product in OSuite, or { description, qty, price, gstRate, hsn?, discountPct?, unit?, periodFrom?, periodTo?, details? }. price is per unit before tax (GST or VAT is added on top, worked out by OSuite), in the invoice’s currency. discountPct is a percentage off that item’s unit price, so the same percentage off the item’s line; the tax is worked out on what is left. hsn takes HSN codes for goods and SAC codes for services (998315), printed in the HSN/SAC column. A SKU fills the name, price, HSN, unit and GST, which you may still give. unit is a word such as year, month, day, hour, session, visit, trip, km, user, gb or nos (or one of the business’s own units); a service with none is a lump sum. periodFrom and periodTo (YYYY-MM-DD) are the item’s own service period, printed under it. details prints under the item: any of when, vehicle, route, measure, person, staff, asset, booking, stay, and own1 to own3 for the business’s own details, such as { \"vehicle\": \"KA01AB1234\", \"route\": \"Airport to Indiranagar\" }."
                  },
                  "currency": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$",
                    "description": "ISO code such as USD, EUR, GBP or AED for a customer abroad; item prices are then in it, and the customer pays in it. The business’s own currency when left out."
                  },
                  "exchangeRate": {
                    "type": "number",
                    "description": "How much of the business’s currency one unit is worth on the invoice date: for goods the CBIC customs rate (CGST rule 34(1)); for services a rate by generally accepted accounting principles for that date (rule 34(2)), such as the RBI reference rate. It sets the rupee value on the GST return. Left out, in India OSuite fills FBIL’s reference rate for the invoice date (the last business day’s at weekends and holidays), as OfinIT reads it each day from RBI’s site, and the invoice notes where it came from; for goods FBIL’s stands in for CBIC’s customs rate, which OSuite has no free source for. With no rate known within a week, the rate on the business’s latest invoice in that currency is used and warnings says so. Send exchangeRate yourself to use another rate, such as your bank’s: one rate a day, from one source you also price with, never a fixed figure."
                  },
                  "exportType": {
                    "type": "string",
                    "enum": [
                      "lut",
                      "igst"
                    ],
                    "description": "\"lut\" (export under LUT, no IGST) or \"igst\" (IGST paid). Needed in India when the place of supply is 96, another country."
                  },
                  "successUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "https address the customer goes to once paid, with ?checkout=<id>&invoice=<id> added. Check GET /api/v1/checkout/{id} before you act on it."
                  },
                  "cancelUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "https address for Back to the shop."
                  },
                  "reference": {
                    "type": "string",
                    "description": "Your order number."
                  },
                  "send": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "email",
                        "whatsapp",
                        "sms"
                      ]
                    },
                    "description": "How the invoice is sent once paid; [\"email\"] when left out."
                  }
                }
              },
              "example": {
                "customer": {
                  "name": "Anita Shah",
                  "email": "anita@example.in",
                  "stateCode": "27"
                },
                "reference": "Order 2041",
                "items": [
                  {
                    "description": "LED panel 18W",
                    "hsn": "9405",
                    "qty": 2,
                    "price": 450,
                    "gstRate": 12
                  }
                ],
                "successUrl": "https://patilstore.in/thanks",
                "cancelUrl": "https://patilstore.in/cart"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "{ checkout: { id, status, url, expiresAt, invoice }, warnings }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutResult"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/checkout/{id}": {
      "get": {
        "operationId": "get-checkout",
        "summary": "A checkout",
        "description": "Whether it is open, paid or expired, with its invoice. Check this on your success page before you ship.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ id, status, url, expiresAt, invoice }",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Checkout"
                }
              }
            }
          },
          "default": {
            "description": "Errors answer { \"error\": \"<what is wrong, in words>\", \"fieldErrors\": { \"<field>\": \"<what it needs>\" } } with 400 or 422 for what you sent, 401 without a working token, 403 for what the token may not do, 404 for what this token cannot see, 409 for a conflict, 429 for limits.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "invoice.posted": {
      "post": {
        "summary": "invoice.posted",
        "description": "Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as \"1416.00\".",
        "parameters": [
          {
            "name": "X-OSuite-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Seconds since 1970, new on every try (retries included) and covered by the signature; refuse a call whose timestamp is more than 5 minutes old. Judge age by this, not by occurredAt."
          },
          {
            "name": "X-OSuite-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "sha256=<hex HMAC-SHA256 of \"<timestamp>.<body>\"> keyed with the webhook’s secret."
          },
          {
            "name": "X-OSuite-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "invoice.posted"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else is tried again, 5 more times over about 50 minutes."
          }
        }
      }
    },
    "invoice.cancelled": {
      "post": {
        "summary": "invoice.cancelled",
        "description": "Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as \"1416.00\".",
        "parameters": [
          {
            "name": "X-OSuite-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Seconds since 1970, new on every try (retries included) and covered by the signature; refuse a call whose timestamp is more than 5 minutes old. Judge age by this, not by occurredAt."
          },
          {
            "name": "X-OSuite-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "sha256=<hex HMAC-SHA256 of \"<timestamp>.<body>\"> keyed with the webhook’s secret."
          },
          {
            "name": "X-OSuite-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "invoice.cancelled"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else is tried again, 5 more times over about 50 minutes."
          }
        }
      }
    },
    "invoice.renumbered": {
      "post": {
        "summary": "invoice.renumbered",
        "description": "Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as \"1416.00\".",
        "parameters": [
          {
            "name": "X-OSuite-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Seconds since 1970, new on every try (retries included) and covered by the signature; refuse a call whose timestamp is more than 5 minutes old. Judge age by this, not by occurredAt."
          },
          {
            "name": "X-OSuite-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "sha256=<hex HMAC-SHA256 of \"<timestamp>.<body>\"> keyed with the webhook’s secret."
          },
          {
            "name": "X-OSuite-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "invoice.renumbered"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else is tried again, 5 more times over about 50 minutes."
          }
        }
      }
    },
    "payment.received": {
      "post": {
        "summary": "payment.received",
        "description": "Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as \"1416.00\".",
        "parameters": [
          {
            "name": "X-OSuite-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Seconds since 1970, new on every try (retries included) and covered by the signature; refuse a call whose timestamp is more than 5 minutes old. Judge age by this, not by occurredAt."
          },
          {
            "name": "X-OSuite-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "sha256=<hex HMAC-SHA256 of \"<timestamp>.<body>\"> keyed with the webhook’s secret."
          },
          {
            "name": "X-OSuite-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "payment.received"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else is tried again, 5 more times over about 50 minutes."
          }
        }
      }
    },
    "checkout.paid": {
      "post": {
        "summary": "checkout.paid",
        "description": "Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as \"1416.00\".",
        "parameters": [
          {
            "name": "X-OSuite-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Seconds since 1970, new on every try (retries included) and covered by the signature; refuse a call whose timestamp is more than 5 minutes old. Judge age by this, not by occurredAt."
          },
          {
            "name": "X-OSuite-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "sha256=<hex HMAC-SHA256 of \"<timestamp>.<body>\"> keyed with the webhook’s secret."
          },
          {
            "name": "X-OSuite-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "checkout.paid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else is tried again, 5 more times over about 50 minutes."
          }
        }
      }
    },
    "checkout.expired": {
      "post": {
        "summary": "checkout.expired",
        "description": "Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as \"1416.00\".",
        "parameters": [
          {
            "name": "X-OSuite-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Seconds since 1970, new on every try (retries included) and covered by the signature; refuse a call whose timestamp is more than 5 minutes old. Judge age by this, not by occurredAt."
          },
          {
            "name": "X-OSuite-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "sha256=<hex HMAC-SHA256 of \"<timestamp>.<body>\"> keyed with the webhook’s secret."
          },
          {
            "name": "X-OSuite-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "checkout.expired"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else is tried again, 5 more times over about 50 minutes."
          }
        }
      }
    },
    "proforma.invoiced": {
      "post": {
        "summary": "proforma.invoiced",
        "description": "Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as \"1416.00\".",
        "parameters": [
          {
            "name": "X-OSuite-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Seconds since 1970, new on every try (retries included) and covered by the signature; refuse a call whose timestamp is more than 5 minutes old. Judge age by this, not by occurredAt."
          },
          {
            "name": "X-OSuite-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "sha256=<hex HMAC-SHA256 of \"<timestamp>.<body>\"> keyed with the webhook’s secret."
          },
          {
            "name": "X-OSuite-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "proforma.invoiced"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProformaEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else is tried again, 5 more times over about 50 minutes."
          }
        }
      }
    },
    "ping": {
      "post": {
        "summary": "ping (Send a test)",
        "description": "Webhooks (Connections › Webhooks) tell your server when invoices are posted (invoice.posted), cancelled (invoice.cancelled) or given another number (invoice.renumbered, which carries previousNumber: find the sale by it and take the new number and PDF), payments received, a checkout is paid (checkout.paid) or closes unpaid (checkout.expired), and a proforma is paid and invoiced (proforma.invoiced), signed with your webhook secret. The events: invoice.posted, invoice.cancelled, invoice.renumbered, payment.received, checkout.paid, checkout.expired, proforma.invoiced; a proforma that expires or is cancelled sends none (you know its validUntil, and cancel it yourself). Each is a POST with the JSON body { id, event, occurredAt, data }: data is the invoice, payment or proforma as OSuite holds it, with OSuite’s own field names (totalAmount, customerId: { id, display }), not the API’s; a checkout event carries the checkout. Before acting, fetch the document through the API: an invoice or proforma by data.id; for payment.received, which carries the payment itself (no endpoint of its own), the invoice each of its lines pays, lines[].invoiceId.id. A call that does not get a 2xx is tried again 5 more times over about 50 minutes, with the same event id and occurredAt but a fresh X-OSuite-Timestamp, so skip one you have already handled, and judge a call’s age by X-OSuite-Timestamp, never by occurredAt. A checkout event carries id, status, website, reference, invoiceId, invoiceNumber, total, currency, paidAt and expiresAt. A checkout for a proforma sends proforma.invoiced, not checkout.paid. openapi.json gives each event’s schema: the fields of data named there are promised, others may change; amounts in data are decimals as text, such as \"1416.00\".",
        "parameters": [
          {
            "name": "X-OSuite-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Seconds since 1970, new on every try (retries included) and covered by the signature; refuse a call whose timestamp is more than 5 minutes old. Judge age by this, not by occurredAt."
          },
          {
            "name": "X-OSuite-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "sha256=<hex HMAC-SHA256 of \"<timestamp>.<body>\"> keyed with the webhook’s secret."
          },
          {
            "name": "X-OSuite-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "const": "ping"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PingEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Anything else is tried again, 5 more times over about 50 minutes."
          }
        }
      }
    }
  }
}