{
  "openapi": "3.1.0",
  "info": {
    "title": "ZiroGate v2 API",
    "version": "2.0.0",
    "description": "Non-custodial USDT, USDC and EURC checkout. Unique deposit address per payment; funds settle 100% to the merchant payout wallet. Full guide: https://zirogate.com/llms-full.txt",
    "contact": {
      "name": "ZiroGate",
      "url": "https://zirogate.com",
      "email": "contact@zirogate.com"
    },
    "license": {
      "name": "API documentation",
      "url": "https://zirogate.com/terms"
    }
  },
  "servers": [
    {
      "url": "https://zirogate.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Payments",
      "description": "Authenticated merchant API"
    },
    {
      "name": "Public",
      "description": "No secret required; the API key is public"
    },
    {
      "name": "Webhooks",
      "description": "Signed server-to-server events"
    }
  ],
  "paths": {
    "/api/v2/payments": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "Create a payment",
        "description": "Creates a payment with a unique deposit address and returns checkout_url. amount is in the merchant invoice currency (USD or EUR).",
        "security": [
          {
            "HmacKey": []
          }
        ],
        "parameters": [
          {
            "name": "X-API-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unix timestamp in seconds."
          },
          {
            "name": "X-API-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Unique per request. Replay-protected."
          },
          {
            "name": "X-API-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "HMAC-SHA256 over timestamp, nonce, method, path with query, and sha256(rawBody), joined with newlines. Sign with the API secret."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount"
                ],
                "properties": {
                  "amount": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "example": "49.00"
                  },
                  "chain": {
                    "type": "string",
                    "description": "Optional chain key. Omit to let the payer choose.",
                    "example": "TRC20"
                  },
                  "order_id": {
                    "type": "string",
                    "maxLength": 128,
                    "example": "ORDER-123"
                  },
                  "return_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "callback_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Payment created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/payments/{id}": {
      "get": {
        "tags": [
          "Payments"
        ],
        "summary": "Get a payment by transaction id",
        "security": [
          {
            "HmacKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-API-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unix timestamp in seconds."
          },
          {
            "name": "X-API-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Unique per request. Replay-protected."
          },
          {
            "name": "X-API-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "HMAC-SHA256 over timestamp, nonce, method, path with query, and sha256(rawBody), joined with newlines. Sign with the API secret."
          }
        ],
        "responses": {
          "200": {
            "description": "Payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/check-payment": {
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "Check a payment or list payments",
        "description": "Form body with api_key and api_secret. Omit transaction_id to list payments. This is intended for server-to-server checks.",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "api_key",
                  "api_secret"
                ],
                "properties": {
                  "api_key": {
                    "type": "string"
                  },
                  "api_secret": {
                    "type": "string"
                  },
                  "transaction_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "PENDING",
                      "FUNDED",
                      "SWEPT",
                      "EXPIRED",
                      "FAILED"
                    ]
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 50
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0,
                    "default": 0
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One payment or a paginated list",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Payment"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Payment"
                          }
                        },
                        "total": {
                          "type": "integer"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v2/webhook": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Register the merchant webhook URL",
        "description": "Stores the webhook URL and returns the HMAC signing secret. Called by the WooCommerce plugin automatically.",
        "security": [
          {
            "HmacKey": []
          }
        ],
        "parameters": [
          {
            "name": "X-API-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unix timestamp in seconds."
          },
          {
            "name": "X-API-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "description": "Unique per request. Replay-protected."
          },
          {
            "name": "X-API-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "HMAC-SHA256 over timestamp, nonce, method, path with query, and sha256(rawBody), joined with newlines. Sign with the API secret."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Registration result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "webhook_secret": {
                      "type": "string"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "created_secret": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v2/checkout": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Hosted checkout link",
        "description": "Redirects to the hosted network chooser. Only the public API key is needed.",
        "parameters": [
          {
            "name": "api_key",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "order_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "return_url",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uri"
            }
          }
        ],
        "responses": {
          "303": {
            "description": "Redirect to checkout"
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Public"
        ],
        "summary": "Create a payment from an HTML form",
        "description": "Form POST used by the copy-paste checkout button. Redirects (303) to checkout.",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "api_key",
                  "amount"
                ],
                "properties": {
                  "api_key": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "string"
                  },
                  "order_id": {
                    "type": "string"
                  },
                  "return_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "chain": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "303": {
            "description": "Redirect to checkout"
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v2/checkout/options": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Available networks for a merchant",
        "parameters": [
          {
            "name": "api_key",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Networks with active flags and average network cost",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "type": "string",
                      "enum": [
                        "USD",
                        "EUR"
                      ]
                    },
                    "options": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CheckoutOption"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v2/payments/{id}": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Public payment status",
        "description": "No authentication. Contains the deposit address and return_url.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Payment"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v2/assets": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Live mainnet asset status",
        "responses": {
          "200": {
            "description": "Assets",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "assets": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "chain_key": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "token_symbol": {
                            "type": "string"
                          },
                          "is_active": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "HmacKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Public API key. Also send X-API-Timestamp, X-API-Nonce and X-API-Signature. HMAC-SHA256 over timestamp, nonce, method, path with query, and sha256(rawBody), joined with newlines. Sign with the API secret."
      }
    },
    "schemas": {
      "Payment": {
        "type": "object",
        "properties": {
          "transaction_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "PENDING",
              "FUNDED",
              "SWEPT",
              "EXPIRED",
              "FAILED"
            ]
          },
          "amount": {
            "type": "string",
            "description": "Exact asset amount"
          },
          "invoice_amount": {
            "type": "string"
          },
          "invoice_currency": {
            "type": "string",
            "enum": [
              "USD",
              "EUR"
            ]
          },
          "amount_usd": {
            "type": "string"
          },
          "chain": {
            "type": "string"
          },
          "chain_name": {
            "type": "string"
          },
          "token_symbol": {
            "type": "string"
          },
          "deposit_address": {
            "type": "string"
          },
          "payout_address": {
            "type": "string"
          },
          "order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "tx_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "sweep_tx_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "tx_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "sweep_tx_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "confirmations": {
            "type": "integer"
          },
          "funded_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "swept_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "late": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "checkout_url": {
            "type": "string",
            "format": "uri"
          },
          "return_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "metadata": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          }
        }
      },
      "CheckoutOption": {
        "type": "object",
        "properties": {
          "chain_key": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "network_label": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "token_symbol": {
            "type": "string"
          },
          "asset_currency": {
            "type": "string",
            "enum": [
              "USD",
              "EUR"
            ]
          },
          "is_active": {
            "type": "boolean"
          },
          "unavailable_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "avg_cost_usd": {
            "type": [
              "number",
              "null"
            ]
          },
          "avg_cost_label": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        }
      }
    }
  }
}