{
  "info": {
    "_postman_id": "58955a92-c200-464a-90d0-fcb101b84cc9",
    "name": "Coconut Trade Fair API",
    "description": "Register -> email QR -> scan at counter to print badge (name/company/contact + new link QR) and record first attendance -> scan badge QR at entrance to reuse or record attendance.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "56775696",
    "_collection_link": "https://go.postman.co/collection/56775696-58955a92-c200-464a-90d0-fcb101b84cc9?source=collection_link"
  },
  "item": [
    {
      "name": "Staff Auth",
      "item": [
        {
          "name": "Login",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const data = pm.response.json();",
                  "if (data && data.data && data.data.token) {",
                  "  pm.collectionVariables.set('staffToken', data.data.token);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"username\": \"admin\",\n  \"password\": \"changeme\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/v1/staff-auth/login",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "staff-auth",
                "login"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Me",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/staff-auth/me",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "staff-auth",
                "me"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Logout",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/staff-auth/logout",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "staff-auth",
                "logout"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Bulk Pre-Registration Import",
      "description": "Admin-only Microsoft Forms Excel import. HOW TO USE\n\n1. Login as admin using Staff Auth > Login.\n2. Select the supplied Excel file in the `file` field.\n3. Send Preview Excel Import first.\n4. Review `mapping`, `unmatchedColumns`, `missingRequiredFields`, duplicate rows, and invalid rows.\n5. If a column is unmatched, add it to `columnMappings` (or explicitly list it in `ignoredColumns`) and run Preview again.\n6. Do not continue until the preview is acceptable and `readyForExecution` is true.\n7. Run Execute Excel Import with the same file and mapping values.\n8. Review registered / duplicate / invalid / failed / emailsSent results.\n\nExample `columnMappings` value:\n{\n  \"FIRSTNAME\": \"first_name\",\n  \"SURNAME\": \"last_name\",\n  \"ORGANIZATION NAME\": \"company\"\n}\n\nOnly active registration_fields.fieldKey values are accepted as targets. Unknown columns are never silently discarded. The endpoint is admin-only; scanner and badge_printer tokens receive 403.",
      "item": [
        {
          "name": "Admin Login",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"username\": \"{{adminUsername}}\",\n  \"password\": \"{{adminPassword}}\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/v1/staff-auth/login",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "staff-auth",
                "login"
              ]
            },
            "description": "Login with an admin account. Copy `data.token` into the collection variable `adminToken` (or use the Staff Auth login request's test script if available). Never commit credentials."
          },
          "response": []
        },
        {
          "name": "Preview Excel Import",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{adminToken}}"
              }
            ],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "file",
                  "type": "file",
                  "src": []
                },
                {
                  "key": "dryRun",
                  "value": "true",
                  "type": "text"
                },
                {
                  "key": "sendEmail",
                  "value": "true",
                  "type": "text"
                },
                {
                  "key": "source",
                  "value": "online",
                  "type": "text"
                },
                {
                  "key": "columnMappings",
                  "value": "{}",
                  "type": "text"
                },
                {
                  "key": "ignoredColumns",
                  "value": "[]",
                  "type": "text"
                },
                {
                  "key": "defaults",
                  "value": "{}",
                  "type": "text"
                }
              ]
            },
            "url": {
              "raw": "{{baseUrl}}/v1/registrations/import-excel",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations",
                "import-excel"
              ]
            },
            "description": "Select the supplied .xlsx file in the file part. This safe preview parses the workbook, derives deterministic mappings from the CURRENT active registration_fields, validates current options/required fields, normalizes emails, and checks duplicates. It does not create registrations, answers, QR rows, email logs, or send email. Resolve every unmatched column before executing."
          },
          "response": []
        },
        {
          "name": "Execute Excel Import",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{adminToken}}"
              }
            ],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "file",
                  "type": "file",
                  "src": []
                },
                {
                  "key": "dryRun",
                  "value": "false",
                  "type": "text"
                },
                {
                  "key": "sendEmail",
                  "value": "true",
                  "type": "text"
                },
                {
                  "key": "source",
                  "value": "online",
                  "type": "text"
                },
                {
                  "key": "columnMappings",
                  "value": "{}",
                  "type": "text"
                },
                {
                  "key": "ignoredColumns",
                  "value": "[]",
                  "type": "text"
                },
                {
                  "key": "defaults",
                  "value": "{}",
                  "type": "text"
                }
              ]
            },
            "url": {
              "raw": "{{baseUrl}}/v1/registrations/import-excel",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations",
                "import-excel"
              ]
            },
            "description": "Run only after Preview Excel Import is acceptable. Re-select the same Excel file and use the same columnMappings/ignoredColumns/defaults. Each valid row calls the existing registration flow independently, creating the normal registrant, dynamic answers, one RegistrationQR, ticketId, and QR email/email_log when enabled. Duplicate, invalid, and unexpected failures are reported per row and do not abort other rows."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Registration Fields (dynamic form)",
      "item": [
        {
          "name": "Get All Fields (public - for register page)",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/v1/registration-fields",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registration-fields"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Create Field",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const data = pm.response.json();",
                  "if (data && data.data && data.data.id) {",
                  "  pm.collectionVariables.set('fieldId', data.data.id);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"fieldKey\": \"t_shirt_size\",\n  \"label\": \"T-Shirt Size\",\n  \"fieldType\": \"radio\",\n  \"fieldRole\": \"none\",\n  \"options\": [\n    { \"label\": \"Small\", \"value\": \"S\" },\n    { \"label\": \"Medium\", \"value\": \"M\" },\n    { \"label\": \"Large\", \"value\": \"L\" }\n  ],\n  \"validation\": { \"required\": true },\n  \"displayOrder\": 6,\n  \"active\": true\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/v1/registration-fields",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registration-fields"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Update Field",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"label\": \"Preferred T-Shirt Size\"\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/v1/registration-fields/{{fieldId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registration-fields",
                "{{fieldId}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Reorder Fields",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"order\": [1, 2, 3, 4, 5]\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/v1/registration-fields/reorder",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registration-fields",
                "reorder"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Deactivate (Delete) Field",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/registration-fields/{{fieldId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registration-fields",
                "{{fieldId}}"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Registration & Scanning",
      "item": [
        {
          "name": "1. Register (public) - sends QR email",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const data = pm.response.json();",
                  "if (data && data.data && data.data.guid) {",
                  "  pm.collectionVariables.set('registrantGuid', data.data.guid);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"source\": \"online\",\n  \"responses\": {\n    \"full_name\": \"Juan Dela Cruz\",\n    \"email\": \"juan.delacruz@example.com\",\n    \"mobile_number\": \"09171234567\",\n    \"company\": \"Coco Farms PH\",\n    \"industry\": \"food_beverage\"\n  }\n}"
            },
            "url": {
              "raw": "{{baseUrl}}/v1/registrations/register",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations",
                "register"
              ]
            }
          },
          "response": []
        },
        {
          "name": "List Registrants",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/registrations?page=1&limit=10",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "1"
                },
                {
                  "key": "limit",
                  "value": "10"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "Get One Registrant",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/registrations/{{registrantGuid}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations",
                "{{registrantGuid}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "2. Scan Registration QR (badge-printing counter)",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/registrations/scan/registration/{{registrationHashedId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations",
                "scan",
                "registration",
                "{{registrationHashedId}}"
              ]
            },
            "description": "hashedId = sha256 of the registrant's guid, this is exactly what's encoded in the emailed QR image. Copy it from the email_logs/registration_qr row, or scan the actual QR image, to test this."
          },
          "response": []
        },
        {
          "name": "3. Scan Badge QR (entrance) - reuses or records time attended",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/registrations/scan/entrance/{{badgeReferenceNumber}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations",
                "scan",
                "entrance",
                "{{badgeReferenceNumber}}"
              ]
            },
            "description": "referenceNumber is the `p=` query param parsed out of the badge QR's URL (e.g. .../profile?p=CTF-7F3K9Q -> CTF-7F3K9Q). Get this from step 2's response (badge.referenceNumber)."
          },
          "response": []
        },
        {
          "name": "Recent Entrance Scans",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/registrations/recent-scans?limit=20",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations",
                "recent-scans"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "20"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "Event Stats",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/registrations/stats",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations",
                "stats"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Delete (Deactivate) Registrant",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{staffToken}}"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/registrations/{{registrantGuid}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "registrations",
                "{{registrantGuid}}"
              ]
            }
          },
          "response": []
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "http://localhost:4000"
    },
              {
                "key": "staffToken",
                "value": ""
              },
              {
                "key": "adminToken",
                "value": "",
                "description": "Runtime JWT returned by Admin Login. Keep blank in the committed collection."
              },
              {
                "key": "adminUsername",
                "value": "",
                "description": "Supply through a Postman environment; do not commit production credentials."
              },
              {
                "key": "adminPassword",
                "value": "",
                "description": "Supply through a Postman environment; do not commit production credentials."
              },
    {
      "key": "registrantGuid",
      "value": ""
    },
    {
      "key": "registrationHashedId",
      "value": ""
    },
    {
      "key": "badgeReferenceNumber",
      "value": ""
    },
    {
      "key": "fieldId",
      "value": ""
    }
  ]
}
