# Leads & CRM

## Lead Overview

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/leads/overview/`

This API endpoint will return lead summary and appointments.

#### Query Parameters

| Name        | Type   | Description                                            |
| ----------- | ------ | ------------------------------------------------------ |
| appointment | string | Possible values are: upcoming, today, week, and month. |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "LeadsData": {
            "status": [
                {
                    "status": <status>,
                    "count": <count>,
                    "Description": "<short_description>",
                    "Color": "<color>"
                },
                ...
            ],
            "source": [
                {
                    "source": <source>
                    "count": <count>
                },
                ...
            ]
        },
        "TotalLeads": <total_leads_count>,
        "appointments": [
            {
                "appointment_note": "<appointment_note>",
                "appointment_status": "<appointment_status>",
                "appointment_date": "<appointment_date>",
                "appointment_to": "<appointment_to>"
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/leads/overview/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/leads/overview/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | Field       | Description                       |
| ----------- | ---------------- | ----------- | --------------------------------- |
| 400         | Validation Error | appointment | Invalid appointment filter value. |

## List Leads

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/leads/list/`

This API endpoint will return a list of owned leads. Use the same URL to get a list of assigned leads with a query parameter list\_type as 'assigned'.&#x20;

#### Query Parameters

| Name           | Type   | Description                                                                                     |
| -------------- | ------ | ----------------------------------------------------------------------------------------------- |
| campaign\_slug | string | Get the list of leads under a campaign.                                                         |
| offset         | string |                                                                                                 |
| limit          | string |                                                                                                 |
| list\_type     | string | Possible value is 'assigned'                                                                    |
| first\_name    | string | first name                                                                                      |
| last\_name     | string | last name                                                                                       |
| email          | string | email address                                                                                   |
| phone          | string | phone number                                                                                    |
| status         | string | lead status, possible values are prospect, tentative, potential, closed, contact, and customer. |
| owner          | string | owner username                                                                                  |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <lead_id>,
                "slug": "<lead_slug>",
                "first_name": "<first_name>",
                "last_name": "<last_name>",
                "name": "<full_name>",
                "phone": "<phone_number>",
                "email": "<email_address>",
                "added_on": "<created_date>",
                "status": "<lead_status>",
                "source": "<lead_source>",
                "owner": "<owner_name>"
            }
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/leads/list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/leads/list/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

## List Appointments

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/leads/appointments/list/`

This API endpoint will return a list of appointments.

#### Query Parameters

| Name        | Type   | Description                                                                                     |
| ----------- | ------ | ----------------------------------------------------------------------------------------------- |
| offset      | string |                                                                                                 |
| limit       | string |                                                                                                 |
| datesetting | string | Possible values are on, before, and after.                                                      |
| ondate      | string | required when datesettigs is given, Formate: MM/DD/YYYY                                         |
| status      | string | <p>Possible values are pending, rescheduled, cancelled, <br> fullfilled, and confirmed.    </p> |
| lead        | string | lead firstname                                                                                  |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "results": [
            {
                "id": <appointment_id>,
                "lead_id": <lead_id>,
                "lead": "<lead_name>",
                "leadslug": "<lead_slug>",
                "leadstatus": "<lead_status>",
                "fromdate": "<from_date>",
                "appointment_note": "<appointment_note>",
                "appointment_status": "<appointment_status>",
                "todate": "<to_date>"
            }
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/appointments/list/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/appointments/list/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

## Lead Details

<mark style="color:blue;">`GET`</mark> `‎https://<domain>/<api prefix>/<version>/leads/view/lead/`

This API endpoint will return details of a lead.

#### Query Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| slug | string | Lead slug.  |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "id": <lead_id>,
        "slug": "<lead_slug>",
        "first_name": "<first_name>",
        "name": "<name>",
        "last_name": "<last_name>",
        "phone": "<phone_number>",
        "email": "<email_address>",
        "status": "<lead_status>",
        "source": "<lead_source>",
        "message": "<lead_message>",
        "added_on": "<created_date>",
        "recent_activities": [
            {
                "id": <activity_id>,
                "activity_type": "<activity_type>",
                "created": "<activity_added_date>",
                "activity": "<activity>"
            },
            ...
        ],
        "notes": [
            {
                "id": <note_id>,
                "note": "<note>",
                "note_created": "<note_created_date>",
                "user": "<note_created_user>"
            }
            ...
        ],
        "conversion": <conversion_percentage>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/view/lead/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/view/lead/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | Field | Description                                                                               |
| ----------- | ---------------- | ----- | ----------------------------------------------------------------------------------------- |
| 400         | Validation Error | slug  | <p>This field is required and this may not be blank.</p><p>Requested slug is invalid.</p> |

