Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

REST API

The REST Api is mainly is used to integrate SolarPlus Contacts and CRM data via any custom connectors to external CRM and databases. It is also used for the Solarplus Wordpress plugin and can be use with other applicationsSolarPlus Wordpress Plugin.


Authentication

The authentication requires token that can be generated through httphttps://devgo.solarplus.co/user/api to be passed through Authentication header of the requests.

Generating access token

To generate go to http://dev.solarplus.co/user/api , Click on the “Generate new Secreto Key” button and after that click “Generate new Token” button.

Base Api Url

Appending Authentication Token

Every request to the api must have token key attached to the header Authorization. Place your generated token key like so:

Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC93d3cuc29sYXJwbHVzLmNvbVwvYXBpXC8iLCJpYXQiOjE0OTg0OTEwMTgsImV4cCI6MTUzMDAzMTAxOCwidHRsIjoiMy4xNTRlKzciLCJ1aWQiOiIxMTI5In0.hfg_GnZSzsFbCesTMGr2CqJAZr8V7lCN6diL95COx60

Creating Contact

API Path: /api/contact

HTTP Verb: POST or PUT

Form Parameters:

...

Name

...

Key

...

Values

...

Required

...

Comments

...

Contact

...

First Name

...

first_name

...

String

...

Yes

...

Last name of the contact

...

Last Name

...

last_name

...

String

...

Yes

...

Last name of the contact

...

Email Address

...

email

...

String

...

Yes

...

Email address of the customer

...

Primary Phone

...

primary_phone

...

String

...

No

...

Primary phone number of the customer

...

Full Address

...

full_address

...

String

...

Yes

...

Full address of the customer

...

Business Name

...

business_name

...

String

...

No

...

Business name of the contact

...

Full Address

...

full_address

...

String

...

Yes

...

Contact and Site full address.

...

Notes

...

notes

...

String

...

No

...

Notes for this customer

...

Business Name as Client

...

business_as_client

...

Boolean

...

No

...

Whether to set the Site name the same as the Business Name.

...

Source

...

source

...

String

...

No

...

Contact source it can be one of the following: Other, TV, Radio, Press, Google, Tradeshow, Friends, Website, Word of Mouth

...

Status

...

status

...

String

...

No

...

Status can be one of the following: Lead, Active, Closed

...

Categories

...

categories[category_name]

...

Array of Strings

...

No

...

Business Category of the Contact.

...

Custom Fields

...

Custom Fields

...

custom_fields[field_name]

...

Array of Strings

...

Yes or No

...

Contact custom fields that the business has. The requirement depends on the creation of the field.

Sample PHP Code Using cURL:

<?php

$url = 'http://dev.solarplus.co/api/contact';

'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC93d3cuc29sYXJwbHVzLmNvbVwvYXBpXC8iLCJpYXQiOjE0OTg0OTEwMTgsImV4cCI6MTUzMDAzMTAxOCwidHRsIjoiMy4xNTRlKzciLCJ1aWQiOiIxMTI5In0.hfg_GnZSzsFbCesTMGr2CqJAZr8V7lCN6diL95COx60';

$auth_header = 'Authorization Bearer ' . $token;

$form = array(

   'first_name' => 'John',

   'last_name' => 'Doe',

   'email' => 'john.doe@domain.com',

   'primary_phone' => '123-123-123',

   'full_address' => '222 Exhibition St, Melbourne VIC 3000, Australia',

   'business_name' => 'John Solar Power',

   'notes' => 'Nullam id dolor id nibh ultricies vehicula ut id elit.'

   'categories' => array(

       'Category 1' => 'Some value',

   ),

   'custom_fields' => array(

       'custom_text_12' => 'Some value',

   ),

);

$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $auth_header));

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($form));

$response = curl_exec($ch);

$json = json_decode($response);

curl_close($ch);

echo '<pre>';

print_r($json);

