{
  "openapi": "3.0.3",
  "info": {
    "title": "ArionPay API",
    "version": "1",
    "description": "Signed requests send x-api-key (store public key pk_...), x-timestamp (Unix seconds) and x-signature = hex(HMAC_SHA256(secret key, \"<timestamp>.<raw body>\")) for POST, or \"<timestamp>.GET <path and query>\" for GET, and Content-Type: application/json on POST. Requests more than 5 minutes off are rejected with 401. Each signed request is accepted once: two identical requests in the same second have the same signature, so wait for the next second before you retry or poll. Webhooks (ArionPay-Signature: t=<unix>,v1=<hex HMAC_SHA256(webhook secret, \"<t>.<raw body>\")>) are described at https://arionpay.com/docs#webhooks."
  },
  "servers": [
    {
      "url": "https://merchant.arionpay.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      },
      "timestamp": {
        "type": "apiKey",
        "in": "header",
        "name": "x-timestamp"
      },
      "signature": {
        "type": "apiKey",
        "in": "header",
        "name": "x-signature"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        }
      },
      "CreateInvoice": {
        "type": "object",
        "required": [
          "amount"
        ],
        "properties": {
          "amount": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ]
          },
          "currency": {
            "type": "string",
            "default": "USD",
            "enum": [
              "USD",
              "EUR",
              "GBP",
              "CAD",
              "AUD",
              "CHF",
              "JPY",
              "TRY",
              "AED",
              "INR",
              "BRL",
              "RUB",
              "CNY",
              "SGD",
              "HKD",
              "KRW",
              "MXN",
              "PLN",
              "SEK",
              "NOK",
              "ZAR"
            ]
          },
          "orderId": {
            "type": "string",
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 500
          },
          "customerEmail": {
            "type": "string",
            "format": "email"
          },
          "successUrl": {
            "type": "string",
            "maxLength": 500
          },
          "cancelUrl": {
            "type": "string",
            "maxLength": 500
          },
          "callbackUrl": {
            "type": "string",
            "maxLength": 500,
            "description": "https, port 443 or 8443, public IP address"
          },
          "expiresMin": {
            "type": "integer",
            "minimum": 5,
            "maximum": 1440
          },
          "allowedAssets": {
            "type": "array",
            "maxItems": 50,
            "items": {
              "type": "string",
              "enum": [
                "BTC",
                "ETH",
                "USDT_ERC20",
                "USDC_ERC20",
                "BNB",
                "USDT_BEP20",
                "USDC_BEP20",
                "POL",
                "USDT_POLYGON",
                "USDC_POLYGON",
                "TRX",
                "USDT_TRC20",
                "LTC",
                "DOGE",
                "BCH",
                "DASH"
              ]
            }
          },
          "asset": {
            "type": "string",
            "enum": [
              "BTC",
              "ETH",
              "USDT_ERC20",
              "USDC_ERC20",
              "BNB",
              "USDT_BEP20",
              "USDC_BEP20",
              "POL",
              "USDT_POLYGON",
              "USDC_POLYGON",
              "TRX",
              "USDT_TRC20",
              "LTC",
              "DOGE",
              "BCH",
              "DASH"
            ]
          },
          "metadata": {
            "type": "object",
            "description": "Up to 4 KB, 4 levels; keys may not start with $ or contain a dot"
          },
          "idempotencyKey": {
            "type": "string",
            "maxLength": 100
          },
          "test": {
            "type": "boolean"
          },
          "storeId": {
            "type": "string",
            "description": "Optional; must be the key's store"
          }
        }
      },
      "InvoiceCreated": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "id": {
            "type": "string"
          },
          "invoice_url": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "invoice_url": {
                "type": "string"
              },
              "amount_fiat": {
                "type": "number"
              },
              "currency": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "new",
                  "pending",
                  "paid_partial",
                  "paid",
                  "expired",
                  "cancelled",
                  "claim_pending",
                  "rejected"
                ]
              },
              "asset": {
                "type": "string",
                "nullable": true
              },
              "address": {
                "type": "string",
                "nullable": true
              },
              "amount_crypto": {
                "type": "string",
                "nullable": true
              },
              "expires_at": {
                "type": "string",
                "format": "date-time"
              },
              "order_id": {
                "type": "string"
              }
            }
          }
        }
      },
      "Invoice": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "NEW",
              "PENDING",
              "PAID_PARTIAL",
              "PAID",
              "EXPIRED",
              "CANCELLED",
              "CLAIM_PENDING",
              "REJECTED"
            ]
          },
          "invoiceId": {
            "type": "string"
          },
          "orderId": {
            "type": "string"
          },
          "settledCurrency": {
            "type": "string",
            "nullable": true
          },
          "network": {
            "type": "string",
            "nullable": true
          },
          "amountFiat": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "amountExpected": {
            "type": "string",
            "nullable": true
          },
          "amountReceived": {
            "type": "string"
          },
          "amountConfirmed": {
            "type": "string"
          },
          "overpaid": {
            "type": "boolean"
          },
          "late": {
            "type": "boolean"
          },
          "txHash": {
            "type": "string",
            "nullable": true
          },
          "transactions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "txid": {
                  "type": "string"
                },
                "amount": {
                  "type": "string"
                },
                "confirmations": {
                  "type": "integer"
                },
                "blockHeight": {
                  "type": "integer",
                  "nullable": true
                },
                "explorerUrl": {
                  "type": "string",
                  "nullable": true
                },
                "firstSeenAt": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          },
          "confirmations": {
            "type": "integer"
          },
          "requiredConfirmations": {
            "type": "integer"
          },
          "settledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "merchantPayoutWallet": {
            "type": "string",
            "nullable": true
          },
          "platformFeeUsd": {
            "type": "number"
          },
          "metadata": {
            "type": "object"
          },
          "test": {
            "type": "boolean"
          },
          "livemode": {
            "type": "boolean"
          },
          "needsReview": {
            "type": "boolean"
          },
          "underpaidWithinTolerance": {
            "type": "boolean"
          },
          "manual": {
            "type": "boolean"
          }
        }
      },
      "SimulateResult": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "scenario": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "new",
              "pending",
              "paid_partial",
              "paid",
              "expired",
              "cancelled",
              "claim_pending",
              "rejected"
            ]
          },
          "credited": {
            "type": "boolean"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/invoices": {
      "post": {
        "summary": "Create an invoice",
        "security": [
          {
            "apiKey": [],
            "timestamp": [],
            "signature": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInvoice"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Invoice created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceCreated"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}": {
      "get": {
        "summary": "Get an invoice",
        "security": [
          {
            "apiKey": [],
            "timestamp": [],
            "signature": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-fA-F]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invoice"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/invoices/{id}/simulate": {
      "post": {
        "summary": "Simulate a test payment (test invoices only)",
        "security": [
          {
            "apiKey": [],
            "timestamp": [],
            "signature": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-fA-F]{24}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "scenario"
                ],
                "properties": {
                  "scenario": {
                    "type": "string",
                    "enum": [
                      "detected",
                      "confirm",
                      "exact",
                      "underpaid_1pct",
                      "underpaid_5pct",
                      "overpaid",
                      "partial_half",
                      "late"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result of the simulation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SimulateResult"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/test": {
      "post": {
        "summary": "Send a test webhook to the store's webhook URL",
        "security": [
          {
            "apiKey": [],
            "timestamp": [],
            "signature": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "eventType": {
                    "type": "string",
                    "enum": [
                      "invoice.pending",
                      "invoice.partial",
                      "invoice.paid",
                      "invoice.expired",
                      "invoice.needs_review"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Delivery result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/store": {
      "get": {
        "summary": "Check your keys (the store the key belongs to)",
        "security": [
          {
            "apiKey": [],
            "timestamp": [],
            "signature": []
          }
        ],
        "responses": {
          "200": {
            "description": "Store id and name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/currencies": {
      "get": {
        "summary": "List coins and networks",
        "responses": {
          "200": {
            "description": "Coins",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rates": {
      "get": {
        "summary": "Get exchange rates",
        "parameters": [
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string",
              "default": "USD"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/wallets/validate": {
      "post": {
        "summary": "Check an address",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "address",
                  "network"
                ],
                "properties": {
                  "address": {
                    "type": "string"
                  },
                  "network": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  }
}
