{
  "info": {
    "name": "Alva Digital Downloads API v1",
    "description": "Collection for the Alva Digital Downloads /api/v1 external REST API. Covers all 37 shipped endpoints. Bearer auth (adk_live_<keyId>_<secret>) is inherited collection-wide; GET /health overrides to noauth. Every non-GET request carries an Idempotency-Key header (idempotency is required on writes via withApiV1Write).",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{api_token}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://app.example.com/api/v1"
    },
    {
      "key": "api_token",
      "value": "adk_live_<keyId>_<secret>"
    },
    {
      "key": "key_id",
      "value": "1"
    },
    {
      "key": "asset_id",
      "value": "123"
    },
    {
      "key": "upload_id",
      "value": ""
    },
    {
      "key": "upload_file_key",
      "value": ""
    },
    {
      "key": "upload_complete_key",
      "value": ""
    },
    {
      "key": "category_id",
      "value": "1"
    },
    {
      "key": "pack_id",
      "value": "1"
    },
    {
      "key": "job_id",
      "value": "ingest_..."
    },
    {
      "key": "mapping_id",
      "value": "1"
    },
    {
      "key": "license_key_tag_id",
      "value": "1"
    },
    {
      "key": "order_id",
      "value": "5501234567890"
    },
    {
      "key": "purchase_id",
      "value": "1"
    },
    {
      "key": "product_id",
      "value": "1234567890"
    },
    {
      "key": "notification_id",
      "value": "cm..."
    },
    {
      "key": "variant_id",
      "value": "gid://shopify/ProductVariant/1234567890"
    }
  ],
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "Health check (public)",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/health",
            "auth": {
              "type": "noauth"
            }
          }
        },
        {
          "name": "Ping (authenticated)",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/ping"
          }
        }
      ]
    },
    {
      "name": "API keys",
      "item": [
        {
          "name": "List keys",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/auth/keys"
          }
        },
        {
          "name": "Create key",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "key-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/auth/keys",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"label\": \"PMT integration\",\n  \"scopes\": []\n}"
            }
          }
        },
        {
          "name": "Revoke key",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "key-revoke-{{$guid}}"
              }
            ],
            "url": "{{base_url}}/auth/keys/{{key_id}}"
          }
        }
      ]
    },
    {
      "name": "Assets",
      "item": [
        {
          "name": "List assets",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/assets?page=1&pageSize=50"
          }
        },
        {
          "name": "Remote URL ingest",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "asset-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/assets",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"source_url\": \"https://dl.dropboxusercontent.com/scl/fi/abc123/video.mp4\",\n  \"filename\": \"video.mp4\",\n  \"content_type\": \"video/mp4\",\n  \"title\": \"Video lesson\"\n}"
            }
          }
        },
        {
          "name": "Get asset",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/assets/{{asset_id}}"
          }
        },
        {
          "name": "Update asset",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "asset-patch-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/assets/{{asset_id}}",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"title\": \"Renamed asset\",\n  \"category_id\": null\n}"
            }
          }
        },
        {
          "name": "Delete asset",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "asset-delete-{{$guid}}"
              }
            ],
            "url": "{{base_url}}/assets/{{asset_id}}"
          }
        },
        {
          "name": "Begin direct upload",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// A successful begin starts a new upload, so clear the complete key:",
                  "// the next \"Complete direct upload\" mints a fresh one for this upload.",
                  "// It also stores the ids \"Complete direct upload\" must send back. For a",
                  "// presigned upload, upload_id equals file_id as a string.",
                  "if (pm.response.code >= 200 && pm.response.code < 300) {",
                  "  pm.collectionVariables.set(\"upload_complete_key\", \"\");",
                  "  const data = pm.response.json().data || {};",
                  "  if (data.upload_id) pm.collectionVariables.set(\"upload_id\", data.upload_id);",
                  "  if (data.file_id) pm.collectionVariables.set(\"asset_id\", String(data.file_id));",
                  "  if (data.file_key) pm.collectionVariables.set(\"upload_file_key\", data.file_key);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "upload-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/assets/uploads",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"filename\": \"manual.pdf\",\n  \"file_size\": 1048576,\n  \"content_type\": \"application/pdf\",\n  \"title\": \"Product manual\"\n}"
            }
          }
        },
        {
          "name": "Complete direct upload",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "// One Idempotency-Key per upload: minted on the first send and reused on",
                  "// every re-send, so a retry repeats the same request with the same key.",
                  "// \"Begin direct upload\" clears it when a new upload starts.",
                  "if (!pm.collectionVariables.get(\"upload_complete_key\")) {",
                  "  pm.collectionVariables.set(\"upload_complete_key\", \"upload-complete-\" + pm.variables.replaceIn(\"{{$guid}}\"));",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{upload_complete_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/assets/uploads/{{upload_id}}/complete",
            "description": "Send \"Begin direct upload\" first: it stores upload_id, asset_id (the file_id) and upload_file_key from its response, and this request sends them back. The path must carry the upload_id the begin returned; for a presigned upload that is its file_id as a string, and a presigned complete under any other id is 400 invalid_request. This body completes a presigned upload (the begin answered \"mode\": \"presigned\"); for a multipart upload send \"mode\": \"multipart\" with its parts. Every failure of this endpoint releases the Idempotency-Key, so the key is kept in {{upload_complete_key}}: minted on the first send, reused on every re-send, and cleared by a successful \"Begin direct upload\" (if you began the upload outside this collection, clear upload_complete_key before its first complete). A 500 with error.details.retryable: true keeps the uploaded bytes: re-send this request unchanged, with backoff and a bounded number of times (for example 5 attempts over about a minute), then begin a new upload. Never retry without a limit: an unexpected server fault is marked retryable too. retryable: false means the upload was discarded; begin a new upload. A retry whose earlier attempt had already finished the upload answers 200 with the asset. A malformed or rejected parts list (400 invalid_request) leaves a multipart upload open: correct it and re-send with the same key. A 404 asset_not_found with error.details.reason (upload_not_found or parts_mismatch): check file_id, filename, upload_id and the parts (a wrong filename lands here while the upload is still open, so a corrected request completes it), or begin a new upload.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"file_id\": {{asset_id}},\n  \"file_key\": \"{{upload_file_key}}\",\n  \"filename\": \"manual.pdf\",\n  \"size\": 1048576,\n  \"content_type\": \"application/pdf\",\n  \"mode\": \"presigned\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Categories",
      "item": [
        {
          "name": "List categories",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/categories"
          }
        },
        {
          "name": "Create category",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "category-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/categories",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Course assets\"\n}"
            }
          }
        },
        {
          "name": "Get category",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/categories/{{category_id}}"
          }
        },
        {
          "name": "Rename category",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "category-patch-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/categories/{{category_id}}",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Renamed category\"\n}"
            }
          }
        },
        {
          "name": "Delete category",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "category-delete-{{$guid}}"
              }
            ],
            "url": "{{base_url}}/categories/{{category_id}}"
          }
        }
      ]
    },
    {
      "name": "Packs",
      "item": [
        {
          "name": "List packs",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/packs?page=1&pageSize=50"
          }
        },
        {
          "name": "Create pack",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "pack-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/packs",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"title\": \"Starter bundle\",\n  \"description\": \"All starter files\",\n  \"file_ids\": [{{asset_id}}]\n}"
            }
          }
        },
        {
          "name": "Get pack",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/packs/{{pack_id}}"
          }
        },
        {
          "name": "Delete pack",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "pack-delete-{{$guid}}"
              }
            ],
            "url": "{{base_url}}/packs/{{pack_id}}"
          }
        }
      ]
    },
    {
      "name": "Links",
      "item": [
        {
          "name": "List links",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/links?page=1&pageSize=50"
          }
        },
        {
          "name": "Create link",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "link-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/links",
            "description": "Paid plan only — a free-plan shop gets 402 plan_required. max_visits and the expiry fields are NOT accepted and are ignored if sent; set them in the admin under Links. The returned data.id is exactly what link_ids on POST/PUT /mappings accepts.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"title\": \"Companion video\",\n  \"url\": \"https://vimeo.com/12345\",\n  \"button_label\": \"Watch now\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "License key tags",
      "item": [
        {
          "name": "List license key tags",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/license-key-tags"
          }
        },
        {
          "name": "Create license key tag",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "tag-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/license-key-tags",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Pro license\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Mappings",
      "item": [
        {
          "name": "List mappings",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/mappings?page=1&pageSize=50"
          }
        },
        {
          "name": "Create mapping",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "mapping-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/mappings",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_product_id\": \"gid://shopify/Product/1234567890\",\n  \"shopify_variant_ids\": [],\n  \"file_ids\": [{{asset_id}}],\n  \"pack_ids\": [],\n  \"link_ids\": [],\n  \"license_key_tag_ids\": [],\n  \"download_type\": \"ZIP\",\n  \"is_active\": true\n}"
            }
          }
        },
        {
          "name": "Create keys-only mapping",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "mapping-keys-only-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/mappings",
            "description": "A body whose only content is license_key_tag_ids (empty file/pack/link ids) creates a first-class KEYS-ONLY mapping — buyers receive a license key and no download files. download-urls for such a purchase returns files: [], has_downloadable_files: false, license_keys populated.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_product_id\": \"gid://shopify/Product/1234567891\",\n  \"shopify_variant_ids\": [],\n  \"file_ids\": [],\n  \"pack_ids\": [],\n  \"link_ids\": [],\n  \"license_key_tag_ids\": [{{license_key_tag_id}}],\n  \"download_type\": \"INDIVIDUAL\",\n  \"is_active\": true\n}"
            }
          }
        },
        {
          "name": "Get mapping",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/mappings/{{mapping_id}}"
          }
        },
        {
          "name": "Replace mapping",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "mapping-put-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/mappings/{{mapping_id}}",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_variant_ids\": [],\n  \"file_ids\": [{{asset_id}}],\n  \"pack_ids\": [],\n  \"link_ids\": [],\n  \"license_key_tag_ids\": [],\n  \"download_type\": \"ZIP\",\n  \"is_active\": true\n}"
            }
          }
        },
        {
          "name": "Replace mapping and notify its buyers",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "mapping-put-notify-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/mappings/{{mapping_id}}",
            "description": "notify_customers (object; {} = no note) queues a product update notification for THIS mapping's buyers after the replace commits. A note that breaks a static rule (blank, too long, bad variable, more than 5 metafields, a link in the text) is 422 invalid_message with nothing written. Everything else — a missing, unsupported or too-long metafield, cooldown, email disabled, nobody to mail — is reported in data.notification as { created: false, error } after the write, which still succeeds. The campaign waits for the archive rebuild this write queued (waiting_for_archive). Same shape on POST /mappings. One campaign per product per 7 days.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_variant_ids\": [],\n  \"file_ids\": [{{asset_id}}],\n  \"pack_ids\": [],\n  \"link_ids\": [],\n  \"license_key_tag_ids\": [],\n  \"download_type\": \"ZIP\",\n  \"is_active\": true,\n  \"notify_customers\": {\n    \"message\": \"We fixed two small errors on page 4, {customer.first_name}. The file is updated.\"\n  }\n}"
            }
          }
        },
        {
          "name": "Create mapping and notify its buyers",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "mapping-notify-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/mappings",
            "description": "The lookup-first upsert with notify_customers. Updating an existing mapping queues a notification for its buyers (data.notification.created: true). A POST that CREATES a brand-new mapping still asks and, if it passes the other checks, reports { created: false, error: \"no_eligible_recipients\" } — nobody has bought it yet. An earlier refusal is reported instead when one applies (forbidden, plan_required, email_disabled, or no_downloadable_content / personalized_product for a keys-only or personalized mapping). When the product has another mapping that could be notified, a no_downloadable_content outcome also carries mapping_ids: the mappings that cannot be announced (the written mapping by default), not a campaign's targets. The flag adds no rate-limit cost: the write costs its usual 2 tokens.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_product_id\": \"{{product_id}}\",\n  \"shopify_variant_ids\": [],\n  \"file_ids\": [{{asset_id}}],\n  \"pack_ids\": [],\n  \"link_ids\": [],\n  \"license_key_tag_ids\": [],\n  \"download_type\": \"ZIP\",\n  \"is_active\": true,\n  \"notify_customers\": {}\n}"
            }
          }
        },
        {
          "name": "Delete mapping",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "mapping-delete-{{$guid}}"
              }
            ],
            "url": "{{base_url}}/mappings/{{mapping_id}}"
          }
        }
      ]
    },
    {
      "name": "Orders",
      "item": [
        {
          "name": "List orders",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/orders?sort=created_at_asc&created_at_min=2026-11-01T00:00:00Z&pageSize=50",
            "description": "The shop's orders, one item per order with every purchase in the GET /orders/{id} shape (pageSize max 50, costs 5 tokens). created_at is the order's earliest purchase; created_at_min is inclusive, created_at_max exclusive, both ISO-8601 with an offset (use Z, or send '+' as %2B). Other filters: shopify_customer_id, shopify_product_id. Metadata only: no download URLs (use Download URLs for assignment) and license_keys[].code is always null (use Get order status). For a sync, start each run a safety margin (10 minutes recommended) before the last created_at you processed, keep created_at_min inclusive and de-duplicate on shopify_order_id: an order is listed only once its write completes, so it can appear after a later-stamped order you already read."
          }
        },
        {
          "name": "Get order status",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/orders/{{order_id}}",
            "description": "Each purchase carries delivery_pending plus release_at (ISO-8601 or null) alongside the fraud/email/stamp state — the per-product download delivery delay, derived from the same predicate the customer-facing surfaces use."
          }
        },
        {
          "name": "List order assignments",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/orders/{{order_id}}/assignments"
          }
        },
        {
          "name": "Create assignment",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "assign-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/{{order_id}}/assignments",
            "description": "Each item may carry an optional quantity (integer 1-1000, default 1) persisted on the created purchase — 0/negative/fractional/non-numeric values are a 400 invalid_request. Duplicate items resolving to the same mapping dedup to ONE purchase (highest explicit quantity wins).",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_customer_id\": \"777888999\",\n  \"items\": [\n    { \"shopify_product_id\": \"gid://shopify/Product/1234567890\", \"quantity\": 1 }\n  ],\n  \"send_email\": false,\n  \"fraud_check\": false,\n  \"assign_license_keys\": false\n}"
            }
          }
        },
        {
          "name": "Create assignment (assign license keys)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "assign-keys-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/{{order_id}}/assignments",
            "description": "assign_license_keys: true (default false) opts in to license-key assignment after the Purchase rows commit, honoring the shop/product license-key delay (immediate at delay 0; scheduled delivery otherwise). items[].quantity (integer 1-1000, default 1) is persisted on the purchase — qty 3 assigns 3 distinct keys per tag; insufficient stock splits into assigned-now + pending-restock. Each purchase in the 201 then carries license_key_assignment: assigned | partial | pending_stock | scheduled | skipped | failed (absent entirely when the flag is off). Same-Idempotency-Key replays re-run nothing; a sequential different-key retry skips purchases that already have key state (outcome: skipped). The EXPLICIT send_email: false here also suppresses the delayed-delivery heads-up email (omitting send_email keeps it). Key codes are never returned by this write — read them via GET /orders/{{order_id}} or the download-urls request.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_customer_id\": \"777888999\",\n  \"items\": [\n    { \"shopify_product_id\": \"gid://shopify/Product/1234567891\", \"quantity\": 3 }\n  ],\n  \"send_email\": false,\n  \"fraud_check\": false,\n  \"assign_license_keys\": true\n}"
            }
          }
        },
        {
          "name": "Download URLs for assignment",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/orders/{{order_id}}/assignments/{{purchase_id}}/download-urls",
            "description": "Response carries has_downloadable_files plus the purchase's assigned license_keys[] ({ code, status, assigned_at }) alongside files[] — a keys-only purchase returns files: [], has_downloadable_files: false with keys populated. A purchase still inside its per-product download delivery delay is fail-closed with 409 delivery_not_yet_released, whose error.details.release_at gives the unlock instant (checked before the consent gate). The EU withdrawal-consent gate (422 withdrawal_consent_required) withholds key codes too."
          }
        },
        {
          "name": "Revoke order access",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "revoke-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/{{order_id}}/revoke",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_product_id\": \"gid://shopify/Product/1234567890\"\n}"
            }
          }
        },
        {
          "name": "Restore order access",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "restore-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/{{order_id}}/restore",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_product_id\": \"gid://shopify/Product/1234567890\"\n}"
            }
          }
        },
        {
          "name": "Grant extra downloads",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "grant-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/{{order_id}}/grant-downloads",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"extra_downloads\": 5,\n  \"shopify_product_id\": \"gid://shopify/Product/1234567890\"\n}"
            }
          }
        },
        {
          "name": "Resend order email",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "resend-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/orders/{{order_id}}/resend",
            "description": "An order still inside its per-product download delivery delay is fail-closed with 409 delivery_not_yet_released (error.details.release_at carries the instant the resend becomes possible) rather than a misleading 404 — the release-time email is already scheduled. The other gates are unchanged: 409 stamping_in_progress, 422 email_disabled, 429 on the per-order 3/hour budget.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"shopify_product_id\": \"gid://shopify/Product/1234567890\"\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Status",
      "item": [
        {
          "name": "Get ingest job",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/jobs/{{job_id}}"
          }
        }
      ]
    },
    {
      "name": "Notifications",
      "item": [
        {
          "name": "Dry-run a product update notification",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "notify-dry-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/products/{{product_id}}/notifications",
            "description": "Runs every gate and returns recipient_count, opted_out_count, the locked subject, the resolved message_preview and every metafield value — queues nothing (200). Costs 10 tokens like a real create. Use a FRESH Idempotency-Key per dry run: the same key with and without dry_run is 409 idempotency_conflict.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"dry_run\": true,\n  \"message\": \"We fixed two small errors on page 4, {customer.first_name}. The file is updated.\"\n}"
            }
          }
        },
        {
          "name": "Create a product update notification",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "notify-{{$guid}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": "{{base_url}}/products/{{product_id}}/notifications",
            "description": "202: one email per eligible buyer of the product's downloadable mappings (or, with variant_ids, of the mappings serving those variants). Every variant_ids id must be a variant of {{product_id}} in Shopify: one that is not, or that no mapping serves, is 404 mapping_not_found with error.details.unresolved_variant_ids; if Shopify does not answer, 500 internal_error (nothing created, retry with the same key). Optional plain-text message up to 2000 characters with {customer.first_name}, {shop.name}, {product.title}, {product.metafields.<ns>.<key>}; NO links. One campaign per product per 7 days: 429 notification_cooldown with Retry-After and error.details.next_available_at — do NOT auto-retry it, schedule at next_available_at. Costs 10 tokens. Poll GET /notifications/{{notification_id}}.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"message\": \"We fixed two small errors on page 4, {customer.first_name}. The file is updated.\",\n  \"variant_ids\": [\"{{variant_id}}\"]\n}"
            }
          }
        },
        {
          "name": "Get a product update notification",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/notifications/{{notification_id}}",
            "description": "Bare resource: status (queued | processing | completed | failed | cancelled), partial, waiting_for_archive (a queued campaign held for a ZIP rebuild), the counts, the note, and a closed error vocabulary on failed. Admin-started campaigns appear too (source: admin). Keeps answering while Alva has switched product update notifications off (create and cancel are 403 forbidden then), so a campaign the switch stopped reads failed with error notifications_switched_off."
          }
        },
        {
          "name": "Cancel a product update notification",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "notify-cancel-{{$guid}}"
              }
            ],
            "url": "{{base_url}}/notifications/{{notification_id}}/cancel",
            "description": "Only a QUEUED campaign can be cancelled (200, status cancelled); anything else is 409 notification_not_cancellable with details.status. KEEPS THE COOLDOWN: a cancelled campaign still counts as the product's one campaign for 7 days, exactly like the admin cancel. Use the dry run to check a note before sending."
          }
        }
      ]
    }
  ]
}