echo '</pre>';

JSON Response:

{
   "success": "true",
   "message": "Contact successfully created.",
   "data": {
       "id": "19670",

       "business_name": null,

       "business_as_client": 0,

       "source": "Other",

       "status": "Lead",

       "first_name": "John",

       "last_name": "Doe",

       "email": "john.doe@domain.com",

       "primary_phone": "123-123-123",

       "secondary_phone": null,

       "full_address": "222 Exhibition St, Melbourne VIC 3000, Australia",

       "categories": null,

       "notes": "Nullam id dolor id nibh ultricies vehicula ut id elit."
   }
}

Response Table:

...

Name

...

Key

...

Values

...

Description

...

Status

...

Success

...

success

...

Boolean

...

A boolean value, if true then request was a success and failed in other case.

...

Message

...

message

...

String or Array

...

A descriptive message about the status of the request.

...

Data

...

Customer Id

...

data[customer_id]

...

Integer

...

The customer identification number.

...

Business Name

...

data[business_name]

...

String

...

Business name of the contact

...

Business Name as Client

...

data[business_as_client]

...

Boolean

...

Whether it was set to the Site name the same as the Business Name.

...

Source

...

data[source]

...

String

...

Contact source

...

Status

...

data[status]

...

String

...

Contact status

...

First Name

...

data[first_name]

...

String

...

Contact first name

...

Last Name

...

data[last_name]

...

String

...

Contact last name

...

Email Address

...

data[email]

...

String

...

Contact email address

...

Primary Phone

...

data[primary_phone]

...

String

...

Contact primary phone

...

Secondary Phone

...

data[secondary_phone]

...

String

...

Contact secondary phone

...

Full Address

...

data[full_address]

...

String

...

Contact full address

...

Notes

...

data[notes]

...

String

...

Contact notes

...

Categories

...

Categories

...

data[categories]

...

Array

...

Contains categories names.

Getting Contact

API Path: /contact/<id>

HTTP Verb: GET

Form Parameters:

...

Name

...

Key

...

Values

...

Required

...

Comments

Sample PHP Code Using cURL:

JSON Response:

{
   "success": true,
   "message": "Successfully retrieved customer information.",
   "data": {

       "id": "19669",

       "business_name": null,

       "business_as_client": 0,

       "source": "Other",

       "status": "Lead",

       "first_name": "John",

       "last_name": "Doe",

       "email": null,

       "primary_phone": null,

       "secondary_phone": null,

       "full_address": "B58 L12 Bloomingdale Subd., Iponan, Cagayan de Oro City, Philippines, 9000",

       "categories": null,

       "notes": null
   }

}

Response Table:

...

Name

...

Key

...

Values

...

Description

...

Status

...

Success

...

success

...

Boolean

...

A boolean value, if true then request was a success and failed in other case.

...

Message

...

message

...

String or Array

...

A descriptive message about the status of the request.

...

Data

...

Customer Id

...

data[customer_id]

...

Integer

...

The customer identification number.

...

Business Name

...

data[business_name]

...

String

...

Business name of the contact

...

Business Name as Client

...

data[business_as_client]

...

Boolean

...

Whether it was set to the Site name the same as the Business Name.

...

Source

...

data[source]

...

String

...

Contact source

...

Status

...

data[status]

...

String

...

Contact status

...

First Name

...

data[first_name]

...

String

...

Contact first name

...

Last Name

...

data[last_name]

...

String

...

Contact last name

...

Email Address

...

data[email]

...

String

...

Contact email address

...

Primary Phone

...

data[primary_phone]

...

String

...

Contact primary phone

...

Secondary Phone

...

data[secondary_phone]

...

String

...

Contact secondary phone

...

Full Address

...

data[full_address]

...

String

...

Contact full address

...

Notes

...

data[notes]

...

String

...

Contact notes

...

Categories

...

Categories

...

data[categories]

...

Array

