Intercode SaaS Kit
  • Welcome to SaaS Starter Kit
  • Getting Started
    • Technology stack
    • Database Setup
    • Local Environment Setup
  • Basics
    • Dependencies
    • App architecture
    • Deployment
    • App roles
    • Endpoints List
      • Auth
      • Two Factor Auth
      • Businesses
      • Demo
      • Email
      • Export Document
      • Email Files
      • Files Demo
      • Leads
      • Orders
      • Payments
      • Subscriptions
      • Teams
      • Team Memberships
      • User Admin
  • Animation and Styles
    • Framer Motion
    • Ant Design and Styles
  • Pages
    • Auth
      • Working with PassportJS
      • Two-Factor Auth
      • OAuth Providers
    • Leads
    • Businesses
    • Team management
      • Ownership
    • Profile
    • User Settings
      • App Tour
    • App Settings
      • Lead Statuses
    • Dashboard
      • Lead volume widget
      • Doughnut chart widget
      • Recent leads table widget
      • Lead count over period widget
    • Demo
  • Features
    • Impersonation
    • Subscriptions (Stripe)
    • Search
    • Sentry
    • Captcha
    • Audit Logs
    • Internationalization
  • External integrations
    • Mailer
    • Google oAuth2
    • Facebook oAuth2
    • S3 compatible storage (AWS, MinIO)
Powered by GitBook
On this page
  1. Basics
  2. Endpoints List

Leads

PreviousFiles DemoNextOrders

Last updated 7 months ago

GET

POST

PATCH

PUT

DELETE

Retrieves all leads for the authenticated user's team.

get
Responses
200
Leads retrieved successfully
application/json
403
Access denied
application/json
get
GET /leads HTTP/1.1
Host: 
Accept: */*
{
  "count": 10,
  "leads": [
    {
      "id": 1,
      "firstName": "John",
      "lastName": "Doe",
      "email": "john.doe@example.com",
      "phoneNumber": [
        "123-456-7890"
      ],
      "status": "New",
      "business": [
        {
          "id": 1,
          "name": "Business Name"
        }
      ]
    }
  ]
}

Searches for leads based on the provided search term.

get
Responses
200
Leads retrieved successfully
application/json
403
Access denied
application/json
get
GET /leads/search HTTP/1.1
Host: 
Accept: */*
[
  {
    "id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "phoneNumber": [
      "123-456-7890"
    ],
    "status": "New",
    "business": [
      {
        "id": 1,
        "name": "Business Name"
      }
    ]
  }
]

Retrieves a lead by its ID.

get
Path parameters
idstringRequired
Responses
200
Lead retrieved successfully
application/json
403
Access denied
application/json
404
Lead not found
application/json
get
GET /leads/{id} HTTP/1.1
Host: 
Accept: */*
{
  "id": 1,
  "firstName": "John",
  "lastName": "Doe",
  "email": "john.doe@example.com",
  "phoneNumber": [
    "123-456-7890"
  ],
  "status": "New",
  "business": [
    {
      "id": 1,
      "name": "Business Name"
    }
  ]
}

Retrieves lead statuses for the authenticated user's team.

get
Responses
200
Lead statuses retrieved successfully
application/json
403
Access denied
application/json
get
GET /leads/statuses HTTP/1.1
Host: 
Accept: */*
{
  "statuses": [
    {
      "id": 1,
      "name": "New",
      "primaryColor": "blue",
      "secondaryColor": "lightblue"
    }
  ],
  "colors": [
    "blue"
  ]
}

Retrieves the volume of leads per business per day.

get
Responses
200
Leads volume retrieved successfully
application/json
403
Access denied
application/json
get
GET /leads/leads-volume HTTP/1.1
Host: 
Accept: */*
{
  "labels": [
    "2023-01-01",
    "2023-01-02"
  ],
  "data": {
    "ANY_ADDITIONAL_PROPERTY": {
      "ANY_ADDITIONAL_PROPERTY": 10
    }
  },
  "totalLeadsAmount": 100,
  "percentageChange": 10
}

Counts the total number of leads over a specified period.

get
Responses
200
Total leads counted successfully
application/json
403
Access denied
application/json
get
GET /leads/total-leads HTTP/1.1
Host: 
Accept: */*
{
  "name": "New",
  "current": 10,
  "percentageChange": 10,
  "color": "blue",
  "backgroundColor": "lightblue"
}

Finds the five most recent leads over a specified period.

