{
  "openapi": "3.1.0",
  "info": {
    "title": "Xaurr API",
    "version": "1.0.0",
    "description": "Payments for Ghana (GHS), Kenya (KES), Uganda (UGX) and Nigeria (NGN). Authenticate with Authorization: Bearer sk_test_... (test) or sk_live_... (live). Full guide: https://xaurr.com/?docs=true. Money is paid out only to an account in its own country, never converted.",
    "contact": {
      "name": "Xaurr",
      "email": "info@xaurr.com",
      "url": "https://xaurr.com"
    }
  },
  "servers": [
    {
      "url": "https://api.xaurr.com"
    }
  ],
  "security": [
    {
      "secretKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "secretKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "sk_test_... or sk_live_..., kept on your server only."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "Currency": {
        "type": "string",
        "enum": [
          "GHS",
          "KES",
          "UGX",
          "NGN",
          "USD"
        ],
        "description": "The operator's own country's currency. USD for Ghana accounts only, charged in cedis."
      },
      "CheckoutSessionCreate": {
        "type": "object",
        "required": [
          "reference",
          "amount",
          "currency",
          "successUrl"
        ],
        "properties": {
          "reference": {
            "type": "string",
            "maxLength": 64,
            "description": "Your own order number. The same reference returns the same session."
          },
          "amount": {
            "type": "number",
            "description": "The total, at most 2 decimals."
          },
          "currency": {
            "$ref": "#/components/schemas/Currency"
          },
          "successUrl": {
            "type": "string",
            "format": "uri",
            "description": "https:// (http://localhost in test). Live: on your approved website."
          },
          "cancelUrl": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "expiresInMinutes": {
            "type": "integer",
            "minimum": 5,
            "maximum": 1440
          },
          "platformFee": {
            "type": "number",
            "description": "Platforms only: your own total fee on this sale, at most the operator's max_fee_percent."
          },
          "platform": {
            "type": "string",
            "description": "Platforms only: your platform code (PLT-...)."
          }
        }
      },
      "CheckoutSession": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "processing",
              "paid",
              "refunded",
              "expired",
              "canceled"
            ]
          },
          "amount": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "environment": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "url": {
            "type": "string",
            "description": "Send the customer here."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "ship_status": {
            "type": "string",
            "enum": [
              "not_paid",
              "hold",
              "safe_to_ship",
              "do_not_ship",
              "refunded"
            ]
          },
          "payout_status": {
            "type": [
              "string",
              "null"
            ]
          },
          "fee": {
            "type": [
              "number",
              "null"
            ],
            "description": "Xaurr's all-in fee, taken when the customer pays."
          },
          "payout_fee": {
            "type": [
              "number",
              "null"
            ],
            "description": "The fee for paying the money out to you."
          },
          "net_amount": {
            "type": [
              "number",
              "null"
            ],
            "description": "What you receive: amount less every fee."
          },
          "payout_speed": {
            "type": "string",
            "enum": [
              "next_day",
              "same_day"
            ]
          },
          "expected_payout_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "platform_fee": {
            "type": "number"
          },
          "duplicate": {
            "type": "boolean"
          }
        }
      },
      "PlatformConnection": {
        "type": "object",
        "properties": {
          "connected": {
            "type": "boolean"
          },
          "platform": {
            "type": "string"
          },
          "platform_name": {
            "type": "string"
          },
          "max_fee_percent": {
            "type": [
              "number",
              "null"
            ]
          },
          "country": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "connected_at": {
            "type": "string"
          },
          "live_ready": {
            "type": "boolean"
          },
          "how_to_connect": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/checkout-sessions": {
      "post": {
        "summary": "Create a hosted checkout for one order",
        "operationId": "createCheckoutSession",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutSessionCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutSession"
                }
              }
            }
          },
          "400": {
            "description": "Refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/checkout-sessions/{reference}": {
      "get": {
        "summary": "Read one order by your reference",
        "operationId": "getCheckoutSession",
        "parameters": [
          {
            "name": "reference",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutSession"
                }
              }
            }
          }
        }
      }
    },
    "/checkout-sessions/{reference}/refund": {
      "post": {
        "summary": "Ask for a refund of a paid order",
        "operationId": "refundCheckoutSession",
        "parameters": [
          {
            "name": "reference",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Refund requested"
          }
        }
      }
    },
    "/payments": {
      "get": {
        "summary": "List payments (test or live, by key)",
        "operationId": "listPayments",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payments"
          }
        }
      }
    },
    "/payments/{receipt}": {
      "get": {
        "summary": "Read one payment",
        "operationId": "getPayment",
        "parameters": [
          {
            "name": "receipt",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payment"
          }
        }
      }
    },
    "/quote": {
      "get": {
        "summary": "What a payment costs (GHS)",
        "operationId": "getQuote",
        "parameters": [
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "in_app",
                "storefront",
                "plugin",
                "fundraiser",
                "rent",
                "susu",
                "plan",
                "bulk"
              ]
            }
          },
          {
            "name": "method",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "mobile_money",
                "bank_transfer",
                "card"
              ]
            }
          },
          {
            "name": "payout_to",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "mobile_money",
                "bank_transfer"
              ]
            }
          },
          {
            "name": "mode",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "receive",
                "charge"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "payer_pays, fee, payout_fee, you_receive"
          }
        }
      }
    },
    "/rates": {
      "get": {
        "summary": "Your live fee rates",
        "operationId": "getRates",
        "responses": {
          "200": {
            "description": "Rates"
          }
        }
      }
    },
    "/platform-connection": {
      "get": {
        "summary": "Xaurr Connect: is this operator connected to your platform? (call with the operator's key)",
        "operationId": "getPlatformConnection",
        "parameters": [
          {
            "name": "platform",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Connection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlatformConnection"
                }
              }
            }
          }
        }
      }
    },
    "/platform/fees": {
      "get": {
        "summary": "Your platform's maximum fee per country",
        "operationId": "getPlatformFees",
        "responses": {
          "200": {
            "description": "Fees"
          }
        }
      },
      "put": {
        "summary": "Set your maximum fee per country (live key)",
        "operationId": "setPlatformFees",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fees": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved"
          }
        }
      }
    },
    "/account/readiness": {
      "get": {
        "summary": "What this account still needs before live payments",
        "operationId": "getAccountReadiness",
        "responses": {
          "200": {
            "description": "Checklist"
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "summary": "Webhooks for this key's environment and recent deliveries",
        "operationId": "listWebhooks",
        "responses": {
          "200": {
            "description": "Webhooks"
          }
        }
      }
    },
    "/webhooks/{id}/test": {
      "post": {
        "summary": "Send a signed test.ping",
        "operationId": "sendTestWebhook",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sent"
          }
        }
      }
    },
    "/test/checkout-sessions/{reference}/pay": {
      "post": {
        "summary": "TEST keys only: pay or fail a test checkout with the sandbox test number",
        "operationId": "payTestCheckout",
        "parameters": [
          {
            "name": "reference",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "outcome": {
                    "type": "string",
                    "enum": [
                      "success",
                      "fail"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment started"
          }
        }
      }
    },
    "/balance": {
      "get": {
        "summary": "Xaurr Payouts: your balance",
        "operationId": "getBalance",
        "parameters": [
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Balance"
          }
        }
      }
    },
    "/balance/test-topup": {
      "post": {
        "summary": "Xaurr Payouts: add test money (test keys)",
        "operationId": "testTopup",
        "responses": {
          "200": {
            "description": "Added"
          }
        }
      }
    },
    "/balance/withdrawals": {
      "post": {
        "summary": "Xaurr Payouts: withdraw your own balance to your account in that country",
        "operationId": "withdrawBalance",
        "responses": {
          "200": {
            "description": "Requested"
          }
        }
      }
    },
    "/collections/methods": {
      "get": {
        "summary": "Xaurr Payouts: ways to pay in one currency's country",
        "operationId": "getCollectionMethods",
        "parameters": [
          {
            "name": "currency",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Methods"
          }
        }
      }
    },
    "/collections": {
      "post": {
        "summary": "Xaurr Payouts: collect a payment into your balance",
        "operationId": "createCollection",
        "responses": {
          "200": {
            "description": "Started"
          }
        }
      }
    },
    "/collections/{id}": {
      "get": {
        "summary": "Xaurr Payouts: a collection's status",
        "operationId": "getCollection",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Collection"
          }
        }
      }
    },
    "/collections/{id}/refund": {
      "post": {
        "summary": "Xaurr Payouts: refund a customer",
        "operationId": "refundCollection",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Refund started"
          }
        }
      }
    },
    "/workers": {
      "post": {
        "summary": "Xaurr Payouts: add a worker (returns onboarding_url)",
        "operationId": "createWorker",
        "responses": {
          "200": {
            "description": "Worker"
          }
        }
      },
      "get": {
        "summary": "Xaurr Payouts: a worker by your reference",
        "operationId": "getWorkerByReference",
        "parameters": [
          {
            "name": "reference",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Worker"
          }
        }
      }
    },
    "/workers/{id}": {
      "get": {
        "summary": "Xaurr Payouts: a worker",
        "operationId": "getWorker",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Worker"
          }
        }
      }
    },
    "/workers/{id}/earnings": {
      "post": {
        "summary": "Xaurr Payouts: credit a worker's earnings",
        "operationId": "creditWorker",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Credited"
          }
        }
      }
    },
    "/workers/{id}/withdrawals": {
      "post": {
        "summary": "Xaurr Payouts: pay a worker",
        "operationId": "payWorker",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payout requested"
          }
        }
      }
    },
    "/workers/{id}/history": {
      "get": {
        "summary": "Xaurr Payouts: a worker's history",
        "operationId": "getWorkerHistory",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "History"
          }
        }
      }
    },
    "/withdrawals/{id}": {
      "get": {
        "summary": "Xaurr Payouts: a payout's status",
        "operationId": "getWithdrawal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payout"
          }
        }
      }
    },
    "/payment-links": {
      "post": {
        "summary": "Create a payment link (test key: test link)",
        "operationId": "createPaymentLink",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title",
                  "currency"
                ],
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "amount": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "currency": {
                    "$ref": "#/components/schemas/Currency"
                  },
                  "description": {
                    "type": "string"
                  },
                  "ships_goods": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "id, url"
          }
        }
      },
      "get": {
        "summary": "Your payment links",
        "operationId": "listPaymentLinks",
        "responses": {
          "200": {
            "description": "Links"
          }
        }
      }
    },
    "/invoices": {
      "post": {
        "summary": "Create an invoice (live key)",
        "operationId": "createInvoice",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "client_name",
                  "currency",
                  "items"
                ],
                "properties": {
                  "client_name": {
                    "type": "string"
                  },
                  "client_email": {
                    "type": "string"
                  },
                  "client_phone": {
                    "type": "string"
                  },
                  "currency": {
                    "$ref": "#/components/schemas/Currency"
                  },
                  "due_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "description",
                        "quantity",
                        "unit_price"
                      ],
                      "properties": {
                        "description": {
                          "type": "string"
                        },
                        "quantity": {
                          "type": "number"
                        },
                        "unit_price": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The invoice"
          }
        }
      },
      "get": {
        "summary": "Your invoices (live key: invoices are real documents)",
        "operationId": "listInvoices",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "unpaid",
                "paid"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invoices"
          }
        }
      }
    },
    "/invoices/{id}/mark-paid": {
      "post": {
        "summary": "Mark an invoice paid (live key)",
        "operationId": "markInvoicePaid",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paid"
          }
        }
      }
    },
    "/summary": {
      "get": {
        "summary": "Money received and sent in the last N days",
        "operationId": "getSummary",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Summary"
          }
        }
      }
    },
    "/payouts/waiting": {
      "get": {
        "summary": "What is waiting for your payout schedule (live key)",
        "operationId": "getWaitingPayouts",
        "responses": {
          "200": {
            "description": "Waiting"
          }
        }
      }
    },
    "/platform/operators": {
      "get": {
        "summary": "Your platform's connected operators (your own platform live key)",
        "operationId": "listPlatformOperators",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "disconnected"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Operators"
          }
        }
      }
    },
    "/platform/earnings": {
      "get": {
        "summary": "Your platform's fee earnings",
        "operationId": "getPlatformEarnings",
        "parameters": [
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Earnings"
          }
        }
      }
    },
    "/books/profit-and-loss": {
      "get": {
        "summary": "Profit & Loss for any dates (live key, read only)",
        "operationId": "getBooksProfitAndLoss",
        "tags": [
          "Books"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "First day, YYYY-MM-DD (default: the first entry)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day, YYYY-MM-DD (default: today)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Report, per currency"
          },
          "403": {
            "description": "Needs a live key with read permission"
          }
        }
      }
    },
    "/books/balance-sheet": {
      "get": {
        "summary": "Balance Sheet on a date (live key, read only)",
        "operationId": "getBooksBalanceSheet",
        "tags": [
          "Books"
        ],
        "parameters": [
          {
            "name": "as_of",
            "in": "query",
            "description": "The date, YYYY-MM-DD (default: today)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Report, per currency"
          },
          "403": {
            "description": "Needs a live key with read permission"
          }
        }
      }
    },
    "/books/cash-flow": {
      "get": {
        "summary": "Cash flow statement for any dates (live key, read only)",
        "operationId": "getBooksCashFlow",
        "tags": [
          "Books"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "First day, YYYY-MM-DD (default: the first entry)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day, YYYY-MM-DD (default: today)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Report, per currency"
          },
          "403": {
            "description": "Needs a live key with read permission"
          }
        }
      }
    },
    "/books/money-owed": {
      "get": {
        "summary": "Unpaid invoices and bills, with ageing (live key, read only)",
        "operationId": "getBooksMoneyOwed",
        "tags": [
          "Books"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Report, per currency"
          },
          "403": {
            "description": "Needs a live key with read permission"
          }
        }
      }
    },
    "/books/vat": {
      "get": {
        "summary": "Ghana VAT summary for any dates (live key, read only)",
        "operationId": "getBooksVat",
        "tags": [
          "Books"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "First day, YYYY-MM-DD (default: the first entry)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day, YYYY-MM-DD (default: today)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Report, per currency"
          },
          "403": {
            "description": "Needs a live key with read permission"
          }
        }
      }
    },
    "/books/entries": {
      "get": {
        "summary": "Ledger entries, newest first (live key, read only)",
        "operationId": "listBooksEntries",
        "tags": [
          "Books"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "First day, YYYY-MM-DD (default: the first entry)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day, YYYY-MM-DD (default: today)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Words in the description or category",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Report, per currency"
          },
          "403": {
            "description": "Needs a live key with read permission"
          }
        }
      }
    },
    "/books/check": {
      "get": {
        "summary": "Books check: things to fix (live key, read only)",
        "operationId": "getBooksCheck",
        "tags": [
          "Books"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Report, per currency"
          },
          "403": {
            "description": "Needs a live key with read permission"
          }
        }
      }
    }
  }
}