...

Contains categories names.

Updating Contact

API Path: /api/contact/<id>

HTTP Verb: POST

Form Parameters:

...

Name

...

Key

...

Values

...

Required

...

Comments

...

Contact

...

First Name

...

first_name

...

String

...

Yes

...

Last name of the contact

...

Last Name

...

last_name

...

String

...

Yes

...

Last name of the contact

...

Email Address

...

email

...

String

...

Yes

...

Email address of the customer

...

Primary Phone

...

primary_phone

...

String

...

No

...

Primary phone number of the customer

...

Full Address

...

full_address

...

String

...

Yes

...

Full address of the customer

...

Business Name

...

business_name

...

String

...

No

...

Business name of the contact

...

Full Address

...

full_address

...

String

...

Yes

...

Contact and Site full address.

...

Notes

...

notes

...

String

...

No

...

Notes for this customer

...

Business Name as Client

...

business_as_client

...

Boolean

...

No

...

Whether to set the Site name the same as the Business Name.

...

Source

...

source

...

String

...

No

...

Contact source it can be one of the following: Other, TV, Radio, Press, Google, Tradeshow, Friends, Website, Word of Mouth

...

Status

...

status

...

String

...

No

...

Status can be one of the following: Lead, Active, Closed

...

Categories

...

categories[category_name]

...

Array of Strings

...

No

...

Business Category of the Contact.

...

Custom Fields

...

Custom Fields

...

custom_fields[field_name]

...

Array of Strings

...

Yes or No

...

Contact custom fields that the business has. The requirement depends on the creation of the field.

Sample PHP Code Using cURL:

<?php

$url = 'http://dev.solarplus.co/api/contact/19668;

'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC93d3cuc29sYXJwbHVzLmNvbVwvYXBpXC8iLCJpYXQiOjE0OTg0OTEwMTgsImV4cCI6MTUzMDAzMTAxOCwidHRsIjoiMy4xNTRlKzciLCJ1aWQiOiIxMTI5In0.hfg_GnZSzsFbCesTMGr2CqJAZr8V7lCN6diL95COx60';

$auth_header = 'Authorization Bearer ' . $token;

$form = array(

   'first_name' => 'John',

   'last_name' => 'Doe',

   'email' => 'john.doe@domain.com',

   'primary_phone' => '123-123-123',

   'full_address' => '222 Exhibition St, Melbourne VIC 3000, Australia',

   'business_name' => 'John Solar Power',

   'notes' => 'Nullam id dolor id nibh ultricies vehicula ut id elit.'

   'categories' => array(

       'Category 1' => 'Some value',

   ),

   'custom_fields' => array(

       'custom_text_12' => 'Some value',

   ),

);

$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $auth_header));

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($form));

$response = curl_exec($ch);

$json = json_decode($response);

curl_close($ch);

echo '<pre>';

print_r($json);

echo '</pre>';

JSON Response:

{
   "success": "true",
   "message": "Contact successfully updated.",
   "data": {
       "id": "19670",

       "business_name": null,

       "business_as_client": 0,

       "source": "Other",

       "status": "Lead",

       "first_name": "John",

       "last_name": "Doe",

       "email": "john.doe@domain.com",

       "primary_phone": "123-123-123",

       "secondary_phone": null,

       "full_address": "222 Exhibition St, Melbourne VIC 3000, Australia",

       "categories": null,

       "notes": "Nullam id dolor id nibh ultricies vehicula ut id elit."
   }
}

Response Table:

...

Name

...

Key

...

Values

...

Description

...

Status

...

Success

...

success

...

Boolean

...

A boolean value, if true then request was a success and failed in other case.

...

Message

...

message

...

String or Array

...

A descriptive message about the status of the request.

...

Data

...

Customer Id

...

data[customer_id]

...

Integer

...

The customer identification number.

...

Business Name

...

data[business_name]

...

String

...

