{
  "info": {
    "name": "LinkPilot Integration API v1",
    "_postman_id": "9c1f4a2e-7f0d-4d8b-9a4b-3e6f1c2d5a7b",
    "description": "Key-authenticated API for short links and secret links. Set the `base_url` and `api_key` collection variables. Contract: docs/api/v1.md. Every route answers 503 disabled until API_V1_ENABLED=true on the edge function.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url", "value": "https://khiydxamyihofmtmgvjz.supabase.co/functions/v1/api-v1" },
    { "key": "api_key", "value": "lp_live_REPLACE_ME" },
    { "key": "client_id", "value": "postman-0123456789abcdef" },
    { "key": "link_id", "value": "" },
    { "key": "secret_id", "value": "" }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{api_key}}", "type": "string" }]
  },
  "item": [
    {
      "name": "Workspace",
      "item": [
        {
          "name": "GET /me",
          "request": { "method": "GET", "url": "{{base_url}}/me" },
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('200 with rate-limit headers', () => {",
                  "  pm.response.to.have.status(200);",
                  "  pm.expect(pm.response.headers.get('X-RateLimit-Limit')).to.exist;",
                  "  pm.expect(pm.response.headers.get('X-RateLimit-Remaining')).to.exist;",
                  "});"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Links",
      "item": [
        {
          "name": "POST /links",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": "{{base_url}}/links",
            "body": { "mode": "raw", "raw": "{\n  \"url\": \"https://example.com/launch\",\n  \"title\": \"Launch post\",\n  \"tags\": [\"campaign\"]\n}" }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('201 created', () => pm.response.to.have.status(201));",
                  "const body = pm.response.json();",
                  "pm.collectionVariables.set('link_id', body.id);",
                  "pm.test('short_url present', () => pm.expect(body.short_url).to.match(/^https:\\/\\//));"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /links",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/links?limit=20", "host": ["{{base_url}}"], "path": ["links"], "query": [{ "key": "limit", "value": "20" }, { "key": "cursor", "value": "", "disabled": true }] } }
        },
        {
          "name": "GET /links/{id}",
          "request": { "method": "GET", "url": "{{base_url}}/links/{{link_id}}" }
        },
        {
          "name": "DELETE /links/{id}",
          "request": { "method": "DELETE", "url": "{{base_url}}/links/{{link_id}}" },
          "event": [{ "listen": "test", "script": { "exec": ["pm.test('204', () => pm.response.to.have.status(204));"] } }]
        }
      ]
    },
    {
      "name": "Secrets",
      "item": [
        {
          "name": "POST /secrets",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": "{{base_url}}/secrets",
            "body": { "mode": "raw", "raw": "{\n  \"ciphertext\": \"{{ciphertext}}\",\n  \"enc_version\": 1,\n  \"ttl_seconds\": 3600,\n  \"burn_after_read\": true\n}" }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test('201 created', () => pm.response.to.have.status(201));",
                  "const body = pm.response.json();",
                  "pm.collectionVariables.set('secret_id', body.id);",
                  "pm.test('ciphertext is never echoed', () => pm.expect(pm.response.text()).to.not.include(pm.variables.get('ciphertext')));",
                  "pm.test('no key fragment in secret_url', () => pm.expect(pm.response.json().secret_url).to.not.include('#'));"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /secrets (passphrase_hash, Pro only)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": "{{base_url}}/secrets",
            "body": { "mode": "raw", "raw": "{\n  \"ciphertext\": \"{{ciphertext_v1p}}\",\n  \"enc_version\": 1,\n  \"passphrase_hash\": \"{{passphrase_sha256}}\",\n  \"ttl_seconds\": 86400\n}" }
          }
        },
        {
          "name": "GET /secrets",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/secrets?limit=20", "host": ["{{base_url}}"], "path": ["secrets"], "query": [{ "key": "limit", "value": "20" }] } }
        },
        {
          "name": "DELETE /secrets/{id}",
          "request": { "method": "DELETE", "url": "{{base_url}}/secrets/{{secret_id}}" },
          "event": [{ "listen": "test", "script": { "exec": ["pm.test('204', () => pm.response.to.have.status(204));"] } }]
        }
      ]
    },
    {
      "name": "Public (no key)",
      "item": [
        {
          "name": "POST /public/links",
          "request": {
            "auth": { "type": "noauth" },
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": "{{base_url}}/public/links",
            "body": { "mode": "raw", "raw": "{\n  \"url\": \"https://example.com\",\n  \"client_id\": \"{{client_id}}\"\n}" }
          }
        },
        {
          "name": "POST /public/secrets",
          "request": {
            "auth": { "type": "noauth" },
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": "{{base_url}}/public/secrets",
            "body": { "mode": "raw", "raw": "{\n  \"ciphertext\": \"{{ciphertext}}\",\n  \"enc_version\": 1,\n  \"ttl_seconds\": 3600,\n  \"client_id\": \"{{client_id}}\"\n}" }
          }
        }
      ]
    }
  ]
}
