{
  "info": {
    "name": "Acorn Learning API",
    "description": "# Acorn Learning REST API v1\n\nThe authoritative reference for the Acorn Learning public API. Every request in\nthis collection carries its own documentation (open a request and read its\n**Description** tab): purpose, required token ability, body fields, and the errors\nit can return. The request body shown on each mutating call is a ready-to-send\nexample.\n\nA machine-readable OpenAPI 3.1 spec is available too — see **API Reference → GET\nOpenAPI spec (v1.json)** in this collection, or open the rendered reference at\n`{{base_url}}/docs`.\n\n## Base URLs\n\n| Environment | URL |\n|---|---|\n| Demo (test server) | `https://acorn-api.hrddemo.com` |\n| Local (this checkout) | `http://localhost:8088` |\n| Staging | set `base_url` to your staging host |\n| Production | set `base_url` to your production host |\n\n`base_url` is an environment variable; switch environments to retarget the whole\ncollection.\n\n## Getting a token\n\nAll endpoints require a **Sanctum bearer token** minted on a **service-account**\nuser of an **API-enabled** tenant. The collection sends `Authorization: Bearer\n{{token}}` automatically — you only need to set `{{token}}`.\n\n- **Demo tenant (local):** run `./dev/artisan db:seed --class=DemoTenantSeeder`.\n  It prints `Demo token: …` once — paste it into the `token` environment variable.\n  Re-running the seeder issues a **new** token and re-seeds the demo data.\n- **Real tenant:** an admin generates a token from the client's **API Tokens**\n  admin screen (requires the *manage api tokens* permission). The plaintext token\n  is shown once at creation.\n\n## Authentication & scopes\n\nAccess is governed by **token abilities**, not human roles. Each request lists the\nability it needs under `Ability:`. Demo/admin tokens are minted with `*`\n(all abilities). The abilities are:\n\n`read`, `read:tenant`, `read:users`, `write:users`, `read:groups`, `write:groups`,\n`read:licenses`, `read:assignments`, `write:assignments`, `read:enrollments`,\n`read:progress`, `read:webhooks`, `write:webhooks`, `launch`.\n\nA token missing the required ability gets `403 ability_denied`.\n\n## Rate limits\n\nLimits are per token, per tier (the ability prefix before `:`), per minute:\n\n| Tier | Limit / min |\n|---|---|\n| `read` | 600 |\n| `write` | 120 |\n| `launch` | 60 |\n\nOn `429` the response carries `Retry-After`, `X-RateLimit-Limit`,\n`X-RateLimit-Remaining`, and `X-RateLimit-Reset` headers.\n\n## Pagination\n\nList endpoints are cursor-paginated and enveloped as `{ \"data\": [...], \"meta\": {...} }`:\n\n```json\n\"meta\": { \"next_cursor\": \"…\", \"prev_cursor\": null, \"per_page\": 20, \"has_more\": true }\n```\n\nPass `?per_page=N` (default 20, clamped 1–100) and `?cursor={{next_cursor}}` to page\nforward. `has_more: false` (or a null `next_cursor`) means the last page.\n\n## Identifiers (ULIDs)\n\nEvery resource is addressed by a 26-character **ULID** `public_id` — never an integer\nid. Format: `^[0-7][0-9A-HJKMNP-TV-Z]{25}$`. The demo environment pins these\nwell-known ids:\n\n| Variable | ULID |\n|---|---|\n| `client_id` | `01HDEMAC000000000000000000` |\n| `user_id` (service account) | `01HDEMSERV0000000000000000` |\n| `course_id` | `01HDEMCRS0000000000000000A` |\n| `series_id` | `01HDEMSRS0000000000000000A` |\n| `license_id` | `01HDEM1CS0000000000000000A` |\n| `group_id` | `01HDEMGRP0000000000000000A` |\n| `webhook_id` | `01HDEMWHK0000000000000000A` |\n| `learner_id` | `01HDEM1RN0000000000000000A` |\n\n(Enrollment ids are HMAC-derived at runtime, not fixed; the Enrollments list request\ncaptures one into `enrollment_id` for you.)\n\n## Errors\n\nEvery 4xx/5xx is a structured envelope — never a raw stack trace:\n\n```json\n{ \"error\": { \"code\": \"ability_denied\", \"message\": \"…\", \"details\": null } }\n```\n\n| Status | Code | Meaning |\n|---|---|---|\n| 401 | `unauthorized` | missing / invalid token |\n| 403 | `ability_denied` | token lacks the required ability |\n| 404 | — | not found, or cross-tenant (existence is not leaked) |\n| 409 | `group_not_empty`, `user.email_taken` | conflict |\n| 410 | — | launch token expired / already redeemed |\n| 422 | validation, `courses_not_accessible` | bad input |\n| 429 | `rate_limit_exceeded` | throttled |\n\n## Webhooks\n\nCreate an endpoint (`POST /webhook-endpoints`) — the signing **secret is returned\nonce**; store it. Rotate it with `POST /webhook-endpoints/{id}/rotate`; the endpoint\nlist/detail responses expose a `needs_rotation` flag for endpoints still on a legacy\nsecret. Acorn delivers these events:\n\n`enrollment.created`, `enrollment.completed`, `user.created`, `user.deactivated`,\n`license.expiring`, `progress.attempt_recorded`.\n\nEach POST to your URL carries an `X-Acorn-Signature: t={unix},v1={hmac}` header.\nVerify it by computing `HMAC-SHA256(rawRequestBody, <your endpoint secret>)` and\ncomparing to `v1` (constant-time). Failed deliveries retry with exponential backoff\n(8 attempts). Deliveries older than 30 days are pruned.\n\n## Versioning\n\nThe API is versioned in the path (`/api/v1`); the OpenAPI spec's `info.version`\n(semver) tracks changes within v1. All notable changes — with breaking items\nflagged — are in the API changelog, `docs/openapi/CHANGELOG.md`, published with the\ndocs. The machine-readable contract is at `{{base_url}}/api/openapi.json`.\n\n## Note on the demo environment\n\nThe demo tenant is seeded so **every** endpoint returns representative data\n(catalog, users, groups, licenses, a series, course uploads, learner progress,\ncompletions, and a webhook delivery). The one exception is the **certificate**\nendpoint, which additionally requires a generated certificate PDF in object storage\nand so returns 404 in the demo (verify it manually against a real completion).",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{token}}",
        "type": "string"
      }
    ]
  },
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "GET /whoami (launch-context; 404 with plain PAT)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/whoami",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "whoami"
              ]
            },
            "description": "Returns the calling token's `public_id`, granted abilities, issue/expiry, and its tenant.\n\n**Ability:** `read`\n\n**Returns:** `data: { public_id, abilities[], issued_at, expires_at, tenant: { public_id } }`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "});",
                  "",
                  "// whoami is a launch-context endpoint: it requires the bearer token to be a",
                  "// launch-derived PAT linked to an active LaunchToken (see AL-160). A plain admin",
                  "// PAT (like the demo token) correctly returns 404. Accept either, validate 200.",
                  "pm.test(\"Status is 200 (launch token) or 404 (non-launch PAT)\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 404]);",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code === 200) {",
                  "        const data = pm.response.json().data;",
                  "        pm.expect(data).to.have.property(\"public_id\");",
                  "        pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /tenant",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/tenant",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "tenant"
              ]
            },
            "description": "The authenticated tenant's profile and brand summary.\n\n**Ability:** `read` + `read:tenant`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /courses (unauthenticated → 401 JSON)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/courses",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "courses"
              ]
            },
            "auth": {
              "type": "noauth"
            },
            "description": "Negative test: no bearer token. Expect **401** `unauthorized` as JSON (not an HTML login redirect). This request deliberately sends no auth."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 401\", function() {",
                  "    pm.expect(pm.response.code).to.equal(401);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "});",
                  "",
                  "pm.test(\"Unauthenticated response is a JSON error envelope (not a redirect)\", function() {",
                  "    pm.expect(pm.response.code).to.not.be.oneOf([301, 302]);",
                  "    pm.expect(pm.response.json()).to.have.property(\"error\");",
                  "});"
                ]
              }
            }
          ]
        }
      ],
      "description": "Identity and connectivity checks — who the token belongs to, the tenant profile, and the unauthenticated 401 behavior."
    },
    {
      "name": "Catalog",
      "item": [
        {
          "name": "GET /courses",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/courses",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "courses"
              ]
            },
            "description": "Lists courses the tenant can access (via license or all-users). Cursor-paginated. Captures `course_id` for later requests.\n\n**Ability:** `read`\n\n**Query:** `per_page` (1–100), `cursor`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture course_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "        pm.environment.set(\"course_id\", data[0].public_id);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /courses/{id}",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/courses/{{course_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "courses",
                "{{course_id}}"
              ]
            },
            "description": "A single course by ULID. Cross-tenant / unknown id → **404**.\n\n**Ability:** `read`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /courses/{id}/uploads",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/courses/{{course_id}}/uploads",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "courses",
                "{{course_id}}",
                "uploads"
              ]
            },
            "description": "SCORM upload/package rows for a course (`name`, `path`). Course must be tenant-accessible, else **404**.\n\n**Ability:** `read`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /series",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/series",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "series"
              ]
            },
            "description": "Lists series linked to the tenant. Captures `series_id`.\n\n**Ability:** `read`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture series_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "        pm.environment.set(\"series_id\", data[0].public_id);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /series/{id}",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/series/{{series_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "series",
                "{{series_id}}"
              ]
            },
            "description": "A single series by ULID (or numeric id for admin-managed access). Not linked to the tenant → **404**.\n\n**Ability:** `read`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        }
      ],
      "description": "Read-only catalog: courses (and their SCORM uploads) and series the tenant can access via licenses. Ability: `read`."
    },
    {
      "name": "Users",
      "item": [
        {
          "name": "GET /users",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users"
              ]
            },
            "description": "Lists tenant users (service accounts excluded). Cursor-paginated.\n\n**Ability:** `read:users`\n\n**Query filters:** `email`, `external_id`, `active` (bool), `group` (group ULID), `updated_since` (date), `per_page`, `cursor`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /users/{id}",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{user_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{user_id}}"
              ]
            },
            "description": "A single user by ULID. Cross-tenant → **404**.\n\n**Ability:** `read:users`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /users",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"email\": \"test@example.com\", \"name\": \"Test User\", \"level\": \"learner\", \"external_id\": \"ext-123\"}"
            },
            "description": "Creates a user in the tenant (password auto-generated, `is_active=true`).\n\n**Ability:** `write:users`\n\n**Body**\n\n| field | type | required | notes |\n|---|---|---|---|\n| email | string | yes | valid email; duplicate in tenant → **409** `user.email_taken` (with existing `public_id`) |\n| name | string | yes | ≤ 255 |\n| external_id | string | no | ≤ 100 |\n| level | string | no | `learner` \\| `instructor` \\| `admin` |\n\nCaptures `created_user_id` from the response."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture created_user_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (data && data.public_id) {",
                  "        pm.environment.set(\"created_user_id\", data.public_id);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "PATCH /users/{id}",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{created_user_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{created_user_id}}"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"name\": \"Updated User\"}"
            },
            "description": "Partial update — send only the fields to change (all optional).\n\n**Ability:** `write:users`\n\n**Body:** `email`, `name` (≤255), `external_id` (≤100, nullable), `level` (`learner|instructor|admin`). Duplicate email in tenant → **409** `user.email_taken`."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /users/{id}/deactivate",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{created_user_id}}/deactivate",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{created_user_id}}",
                "deactivate"
              ]
            },
            "description": "Sets the user inactive (`is_active=false`). Idempotent.\n\n**Ability:** `write:users`\n\n**Body:** none required — the action is inferred from the URL (an empty `{}` is sent).",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /users/{id}/reactivate",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{created_user_id}}/reactivate",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{created_user_id}}",
                "reactivate"
              ]
            },
            "description": "Sets the user active (`is_active=true`). Idempotent.\n\n**Ability:** `write:users`\n\n**Body:** none required — the action is inferred from the URL (an empty `{}` is sent).",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /users/{id}/groups (attach group)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{created_user_id}}/groups",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{created_user_id}}",
                "groups"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"group_id\": \"{{group_id}}\"}"
            },
            "description": "Adds the user to a group. Idempotent (re-adding is a no-op).\n\n**Ability:** `write:users`\n\n**Body**\n\n| field | type | required | notes |\n|---|---|---|---|\n| group_id | string | yes | group ULID; not in tenant → **404** |"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "DELETE /users/{id}/groups/{group} (detach group)",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{created_user_id}}/groups/{{group_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{created_user_id}}",
                "groups",
                "{{group_id}}"
              ]
            },
            "description": "Removes the user from the group. Idempotent. Cross-tenant target → **404**.\n\n**Ability:** `write:users`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /users/{id}/progress",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{learner_id}}/progress",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{learner_id}}",
                "progress"
              ]
            },
            "description": "Per-course progress summary for the user (`course_public_id`, `completion`, `last_activity`, `attempt_count`).\n\n**Ability:** `read:progress`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /users/{id}/courses/{course}/progress",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{learner_id}}/courses/{{course_id}}/progress",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{learner_id}}",
                "courses",
                "{{course_id}}",
                "progress"
              ]
            },
            "description": "SCORM attempt detail for one user+course (latest cmi.core state plus the full `attempts` history). No attempts → **404**.\n\n**Ability:** `read:progress`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /users/{id}/courses/{course}/certificate",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{learner_id}}/courses/{{course_id}}/certificate",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{learner_id}}",
                "courses",
                "{{course_id}}",
                "certificate"
              ]
            },
            "description": "Returns a signed certificate URL — only when the course is **passed** AND the certificate PDF exists in object storage; otherwise the request does not succeed.\n\n**Ability:** `read:progress`\n\n_Demo note (manual-only): this is the one endpoint the seeder cannot fully satisfy. The demo learner has a passing attempt, but no certificate PDF exists in object storage — so it returns **404** where S3 is configured, or **500** on a local stack with no S3 credentials. Verify it manually against a real completion in an S3-configured environment._"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "DELETE /users/{id}",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/users/{{created_user_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{created_user_id}}"
              ]
            },
            "description": "Deletes the user. **204** on success.\n\n**Ability:** `write:users`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        }
      ],
      "description": "Manage tenant users: CRUD, activate/deactivate, group membership, and per-user progress/certificate reads. Abilities: `read:users` / `write:users` (progress reads use `read:progress`)."
    },
    {
      "name": "Groups",
      "item": [
        {
          "name": "GET /groups",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/groups",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "groups"
              ]
            },
            "description": "Lists tenant groups. Cursor-paginated.\n\n**Ability:** `read:groups`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture group_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "        pm.environment.set(\"group_id\", data[0].public_id);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /groups/{id}",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/groups/{{group_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "groups",
                "{{group_id}}"
              ]
            },
            "description": "A single group by ULID. Cross-tenant → **404**.\n\n**Ability:** `read:groups`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /groups/{id}/courses",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/groups/{{group_id}}/courses",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "groups",
                "{{group_id}}",
                "courses"
              ]
            },
            "description": "Courses assigned to the group.\n\n**Ability:** `read:groups`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /groups",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/groups",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "groups"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"name\": \"Test Group\", \"description\": \"A test group for API testing\"}"
            },
            "description": "Creates a group.\n\n**Ability:** `write:groups`\n\n**Body**\n\n| field | type | required | notes |\n|---|---|---|---|\n| name | string | yes | ≤ 255 |\n| description | string | no | nullable |"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture group_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (data && data.public_id) {",
                  "        pm.environment.set(\"created_group_id\", data.public_id);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "PATCH /groups/{id}",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/groups/{{created_group_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "groups",
                "{{created_group_id}}"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"name\": \"Updated Group\", \"description\": \"Updated description\"}"
            },
            "description": "Partial update (both fields optional/nullable).\n\n**Ability:** `write:groups`\n\n**Body:** `name` (≤255), `description`."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /groups/{id}/courses (assign courses)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/groups/{{created_group_id}}/courses",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "groups",
                "{{created_group_id}}",
                "courses"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"course_ids\": [\"{{course_id}}\"]}"
            },
            "description": "Assigns courses to the group.\n\n**Ability:** `write:assignments`\n\n**Body**\n\n| field | type | required | notes |\n|---|---|---|---|\n| course_ids | string[] | yes | course ULIDs; any not accessible → **422** `courses_not_accessible` |\n\n**Returns:** `data: { assigned: <count> }`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "DELETE /groups/{id}/courses/{course} (remove assignment)",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/groups/{{created_group_id}}/courses/{{course_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "groups",
                "{{created_group_id}}",
                "courses",
                "{{course_id}}"
              ]
            },
            "description": "Unassigns a course from the group. **204**, idempotent.\n\n**Ability:** `write:assignments`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "DELETE /groups/{id}",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/groups/{{created_group_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "groups",
                "{{created_group_id}}"
              ]
            },
            "description": "Deletes a group. A non-empty group requires `?force=true`, else **409** `group_not_empty`.\n\n**Ability:** `write:groups`\n\n**Query:** `force` (bool)"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        }
      ],
      "description": "Manage groups and their course assignments. Abilities: `read:groups` / `write:groups` (course assignment uses `write:assignments`)."
    },
    {
      "name": "Licenses",
      "item": [
        {
          "name": "GET /licenses",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/licenses",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "licenses"
              ]
            },
            "description": "Lists licenses with consumption (remaining/consumed, per-user/per-group breakdown, expiry flags).\n\n**Ability:** `read:licenses`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture license_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "        pm.environment.set(\"license_id\", data[0].public_id);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /licenses/{id}",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/licenses/{{license_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "licenses",
                "{{license_id}}"
              ]
            },
            "description": "A single license by ULID.\n\n**Ability:** `read:licenses`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /assignments",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/assignments",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "assignments"
              ]
            },
            "description": "Lists course assignments. Captures `assignment_id` for the delete request.\n\n**Ability:** `read:assignments`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture assignment_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "        pm.environment.set(\"assignment_id\", data[0].public_id);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /assignments (bulk)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/assignments",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "assignments"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "[{\"courses_id\": \"{{course_id}}\", \"entity_id\": \"{{group_id}}\", \"entity_type\": \"group\"}]"
            },
            "description": "Bulk-creates course assignments. The body is a **JSON array** (max 100 items); the operation is atomic.\n\n**Ability:** `write:assignments`\n\n**Each item**\n\n| field | type | required | notes |\n|---|---|---|---|\n| courses_id | string | yes | course ULID; not found → **422** |\n| entity_id | string | yes | user or group ULID; not found → **422** |\n| entity_type | string | yes | `user` \\| `group` |"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "DELETE /assignments/{id}",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/assignments/{{assignment_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "assignments",
                "{{assignment_id}}"
              ]
            },
            "description": "Deletes an assignment by ULID. **204**, idempotent. Cross-tenant → **404**.\n\n**Ability:** `write:assignments`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        }
      ],
      "description": "Read license consumption and manage course assignments (bulk create / delete). Abilities: `read:licenses`, `read:assignments` / `write:assignments`."
    },
    {
      "name": "Enrollments",
      "item": [
        {
          "name": "GET /enrollments",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/enrollments",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "enrollments"
              ]
            },
            "description": "Synthetic enrollments projected from purchases and licenses (deduped). Stable ids across calls. Captures `enrollment_id`.\n\n**Ability:** `read:enrollments`\n\n**Query:** `source` (`license` \\| `purchase`; invalid → **422**), `user_id`, `per_page`, `cursor`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        // Enrollment ids are HMAC-derived (not ULIDs); this guard skips them.",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture enrollment_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (Array.isArray(data) && data.length > 0 && data[0].id) {",
                  "        pm.environment.set(\"enrollment_id\", data[0].id);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /enrollments/{id}",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/enrollments/{{enrollment_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "enrollments",
                "{{enrollment_id}}"
              ]
            },
            "description": "A single enrollment by its (HMAC-derived) id. Unknown id → **404**.\n\n**Ability:** `read:enrollments`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /completions",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/completions",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "completions"
              ]
            },
            "description": "Completions feed (passed course_stats), deduped by user+course.\n\n**Ability:** `read:progress`\n\n**Query:** `updated_since` (date; invalid → **422**), `per_page`, `cursor`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});"
                ]
              }
            }
          ]
        }
      ],
      "description": "Synthetic enrollments (projected from licenses + purchases) and the completions feed. Abilities: `read:enrollments`, `read:progress`."
    },
    {
      "name": "Launch",
      "item": [
        {
          "name": "POST /launch",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/launch",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "launch"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"course_id\": \"{{course_id}}\", \"ttl_seconds\": 300}"
            },
            "description": "Mints a signed, single-use launch URL for a course.\n\n**Ability:** `launch`\n\n**Body**\n\n| field | type | required | notes |\n|---|---|---|---|\n| course_id | string | yes | course ULID; must exist and be tenant-accessible (else **404**) |\n| ttl_seconds | integer | no | default 300; clamped to a 900 max |\n\n**Returns** `data: { launch_url, signed_url, expires_at, ttl_seconds }`, `meta: { jti }`.\n\n- **`launch_url`** — the **actionable link**. Open it in a browser or embed it in an `<iframe src>`. It hits the public redeem route, logs the learner in via the signed token, and lands them in the SCORM player. Single-use; expires after `ttl_seconds`.\n- **`signed_url`** — advanced: the server-side verify endpoint (`/api/v1/launch/verify/…`). It requires the API bearer token and **spends** the token, so do not open it in a browser or fetch it just to \"check\" a launch.\n\nThis request captures `launch_url` and (as `verify_url`) `signed_url` into the environment."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture launch_url (actionable), verify_url, and jti\", function() {",
                  "    const response = pm.response.json();",
                  "    // launch_url is the ready-to-open browser/iframe redeem link.",
                  "    if (response.data && response.data.launch_url) {",
                  "        pm.environment.set(\"launch_url\", response.data.launch_url);",
                  "    }",
                  "    // signed_url is the advanced server-side verify endpoint.",
                  "    if (response.data && response.data.signed_url) {",
                  "        pm.environment.set(\"verify_url\", response.data.signed_url);",
                  "    }",
                  "    if (response.meta && response.meta.jti) {",
                  "        pm.environment.set(\"jti\", response.meta.jti);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /api/v1/sso/login",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/sso/login",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "sso",
                "login"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"external_id\": \"{{learner_id}}\", \"email\": \"learner@example.com\", \"ttl_seconds\": 300}"
            },
            "description": "Mints a signed, single-use, **course-agnostic** SSO login URL. Redirect the learner's browser to it and they land on their Acorn dashboard, already authenticated (no course targeted — see POST /launch for course launches).\n\n**Ability:** `sso:login`\n\n**Body**\n\n| field | type | required | notes |\n|---|---|---|---|\n| external_id | string | yes | your stable identifier for the learner (≤100); reuses the same Acorn user on repeat logins |\n| email | string | yes | learner email; a `learner` user is provisioned on first login |\n| name | string | no | display name (≤255) |\n| ttl_seconds | integer | no | default 300; clamped to a 900 max |\n\n**Returns** `data: { login_url, expires_at, ttl_seconds }`, `meta: { jti }`.\n\n- **`login_url`** — the **actionable link**. Redirect the browser to it (top-level `wp_redirect`) or embed it. It hits the public redeem route, logs the learner in via the signed token, and lands them on the dashboard. Single-use; expires after `ttl_seconds`.\n\nAuth uses the collection's inherited bearer (`{{token}}`) — a **tenant-wide** service-account credential; never hardcode a real token here. This request captures `login_url` and `jti` into the environment."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture login_url (actionable) and jti\", function() {",
                  "    const response = pm.response.json();",
                  "    // login_url is the ready-to-open browser redeem link.",
                  "    if (response.data && response.data.login_url) {",
                  "        pm.environment.set(\"login_url\", response.data.login_url);",
                  "    }",
                  "    if (response.meta && response.meta.jti) {",
                  "        pm.environment.set(\"jti\", response.meta.jti);",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        const userId = data && data.user_id;",
                  "        if (userId) {",
                  "            pm.expect(userId).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /launch/verify/{token_public_id}",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{verify_url}}",
              "host": [
                "{{verify_url}}"
              ]
            },
            "description": "Advanced: verifies a launch token's state at the API verify endpoint (`{{verify_url}}`, captured from POST /launch's `signed_url`). Requires the API bearer token and **spends** the single-use token.\n\n**Ability:** `launch`\n\nTo actually launch a course in a browser/iframe, open **`{{launch_url}}`** instead (the public redeem link) — not this endpoint.\n\nExpired / revoked / already-redeemed / bad-HMAC → **410/403**; unknown token → **404**."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        const token = data && data.token;",
                  "        if (token && token.public_id) {",
                  "            pm.expect(token.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        }
      ],
      "description": "Mint and verify signed, single-use SCORM launch URLs. Ability: `launch`."
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "GET /webhook-endpoints",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/webhook-endpoints",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "webhook-endpoints"
              ]
            },
            "description": "Lists webhook endpoints for the tenant.\n\n**Ability:** `read:webhooks`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "            pm.expect(data[0].public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture webhook_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (Array.isArray(data) && data.length > 0 && data[0].public_id) {",
                  "        pm.environment.set(\"webhook_id\", data[0].public_id);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /webhook-endpoints/{id}",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/webhook-endpoints/{{webhook_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "webhook-endpoints",
                "{{webhook_id}}"
              ]
            },
            "description": "A single endpoint (`public_id`, `url`, `is_active`, `last_rotated_at`, timestamps). The secret is never returned here.\n\n**Ability:** `read:webhooks`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "GET /webhook-endpoints/{id}/deliveries",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/webhook-endpoints/{{webhook_id}}/deliveries",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "webhook-endpoints",
                "{{webhook_id}}",
                "deliveries"
              ]
            },
            "description": "Delivery history for the endpoint (newest first). Payload and response body are never exposed.\n\n**Ability:** `read:webhooks`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Cursor pagination meta is present\", function() {",
                  "    const body = pm.response.json();",
                  "    pm.expect(body).to.have.property(\"meta\");",
                  "    pm.expect(body.meta).to.have.property(\"next_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"prev_cursor\");",
                  "    pm.expect(body.meta).to.have.property(\"per_page\");",
                  "    pm.expect(body.meta).to.have.property(\"has_more\");",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /webhook-endpoints",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/webhook-endpoints",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "webhook-endpoints"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"url\": \"https://webhook.site/acorn-demo-endpoint\"}"
            },
            "description": "Creates an endpoint. **The signing secret is returned once** in the response — store it now; it is never retrievable again.\n\n**Ability:** `write:webhooks`\n\n**Body**\n\n| field | type | required | notes |\n|---|---|---|---|\n| url | string | yes | valid URL |\n\n**Returns:** `data: { public_id, url, secret }`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture webhook_id for later use\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (data && data.public_id) {",
                  "        pm.environment.set(\"webhook_id\", data.public_id);",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture hmac secret\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (data && data.secret) {",
                  "        pm.environment.set(\"hmac\", data.secret);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "PATCH /webhook-endpoints/{id}",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/webhook-endpoints/{{webhook_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "webhook-endpoints",
                "{{webhook_id}}"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\"is_active\": false}"
            },
            "description": "Updates an endpoint (both fields optional).\n\n**Ability:** `write:webhooks`\n\n**Body:** `url` (valid URL), `is_active` (bool)."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /webhook-endpoints/{id}/rotate",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/webhook-endpoints/{{webhook_id}}/rotate",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "webhook-endpoints",
                "{{webhook_id}}",
                "rotate"
              ]
            },
            "description": "Rotates the signing secret and returns the **new secret once**; sets `last_rotated_at`.\n\n**Ability:** `write:webhooks`\n\n**Body:** none required — an empty `{}` is sent.\n\n**Returns:** `data: { secret }`",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Capture rotated hmac secret\", function() {",
                  "    const data = pm.response.json().data;",
                  "    if (data && data.secret) {",
                  "        pm.environment.set(\"hmac\", data.secret);",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "POST /webhook-endpoints/{id}/test",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/webhook-endpoints/{{webhook_id}}/test",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "webhook-endpoints",
                "{{webhook_id}}",
                "test"
              ]
            },
            "description": "Sends a real `webhook.test` event to this endpoint only. Creates one `WebhookDelivery` row and queues a signed `DeliverWebhookJob` (payload `{\"event\":\"webhook.test\",\"endpoint\":\"<public_id>\"}`, signed with the endpoint's current secret as `X-Acorn-Signature`), visible in `GET /webhook-endpoints/{id}/deliveries`. **202** returns `data.message` and `data.event_type` (`webhook.test`) — no delivery id, since deliveries have no public id; find the row via the deliveries list. Throttled to 5/min per endpoint (6th → **429** `test_ping_rate_limited`, no delivery). An inactive endpoint → **409** `webhook_endpoint_inactive`; a legacy endpoint with no stored secret → **409** `webhook_secret_missing`; neither creates a delivery. A cross-tenant/unknown endpoint → **404** `webhook_endpoint_not_found`.\n\n**Ability:** `write:webhooks`\n\n**Body:** none required — an empty `{}` is sent.",
            "body": {
              "mode": "raw",
              "raw": "{}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        },
        {
          "name": "DELETE /webhook-endpoints/{id}",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/webhook-endpoints/{{webhook_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "webhook-endpoints",
                "{{webhook_id}}"
              ]
            },
            "description": "Deletes an endpoint (and cascades its deliveries). **204**.\n\n**Ability:** `write:webhooks`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        }
      ],
      "description": "Manage outbound webhook endpoints, rotate secrets, send test pings, and read deliveries. Abilities: `read:webhooks` / `write:webhooks`."
    },
    {
      "name": "Admin",
      "item": [
        {
          "name": "GET /tenant (admin scope)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{base_url}}/api/v1/tenant",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "v1",
                "tenant"
              ]
            },
            "description": "Tenant profile via an admin-scoped token.\n\n**Ability:** `read` + `read:tenant`"
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 2xx\", function() {",
                  "    pm.expect(pm.response.code).to.be.oneOf([200, 201, 202, 204]);",
                  "});",
                  "",
                  "pm.test(\"Content-Type is JSON\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.headers.get(\"content-type\")).to.include(\"application/json\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"Response has data envelope\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        pm.expect(pm.response.json()).to.have.property(\"data\");",
                  "    }",
                  "});",
                  "",
                  "pm.test(\"IDs are valid ULIDs\", function() {",
                  "    if (pm.response.code !== 204) {",
                  "        const data = pm.response.json().data;",
                  "        if (data && data.public_id) {",
                  "            pm.expect(data.public_id).to.match(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/);",
                  "        }",
                  "    }",
                  "});"
                ]
              }
            }
          ]
        }
      ],
      "description": "Admin-scoped tenant reads."
    },
    {
      "name": "API Reference",
      "description": "Machine-readable API contract — fetch the OpenAPI 3.1 spec.",
      "item": [
        {
          "name": "GET OpenAPI spec (v1.json)",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 200\", function() {",
                  "    pm.expect(pm.response.code).to.eql(200);",
                  "});",
                  "pm.test(\"Body is an OpenAPI 3 document\", function() {",
                  "    const spec = pm.response.json();",
                  "    pm.expect(spec).to.have.property(\"openapi\");",
                  "    pm.expect(spec).to.have.property(\"paths\");",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/api/openapi.json",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "openapi.json"
              ]
            },
            "description": "Fetches the machine-readable **OpenAPI 3.1** specification for the API. `{{base_url}}/api/openapi.json` is the public machine-readable contract: its availability is controlled by the `API_DOCS_PUBLIC` flag, so it can be published outside local/testing when a tenant needs it. Import the response into Postman, Swagger UI, Scalar, or any OpenAPI tool to generate clients or an interactive reference.\n\nA rendered version is served at `{{base_url}}/docs`. The older `{{base_url}}/docs/api.json` route remains as the internal local/testing-only variant and returns 403 in production."
          }
        }
      ]
    }
  ]
}