get
Responses
200
Recent leads found successfully
application/json
403
Access denied
application/json
get
GET /leads/recent-leads HTTP/1.1
Host: 
Accept: */*
[
  {
    "id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "phoneNumber": [
      "123-456-7890"
    ],
    "status": "New",
    "business": [
      {
        "id": 1,
        "name": "Business Name"
      }
    ]
  }
]

Retrieves the number of leads per business over a specified period.

get
Responses
200
Leads per business retrieved successfully
application/json
403
Access denied
application/json
get
GET /leads/leads-per-business HTTP/1.1
Host: 
Accept: */*
{
  "ANY_ADDITIONAL_PROPERTY": 10
}

Retrieves a photo for a lead by its file name.

get
Path parameters
fileNamestringRequired
Responses
200
Photo retrieved successfully
application/json
Responsestring ยท binary
404
Photo not found
application/json
get
GET /leads/get-photo/{fileName} HTTP/1.1
Host: 
Accept: */*
binary

Retrieves logs for a lead by its ID.

get
Path parameters
idnumberRequired
Responses
200
Logs retrieved successfully
application/json
400
Invalid lead ID
application/json
403
Access denied
application/json
404
Lead not found
application/json
get
GET /leads/logs/{id} HTTP/1.1
Host: 
Accept: */*
{
  "count": 5,
  "logs": [
    {
      "id": 1,
      "action": "CreateLead",
      "entityType": "Lead",
      "user": {
        "id": 1,
        "email": "user@example.com"
      },
      "createdAt": "2023-01-01T00:00:00Z"
    }
  ]
}

Retrieves logs and comments for a lead by its ID.

get
Path parameters
idnumberRequired
Responses
200
Logs and comments retrieved successfully
application/json
400
Invalid lead ID
application/json
403
Access denied
application/json
404
Lead not found
application/json
get
GET /leads/logs-and-comments/{id} HTTP/1.1
Host: 
Accept: */*
{
  "logsAndComments": [
    {
      "id": 1,
      "action": "CreateLead",
      "entityType": "Lead",
      "user": {
        "id": 1,
        "email": "user@example.com"
      },
      "content": "This is a comment.",
      "createdAt": "2023-01-01T00:00:00Z"
    }
  ],
  "logsCount": 5,
  "commentsCount": 5
}

Deletes a photo for a lead by its file name.

delete
Path parameters
fileNamestringRequired
Responses
200
Photo deleted successfully
application/json
ResponseanyExample: {"message":"Photo deleted successfully","description":"The photo has been deleted successfully."}
404
Lead not found
application/json
delete
DELETE /leads/delete-photo/{fileName} HTTP/1.1
Host: 
Accept: */*
{
  "message": "Photo deleted successfully",
  "description": "The photo has been deleted successfully."
}

Deletes a lead status by its ID.