Business name of the contact

...

Business Name as Client

...

data[business_as_client]

...

Boolean

...

Whether it was set to the Site name the same as the Business Name.

...

Source

...

data[source]

...

String

...

Contact source

...

Status

...

data[status]

...

String

...

Contact status

...

First Name

...

data[first_name]

...

String

...

Contact first name

...

Last Name

...

data[last_name]

...

String

...

Contact last name

...

Email Address

...

data[email]

...

String

...

Contact email address

...

Primary Phone

...

data[primary_phone]

...

String

...

Contact primary phone

...

Secondary Phone

...

data[secondary_phone]

...

String

...

Contact secondary phone

...

Full Address

...

data[full_address]

...

String

...

Contact full address

...

Notes

...

data[notes]

...

String

...

Contact notes

...

Categories

...

Categories

...

data[categories]

...

Array

...

Contains categories names.

Deleting Contact

API Path: /api/contact/<id>

HTTP Verb: DELETE

Form Parameters:

...

Name

...

Key

...

Values

...

Required

...

Comments

Sample PHP Code Using cURL:

<?php

$url = 'http://dev.solarplus.co/api/contact/19668;

'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC93d3cuc29sYXJwbHVzLmNvbVwvYXBpXC8iLCJpYXQiOjE0OTg0OTEwMTgsImV4cCI6MTUzMDAzMTAxOCwidHRsIjoiMy4xNTRlKzciLCJ1aWQiOiIxMTI5In0.hfg_GnZSzsFbCesTMGr2CqJAZr8V7lCN6diL95COx60';

$auth_header = 'Authorization Bearer ' . $token;

$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $auth_header));

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

$json = json_decode($response);

curl_close($ch);

echo '<pre>';

print_r($json);

echo '</pre>';

JSON Response:

{

   "success": true,

   "message": "Successfully deleted contact record."

}

Response Table:

...

Name

...

Key

...

Values

...

Description

...

Status

...

Success

...

success

...

Boolean

...

A boolean value, if true then request was a success and failed in other case.

...

Message

...

message

...

String or Array

...

A descriptive message about the status of the request.

Getting Contact Fields

API Path: /contact/fields

HTTP Verb: GET

Form Parameters:

...

Name

...

Key

...

Values

...

Required

...

Comments

Sample PHP Code Using cURL:

<?php

$url = 'http://dev.solarplus.co/api/contact/fields;

$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC93d3cuc29sYXJwbHVzLmNvbVwvYXBpXC8iLCJpYXQiOjE0OTg0OTEwMTgsImV4cCI6MTUzMDAzMTAxOCwidHRsIjoiMy4xNTRlKzciLCJ1aWQiOiIxMTI5In0.hfg_GnZSzsFbCesTMGr2CqJAZr8V7lCN6diL95COx60';

$auth_header = 'Authorization Bearer ' . $token;

$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $auth_header));

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

$json = json_decode($response);

curl_close($ch);

echo '<pre>';

print_r($json);

echo '</pre>';


JSON Response:

