πŸš€ Create a New Lead Using API

Step 1: Generate an API Key

  1. Go to: {{workspaceUrl}}/workspace-config?tab=api-keyGenerate

  2. Copy the API key.

Step 2: Get Company ID

πŸ“ Endpoint:

{{URL}}/accounts/companies

πŸ› οΈ Set Headers:

x-api-key: <API_KEY>

πŸ“₯ Response Example:

{
  "message": "Companies associated with API token.",
  "companies": [
    {
      "_id": "6525994184e9ddd79853450e",
      "name": "onethread123",
      "logo": "",
      "extraSmallLogo": "",
      "largeLogo": ""
    }
  ]
}

πŸ“ What to Do:

  • Extract the Company ID from the response: companies[0]._id.

  • Store the ID for later use:

    const companyId = "COMPANY_ID_HERE"; // Replace with actual ID

Step 3: Get Client Role ID

πŸ“ Endpoint:

{{URL}}/roles?type=company

πŸ› οΈ Set Headers:

x-api-key: <API_KEY>
companyId: <COMPANY_ID>

πŸ“₯ Response Example:

{
  "roles": [
    {
      "_id": "6525994184e9ddd798534535",
      "role": {
        "_id": "6525994184e9ddd79853451e",
        "responsibility": "",
        "name": "client"
      },
      "company": "6525994184e9ddd79853450e",
      "createdAt": "2023-10-10T18:34:41.567Z",
      "updatedAt": "2024-10-01T07:28:48.340Z",
      "__v": 0,
      "type": "company"
    }
  ]
}

πŸ“ What to Do:

  • Find the role where roles[0].role.name === "client".

  • Extract and store the Client Role ID:

    const clientRoleId = "ROLE_ID_HERE"; // Replace with actual ID
  • Important: Ensure you do not copy _id from roles[0].role, but from roles[0] itself.

Step 4: Create a New Lead

πŸ“ Endpoint:

{{URL}}/company/{{companyId}}/members/bulk-client

πŸ› οΈ Set Headers:

x-api-key: <API_KEY>
companyId: <COMPANY_ID>

πŸ“¦ Request Body:


   [
    {
      "firstName": "John",
      "lastName": "Doe",
      "email": "[email protected]",
      "role": "ROLE_ID_HERE",
      "isConvertedClient": false,
      "status": "New",
      "contactNo": "1234567890",
      "source": "website",
      "positionInBoard": 1,
      "isConvertedClient": false
    }
  ]

βœ… Success Response:

{
  "message": "Lead created successfully",
  "createdMembers": [
    {
      "_id": "NEW_MEMBER_ID",
      "name": "John Doe",
      "status": "New",
      "role": "client"
    }
  ]
}

❗ Important Tips:

  • Ensure "isConvertedClient": false is set in the request.

  • Use the correct Role ID from Step 3.

Last updated

Was this helpful?