delete
Path parameters
idstringRequired
Responses
200
Lead status deleted successfully
application/json
ResponseanyExample: {"message":"Lead status deleted successfully","description":"The lead status has been deleted successfully."}
400
Cannot delete status
application/json
500
Internal server error
application/json
delete
DELETE /leads/status/{id} HTTP/1.1
Host: 
Accept: */*
{
  "message": "Lead status deleted successfully",
  "description": "The lead status has been deleted successfully."
}
  • GET
  • GETRetrieves all leads for the authenticated user's team.
  • GETSearches for leads based on the provided search term.
  • GETRetrieves a lead by its ID.
  • GETRetrieves lead statuses for the authenticated user's team.
  • GETRetrieves the volume of leads per business per day.
  • GETCounts the total number of leads over a specified period.
  • GETFinds the five most recent leads over a specified period.
  • GETRetrieves the number of leads per business over a specified period.
  • GETRetrieves a photo for a lead by its file name.
  • GETRetrieves logs for a lead by its ID.
  • GETRetrieves logs and comments for a lead by its ID.
  • POST
  • POSTCreates a new lead.
  • POSTCreates a new lead status for the authenticated user's team.
  • POSTUploads a photo for a lead.
  • POSTLeaves a comment on a lead.
  • PATCH
  • PATCHArchives multiple leads.
  • PATCHRestores multiple archived leads.
  • PUT
  • PUTUpdates a lead by its ID.
  • PUTChanges the status of multiple leads.
  • PUTUpdates a lead status by its ID.
  • PUTUpdates the order of lead statuses.
  • PUTEdits a comment on a lead.
  • DELETE
  • DELETEDeletes multiple leads.
  • DELETEDeletes a photo for a lead by its file name.
  • DELETEDeletes a lead status by its ID.

Creates a new lead.

post
Body
firstNamestringRequiredExample: John
lastNamestringRequiredExample: Doe
businessnumber[]RequiredExample: [1,2,3]
photostringRequiredExample: photo.jpg
statestring ยท enumRequiredExample: ActivePossible values:
statusIdnumberRequiredExample: 1
sourcestringRequiredExample: Referral
phoneNumberstring[]RequiredExample: ["123-456-7890"]
emailstringRequiredExample: john.doe@example.com
descriptionstringRequiredExample: Lead description
locationstringRequiredExample: New York
positionstringRequiredExample: Manager
companystringRequiredExample: Company Name
Responses
201
Lead created successfully
application/json
400
Email already exists
application/json
404
No lead status found
application/json
500
Internal server error
application/json
post
POST /leads HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 427

{
  "firstName": "John",
  "lastName": "Doe",
  "business": [
    1,
    2,
    3
  ],
  "photo": "photo.jpg",
  "state": "Active",
  "statusId": 1,
  "source": "Referral",
  "phoneNumber": [
    "123-456-7890"
  ],
  "email": "john.doe@example.com",
  "description": "Lead description",
  "location": "New York",
  "socialMedia": {
    "youtube": "youtube.com/lead",
    "facebook": "facebook.com/lead",
    "instagram": "instagram.com/lead",
    "twitter": "twitter.com/lead"
  },
  "position": "Manager",
  "company": "Company Name"
}
{
  "id": 1,
  "firstName": "John",
  "lastName": "Doe",
  "email": "john.doe@example.com",
  "phoneNumber": [
    "123-456-7890"
  ],
  "status": "New",
  "business": [
    {
      "id": 1,
      "name": "Business Name"
    }
  ]
}

Creates a new lead status for the authenticated user's team.

post
Body
namestringRequiredExample: New
primaryColorstring ยท enumRequiredExample: bluePossible values:
Responses
201
Lead status created successfully
application/json
400
Lead status already exists
application/json
500
Internal server error
application/json
post
POST /leads/status HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 36

{
  "name": "New",
  "primaryColor": "blue"
}
{
  "id": 1,
  "name": "New",
  "primaryColor": "blue",
  "secondaryColor": "lightblue"
}

Uploads a photo for a lead.

post
Body
idnumberOptionalExample: 1
photostring ยท binaryOptional
Responses
200
Photo uploaded successfully
application/json
ResponsestringExample: formatted_file_name.jpg
400
Invalid file
application/json
403
Access denied
application/json
post
POST /leads/upload-photo HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 25

{
  "id": 1,
  "photo": "binary"
}
formatted_file_name.jpg

Leaves a comment on a lead.

post
Path parameters
idnumberRequired
Body
contentstringOptionalExample: This is a comment.
Responses
201
Comment added successfully
application/json
400
Invalid lead ID
application/json
403
Access denied
application/json
404
Lead not found
application/json
post
POST /leads/comments/{id} HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 32

{
  "content": "This is a comment."
}
{
  "id": 1,
  "content": "This is a comment.",
  "user": {
    "id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "email": "user@example.com"
  },
  "createdAt": "2023-01-01T00:00:00Z"
}

Archives multiple leads.

patch
Body
idsnumber[]OptionalExample: [1,2,3]
Responses
200
Leads archived successfully
application/json
ResponseanyExample: {"message":"Leads archived successfully","description":"The leads have been archived successfully."}
400
One or more leads not found
application/json
403
Access denied
application/json
500
Internal server error
application/json
patch
PATCH /leads/archive HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 15

{
  "ids": [
    1,
    2,
    3
  ]
}
{
  "message": "Leads archived successfully",
  "description": "The leads have been archived successfully."
}

Restores multiple archived leads.

patch
Body
idsnumber[]OptionalExample: [1,2,3]
Responses
200
Leads restored successfully
application/json
ResponseanyExample: {"message":"Leads restored successfully","description":"The leads have been restored successfully."}
400
One or more leads not found
application/json
403
Access denied
application/json
500
Internal server error
application/json
patch
PATCH /leads/restore HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 15

{
  "ids": [
    1,
    2,
    3
  ]
}
{
  "message": "Leads restored successfully",
  "description": "The leads have been restored successfully."
}

Updates a lead by its ID.

put
Path parameters
idstringRequired
Body
firstNamestring | nullableRequiredExample: John
lastNamestring | nullableRequiredExample: Doe
businessnumber[]RequiredExample: [1,2,3]
photostring | nullableRequiredExample: photo.jpg
statestring ยท enum | nullableRequiredExample: ActivePossible values:
statusIdnumber | nullableRequiredExample: 1
sourcestring | nullableRequiredExample: Referral
phoneNumberstring[] | nullableRequiredExample: ["123-456-7890"]
emailstring | nullableOptionalExample: john.doe@example.com
descriptionstring | nullableRequiredExample: Lead description
locationstring | nullableRequiredExample: New York
positionstring | nullableRequiredExample: Manager
companystring | nullableRequiredExample: Company Name
Responses
200
Lead updated successfully
application/json
400
Invalid lead data
application/json
403
Access denied
application/json
404
Lead not found
application/json
put
PUT /leads/{id} HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 427

{
  "firstName": "John",
  "lastName": "Doe",
  "business": [
    1,
    2,
    3
  ],
  "photo": "photo.jpg",
  "state": "Active",
  "statusId": 1,
  "source": "Referral",
  "phoneNumber": [
    "123-456-7890"
  ],
  "email": "john.doe@example.com",
  "description": "Lead description",
  "location": "New York",
  "socialMedia": {
    "youtube": "youtube.com/lead",
    "facebook": "facebook.com/lead",
    "instagram": "instagram.com/lead",
    "twitter": "twitter.com/lead"
  },
  "position": "Manager",
  "company": "Company Name"
}
{
  "id": 1,
  "firstName": "John",
  "lastName": "Doe",
  "email": "john.doe@example.com",
  "phoneNumber": [
    "123-456-7890"
  ],
  "status": "Updated Status",
  "business": [
    {
      "id": 1,
      "name": "Business Name"
    }
  ]
}

Changes the status of multiple leads.

put
Body
idsnumber[]RequiredExample: [1,2,3]
statusIdnumberRequiredExample: 1
Responses
200
Lead statuses updated successfully
application/json
400
Invalid status ID
application/json
403
Access denied
application/json
404
Lead not found
application/json
put
PUT /leads/change-status HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 28

{
  "ids": [
    1,
    2,
    3
  ],
  "statusId": 1
}
[
  {
    "id": 1,
    "status": "Updated Status"
  }
]

Updates a lead status by its ID.

put
Path parameters
idstringRequired
Body
namestring | nullableRequiredExample: New
primaryColorstring ยท enum | nullableRequiredExample: bluePossible values:
Responses
200
Lead status updated successfully
application/json
400
Lead status not found
application/json
500
Internal server error
application/json
put
PUT /leads/status/{id} HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 36

{
  "name": "New",
  "primaryColor": "blue"
}
{
  "id": 1,
  "name": "Updated Status",
  "primaryColor": "green",
  "secondaryColor": "lightgreen"
}

Updates the order of lead statuses.

put
Body
idnumberOptionalExample: 1
statusOrdernumberOptionalExample: 1
Responses
200
Lead statuses order updated successfully
application/json
500
Internal server error
application/json
put
PUT /leads/statuses/order HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 24

{
  "id": 1,
  "statusOrder": 1
}
[
  {
    "id": 1,
    "statusOrder": 1
  }
]

Edits a comment on a lead.

put
Path parameters
idnumberRequired
Body
contentstringOptionalExample: This is an edited comment.
Responses
200
Comment edited successfully
application/json
400
Invalid comment ID
application/json
403
Access denied
application/json
404
Comment not found
application/json
put
PUT /leads/comments/{id} HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 40

{
  "content": "This is an edited comment."
}
{
  "id": 1,
  "content": "This is an edited comment.",
  "user": {
    "id": 1,
    "firstName": "John",
    "lastName": "Doe",
    "email": "user@example.com"
  },
  "createdAt": "2023-01-01T00:00:00Z"
}

Deletes multiple leads.

delete
Body
idsnumber[]OptionalExample: [1,2,3]
Responses
200
Leads deleted successfully
application/json
ResponseanyExample: {"message":"Leads deleted successfully","description":"The leads have been deleted successfully."}
400
One or more leads not found
application/json
403
Access denied
application/json
500
Internal server error
application/json
delete
DELETE /leads HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 15

{
  "ids": [
    1,
    2,
    3
  ]
}
{
  "message": "Leads deleted successfully",
  "description": "The leads have been deleted successfully."
}