{
  "info": {
    "name": "RubyOrbit API",
    "_postman_id": "rubyorbit-api-collection",
    "description": "RubyOrbit API endpoints for lead management and timeline events.\n\nSet the `api_key` variable in your Postman environment.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "api_key",
      "value": "YOUR_API_KEY_HERE",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Connection",
      "item": [
        {
          "name": "Test API Key",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-test",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-test"
              ]
            },
            "description": "Verify your API key is valid."
          },
          "response": []
        }
      ]
    },
    {
      "name": "Leads: Upsert",
      "item": [
        {
          "name": "Create New Lead (minimal)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-leads-upsert",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-leads-upsert"
              ]
            },
            "description": "Create a lead with a few fields. Only email is required.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"Sarah\",\n  \"last_name\": \"Chen\",\n  \"email\": \"sarah@example.com\",\n  \"phone\": \"+1-555-0101\",\n  \"source\": \"website\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Create Lead: Real Estate Buyer",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-leads-upsert",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-leads-upsert"
              ]
            },
            "description": "Create a Real Estate buyer lead with full context fields.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"James\",\n  \"last_name\": \"Wilson\",\n  \"email\": \"james.wilson@example.com\",\n  \"phone\": \"+1-555-0202\",\n  \"source\": \"zillow\",\n  \"category\": \"real_estate\",\n  \"lead_type\": \"buyer\",\n  \"property_type\": \"single_family\",\n  \"bedrooms\": 4,\n  \"bathrooms\": 3,\n  \"preferred_city\": \"Austin\",\n  \"preferred_area\": \"South Congress\",\n  \"deal_value_min\": 400000,\n  \"deal_value_max\": 650000,\n  \"timeline\": \"1-3 months\",\n  \"pre_approved\": true,\n  \"first_time_buyer\": false,\n  \"cash_buyer\": false,\n  \"tags\": [\n    \"zillow\",\n    \"hot-lead\"\n  ]\n}"
            }
          },
          "response": []
        },
        {
          "name": "Create Lead: Real Estate Seller",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-leads-upsert",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-leads-upsert"
              ]
            },
            "description": "Create a Real Estate seller lead.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"Maria\",\n  \"last_name\": \"Garcia\",\n  \"email\": \"maria.garcia@example.com\",\n  \"phone\": \"+1-555-0303\",\n  \"source\": \"referral\",\n  \"category\": \"real_estate\",\n  \"lead_type\": \"seller\",\n  \"property_type\": \"condo\",\n  \"address\": \"456 Oak Ave, Austin TX 78704\",\n  \"bedrooms\": 2,\n  \"bathrooms\": 2,\n  \"timeline\": \"immediate\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Create Lead: Marketing Agency",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-leads-upsert",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-leads-upsert"
              ]
            },
            "description": "Create a Marketing lead with service and budget context.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"David\",\n  \"last_name\": \"Park\",\n  \"email\": \"david@acmecorp.com\",\n  \"phone\": \"+1-555-0404\",\n  \"source\": \"linkedin\",\n  \"category\": \"marketing\",\n  \"lead_type\": \"new_client\",\n  \"service_needed\": \"SEO + Content Marketing\",\n  \"monthly_budget\": \"$5,000-$10,000\",\n  \"business_type\": \"e-commerce\",\n  \"company_name\": \"Acme Corp\",\n  \"website\": \"https://acmecorp.com\",\n  \"timeline\": \"next quarter\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Create Lead: Software / SaaS",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-leads-upsert",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-leads-upsert"
              ]
            },
            "description": "Create a Software/SaaS trial lead.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"Emily\",\n  \"last_name\": \"Zhang\",\n  \"email\": \"emily@techstartup.io\",\n  \"source\": \"demo_request\",\n  \"category\": \"software\",\n  \"lead_type\": \"trial\",\n  \"use_case\": \"Team project management\",\n  \"team_size\": \"50-100\",\n  \"current_tools\": \"Asana, Slack\",\n  \"company_name\": \"TechStartup\",\n  \"timeline\": \"evaluating\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Update Existing Lead (by email)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-leads-upsert",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-leads-upsert"
              ]
            },
            "description": "Update an existing lead by matching on email. Fields are merged.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"sarah@example.com\",\n  \"first_name\": \"Sarah\",\n  \"tags\": [\n    \"qualified\",\n    \"high-value\"\n  ],\n  \"notes\": \"Followed up after demo, very interested.\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Update Lead: Assign Agent",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-leads-upsert",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-leads-upsert"
              ]
            },
            "description": "Assign an agent by name (auto-resolves or creates agent record).",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"james.wilson@example.com\",\n  \"first_name\": \"James\",\n  \"assigned_agent\": \"Alex Thompson\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Create Lead: All Contact Fields",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-leads-upsert",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-leads-upsert"
              ]
            },
            "description": "Create a lead with all contact fields including alternates.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"Robert\",\n  \"last_name\": \"Kim\",\n  \"email\": \"robert@example.com\",\n  \"phone\": \"+1-555-0505\",\n  \"alt_email\": \"rob.personal@gmail.com\",\n  \"alt_phone\": \"+1-555-0506\",\n  \"source\": \"trade_show\",\n  \"notes\": \"Met at CES 2025, interested in enterprise plan.\"\n}"
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Timeline: Add Events",
      "item": [
        {
          "name": "Log a Phone Call",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-timeline-add",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-timeline-add"
              ]
            },
            "description": "Log a phone call event on a lead's timeline.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"sarah@example.com\",\n  \"event_type\": \"call\",\n  \"event_title\": \"Discovery call\",\n  \"event_body\": \"Discussed requirements and budget. Client prefers 4-bed homes in South Austin.\",\n  \"source\": \"phone\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Log an SMS",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-timeline-add",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-timeline-add"
              ]
            },
            "description": "Log an SMS/text message event.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"james.wilson@example.com\",\n  \"event_type\": \"sms\",\n  \"event_title\": \"Follow-up text\",\n  \"event_body\": \"Sent listing link for 123 Main St. Client replied 'looks great'.\",\n  \"source\": \"twilio\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Log a Meeting",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-timeline-add",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-timeline-add"
              ]
            },
            "description": "Log a meeting or appointment event.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"david@acmecorp.com\",\n  \"event_type\": \"meeting\",\n  \"event_title\": \"Strategy kickoff meeting\",\n  \"event_body\": \"Presented SEO audit findings. Agreed on 6-month content plan.\",\n  \"source\": \"calendly\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Log an Email",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-timeline-add",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-timeline-add"
              ]
            },
            "description": "Log an email sent or received.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"emily@techstartup.io\",\n  \"event_type\": \"email\",\n  \"event_title\": \"Trial onboarding email\",\n  \"event_body\": \"Sent getting-started guide and invited to onboarding webinar.\",\n  \"source\": \"mailchimp\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Add a Note",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-timeline-add",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-timeline-add"
              ]
            },
            "description": "Add a general note to a lead's timeline.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"maria.garcia@example.com\",\n  \"event_type\": \"note\",\n  \"event_title\": \"Internal note\",\n  \"event_body\": \"Client mentioned they may also want to buy an investment property. Flag for follow-up.\",\n  \"source\": \"manual\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Timeline Event by lead_id",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-timeline-add",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-timeline-add"
              ]
            },
            "description": "Add a timeline event using lead_id instead of email.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"lead_id\": \"{{lead_id}}\",\n  \"event_type\": \"call\",\n  \"event_title\": \"Check-in call\",\n  \"event_body\": \"Quick check-in, still interested but waiting on financing.\",\n  \"source\": \"api\"\n}"
            }
          },
          "response": []
        },
        {
          "name": "Timeline Event with Timestamp",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "x-api-key",
                "value": "{{api_key}}"
              }
            ],
            "url": {
              "raw": "https://backend.rubyorbit.com/functions/v1/api-timeline-add",
              "protocol": "https",
              "host": [
                "backend",
                "rubyorbit",
                "com"
              ],
              "path": [
                "functions",
                "v1",
                "api-timeline-add"
              ]
            },
            "description": "Add a timeline event with a custom original timestamp.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"sarah@example.com\",\n  \"event_type\": \"meeting\",\n  \"event_title\": \"Property showing\",\n  \"event_body\": \"Showed 3 properties in South Congress area.\",\n  \"source\": \"field\",\n  \"timestamp\": \"2025-06-15T14:30:00Z\"\n}"
            }
          },
          "response": []
        }
      ]
    }
  ]
}