{
  "openapi": "3.1.1",
  "info": {
    "title": "DigiPay API",
    "description": "REST API for DigiByte payments. Merchants register once, create checkout sessions per customer, and receive webhook notifications when payment state changes.\n\n**Auth.** Every endpoint outside `public/*` and `test/*` expects `Authorization: Bearer {prefix}_{secret}` where `{prefix}` is `dgp_` (long-lived API key) or `dps_` (browser session token). Only SHA-256 hashes are stored server-side — secrets are shown once on creation.",
    "contact": {
      "name": "DigiByte Pay",
      "url": "https://pay.dgbwallet.app"
    },
    "license": {
      "name": "MIT",
      "url": "https://github.com/DennisPitallano/digibyte-wallet/blob/main/LICENSE"
    },
    "version": "v1"
  },
  "servers": [
    {
      "url": "http://api.pay.dgbwallet.app/"
    }
  ],
  "paths": {
    "/v1/pay/merchants": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMerchantRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          }
        },
        "security": [ ]
      }
    },
    "/v1/pay/sessions": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSessionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      },
      "get": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "storeId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "take",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32",
              "default": 25
            }
          },
          {
            "name": "skip",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32",
              "default": 0
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/sessions/{id}": {
      "get": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/sessions/{id}/options/dd": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/sessions/{id}/refund": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/sessions/{id}/void": {
      "post": {
        "tags": [
          "Sessions"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/VoidRequest"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores": {
      "get": {
        "tags": [
          "Stores & webhooks"
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      },
      "post": {
        "tags": [
          "Stores & webhooks"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateStoreRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}": {
      "get": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      },
      "patch": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateStoreRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      },
      "delete": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}/webhook-secret/rotate": {
      "post": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}/dd-key/preview": {
      "post": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DdKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}/dd-key": {
      "put": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DdKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      },
      "delete": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}/donation-address": {
      "get": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}/webhook/test": {
      "post": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}/webhook-deliveries": {
      "get": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "take",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32",
              "default": 25
            }
          },
          {
            "name": "sessionId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}/webhook-deliveries/{deliveryId}/replay": {
      "post": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}/analytics": {
      "get": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32",
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/stores/{storeId}/stats/daily": {
      "get": {
        "tags": [
          "Stores & webhooks"
        ],
        "parameters": [
          {
            "name": "storeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          },
          {
            "name": "tz",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "401": {
            "description": "Missing or invalid Bearer token."
          },
          "404": {
            "description": "Resource not found (or not owned by the authenticated merchant)."
          }
        }
      }
    },
    "/v1/pay/public/stores/{id}/donation-options": {
      "get": {
        "tags": [
          "Public"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          }
        },
        "security": [ ]
      }
    },
    "/v1/pay/public/stats": {
      "get": {
        "tags": [
          "Public"
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          }
        },
        "security": [ ]
      }
    },
    "/v1/pay/public/price": {
      "get": {
        "tags": [
          "Public"
        ],
        "parameters": [
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          }
        },
        "security": [ ]
      }
    },
    "/v1/pay/public/currencies": {
      "get": {
        "tags": [
          "Public"
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          }
        },
        "security": [ ]
      }
    },
    "/v1/pay/test/demo-session": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "429": {
            "description": "Rate limit exceeded — sandbox is capped at 20 requests/minute per IP."
          }
        },
        "security": [ ]
      }
    },
    "/v1/pay/test/sessions/{id}/advance": {
      "post": {
        "tags": [
          "Sandbox"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request — validation failed or malformed input."
          },
          "429": {
            "description": "Rate limit exceeded — sandbox is capped at 20 requests/minute per IP."
          }
        },
        "security": [ ]
      }
    }
  },
  "components": {
    "schemas": {
      "CreateMerchantRequest": {
        "required": [
          "displayName",
          "addressOrXpub",
          "xpub",
          "network",
          "webhookUrl"
        ],
        "type": "object",
        "properties": {
          "displayName": {
            "type": "string"
          },
          "addressOrXpub": {
            "type": [
              "null",
              "string"
            ]
          },
          "xpub": {
            "type": [
              "null",
              "string"
            ]
          },
          "network": {
            "type": [
              "null",
              "string"
            ]
          },
          "webhookUrl": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "CreateSessionRequest": {
        "required": [
          "amount",
          "storeId",
          "fiatCurrency",
          "fiatAmount",
          "dgbPriceAtCreation",
          "label",
          "memo",
          "expiresInSeconds",
          "returnUrl"
        ],
        "type": "object",
        "properties": {
          "amount": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "storeId": {
            "type": [
              "null",
              "string"
            ]
          },
          "fiatCurrency": {
            "type": [
              "null",
              "string"
            ]
          },
          "fiatAmount": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "dgbPriceAtCreation": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "label": {
            "type": [
              "null",
              "string"
            ]
          },
          "memo": {
            "type": [
              "null",
              "string"
            ]
          },
          "expiresInSeconds": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "returnUrl": {
            "type": [
              "null",
              "string"
            ]
          },
          "currency": {
            "type": [
              "null",
              "string"
            ]
          },
          "amountCentsDd": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "buyerChoice": {
            "type": [
              "null",
              "boolean"
            ]
          }
        }
      },
      "CreateStoreRequest": {
        "required": [
          "name",
          "network"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "network": {
            "type": [
              "null",
              "string"
            ]
          },
          "defaultCurrency": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "DdKeyRequest": {
        "required": [
          "key",
          "confirmFirstAddress"
        ],
        "type": "object",
        "properties": {
          "key": {
            "type": [
              "null",
              "string"
            ]
          },
          "confirmFirstAddress": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "JsonElement": { },
      "RefundRequest": {
        "required": [
          "txid",
          "note"
        ],
        "type": "object",
        "properties": {
          "txid": {
            "type": [
              "null",
              "string"
            ]
          },
          "note": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "UpdateStoreRequest": {
        "required": [
          "name",
          "network",
          "addressOrXpub",
          "webhookUrl",
          "defaultSessionExpiryMinutes",
          "digiDollarEnabled"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": [
              "null",
              "string"
            ]
          },
          "network": {
            "type": [
              "null",
              "string"
            ]
          },
          "addressOrXpub": {
            "type": [
              "null",
              "string"
            ]
          },
          "webhookUrl": {
            "type": [
              "null",
              "string"
            ]
          },
          "defaultSessionExpiryMinutes": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "digiDollarEnabled": {
            "type": [
              "null",
              "boolean"
            ]
          },
          "buyerChoiceEnabled": {
            "type": [
              "null",
              "boolean"
            ]
          },
          "defaultCurrency": {
            "$ref": "#/components/schemas/JsonElement"
          }
        }
      },
      "VoidRequest": {
        "required": [
          "note"
        ],
        "type": "object",
        "properties": {
          "note": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "API key (dgp_…) for server-side integrations, or session token (dps_…) minted by Digi-ID sign-in.",
        "scheme": "bearer",
        "bearerFormat": "dgp_… or dps_…"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ]
    }
  ],
  "tags": [
    {
      "name": "Sessions"
    },
    {
      "name": "Stores & webhooks"
    },
    {
      "name": "Public"
    },
    {
      "name": "Sandbox"
    }
  ]
}