{
  "info": {
    "_postman_id": "f4e91fd0-8336-4f9a-821b-159a55d42e41",
    "name": "Cozzix Business Line API v1",
    "description": "Production-ready requests for an ANX product Business Line. Set the collection variables before sending requests. Never share a populated export.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      { "key": "token", "value": "{{apiKey}}", "type": "string" }
    ]
  },
  "variable": [
    { "key": "baseUrl", "value": "https://api.cozzix.com", "type": "string" },
    { "key": "apiKey", "value": "czx_live_REPLACE_WITH_SECRET", "type": "string" },
    { "key": "stripeAccountId", "value": "acct_REPLACE", "type": "string" },
    { "key": "externalCustomerId", "value": "cus_REPLACE", "type": "string" },
    { "key": "externalInvoiceId", "value": "in_REPLACE", "type": "string" },
    { "key": "paymentIntentId", "value": "pi_REPLACE", "type": "string" },
    { "key": "chargeId", "value": "ch_REPLACE", "type": "string" },
    { "key": "eventId", "value": "evt_REPLACE_WITH_UNIQUE_EVENT", "type": "string" }
  ],
  "item": [
    {
      "name": "1. Check connection",
      "request": {
        "method": "GET",
        "header": [],
        "url": "{{baseUrl}}/api/external/v1/status",
        "description": "Verifies the API key and returns its Business Line, currencies, totals, recent transactions, and recent deliveries."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Status is 200', () => pm.response.to.have.status(200));",
              "pm.test('Business Line is connected', () => pm.expect(pm.response.json().ok).to.eql(true));"
            ]
          }
        }
      ]
    },
    {
      "name": "2. Create paid invoice",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json", "type": "text" },
          { "key": "Idempotency-Key", "value": "{{eventId}}", "type": "text" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"externalInvoiceId\": \"{{externalInvoiceId}}\",\n  \"invoicedAt\": \"2026-10-20T14:25:00.000Z\",\n  \"paidAt\": \"2026-10-20T14:25:03.000Z\",\n  \"currency\": \"USD\",\n  \"customer\": {\n    \"externalId\": \"{{externalCustomerId}}\",\n    \"name\": \"API Test Customer\",\n    \"email\": \"billing@example.com\",\n    \"country\": \"US\",\n    \"timezone\": \"America/New_York\"\n  },\n  \"items\": [\n    {\n      \"externalProductId\": \"monthly-plan\",\n      \"description\": \"Monthly subscription\",\n      \"quantity\": 1,\n      \"unitAmount\": 79.99,\n      \"taxPercent\": 0\n    }\n  ],\n  \"discountTotal\": 0,\n  \"payment\": {\n    \"provider\": \"stripe\",\n    \"method\": \"card\",\n    \"accountId\": \"{{stripeAccountId}}\",\n    \"paymentId\": \"{{paymentIntentId}}\",\n    \"chargeId\": \"{{chargeId}}\",\n    \"card\": {\n      \"brand\": \"visa\",\n      \"last4\": \"4242\",\n      \"expMonth\": 12,\n      \"expYear\": 2030,\n      \"funding\": \"credit\"\n    }\n  }\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": "{{baseUrl}}/api/external/v1/invoices",
        "description": "Run only with real unique test IDs in the intended environment. Replaying the same event ID and exact body is safe."
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Accepted', () => pm.expect([200, 201]).to.include(pm.response.code));",
              "pm.test('Invoice ID returned', () => pm.expect(pm.response.json().invoice.id).to.be.a('string'));"
            ]
          }
        }
      ]
    },
    {
      "name": "3. Synchronize transaction",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Content-Type", "value": "application/json", "type": "text" },
          { "key": "Idempotency-Key", "value": "{{eventId}}", "type": "text" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"provider\": \"stripe\",\n  \"accountId\": \"{{stripeAccountId}}\",\n  \"paymentId\": \"{{paymentIntentId}}\",\n  \"chargeId\": \"{{chargeId}}\",\n  \"externalInvoiceId\": \"{{externalInvoiceId}}\",\n  \"status\": \"succeeded\",\n  \"amount\": 79.99,\n  \"amountRefunded\": 0,\n  \"currency\": \"USD\",\n  \"description\": \"Monthly subscription\",\n  \"occurredAt\": \"2026-10-20T14:25:03.000Z\",\n  \"paidAt\": \"2026-10-20T14:25:03.000Z\",\n  \"customer\": {\n    \"externalId\": \"{{externalCustomerId}}\",\n    \"name\": \"API Test Customer\",\n    \"email\": \"billing@example.com\"\n  },\n  \"paymentMethod\": {\n    \"type\": \"card\",\n    \"cardBrand\": \"visa\",\n    \"cardLast4\": \"4242\",\n    \"cardExpMonth\": 12,\n    \"cardExpYear\": 2030,\n    \"cardFunding\": \"credit\"\n  },\n  \"refunds\": [],\n  \"metadata\": {\n    \"environment\": \"production\"\n  }\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": "{{baseUrl}}/api/external/v1/transactions"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Accepted', () => pm.expect([200, 201]).to.include(pm.response.code));",
              "pm.test('Transaction ID returned', () => pm.expect(pm.response.json().transaction.id).to.be.a('string'));"
            ]
          }
        }
      ]
    }
  ]
}