## Create Appointment

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/create/appointment/`

This API endpoint will create an appointment in a lead.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                                | Type   | Description                                                                                                                              |
| --------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| slug<mark style="color:red;">\*</mark>              | string | Lead slug                                                                                                                                |
| appointment\_date<mark style="color:red;">\*</mark> | string | Appointment date, format: yyyy-mm-dd hh:mm                                                                                               |
| appointment\_to<mark style="color:red;">\*</mark>   | string | Appointment to date, format: yyyy-mm-dd hh:mm                                                                                            |
| appointment\_note                                   | string | Appointment note. default value is "Prospect appointment''.                                                                              |
| appointment\_status                                 | string | <p>Appointment status, possible values are pending, rescheduled, cancelled, fullfilled, and, confirmed.<br>default value is pending.</p> |

{% tabs %}
{% tab title="200 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/create/appointment/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'slug': '<lead_slug>',
    'appointment_date': '<yyyy-mm-dd HH:MM>',
    'appointment_note': '<appointment_note>',
    'appointment_status': '<appointment_status>',
    'appointment_to': '<yyyy-mm-dd HH:MM>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/create/appointment/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('slug' => '<lead_slug>','appointment_date' => '<yyyy-mm-dd HH:MM>','appointment_note' => '<appointment_note>','appointment_status' => '<appointment_status>','appointment_to' => '<yyyy-mm-dd HH:MM>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| Status Code | Error Type       | Field               | Description                                                                                                                                                          |
| ----------- | ---------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 401         | Request Failed   |                     | <p>Body data not found.</p><p>Appointment schedule exists for this time.</p><p>End Date Can't be prior to Start Date.</p><p>Please Specify a date in the future.</p> |
| 400         | Validation Error | slug                | <p>This field is required.</p><p>This field is may not be blank.</p><p>Requested slug is invalid.</p><p>You can't take appointment under this lead.</p>              |
| 400         | Validation Error | appointment\_date   | <p>This field is required.</p><p>This field is may not be blank.</p><p>Invalid date format.</p>                                                                      |
| 400         | Validation Error | appointment\_to     | <p>This field is required.</p><p>This field is may not be blank.</p><p>Invalid date format.</p>                                                                      |
| 400         | Validation Error | appointment\_note   | Ensure this field has no more than 200 characters.                                                                                                                   |
| 400         | Validation Error | appointment\_status | Invalid appointment status.                                                                                                                                          |

## Update Appointment

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/update/appointment/`

This API endpoint will update an appointment.

#### Query Parameters

| Name                | Type   | Description                                                                                                                    |
| ------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------ |
| appointment\_id     | string | Id of appointment.                                                                                                             |
| slug                | string | Lead slug.                                                                                                                     |
| appointment\_date   | string | Appointment date, format: yyyy-mm-dd hh-mm                                                                                     |
| appointment\_note   | string | mmappointment\_note                                                                                                            |
| appointment\_to     | string | Appointment to date, format: yyyy-mm-dd hh-mm                                                                                  |
| appointment\_status | string | Appointment status, possible values are pending, rescheduled, cancelled, fullfilled, and, confirmed. default value is pending. |

#### Headers

| Name                                           | Type   | Description         |
| ---------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>       | string | Apikey              |
| Authrization<mark style="color:red;">\*</mark> | string | Bearer access token |

{% tabs %}
{% tab title="200 " %}

```markup
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/update/appointment/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'appointment_id': '<appointment_id>'
    'slug': '<lead_slug>',
    'appointment_date': '<appointment_date>',
    'appointment_note': '<appointment_note>',
    'appointment_status': '<appointment_status>',
    'appointment_to': '<appointment_to>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/update/appointment/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('slug' => '<lead_slug>','appointment_date' => '<appointment_date>','appointment_note' => '<appointment_note>','appointment_status' => '<appointment_status>','appointment_to' => '<appointment_to>','appointment_id' => '<appointment_id>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | Field               | Description                                                                                                                                                                                                   |
| ----------- | ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 401         | Request Failed   |                     | <p>Body data not found.</p><p>Appointment schedule exists for this time.</p><p>End Date Can't be prior to Start Date.</p><p>Please Specify a date in the future.</p><p>You can't update this appointment.</p> |
| 400         | Validation Error | appointment\_id     | <p>This field is required.</p><p>This field is may not be blank.</p><p>Invalid appointment id.</p><p>Requested appointment not found.</p><p></p>                                                              |
| 400         | Validation Error | slug                | <p>This field is may not be blank.</p><p>Requested slug is invalid.</p><p>You can't take appointment under this lead.</p>                                                                                     |
| 400         | Validation Error | appointment\_date   | <p>This field is may not be blank.</p><p>Invalid date format.</p>                                                                                                                                             |
| 400         | Validation Error | appointment\_to     | <p>This field is may not be blank.</p><p>Invalid date format.</p>                                                                                                                                             |
| 400         | Validation Error | appointment\_note   | Ensure this field has no more than 200 characters.                                                                                                                                                            |
| 400         | Validation Error | appointment\_status | Invalid appointment status.                                                                                                                                                                                   |

## Delete Appointment

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/delete/appointment/`