{

   "success": true,

   "message": "Successfully retrieve Contact fields list.",

   "data": {

       "fields": [

           {

               "name": "business_name",

               "label": "Business Name (opt)",

               "type": "text",

               "required": false

           },

           {

               "name": "business_as_client",

               "label": "Use Bus. Name as Client",

               "type": "checkbox",

               "required": false

           },

           {

               "name": "source",

               "label": "Source",

               "type": "select",

               "required": true,

               "options": [

                   {

                       "value": 0,

                       "label": "Other"

                   },

                   {

                       "value": 1,

                       "label": "TV"

                   },

                   {

                       "value": 2,

                       "label": "Radio"

                   },

                   {

                       "value": 3,

                       "label": "Press"

                   },

                   {

                       "value": 4,

                       "label": "Google"

                   },

                   {

                       "value": 5,

                       "label": "Tradeshow"

                   },

                   {

                       "value": 6,

                       "label": "Friends"

                   },

                   {

                       "value": 7,

                       "label": "Website"

                   },

                   {

                       "value": 8,

                       "label": "Word of Mouth"

                   }

               ]

           },

           {

               "name": "status",

               "label": "Status",

               "type": "select",

               "required": true,

               "options": [

                   {

                       "value": 0,

                       "label": "Lead"

                   },

                   {

                       "value": 1,

                       "label": "Active"

                   },

                   {

                       "value": 2,

                       "label": "Closed"

                   }

               ]

           },

           {

               "name": "first_name",

               "label": "First Name",

               "type": "text",

               "required": true

           },

           {

               "name": "last_name",

               "label": "Last Name",

               "type": "text",

               "required": true

           },

           {

               "name": "email",

               "label": "Email",

               "type": "email",

               "required": false

           },

           {

               "name": "primary_phone",

               "label": "Primary Phone",

               "type": "text",

               "required": false

           },

           {

               "name": "secondary_phone",

               "label": "Secondary Phone",

               "type": "text",

               "required": false

           },

           {

               "name": "notes",

               "label": "Notes",

               "type": "textarea",

               "required": false

           },

           {

               "name": "full_address",

               "label": "Full Address",

               "type": "textarea",

               "required": true

           }

       ],

       "categories": []

   }

}

Response Table:

...

Name

...

Key

...

Values

...

Description

...

Status

...

Success

...

success

...

Boolean

...

A boolean value, if true then request was a success and failed in other case.

...

Message

...

message

...

String or Array

...

A descriptive message about the status of the request.

...

Data

...

Fields

...

data[fields]

...

Array

...

This will contain the list of available contact fields. The items will contain Name, Label, Type, Required, Options (if it is a select input)

Getting Contact Custom Fields

API Path: /contact/custom-fields

HTTP Verb: GET

Form Parameters:

...

Name

...

Key

...

Values

...

Required

...

Comments

Sample PHP Code Using cURL:

<?php

$url = 'http://dev.solarplus.co/api/contact/fields;

$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC93d3cuc29sYXJwbHVzLmNvbVwvYXBpXC8iLCJpYXQiOjE0OTg0OTEwMTgsImV4cCI6MTUzMDAzMTAxOCwidHRsIjoiMy4xNTRlKzciLCJ1aWQiOiIxMTI5In0.hfg_GnZSzsFbCesTMGr2CqJAZr8V7lCN6diL95COx60';

$auth_header = 'Authorization Bearer ' . $token;

$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $auth_header));

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

$json = json_decode($response);

curl_close($ch);

echo '<pre>';

print_r($json);

echo '</pre>';

JSON Response:

{

   "success": true,

   "message": "Successfully retrieve Custom Contact fields list.",

   "data": {

       "fields": [

           {

               "name": "custom_text_12",

               "label": "Custom Text",

               "type": "text",

               "required": false

           },

           {

               "name": "custom_select_13",

               "label": "Custom Select",

               "type": "select",

               "required": false,

               "options": [

                   {

                       "value": "1",

                       "label": "One"

                   },

                   {

                       "value": "Two",

                       "label": "2"

                   },

                   {

                       "value": "Three",

                       "label": "3"

                   }

               ]

           }

       ]

   }

}

Response Table:

...

Name

...

Key

...

Values

...

Description

...

Status

...

Success

...

success

...

Boolean

...

A boolean value, if true then request was a success and failed in other case.

...

Message

...

message

...

String or Array

...

A descriptive message about the status of the request.

...

Data

...

Fields

...

data[fields]

...

Array

...

See full documentation of this API at:
https://docs.google.com/document/d/1Ng9jSEO5KRzmsCLuAFBNjAQ7hNcBP7Jx5FmgTDOC0oY?usp=sharing


See related information:

Quote API & Webhooks Guide