{
  "openapi": "3.0.3",
  "info": {
    "title": "Jabuntu public API",
    "version": "1.0.0",
    "description": "Tenant-scoped ERP reads and customer/draft creation, not the NRS/MBS API. Staging: https://erp.staging.jabuntu.com/api/public/v1. Production at erp.jabuntu.com is planned and not yet ready. Authenticate with Authorization: Bearer using a business-issued API key (jbt_pk_) or OAuth access token (jbt_at_), not NRS API credentials. Credentials have scopes, a configured per-minute limit and optional IP allowlist. 429 responses include Retry-After (currently 60 seconds). POSTs require Idempotency-Key (8-80 letters, digits, - or _). The key namespace is tenant-wide across POST endpoints. Within 24 hours, the same key and parsed body replay the stored result, including stored application errors, with Idempotent-Replayed: true; a different body returns 422. Invalid inputs/keys return 400; duplicate customer names return 409. No cursor pagination is currently provided. No endpoint here submits or signs at NRS or returns a QR image. Public draft input lacks the editor's complete NRS address, service classification and unit metadata; review and complete it in the app before authorized submission. Documentation revision 2026-11-15.2."
  },
  "servers": [{ "url": "/api/public/v1" }],
  "security": [{ "bearer": [] }],
  "components": {
    "securitySchemes": { "bearer": { "type": "http", "scheme": "bearer" } },
    "parameters": {
      "IdempotencyKey": { "name": "Idempotency-Key", "in": "header", "required": true, "description": "24-hour replay window; tenant-wide namespace across POST routes. Use a unique key per logical operation and endpoint. Same parsed body replays the stored result; changed body returns 422. Invalid/missing key returns 400.", "schema": { "type": "string", "pattern": "^[A-Za-z0-9_-]{8,80}$" } },
      "From": { "name": "from", "in": "query", "required": true, "description": "First calendar day, Nigeria time (Africa/Lagos)", "schema": { "type": "string", "format": "date" } },
      "To": { "name": "to", "in": "query", "required": true, "description": "Last calendar day, inclusive, Nigeria time (Africa/Lagos)", "schema": { "type": "string", "format": "date" } }
    },
    "schemas": {
      "Error": { "type": "object", "properties": { "error": { "type": "string" } } },
      "Party": { "type": "object", "properties": { "name": { "type": "string" }, "tin": { "type": "string" }, "email": { "type": "string" }, "address": { "type": "string" } } },
      "Line": { "type": "object", "required": ["description", "quantity", "unitPrice", "hsCode", "vatRate"],
        "properties": { "description": { "type": "string" }, "quantity": { "type": "string", "example": "2" }, "unitPrice": { "type": "string", "example": "50000" },
          "hsCode": { "type": "string" }, "vatRate": { "type": "string", "description": "Fraction, e.g. 0.075" }, "vatAmount": { "type": "string" } } },
      "DraftInput": { "type": "object", "required": ["invoiceNumber", "lines"],
        "properties": { "invoiceNumber": { "type": "string" }, "invoiceType": { "type": "string", "enum": ["B2B", "B2C", "B2G"] }, "currency": { "type": "string", "example": "NGN" },
          "buyer": { "$ref": "#/components/schemas/Party" }, "lines": { "type": "array", "items": { "$ref": "#/components/schemas/Line" }, "maxItems": 100 } } },
      "Draft": { "type": "object", "properties": { "id": { "type": "integer" }, "invoiceNumber": { "type": "string" }, "invoiceType": { "type": "string" },
        "currency": { "type": "string" }, "total": { "type": "string" }, "createdAt": { "type": "string" } } },
      "Invoice": { "type": "object", "properties": { "invoiceNumber": { "type": "string" }, "status": { "type": "string" }, "irn": { "type": "string" },
        "currency": { "type": "string" }, "total": { "type": "string" }, "issueDate": { "type": "string" }, "createdAt": { "type": "string" }, "link": { "type": "string" } } },
      "Customer": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "tin": { "type": "string" }, "email": { "type": "string" }, "address": { "type": "string" } } },
      "Product": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "unitPrice": { "type": "string" }, "currency": { "type": "string" },
        "active": { "type": "boolean" }, "stock": { "type": "string" } } }
    }
  },
  "paths": {
    "/me": { "get": { "summary": "The business, the credential's scopes and whether the business is a developer sandbox", "responses": { "200": { "description": "OK" }, "401": { "description": "Not authenticated" } } } },
    "/invoices": { "get": { "summary": "NRS-cleared and other invoices (scope invoices:read)", "parameters": [{ "$ref": "#/components/parameters/From" }, { "$ref": "#/components/parameters/To" }],
      "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Invoice" } } } } } } } },
    "/invoices/{number}": { "get": { "summary": "One invoice (scope invoices:read)", "parameters": [{ "name": "number", "in": "path", "required": true, "schema": { "type": "string" } }],
      "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Invoice" } } } }, "404": { "description": "Not found" } } } },
    "/drafts": {
      "get": { "summary": "Invoice drafts (scope drafts:read)", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Draft" } } } } } } },
      "post": { "summary": "Create an invoice draft (scope drafts:write); it is not submitted to NRS", "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DraftInput" } } } },
        "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Draft" } } } },
          "400": { "description": "Invalid; the body lists every problem" }, "422": { "description": "Idempotency-Key reused with a different request" } } } },
    "/drafts/{id}": { "get": { "summary": "One draft (scope drafts:read)", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
      "responses": { "200": { "description": "OK" }, "404": { "description": "Not found" } } } },
    "/customers": {
      "get": { "summary": "Customers (scope customers:read)", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Customer" } } } } } } },
      "post": { "summary": "Create a customer (scope customers:write)", "parameters": [{ "$ref": "#/components/parameters/IdempotencyKey" }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Customer" } } } },
        "responses": { "201": { "description": "Created" }, "409": { "description": "A customer with that name exists" } } } },
    "/products": { "get": { "summary": "Products with stock on hand (scope products:read)", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Product" } } } } } } } },
    "/submissions": { "get": { "summary": "Where each invoice is on its way to NRS (scope submissions:read)", "parameters": [{ "$ref": "#/components/parameters/From" }, { "$ref": "#/components/parameters/To" }],
      "responses": { "200": { "description": "OK" } } } },
    "/reports/trial-balance": { "get": { "summary": "Trial balance (scope reports:read)", "parameters": [{ "name": "asOf", "in": "query", "schema": { "type": "string", "format": "date" } }],
      "responses": { "200": { "description": "OK" } } } },
    "/reports/profit-and-loss": { "get": { "summary": "Profit and loss (scope reports:read)", "parameters": [{ "$ref": "#/components/parameters/From" }, { "$ref": "#/components/parameters/To" }],
      "responses": { "200": { "description": "OK" } } } }
  }
}
