{
  "openapi": "3.1.0",
  "info": {
    "title": "EduFlexTech Reseller API",
    "version": "1.0.0",
    "description": "Sell WASSCE / BECE result checker vouchers and MTN AFA registration from your own platform, paid from your EduFlexTech wallet. Full guide: https://eduflextech.com/developers.html",
    "contact": {
      "name": "EduFlexTech",
      "url": "https://eduflextech.com/developers.html#support"
    }
  },
  "servers": [
    {
      "url": "https://eduflextech.com/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Account",
      "description": "Your account, prices, stock flags and wallet ledger."
    },
    {
      "name": "Checkers",
      "description": "WASSCE and BECE result checker vouchers."
    },
    {
      "name": "AFA",
      "description": "MTN AFA registration."
    },
    {
      "name": "Webhooks",
      "description": "Where we send asynchronous events."
    },
    {
      "name": "Status",
      "description": "Service health, no key needed."
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": [
          "Status"
        ],
        "summary": "Service health",
        "security": [],
        "operationId": "getHealth",
        "responses": {
          "200": {
            "description": "Service is up.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "version": {
                          "type": "string"
                        },
                        "status": {
                          "const": "ok"
                        },
                        "time": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/account": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Get your account, balance and limits",
        "operationId": "getAccount",
        "responses": {
          "200": {
            "description": "Your account.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Account"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/products": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "List products, prices and stock flags",
        "operationId": "listProducts",
        "responses": {
          "200": {
            "description": "Products at your price.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Products"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/checkers/orders": {
      "post": {
        "tags": [
          "Checkers"
        ],
        "summary": "Buy result checker vouchers",
        "operationId": "createCheckerOrder",
        "description": "Charges your wallet and returns PINs immediately. Orders are filled completely or not at all. Requires the checkers scope.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Unique per order (a UUID is ideal). Retrying with the same key never charges twice. Remembered for 24 hours.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,100}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckerOrderRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Order completed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/CheckerOrderCreated"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "description": "IDEMPOTENCY_KEY_REQUIRED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "INSUFFICIENT_BALANCE. details.required and details.balance are included. Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "OUT_OF_STOCK (details.available) or REQUEST_IN_PROGRESS.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "VALIDATION_ERROR (details.fields) or IDEMPOTENCY_KEY_REUSED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/checkers/orders/{reference}": {
      "get": {
        "tags": [
          "Checkers"
        ],
        "summary": "Get a checker order and its PINs",
        "operationId": "getCheckerOrder",
        "parameters": [
          {
            "name": "reference",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "API-CHK-MH8K2Q1Z4F2A"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/CheckerOrder"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/afa/registrations": {
      "post": {
        "tags": [
          "AFA"
        ],
        "summary": "Submit an MTN AFA registration",
        "operationId": "createAfaRegistration",
        "description": "Charges the AFA fee and returns status pending. The outcome arrives by webhook (afa.registration.completed / .failed) or by polling. Requires the afa scope.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Unique per order (a UUID is ideal). Retrying with the same key never charges twice. Remembered for 24 hours.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_\\-:.]{8,100}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AfaRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted, pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AfaRegistrationCreated"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "400": {
            "description": "IDEMPOTENCY_KEY_REQUIRED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "INSUFFICIENT_BALANCE. Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "REQUEST_IN_PROGRESS.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "VALIDATION_ERROR or IDEMPOTENCY_KEY_REUSED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/afa/registrations/{reference}": {
      "get": {
        "tags": [
          "AFA"
        ],
        "summary": "Get AFA registration status",
        "operationId": "getAfaRegistration",
        "parameters": [
          {
            "name": "reference",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "API-CHK-MH8K2Q1Z4F2A"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The registration.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AfaRegistration"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/transactions": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "List wallet transactions, newest first",
        "operationId": "listTransactions",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of transactions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/TransactionPage"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "VALIDATION_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/webhook": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Get webhook URL and recent deliveries",
        "operationId": "getWebhook",
        "responses": {
          "200": {
            "description": "Webhook settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/WebhookSettings"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Set the webhook URL",
        "operationId": "setWebhook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "additionalProperties": false,
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Public https:// URL."
                  },
                  "rotate_secret": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved. secret is present only when newly issued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string"
                        },
                        "secret": {
                          "type": "string",
                          "example": "whsec_..."
                        },
                        "secret_hint": {
                          "type": "string"
                        },
                        "secret_note": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "VALIDATION_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Stop sending webhooks",
        "operationId": "deleteWebhook",
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "null"
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/webhook/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Queue a webhook.test event",
        "operationId": "testWebhook",
        "responses": {
          "202": {
            "description": "Queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "queued": {
                          "const": true
                        },
                        "note": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/X-Request-Id"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key (UNAUTHORIZED, KEY_REVOKED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "ACCOUNT_NOT_ACTIVE, FORBIDDEN_SCOPE or IP_NOT_ALLOWED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "No webhook URL set.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "RATE_LIMITED. See the Retry-After header.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "INTERNAL_ERROR.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "SERVICE_UNAVAILABLE. Nothing was charged; retry with backoff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "afa.registration.completed": {
      "post": {
        "summary": "An AFA registration succeeded",
        "operationId": "onAfaRegistrationCompleted",
        "description": "Signed with X-EST-Signature: t=<unix>,v1=<hex HMAC-SHA256(secret, \"<t>.<raw body>\")>. Respond 2xx within 10 seconds.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged."
          }
        }
      }
    },
    "afa.registration.failed": {
      "post": {
        "summary": "An AFA registration failed",
        "operationId": "onAfaRegistrationFailed",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Acknowledged."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key: est_live_… (live) or est_test_… (sandbox). Server-side use only."
      }
    },
    "headers": {
      "X-Request-Id": {
        "description": "Unique ID for this request. Quote it to support.",
        "schema": {
          "type": "string"
        }
      },
      "X-RateLimit-Limit": {
        "description": "Requests allowed per minute.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Requests left in this window.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Reset": {
        "description": "Unix time when the window resets.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "required": [
          "success",
          "error"
        ],
        "properties": {
          "success": {
            "const": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "request_id"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "UNAUTHORIZED",
                  "KEY_REVOKED",
                  "ACCOUNT_NOT_ACTIVE",
                  "FORBIDDEN_SCOPE",
                  "IP_NOT_ALLOWED",
                  "VALIDATION_ERROR",
                  "IDEMPOTENCY_KEY_REQUIRED",
                  "IDEMPOTENCY_KEY_REUSED",
                  "REQUEST_IN_PROGRESS",
                  "INSUFFICIENT_BALANCE",
                  "OUT_OF_STOCK",
                  "NOT_FOUND",
                  "METHOD_NOT_ALLOWED",
                  "RATE_LIMITED",
                  "USE_PUBLIC_ENDPOINT",
                  "INTERNAL_ERROR",
                  "SERVICE_UNAVAILABLE"
                ]
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "additionalProperties": true
              },
              "request_id": {
                "type": "string"
              }
            }
          }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "business_name": {
            "type": "string"
          },
          "account_status": {
            "type": "string",
            "enum": [
              "pending",
              "approved",
              "suspended",
              "rejected"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "test"
            ]
          },
          "balance": {
            "type": "number",
            "description": "Amount in GHS, up to two decimal places."
          },
          "currency": {
            "const": "GHS"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "read",
                "checkers",
                "afa"
              ]
            }
          },
          "limits": {
            "type": "object",
            "properties": {
              "requests_per_minute": {
                "type": "integer"
              },
              "max_vouchers_per_order": {
                "type": "integer"
              }
            }
          },
          "webhook_configured": {
            "type": "boolean"
          }
        }
      },
      "Products": {
        "type": "object",
        "properties": {
          "currency": {
            "const": "GHS"
          },
          "max_vouchers_per_order": {
            "type": "integer"
          },
          "checkers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "exam_type": {
                  "type": "string",
                  "enum": [
                    "WASSCE",
                    "BECE"
                  ]
                },
                "unit_price": {
                  "type": "number",
                  "description": "Amount in GHS, up to two decimal places."
                },
                "pricing_tiers": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "min_quantity": {
                        "type": "integer"
                      },
                      "max_quantity": {
                        "type": [
                          "integer",
                          "null"
                        ]
                      },
                      "unit_price": {
                        "type": "number",
                        "description": "Amount in GHS, up to two decimal places."
                      }
                    }
                  }
                },
                "years": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "exam_year": {
                        "type": "integer"
                      },
                      "in_stock": {
                        "type": "boolean"
                      },
                      "low_stock": {
                        "type": "boolean"
                      }
                    }
                  }
                }
              }
            }
          },
          "afa_registration": {
            "type": "object",
            "properties": {
              "fee": {
                "type": "number",
                "description": "Amount in GHS, up to two decimal places."
              },
              "available": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "CheckerOrderRequest": {
        "type": "object",
        "required": [
          "exam_type",
          "exam_year",
          "quantity"
        ],
        "additionalProperties": false,
        "properties": {
          "exam_type": {
            "type": "string",
            "enum": [
              "WASSCE",
              "BECE"
            ]
          },
          "exam_year": {
            "type": "integer",
            "minimum": 2020,
            "maximum": 2100,
            "example": 2026
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000,
            "description": "Up to your account max_vouchers_per_order (100 by default)."
          },
          "customer_phone": {
            "type": "string",
            "description": "Optional. If set, PINs are also sent to this number by SMS.",
            "example": "0241234567"
          },
          "client_reference": {
            "type": "string",
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9_\\-:./]{1,64}$",
            "description": "Your own ID. Returned on the order and in webhooks. In the sandbox, simulate_insufficient_balance, simulate_out_of_stock and simulate_failure trigger those outcomes."
          }
        }
      },
      "Voucher": {
        "type": "object",
        "properties": {
          "serial": {
            "type": [
              "string",
              "null"
            ]
          },
          "pin": {
            "type": "string"
          }
        }
      },
      "CheckerOrder": {
        "type": "object",
        "properties": {
          "reference": {
            "type": "string"
          },
          "client_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "test"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "completed",
              "failed"
            ]
          },
          "exam_type": {
            "type": "string"
          },
          "exam_year": {
            "type": "integer"
          },
          "quantity": {
            "type": "integer"
          },
          "unit_price": {
            "type": "number",
            "description": "Amount in GHS, up to two decimal places."
          },
          "total_amount": {
            "type": "number",
            "description": "Amount in GHS, up to two decimal places."
          },
          "currency": {
            "const": "GHS"
          },
          "vouchers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Voucher"
            }
          },
          "customer_phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CheckerOrderCreated": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CheckerOrder"
          },
          {
            "type": "object",
            "properties": {
              "sms": {
                "type": "object",
                "properties": {
                  "requested": {
                    "type": "boolean"
                  },
                  "sent": {
                    "type": "boolean"
                  }
                }
              },
              "balance_after": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Amount in GHS, up to two decimal places."
              }
            }
          }
        ]
      },
      "AfaRequest": {
        "type": "object",
        "required": [
          "full_name",
          "phone",
          "id_number",
          "date_of_birth",
          "town",
          "occupation"
        ],
        "additionalProperties": false,
        "properties": {
          "full_name": {
            "type": "string",
            "maxLength": 100
          },
          "phone": {
            "type": "string",
            "description": "Ghana mobile number: 0XXXXXXXXX or +233XXXXXXXXX.",
            "example": "0241234567"
          },
          "id_number": {
            "type": "string",
            "maxLength": 30,
            "example": "GHA-123456789-0"
          },
          "date_of_birth": {
            "type": "string",
            "format": "date",
            "example": "2005-04-16"
          },
          "town": {
            "type": "string",
            "maxLength": 60
          },
          "occupation": {
            "type": "string",
            "maxLength": 60
          },
          "client_reference": {
            "type": "string",
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9_\\-:./]{1,64}$",
            "description": "Your own ID. Returned on the order and in webhooks. In the sandbox, simulate_insufficient_balance, simulate_out_of_stock and simulate_failure trigger those outcomes."
          }
        }
      },
      "AfaRegistration": {
        "type": "object",
        "properties": {
          "reference": {
            "type": "string"
          },
          "client_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "test"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "completed",
              "failed"
            ]
          },
          "phone": {
            "type": "string"
          },
          "fee": {
            "type": "number",
            "description": "Amount in GHS, up to two decimal places."
          },
          "currency": {
            "const": "GHS"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AfaRegistrationCreated": {
        "allOf": [
          {
            "$ref": "#/components/schemas/AfaRegistration"
          },
          {
            "type": "object",
            "properties": {
              "balance_after": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Amount in GHS, up to two decimal places."
              }
            }
          }
        ]
      },
      "TransactionPage": {
        "type": "object",
        "properties": {
          "transactions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "reference": {
                  "type": "string"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "credit",
                    "debit"
                  ]
                },
                "service": {
                  "type": "string"
                },
                "amount": {
                  "type": "number",
                  "description": "Amount in GHS, up to two decimal places."
                },
                "currency": {
                  "const": "GHS"
                },
                "status": {
                  "type": "string"
                },
                "channel": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "WebhookSettings": {
        "type": "object",
        "properties": {
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "secret_hint": {
            "type": [
              "string",
              "null"
            ]
          },
          "recent_deliveries": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "event_type": {
                  "type": "string"
                },
                "mode": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "delivered",
                    "failed"
                  ]
                },
                "attempts": {
                  "type": "integer"
                },
                "last_status_code": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "last_error": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "delivered_at": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                },
                "next_attempt_at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "created_at",
          "mode",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "evt_8f14e45fceea167a5a36dedd4bea2543"
          },
          "type": {
            "type": "string",
            "enum": [
              "afa.registration.completed",
              "afa.registration.failed",
              "webhook.test"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "test"
            ]
          },
          "data": {
            "type": "object",
            "properties": {
              "reference": {
                "type": "string"
              },
              "client_reference": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "completed",
                  "failed"
                ]
              },
              "phone": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