This API endpoint will delete an appointment.

#### Headers

| Name                                            | Type   | Description          |
| ----------------------------------------------- | ------ | -------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey               |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token. |

#### Request Body

| Name                                              | Type   | Description    |
| ------------------------------------------------- | ------ | -------------- |
| appointment\_id<mark style="color:red;">\*</mark> | string | Appointment id |

{% tabs %}
{% tab title="200 " %}

```
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/delete/appointment/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'appointment_id': '<appointment id>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/delete/appointment/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('appointment_id' => '<appointment id>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type       | Field           | Description                                                                                                                                      |
| ----------- | ---------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 401         | Request Failed   |                 | You can't delete this appointment.                                                                                                               |
| 400         | Validation Error | appointment\_id | <p>This field is required.</p><p>This field is may not be blank.</p><p>Invalid appointment id.</p><p>Requested appointment not found.</p><p></p> |

## Create Lead

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/v1/leads/create/lead/`

This API endpoint will create a lead.

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey       |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer token |

#### Request Body

| Name                                          | Type   | Description                                                                                                           |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| first\_name<mark style="color:red;">\*</mark> | string | First name.                                                                                                           |
| last\_name<mark style="color:red;">\*</mark>  | string | Last name.                                                                                                            |
| email<mark style="color:red;">\*</mark>       | string | Email address                                                                                                         |
| status                                        | string | Lead status, possible values are prospect, tentative, potential, closed, contact, and customer.                       |
| source                                        | string | Lead source, possible values are direct, website, facebook, twitter, instagram, search, pinterest, reddit and, other. |
| phone<mark style="color:red;">\*</mark>       | string | Phone number.                                                                                                         |
| location<mark style="color:red;">\*</mark>    | string | Location                                                                                                              |
| message<mark style="color:red;">\*</mark>     | string | Lead message.                                                                                                         |
| assignee<mark style="color:red;">\*</mark>    | string | Assignee username.                                                                                                    |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/v1/create/lead/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'first_name': '<first_name>',
    'last_name': '<last_name>',
    'email': '<email>',
    'status': '<status>',
    'source': '<source>',
    'phone': '<phone>',
    'location': '<location>',
    'message': '<message>',
    'assignee': '<assignee_username>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/v1/create/lead/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('first_name' => '<first_name>','last_name' => '<last_name>','email' => '<email>','status' => '<status>','source' => '<source>','phone' => '<phone>','location' => '<location>','message' => '<message>','assignee' => '<assignee>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Response

| **Status Code** | Error Type       | Field       | Description                                                                                                                                               |
| --------------- | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400             | Validation Error | first\_name | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p>                                |
| 400             | Validation Error | last\_name  | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p>                                |
| 400             | Validation Error | email       | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p><p>Invalid email.</p>           |
| 400             | Validation Error | phone       | <p>This field is required.</p><p>This field may not be blank.</p><p>Phone number must be entered in the format: '999999999'. Up to 15 digits allowed.</p> |
| 400             | Validation Error | location    | Ensure this field has no more than 255 characters.                                                                                                        |
| 400             | Validation Error | message     | Ensure this field has no more than 255 characters.                                                                                                        |
| 400             | Validation Error | status      | \<status> is not a valid choice.                                                                                                                          |
| 400             | Validation Error | source      | \<source> is not a valid choice.                                                                                                                          |
| 400             | Validation Error | assignee    | <p>This field may not be blank.</p><p>Assignee not found.</p>                                                                                             |

