# Lead Campaign

## List Category

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

This API endpoint will return a list of campaign categories.

#### Query Parameters

| Name        | Type   | Description                                             |
| ----------- | ------ | ------------------------------------------------------- |
| datesetting | string | Possible values are 'on', 'before', and  'after'        |
| dateon      | string | Required if datesetting is provided, formate mm/dd/yyyy |
| offset      | string |                                                         |
| limit       | string |                                                         |
| name        | string | Category name                                           |

#### 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": <id>,
                "category": "<category_name>",
                "description": "<category_description>",
                "slug": "<category_slug>"
            }
            ...
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/campaign/list/category/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: { }
};
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>/campaign/list/category/',
  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 | datesetting | Inavalid date settings.    |
| 400         | dateon           | dateon      | Invalid date formate...etc |

## List Campaign

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

This API endpoint will return a list of lead campaigns.

#### Query Parameters

| Name        | Type   | Description                                             |
| ----------- | ------ | ------------------------------------------------------- |
| datesetting | string | Possible values are on, before, and after               |
| dateon      | string | Required if datesetting is provided, formate mm/dd/yyyy |
| offset      | string |                                                         |
| linit       | string |                                                         |
| title       | string | Campaign title                                          |
| category    | string | Category name                                           |
| user        | string | user name                                               |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | Aapikey             |
| 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": <campaign_id>,
                "campaign": "<campaign_title>",
                "description": "<description>",
                "slug": "<slug>",
                "created": "<created>",
                "campaign_image": "<campaign_image>"
            },

        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/campaign/list/campaign/',
  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;
```

**Node**

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

```

#### Error Responses

| Status Code | Error Type       | FIeld       | Description                |
| ----------- | ---------------- | ----------- | -------------------------- |
| 400         | Validation Error | datesetting | Inavalid date settings.    |
| 400         | dateon           | dateon      | Invalid date formate...etc |

## List Campaign Pages

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

This API endpoint will return a list of pages under a campaign.

#### Query Parameters

| Name           | Type   | Description                                                |
| -------------- | ------ | ---------------------------------------------------------- |
| campaign\_slug | string | Slug of the campaign.                                      |
| offset         | string |                                                            |
| limit          | string |                                                            |
| datesetting    | string | Possible values are on, before, and after.                 |
| dateon         | string | Required if datesetting is provided. formate is mm/dd/yyyy |
| title          | string | Page title                                                 |
| user           | string | user                                                       |

#### 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": <id>,
                "slug": "<slug>",
                "title": "<title>",
                "description": "<description>"
                "body": "<body>",
                "image": "<image>",
                "created": "<created>",
                "preview_url": "<page_preview_url>",
                "facebooklink": "<facebooke_share_link>",
                "twitterlink": "<twitter_share_link>"
            }
        ],
        "count": <list_count>,
        "previous": <previous_page_url>,
        "next": <next_page_url>,
    }
}
```

{% endtab %}
{% endtabs %}

#### Sample Code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/campaign/list/pages/?campaign_slug=<slug>',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access token>',
  },
  formData: {}
};
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>/campaign/list/pages/?campaign_slug=<slug>',
  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 | campaign\_slug | Campaign slug is required. |
| 400         | Validation Error | datesetting    | Inavalid date settings.    |
| 400         | Validation Error | dateon         | Invalid date formate...etc |
