{
  "info": {
    "name": "FlowwPay XP API (v2)",
    "description": "FlowwPay merchant API for USDT invoices, payouts and ledger balance. Authentication: Authorization: Bearer {{apiKey}}.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://flowwpay.trade/api/public"
    },
    {
      "key": "apiKey",
      "value": ""
    },
    {
      "key": "invoiceId",
      "value": ""
    },
    {
      "key": "payoutId",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Create deposit (invoice)",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "const body = pm.response.json();",
              "if (body.invoiceId) pm.collectionVariables.set('invoiceId', body.invoiceId);"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{apiKey}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/xp/v1/invoices",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "xp",
            "v1",
            "invoices"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"amount\": 100,\n  \"currency\": \"USDT\",\n  \"network\": \"tron\",\n  \"clientId\": \"trader-8412\",\n  \"orderId\": \"order-12345\",\n  \"redirectUrl\": \"https://your-site.com/thanks\",\n  \"webhookUrl\": \"https://your-site.com/hooks/flowwpay\"\n}"
        }
      }
    },
    {
      "name": "Get invoice",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{apiKey}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/xp/v1/invoices/{{invoiceId}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "xp",
            "v1",
            "invoices",
            "{{invoiceId}}"
          ]
        }
      }
    },
    {
      "name": "Create payout",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{apiKey}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/xp/v1/payouts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "xp",
            "v1",
            "payouts"
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"amount\": 25,\n  \"currency\": \"USDT\",\n  \"network\": \"tron\",\n  \"recipientAddress\": \"T...\",\n  \"referenceId\": \"payout-12345\"\n}"
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "const body = pm.response.json();",
              "if (body.payoutId) pm.collectionVariables.set('payoutId', body.payoutId);"
            ]
          }
        }
      ]
    },
    {
      "name": "Get payout",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{apiKey}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/xp/v1/payouts/{{payoutId}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "xp",
            "v1",
            "payouts",
            "{{payoutId}}"
          ]
        }
      }
    },
    {
      "name": "Balance",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{apiKey}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/xp/v1/ledger/balance",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "xp",
            "v1",
            "ledger",
            "balance"
          ]
        }
      }
    }
  ]
}