## Update Lead

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/update/lead/`

This API endpoint will update a lead.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Beare access token. |

#### Request Body

| Name                                          | Type   | Description                                                                                                           |
| --------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| slug<mark style="color:red;">\*</mark>        | string | Lead slug                                                                                                             |
| first\_name<mark style="color:red;">\*</mark> | string | First name.- existing or new                                                                                          |
| last\_name<mark style="color:red;">\*</mark>  | string | Last name.- existing or new                                                                                           |
| email<mark style="color:red;">\*</mark>       | string | Email address.- existing or new                                                                                       |
| status                                        | string | Lead status, possible values are prospect, tentative, potential, closed, contact, and customer.                       |
| source                                        | string | Lead source, possible values are direct, website, facebook, twitter, instagram, search, pinterest, reddit and, other. |
| phone<mark style="color:red;">\*</mark>       | string | Phone number.- existing or new.                                                                                       |
| location<mark style="color:red;">\*</mark>    | string | Location                                                                                                              |
| message<mark style="color:red;">\*</mark>     | string | Message                                                                                                               |
| assignee<mark style="color:red;">\*</mark>    | string | Assignee username.                                                                                                    |

{% tabs %}
{% tab title="200 " %}

```
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/update/lead/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'first_name': '<first_name>',
    'last_name': '<last_name>',
    'email': '<email>',
    'status': '<status>',
    'source': '<source>',
    'phone': '<phone>',
    'location': '<location>',
    'message': '<message>',
    'slug': '<lead_slug>',
    'assignee': '<assignee_username>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/update/lead/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('first_name' => '<first_name>','last_name' => '<last_name>','email' => '<email>','status' => '<status>','source' => '<source>','phone' => '<phone>','location' => '<location>','message' => '<message>','slug' => '<lead_slug>','assignee' => '<assignee_username>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| **Status Code** | Error Type       | Field       | Description                                                                                                                                               |
| --------------- | ---------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400             | Validation Error | slug        | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 258 characters.</p>                                |
| 400             | Validation Error | first\_name | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p>                                |
| 400             | Validation Error | last\_name  | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p>                                |
| 400             | Validation Error | email       | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 255 characters.</p><p>Invalid email.</p>           |
| 400             | Validation Error | phone       | <p>This field is required.</p><p>This field may not be blank.</p><p>Phone number must be entered in the format: '999999999'. Up to 15 digits allowed.</p> |
| 400             | Validation Error | location    | Ensure this field has no more than 255 characters.                                                                                                        |
| 400             | Validation Error | message     | Ensure this field has no more than 255 characters.                                                                                                        |
| 400             | Validation Error | status      | \<status> is not a valid choice.                                                                                                                          |
| 400             | Validation Error | source      | \<source> is not a valid choice.                                                                                                                          |
| 400             | Validation Error | assignee    | <p>This field may not be blank.</p><p>Assignee not found.</p>                                                                                             |
| 401             | Request Failed   |             | <p>Requested lead does not esixt.</p><p>You are not owner of this lead.</p>                                                                               |

## Delete Lead

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/delete/lead/`

This API endpoint will delete a lead.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| slug<mark style="color:red;">\*</mark> | string | Lead slug   |

{% tabs %}
{% tab title="200 " %}

```
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/delete/lead/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'slug': '<lead_slug>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/delete/lead/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('slug' => 'binuser1'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| **Status Code** | Error Type       | Field | Description                                                                                                                                       |
| --------------- | ---------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400             | Validation Error | slug  | <p>This field is required.</p><p>This field may not be blank.<br>Requested lead not found.</p><p>Requested lead already has a deleted status.</p> |
| 401             | Request Failed   |       | You can't delete this lead.                                                                                                                       |

## Create Lead Note

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/create/leadnote/`

This API endpoint will create a note on lead.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| note<mark style="color:red;">\*</mark> | string | Lead note.  |
| slug<mark style="color:red;">\*</mark> | string | Lead slug   |

{% tabs %}
{% tab title="200 " %}

```
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/create/leadnote/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'slug': '<lead_slug>',
    'note': '<note>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/create/leadnote/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('slug' => '<lead_slug>','note' => '<note>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| **Status Code** | Error Type       | Field | Description                                                                                                                                       |
| --------------- | ---------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400             | Validation Error | slug  | <p>This field is required.</p><p>This field may not be blank.<br>Requested lead not found.</p><p>Requested lead already has a deleted status.</p> |
| 400             | Validation Error | note  | <p>This field is required.</p><p>This field may not be blank.</p><p>Ensure this field has no more than 499 characters.</p>                        |
| 401             | Request Failed   |       | You can't add note on this lead.                                                                                                                  |

## Delete Lead Note

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/leads/delete/leadnote/`

This API endpoint will delete a note of lead.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access token |

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| note\_id<mark style="color:red;">\*</mark> | string | Note id     |

{% tabs %}
{% tab title="200 " %}

```
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```php
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/delete/leadnote/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>'
  },
  formData: {
    'note_id': '<note_id>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/delete/leadnote/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('note_id' => '<nit_id>'),
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'Authorization: Bearer <access-token>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

#### Error Responses

| **Status Code** | Error Type       | Field    | Description                                                                                                           |
| --------------- | ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------- |
| 400             | Validation Error | note\_id | <p>This field is required.</p><p>This field may not be blank.<br>Requested note not found.</p><p>Invalid note id.</p> |
| 401             | Request Failed   |          | You can't delete this note.                                                                                           |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api.epixelsoftware.help/leads-and-crm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
