{"info":{"_postman_id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","name":"LeadDesk Mini API","description":"<html><head></head><body><p>LeadDesk Mini — Full REST API for lead intake and admin status management.</p>\n<p>Base endpoints:</p>\n<ul>\n<li><code>http://localhost:5000/api/health</code> — service health (public)</li>\n<li><code>http://localhost:5000/api/auth/login</code> — admin login, returns 24h JWT (public)</li>\n<li><code>http://localhost:5000/api/leads</code> — create lead (public) + list leads (auth)</li>\n<li><code>http://localhost:5000/api/leads/:id/status</code> — update lead status (auth)</li>\n</ul>\n<p>Authorization:</p>\n<ol>\n<li>Run <strong>Auth → Login</strong> first (seed default: <code>admin@leaddesk.com</code> / <code>AdminPassword123!</code>)</li>\n<li>The test script auto-saves the returned token into the <code>token</code> environment variable.</li>\n<li>All protected requests use <code>Bearer </code> inherited from the collection.</li>\n</ol>\n<p>Seed admin (backend folder): <code>npm run seed</code></p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"39216526","collectionId":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","publishedId":"2sBY4QtfSh","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF6C37"},"publishDate":"2026-07-25T17:37:41.000Z"},"item":[{"name":"Health","item":[{"name":"GET Health check","event":[{"listen":"test","script":{"type":"text/javascript","exec":["pm.test('Status is 200', () => pm.response.to.have.status(200));","pm.test('success === true', () => pm.response.json().success === true);"],"id":"20f0f09d-3826-4fa1-ae87-5c7e5df73159"}}],"id":"79a5b577-d2bb-4ee8-8b8e-a0932df6131e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"GET","header":[],"url":"http://localhost:5000/api/health","description":"<p>Returns a simple success object. No auth required. Useful to confirm server + MongoDB are up (server will fail to start without DB, so a 200 here means DB is connected too).</p>\n","urlObject":{"path":["api","health"],"host":["http://localhost:5000"],"query":[],"variable":[]}},"response":[{"id":"4ad66733-e118-460e-8a3b-189fb1447a2b","name":"200 OK — Service running","originalRequest":{"method":"GET","header":[],"url":"http://localhost:5000/api/health"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": true,\n  \"message\": \"LeadDesk API is running\"\n}"}],"_postman_id":"79a5b577-d2bb-4ee8-8b8e-a0932df6131e"}],"id":"0bdf004d-9c69-4573-b382-4a23c06760a3","description":"<p>Public endpoints for verifying the service is reachable.</p>\n","_postman_id":"0bdf004d-9c69-4573-b382-4a23c06760a3","auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":""}]},"isInherited":true,"source":{"_postman_id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","name":"LeadDesk Mini API","type":"collection"}}},{"name":"Auth","item":[{"name":"POST Login admin","event":[{"listen":"test","script":{"type":"text/javascript","exec":["pm.test('Status is 200 on success', () => pm.response.to.have.status(200));","const json = pm.response.json();","if (json.success && json.token) {","  pm.environment.set('token', json.token);","  pm.collectionVariables.set('token', json.token);","  pm.test('Token saved to token variable', () => true);","  console.log('Saved JWT token (expires ~24h):', json.token.slice(0, 24) + '…');","}","pm.test('Returns user.email', () => json && typeof json.user?.email === 'string');"],"id":"e87a8313-fbbd-4e65-9d05-bd04941de920"}}],"id":"376ec562-6b8f-4077-b291-9a24cbc52b88","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n  \"email\": \"admin@leaddesk.com\",\n  \"password\": \"AdminPassword123!\"\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/api/auth/login","description":"<p>Authenticate an admin user and receive a JWT valid for 24 hours. Seed default credentials (run <code>npm run seed</code> in <code>/backend</code>):</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Default value</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>email</td>\n<td><code>admin@leaddesk.com</code></td>\n</tr>\n<tr>\n<td>password</td>\n<td><code>AdminPassword123!</code></td>\n</tr>\n</tbody>\n</table>\n</div><p>Both fields are validated: email must be valid email format, password must be non-empty.</p>\n","urlObject":{"path":["api","auth","login"],"host":["http://localhost:5000"],"query":[],"variable":[]}},"response":[{"id":"d097cccf-8a54-495f-81bd-ff937152a59b","name":"200 OK — Login successful","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\"email\":\"admin@leaddesk.com\",\"password\":\"AdminPassword123!\"}"},"url":"http://localhost:5000/api/auth/login"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": true,\n  \"token\": \"{{supabase_service_role_api_key_1byv}}\",\n  \"user\": {\n    \"email\": \"admin@leaddesk.com\"\n  }\n}"},{"id":"948f7fd0-7727-44cc-9460-5c09cdf04cb4","name":"401 Unauthorized — Invalid credentials","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\"email\":\"admin@leaddesk.com\",\"password\":\"wrongpass\"}"},"url":"http://localhost:5000/api/auth/login"},"status":"Unauthorized","code":401,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": false,\n  \"message\": \"Invalid email or password\"\n}"},{"id":"32ce72e8-d43d-4a17-98e1-7f6f6ee83326","name":"400 Bad Request — Validation errors","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\"email\":\"not-an-email\",\"password\":\"\"}"},"url":"http://localhost:5000/api/auth/login"},"status":"Bad Request","code":400,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": false,\n  \"errors\": [\n    { \"field\": \"email\", \"message\": \"Please provide a valid email address\" },\n    { \"field\": \"password\", \"message\": \"Password is required\" }\n  ]\n}"}],"_postman_id":"376ec562-6b8f-4077-b291-9a24cbc52b88"}],"id":"39ecb578-1fc6-4a0b-9c06-9ab6ec912ee7","description":"<p>Admin authentication. Use Login first to get a JWT — the test script will save it to the <code>token</code> variable automatically.</p>\n","_postman_id":"39ecb578-1fc6-4a0b-9c06-9ab6ec912ee7","auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":""}]},"isInherited":true,"source":{"_postman_id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","name":"LeadDesk Mini API","type":"collection"}}},{"name":"Leads","item":[{"name":"POST Create lead (public)","event":[{"listen":"test","script":{"type":"text/javascript","exec":["pm.test('Status is 201 Created', () => pm.response.to.have.status(201));","const json = pm.response.json();","pm.test('success === true', () => json.success === true);","pm.test('Returns created lead with _id', () => json.data && json.data._id);","if (json?.data?._id) {","  pm.environment.set('leadId', json.data._id);","  pm.collectionVariables.set('leadId', json.data._id);","}"],"id":"eb2d197e-c2bc-467e-a5f7-b25068be95b6"}}],"id":"ec6f8813-8d7d-4500-853f-efe918ecf2ac","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"Alex Rivera\",\n  \"email\": \"alex@studio.co\",\n  \"budgetRange\": \"$5,000 - $10,000\",\n  \"message\": \"Hi! We are launching a new SaaS product and need a landing page, admin dashboard, and onboarding flow. Timeline: ~6 weeks.\"\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/api/leads","description":"<p>Submit a new lead from the public landing page form. <strong>No auth required.</strong></p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Field</th>\n<th>Required</th>\n<th>Rules</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>name</code></td>\n<td>✅</td>\n<td>2 – 100 chars</td>\n</tr>\n<tr>\n<td><code>email</code></td>\n<td>✅</td>\n<td>valid email (lowercased + normalized)</td>\n</tr>\n<tr>\n<td><code>budgetRange</code></td>\n<td>✅</td>\n<td>one of: <code>Under $1,000</code> · <code>$1,000 - $5,000</code> · <code>$5,000 - $10,000</code> · <code>$10,000 - $25,000</code> · <code>$25,000+</code></td>\n</tr>\n<tr>\n<td><code>message</code></td>\n<td>✅</td>\n<td>10 – 2000 chars</td>\n</tr>\n</tbody>\n</table>\n</div><p>Server auto-sets <code>status: \"New\"</code> and <code>createdAt: Date.now</code>.</p>\n","urlObject":{"path":["api","leads"],"host":["http://localhost:5000"],"query":[],"variable":[]}},"response":[{"id":"e38cfdac-1e76-41cc-b61e-07e0adec8ce8","name":"201 Created — Lead submitted","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\"name\":\"Alex Rivera\",\"email\":\"alex@studio.co\",\"budgetRange\":\"$5,000 - $10,000\",\"message\":\"Hi! We need a landing page + dashboard.\"}"},"url":"http://localhost:5000/api/leads"},"status":"Created","code":201,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": true,\n  \"data\": {\n    \"_id\": \"678401111111111111111111\",\n    \"name\": \"Alex Rivera\",\n    \"email\": \"alex@studio.co\",\n    \"budgetRange\": \"$5,000 - $10,000\",\n    \"message\": \"Hi! We need a landing page + dashboard.\",\n    \"status\": \"New\",\n    \"createdAt\": \"2026-07-25T17:00:00.000Z\",\n    \"__v\": 0\n  },\n  \"message\": \"Lead submitted successfully\"\n}"},{"id":"01c7834c-3a2d-40f1-adcb-9cb06207d6d5","name":"400 Bad Request — Validation errors","originalRequest":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\"name\":\"A\",\"email\":\"bad\",\"budgetRange\":\"Free\",\"message\":\"short\"}"},"url":"http://localhost:5000/api/leads"},"status":"Bad Request","code":400,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": false,\n  \"errors\": [\n    { \"field\": \"name\", \"message\": \"Name must be between 2 and 100 characters\" },\n    { \"field\": \"email\", \"message\": \"Please provide a valid email address\" },\n    { \"field\": \"budgetRange\", \"message\": \"Budget range must be one of: Under $1,000, $1,000 - $5,000, $5,000 - $10,000, $10,000 - $25,000, $25,000+\" },\n    { \"field\": \"message\", \"message\": \"Message must be between 10 and 2000 characters\" }\n  ]\n}"}],"_postman_id":"ec6f8813-8d7d-4500-853f-efe918ecf2ac"},{"name":"GET List leads (with optional search)","event":[{"listen":"test","script":{"type":"text/javascript","exec":["pm.test('Status is 200 OK', () => pm.response.to.have.status(200));","const json = pm.response.json();","pm.test('success === true', () => json.success === true);","pm.test('count matches data.length', () => json.count === json.data.length);","pm.test('data is an array', () => Array.isArray(json.data));"],"id":"94dc007d-a80f-4d48-9019-719484a4ebea"}}],"id":"8a5b24b6-ba37-466a-b351-e835db96285e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:5000/api/leads?search=","description":"<p>List all leads, newest first. <strong>Requires Bearer token.</strong></p>\n<p>Response shape:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{ success: true, count: number, data: Lead[] }\n</code></pre>\n<p>When <code>?search=</code> is provided, the server filters <code>{name: regex} OR {email: regex}</code> (case-insensitive).</p>\n","auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":""}]},"isInherited":true,"source":{"_postman_id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","name":"LeadDesk Mini API","type":"collection"}},"urlObject":{"path":["api","leads"],"host":["http://localhost:5000"],"query":[{"description":{"content":"<p>Optional. Case-insensitive match on lead <code>name</code> OR <code>email</code> (MongoDB regex). Leave empty to return all.</p>\n","type":"text/plain"},"key":"search","value":""}],"variable":[]}},"response":[{"id":"3965c3f6-9193-437e-a069-95c8b83e2b31","name":"200 OK — Leads array","originalRequest":{"method":"GET","header":[],"url":"http://localhost:5000/api/leads"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": true,\n  \"count\": 2,\n  \"data\": [\n    {\n      \"_id\": \"678401111111111111111111\",\n      \"name\": \"Alex Rivera\",\n      \"email\": \"alex@studio.co\",\n      \"budgetRange\": \"$5,000 - $10,000\",\n      \"message\": \"We need a landing page + dashboard.\",\n      \"status\": \"Contacted\",\n      \"createdAt\": \"2026-07-25T17:00:00.000Z\",\n      \"__v\": 0\n    },\n    {\n      \"_id\": \"678402222222222222222222\",\n      \"name\": \"Jordan Chen\",\n      \"email\": \"jordan@agency.io\",\n      \"budgetRange\": \"$25,000+\",\n      \"message\": \"Full e-commerce rebuild with CMS.\",\n      \"status\": \"New\",\n      \"createdAt\": \"2026-07-24T09:12:00.000Z\",\n      \"__v\": 0\n    }\n  ]\n}"},{"id":"8379378e-fc3e-4147-9290-758090feaca8","name":"401 Unauthorized — Missing / invalid token","originalRequest":{"method":"GET","header":[],"url":"http://localhost:5000/api/leads"},"status":"Unauthorized","code":401,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": false,\n  \"message\": \"Authentication required\"\n}"}],"_postman_id":"8a5b24b6-ba37-466a-b351-e835db96285e"},{"name":"PATCH Update lead status by ID","event":[{"listen":"test","script":{"type":"text/javascript","exec":["pm.test('Status 200 / valid response', () => {","  pm.expect([200, 400, 401, 404]).to.include(pm.response.code);","});","if (pm.response.code === 200) {","  const json = pm.response.json();","  pm.test('success + returns updated lead with enum status', () => {","    pm.expect(json.success).to.eql(true);","    pm.expect(['New','Contacted','Closed']).to.include(json.data.status);","  });","}"],"id":"f33df9dc-1fd7-409a-a1a9-31e0308642e0"}}],"id":"36af85c3-82aa-4d98-9bb6-a4ad1c2925e2","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n  \"status\": \"Contacted\"\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/api/leads//status","description":"<p>Update a lead's status workflow value. <strong>Requires Bearer token.</strong></p>\n<p>Allowed <code>status</code> values (enum in Mongo + express-validator):</p>\n<ul>\n<li><code>\"New\"</code> (default on create)</li>\n<li><code>\"Contacted\"</code></li>\n<li><code>\"Closed\"</code></li>\n</ul>\n<p>Route param <code>:id</code> must be a valid MongoDB ObjectId or you'll get a 400 validation error. Unknown IDs return 404.</p>\n","auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":""}]},"isInherited":true,"source":{"_postman_id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","name":"LeadDesk Mini API","type":"collection"}},"urlObject":{"path":["api","leads","","status"],"host":["http://localhost:5000"],"query":[],"variable":[{"id":"54e20dc8-7ffc-421e-ada0-4e9707007dda","description":{"content":"<p>MongoDB _id of the lead. The Create Lead test auto-saves this, or paste one from GET /api/leads.</p>\n","type":"text/plain"},"type":"any","value":"","key":"leadId"}]}},"response":[{"id":"f1a96d91-230d-408b-84f4-c970f21c6b9d","name":"200 OK — Status updated","originalRequest":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\"status\":\"Closed\"}"},"url":"http://localhost:5000/api/leads/678401111111111111111111/status"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": true,\n  \"data\": {\n    \"_id\": \"678401111111111111111111\",\n    \"name\": \"Alex Rivera\",\n    \"email\": \"alex@studio.co\",\n    \"budgetRange\": \"$5,000 - $10,000\",\n    \"message\": \"We need a landing page + dashboard.\",\n    \"status\": \"Closed\",\n    \"createdAt\": \"2026-07-25T17:00:00.000Z\",\n    \"__v\": 0\n  },\n  \"message\": \"Status updated successfully\"\n}"},{"id":"e8049877-c925-4627-9263-a7817d383071","name":"400 Bad Request — Invalid status or id","originalRequest":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\"status\":\"Won\"}"},"url":"http://localhost:5000/api/leads/678401111111111111111111/status"},"status":"Bad Request","code":400,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": false,\n  \"errors\": [\n    { \"field\": \"status\", \"message\": \"Status must be one of: New, Contacted, Closed\" }\n  ]\n}"},{"id":"db23f82d-28a6-4810-8574-b59137452b98","name":"404 Not Found — Lead does not exist","originalRequest":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\"status\":\"Closed\"}"},"url":"http://localhost:5000/api/leads/ffffffffffffffffffffffff/status"},"status":"Not Found","code":404,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json; charset=utf-8"}],"cookie":[],"responseTime":null,"body":"{\n  \"success\": false,\n  \"message\": \"Lead not found\"\n}"}],"_postman_id":"36af85c3-82aa-4d98-9bb6-a4ad1c2925e2"}],"id":"86bd9baf-ceec-4f0d-ad53-ba44626f7ad8","description":"<p>Lead resource endpoints. Creating a lead is <strong>public</strong> (landing page). Listing and updating status requires <code>Authorization: Bearer &lt;token&gt;</code> (inherited from collection).</p>\n","_postman_id":"86bd9baf-ceec-4f0d-ad53-ba44626f7ad8","auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":""}]},"isInherited":true,"source":{"_postman_id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","id":"7abd3c4c-af90-43fe-a62d-31a1cfef282d","name":"LeadDesk Mini API","type":"collection"}}}],"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":""}]}},"event":[{"listen":"prerequest","script":{"type":"text/javascript","exec":["// Ensure baseUrl variable falls back if env var is not set","if (!pm.variables.get('baseUrl') && pm.environment.get('baseUrl')) {","  pm.variables.set('baseUrl', pm.environment.get('baseUrl'));","}","pm.variables.set('baseUrl', pm.environment.get('baseUrl') || 'http://localhost:5000');"],"id":"e463d715-c217-48ab-9a43-b8f33f79c6d3"}}],"variable":[{"key":"baseUrl","value":"http://localhost:5000"},{"key":"token","value":""},{"key":"leadId","value":""},{"key":"supabase_service_role_api_key_1byv","secret":true}]}