Introduction Getting Started Create Customer Update Customer Login Customer Get Customer Information Reset Customer Password Create Order Update an Order Delete an Order Create Repeat Pickup Delete Repeat Pickup Get Repeat Pickups Get Orders Get Products Get Pickup/Delivery Dates Get Pickup/Delivery Times Get Route from Lat/Lng Get Referral Code and Gift Use Promo Code Add Subscription Add Credit Card

Introduction

The CleanCloud API allows you to send information into and out of CleanCloud. It is typically used for the following use cases

The API is a RESTful API, and requires you to use POST requests to communicate with it. You can use any programming language to communicate with the API, and we have code examples for PHP below

Getting Started

To begin you will need to:

Once done you be able to complete the following tasks

Create a Customer Account

To create a customer account you send a POST request to https://cleancloudapp.com/api/addCustomer with the below parameters. The response will contain the ID of the newly created customer account which you will need to store on your server to perform other tasks for this customer.

Parameter Description Required
api_token Your secret API token Y
customerName Name of Customer Y
customerTel Telephone number of customer Y
customerEmail Email of customer Y
customerAddress Address of customer
customerRoute Route Number of Customer
customerLat Latitude of customer address
customerLng Longitude of customer address
makeLatLng Have CleanCloud convert customer address to Latitude / Longitude
1 = convert address to GPS co-ordinates
findRoute Have CleanCloud assign customer to route based on customer address and your geofences
1 = assign to route based on customer address/GPS co-ordinates
customerNotes Saved Notes for customer account
customerPassword Password for customer account, only required if CleanCloud will handle customer login
promoCode Invite or Promo Code that customer can use on signup
marketingOptIn If a customer provides marketing permission 1 = opt in, 0 = no permission given
stripe Stripe customer token
evoToken EVO card token

PHP Code Example

//SET YOUR TOKEN HERE $api_token = "MY_API_TOKEN"; $url="https://cleancloudapp.com/api/addCustomer"; //CREATE JSON ARRAY TO SEND $jsonArray = array('api_token' => $api_token, 'customerName' => 'John Doe', 'customerTel' => '5554432324', 'customerEmail' => 'emailexample@email.com', 'customerAddress' => '113 Street Avenue, New York, 10012', 'customerNotes' => 'Notes about the customer'); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //SUCCESS AND RETURNS CUSTOMER ID. YOU WILL NEED THIS CUSTOMER ID FOR WHEN YOU SEND IN NEW ORDERS INTO CLEANCLOUD echo "Success Submitting to API with New Customer ID: ".$json_response->CustomerID; } else if($json_response->Error!="") { echo "Error Submitting to API: ".$json_response->Error; die(); } }

Update a Customer Account

To update a customer account you send a POST request to https://cleancloudapp.com/api/updateCustomer with the below parameters. Only submit the parameters that you wish to update.

Parameter Description Required
api_token Your secret API token Y
customerID ID of Customer Y
customerName Name of Customer
customerTel Telephone number of customer
customerEmail Email of customer
customerAddress Address of customer
customerRoute Route Number of Customer
customerLat Latitude of customer address
customerLng Longitude of customer address
makeLatLng Have CleanCloud convert customer address to Latitude / Longitude
1 = convert address to GPS co-ordinates
findRoute Have CleanCloud assign customer to route based on customer address and your geofences
1 = assign to route based on customer address/GPS co-ordinates
customerPassword Password for customer account
customerNotes Saved Notes for customer account
stripe Stripe customer token
evoToken EVO card token

PHP Code Example

//SET PARAMETERS $api_token = "MY_API_TOKEN"; $url="https://cleancloudapp.com/api/updateCustomer"; //SET CUSTOMER ID. THIS IS THE CUSTOMER YOU ARE UPDATING $customerID="1"; /// ///WHEN UPDATING YOU SHOULD ONLY SEND THE FIELDS THAT WISH TO UPDATE. /// //EXAMPLE 1: CHANGE ONLY CUSTOMER PHONE NUMBER $jsonArray = array("api_token" => $api_token, "customerID" => $customerID, "customerTel" => "55512321"); //EXAMPLE 2: UPDATE ALL AVAILABLE FIELDS IN THE API $jsonArray = array("api_token" => $api_token, "customerID" => $customerID, "customerName" => "New Name", "customerTel" => "12345", "customerEmail" => "apiupdate@cleancloudapp.com", "customerAddress" => "20 API Street, API Land", "customerNotes" => "New Customer Notes from API"); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //CUSTOMER UPDATED echo "Success Submitting to API"; } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD. PLEASE CORRECT THE ERROR MENTIONED echo "Error Submitting to API: ".$json_response->Error; die(); } }

Login to Customer Account

To check the email and password of a customer and retrieve their customer ID you can send a POST request to https://cleancloudapp.com/api/loginCustomer with the below parameters

Parameter Description Required
api_token Your secret API token Y
customerEmail Email of the customer Y
customerPassword Password of the customer Y

PHP Code Example

//SET PARAMETERS $api_token = "MY_API_TOKEN"; $url="https://cleancloudapp.com/api/loginCustomer"; /// //CREATE JSON ARRAY /// $jsonArray = array("api_token" => $api_token, "customerEmail" => "emailexample@email.com", "customerPassword" => "thisWasMyPassword"); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //SUCCESSFUL LOGIN echo "Success Logging In with ID: ".$json_response->cid; } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD. PLEASE CORRECT THE ERROR MENTIONED echo "Error Submitting to API: ".$json_response->Error; die(); } }

Get Customer Information

To retrieve available information about a customer you send a POST request to https://cleancloudapp.com/api/getCustomer with the below parameters

Parameter Description Required
api_token Your secret API token Y
customerID ID of the customer Y

PHP Code Example

//SET TOKEN $api_token = "MY_API_TOKEN"; //URL FOR GET CUSTOMER $url="https://cleancloudapp.com/api/getCustomer"; //CUSTOMER ID THAT YOU WANT INFORMATION FOR $customerID="12"; $jsonArray = array("api_token" => $api_token, "customerID" => $customerID); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //SUCCESS echo "Success Getting Customer Information: ".$json_response->Success; //SHOW RESPONSE IN JSON var_dump($json_response); } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD echo "Error Submitting to API: ".$json_response->Error; die(); } }

Reset Customer Password

To iniate a password reset for a customer and send them an email with reset instructions you send a POST request to https://cleancloudapp.com/api/passwordCustomer with the below parameters

Parameter Description Required
api_token Your secret API token Y
customerEmail Email of the customer Y

Create an Order

To create an order you send a POST request to https://cleancloudapp.com/api/addOrder with the below parameters. You will need the ID of the customer account that you are creating the order for. This ID is obtained when you create a customer using the API.

Parameter Description Required
api_token Your secret API token Y
customerID ID of the customer Y
finalTotal Final value of the order Y
discount Discount amount applied to order
creditUsed Amount of credit used with this order
Will return error if more used than available on customer account
tax Tax amount applied to the order
tax2 Second Tax amount applied to the order
tip Tip amount applied to the order
express Specify if the order is express or not. 0 = Normal, 1 = Express
products Associative Array of products in the order
pickupDate Unix timestamp of pickup date, set without timezone at 12pm UTC time
pickupStart Start time for pickup, set with 12 hour clock (e.g. 10am)
pickupEnd End time for pickup, set with 12 hour clock (e.g. 11am)
delivery Whether the order is a delivery or not 1 = Order will also be a delivery, 0 = no delivery
deliveryDate Unix timestamp of delivery date, set without timezone at 12pm UTC time
deliveryStart Start time for delivery, set with 12 hour clock (e.g. 10am)
deliveryEnd End time for delivery, set with 12 hour clock (e.g. 11am)
orderNotes Notes for the order
notifyMethod How to notify customer on order status changes1 = SMS, 2 = EMAIL, 3 = DO NOT NOTIFY, 4 = EMAIL & SMS
priceListID If you are using a custom price list from CleanCloud, Leave blank or 0 for default
sendEmail Send email notification to the customer. 1 = send them an email
staffVerify Staff need to approve the order in the POS. 1 = require staff approval

PHP Code Example

//SET PARAMETERS $api_token = "MY_API_TOKEN"; $url="https://cleancloudapp.com/api/addOrder"; //SET CUSTOMER ID $customerID="1"; //CREATE LIST OF PRODUCTS OF ORDER IN AN ARRAY $products_array = array(); //NOTES: /// ID CORRESPONDS TO ID OF PRODUCT IN YOUR CLEANCLOUD ACCOUNT, IF ITEM DOES NOT EXIST IN CLEANCLOUD THEN CREATE ONE TIME CUSTOM ITEM BY SETTING ID TO 0. YOU CAN USE UP TO 5 CUSTOM PRODUCTS PER ORDER /// ALL FIELDS MUST BE PROVIDED /// PIECES IS PIECES PER ITEM. FOR EXAMPLE SPECIFYING 2 PIECES AND 2 QUANTITY MEANS 4 PIECES IN TOTAL /// PRICE IS PRICE PER ITEM. FOR EXAMPLE PRICE OF $20 AND QUANTITY OF 2 MEANS $40 TOTAL $product1 = array("id" => "10", "price" => "45", "pieces" => "1", "quantity" => "1", "name" => "Product Name"); $product2 = array("id" => "9", "price" => "20", "pieces" => "2", "quantity" => "2", "name" => "Second Product"); $productCustom = array("id" => "0", "price" => "10", "pieces" => "1", "quantity" => "3", "name" => "Custom Product Name"); //PUSH ITEMS INTO PRODUCTS ARRAY FOR JSON. PRODUCTS ARRAY WILL BE NESTED INSIDE THE MAIN JSON ARRAY SENT TO CLEANCLOUD API $products_array[] = $product1; $products_array[] = $product2; $products_array[] = $productCustom; /// //CREATE JSON ARRAY /// $jsonArray = array("api_token" => $api_token, "customerID" => $customerID, "products" => $products_array, "discount" => "1.05", "tax" => "1.07", "finalTotal" => "10.06", "pickupStart" => "10am", "pickupDate" => "1505736000", "pickupEnd" => "11am", "delivery" => "1", "deliveryDate" => "1506686400","deliveryStart" => "1pm", "deliveryEnd" => "2pm", "orderNotes" => "Notes for the Order", "notifyMethod" => "2", "priceListID" => ""); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //ORDER SUCCESSFULLY INSERTED INTO CLEANCLOUD ACCOUNT AND RETURNS ORDER ID FROM CLEANCLOUD echo "Success Submitting to API with New ORDER ID: ".$json_response->orderID; } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD, ORDER WAS NOT INSERTED INTO ACCOUNT. PLEASE CORRECT THE ERROR MENTIONED echo "Error Submitting to API: ".$json_response->Error; die(); } }

Update an Order

To update an order you send a POST request to https://cleancloudapp.com/api/updateOrder with the below parameters. You will need the ID of the order that you are updating. Only submit the parameters that you wish to update.

Parameter Description Required
api_token Your secret API token Y
orderID ID of the order Y
customerID ID of the customer
finalTotal Final value of the order
discount Discount amount applied to order
tax Tax amount applied to the order
tax2 Second Tax amount applied to the order
tip Tip amount applied to the order
pickupDate Unix timestamp of pickup date, set without timezone at 12pm UTC time
pickupStart Start time for pickup, set with 12 hour clock (e.g. 10am)
pickupEnd End time for pickup, set with 12 hour clock (e.g. 11am)
delivery Whether the order is a delivery or not (1 or 0)
deliveryDate Unix timestamp of delivery date, set without timezone at 12pm UTC time
deliveryStart Start time for delivery, set with 12 hour clock (e.g. 10am)
deliveryEnd End time for delivery, set with 12 hour clock (e.g. 11am)
orderNotes Notes for the order
notifyMethod How to notify customer on order status changes1 = SMS, 2 = EMAIL, 3 = DO NOT NOTIFY, 4 = EMAIL & SMS
priceListID If you are using a custom price list from CleanCloud, Leave blank or 0 for default
paid If the order is paid or not.1 = Paid, 0 = Unpaid
paymentType The payment type used0 = No payment type, 1 = Cash, 2 = Card, 3 = Check
status The status of the order.4 = Awaiting Pickup, 0 = Cleaning, 1 = Cleaned and Ready to Deliver, 2 = Completed

PHP Code Example

//SET PARAMETERS $api_token = "MY_API_TOKEN"; $url="https://cleancloudapp.com/api/updateOrder"; //SET ORDER ID. THIS IS THE ORDER ID YOU ARE UPDATING $orderID="255"; /// ///WHEN UPDATING YOU SHOULD ONLY SEND THE FIELDS THAT WISH TO UPDATE. /// //EXAMPLE 1: SET ORDER AS PAID, WITH PAYMENT TYPE PAID BY CARD $jsonArray = array("api_token" => $api_token, "orderID" => $orderID, "paid" => "1", "paymentType" => "2"); //EXAMPLE 2: JUST UPDATING STATUS OF ORDER $jsonArray = array("api_token" => $api_token, "orderID" => $orderID, "status" => "2"); //EXAMPLE 3: UPDATE LOTS OF FIELDS IN THE API, INCLUDING CHANGING THE CUSTOMER ID $customerID = 1; $jsonArray = array("api_token" => $api_token, "orderID" => $orderID, "customerID" => $customerID, "status" => "2", "discount" => "1.05","discount" => "1.05", "tax" => "1.07", "tax2" => "0.95", "finalTotal" => "10.06", "pickupStart" => "10am", "pickupDate" => "1505736000", "pickupEnd" => "11am", "delivery" => "1", "deliveryDate" => "1506686400","deliveryStart" => "1pm", "deliveryEnd" => "2pm", "orderNotes" => "New Notes for the Order", "paid" => "1", "paymentType" => "2"); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //ORDER SUCCESSFULLY UPDATED echo "Success Submitting to API"; } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD echo "Error Submitting to API: ".$json_response->Error; die(); } }

Delete an Order

You can delete an existing order by sending a POST request to https://cleancloudapp.com/api/deleteOrder with the below parameters

Parameter Description Required
api_token Your secret API token Y
orderID ID of the order Y

PHP Code Example

//SET PARAMETERS $api_token = "MY_API_TOKEN"; $url="https://cleancloudapp.com/api/deleteOrder"; $orderID="670"; $jsonArray = array("api_token" => $api_token, "orderID" => $orderID); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { echo "Success"; //SHOW RESPONSE IN JSON var_dump($json_response); } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD. PLEASE CORRECT THE ERROR MENTIONED echo "Error Submitting to API: ".$json_response->Error; die(); } }

Create Repeat Pickup

Create a Repeat Pickup order by sending a POST request to https://cleancloudapp.com/api/repeatPickup with the below parameters

Parameter Description Required
api_token Your secret API token Y
customerID ID of the customer Y
pickupDate Unix timestamp of first pickup date, set without timezone at 12pm UTC time Y
pickupStart Start time for pickup, set with 12 hour clock (e.g. 11am) Y
pickupEnd End time for pickup, set with 12 hour clock (e.g. 1pm) Y
frequency How often the pickup should repeat
1=Every week, 2=Every 2 weeks, 3=Every 3 weeks, 4=Every 4 weeks
Y
duration How many times this pickup should repeat
0=Until cancelled, 1=1 order, 2=2 orders, ... 20 = 20 orders
Y
deliveryDays How many days after the pickup the delivery should be
0=Do not set, 1= +1 day from Pickup, 2= +2 days, 3= +3 days...
Y
deleteOld Delete any old repeat pickups for this customer
1 = delete

Delete Repeat Pickup

Delete a Repeat Pickup for a customer by sending a POST request to https://cleancloudapp.com/api/deletePickup with the below parameters

Parameter Description Required
api_token Your secret API token Y
customerID ID of the customer Y
pickupID ID of the pickup Y

Get Repeat Pickups

Get a list of Repeat Pickups for a customer by sending a POST request to https://cleancloudapp.com/api/getPickups with the below parameters

Parameter Description Required
api_token Your secret API token Y
customerID ID of the customer Y

Get List of Orders

This POST request allows you to return a JSON response of details for a particular order or multiple orders, which can be filtered using the parameters below.

Parameter Description Required
api_token Your secret API token Y
orderID ID of the order
customerID ID of the customer
status Status of the order(s)
4 = Awaiting Pickup, 0 = Cleaning, 1 = Cleaned and Ready to Deliver, 2 = Completed
completed If order(s) have been completed or not. 0 = not complete, 1 = complete
paid If order(s) have been paid or not. 0 = not paid, 1 = paid

PHP Code Example

//SET TOKEN $api_token = "MY_API_TOKEN"; //URL FOR GET ORDERS $url="https://cleancloudapp.com/api/getOrders"; //CUSTOMER ID $customerID="19"; $jsonArray = array("api_token" => $api_token, "customerID" => $customerID); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { echo "Success Getting Orders: ".$json_response->Success; //SHOW RESPONSE IN JSON var_dump($json_response); } else if($json_response->Error!="") { //ERROR WITH DATA SENT TO CLEANCLOUD echo "Error Submitting to API: ".$json_response->Error; die(); } }

Get List of Products

This POST request to https://cleancloudapp.com/api/getProducts allows you to return a JSON response of all active products, by sending the following parameters.

Parameter Description Required
api_token Your secret API token Y
priceListID ID of the price list

PHP Code Example

//SET TOKEN $api_token = "MY_API_TOKEN"; //URL FOR GET PRODUCTS $url="https://cleancloudapp.com/api/getProducts"; //PRICE LIST ID (optional) $priceListID=""; $jsonArray = array("api_token" => $api_token, "priceListID" => $priceListID); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { echo "Success Getting Products: ".$json_response->Success; //SHOW RESPONSE IN JSON var_dump($json_response); } else if($json_response->Error!="") { //ERROR WITH DATA SENT TO CLEANCLOUD echo "Error Submitting to API: ".$json_response->Error; die(); } }

Get Available Pickup/Delivery Dates

This POST request to https://cleancloudapp.com/api/getDates allows you to return a JSON response of all the available pickup and delivery dates with their available slot times for a particular route, by sending the following parameters. The response will contain a list of dates, with available slot times and the remaining number of available slots.

Parameter Description Required
api_token Your secret API token Y
routeID ID of the Route Y

PHP Code Example

//SET TOKEN $api_token = "MY_API_TOKEN"; //URL FOR GET DATES $url="https://cleancloudapp.com/api/getDates"; $jsonArray = array("api_token" => $api_token, "routeID" => '1'); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //SHOW RESPONSE IN JSON var_dump($json_response); } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD echo "Error Submitting to API: ".$json_response->Error; die(); } }

Get Available Pickup/Delivery Times

This POST request to https://cleancloudapp.com/api/getSlots allows you to return a JSON response of all the available pickup and delivery slots for a particular route on a particular day, by sending the following parameters. The response will contain a comma separated list of available slot times.

Parameter Description Required
api_token Your secret API token Y
routeID ID of the Route Y
day Unix Timestamp of the Day without timezone at 12pm UTC time Y

PHP Code Example

//SET TOKEN $api_token = "MY_API_TOKEN"; //URL FOR GET SLOTS $url="https://cleancloudapp.com/api/getSlots"; $jsonArray = array("api_token" => $api_token, "routeID" => '1', "day" => '1558353600'); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //SHOW RESPONSE IN JSON var_dump($json_response); } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD echo "Error Submitting to API: ".$json_response->Error; die(); } }

Get Route Number from Latitude/Longitude

This POST request to https://cleancloudapp.com/api/getRoute allows you to send in latitude/longitude values for a customer address and return a JSON response with the route number. If no route is available for that route an error will return. If you only have the street address of the customer, you will need to use a service like the Google Maps Geocode API to convert the street address to latitude and longitude values

Parameter Description Required
api_token Your secret API token Y
lat Latitude of the address Y
lng Longitude of the address Y

PHP Code Example

//SET TOKEN $api_token = "MY_API_TOKEN"; //URL FOR GET SLOTS $url="https://cleancloudapp.com/api/getRoute"; $jsonArray = array("api_token" => $api_token, "lat" => '10.14', "lng" => '34.43'); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //SHOW RESPONSE IN JSON var_dump($json_response); } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD echo "Error Submitting to API: ".$json_response->Error; die(); } }

Get Referral Code and Gift

This POST request to https://cleancloudapp.com/api/getReferral allows you to get the unique referral code for a customer and the gift that they and the customer they they refer will receive

Parameter Description Required
api_token Your secret API token Y
customerID ID of the Customer Y

PHP Code Example

//SET TOKEN $api_token = "MY_API_TOKEN"; //URL FOR GET CUSTOMER $url="https://cleancloudapp.com/api/getReferral"; //CUSTOMER ID THAT YOU WANT INFORMATION FOR $customerID="12"; $jsonArray = array("api_token" => $api_token, "customerID" => $customerID); $postFields = json_encode($jsonArray); //SEND TO CLEANCLOUD API USING CURL $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$postFields); $response = curl_exec($ch); curl_close($ch); $json_response=json_decode($response); if(curl_error($ch)) { //ERROR SENDING TO CLEANCLOUD API echo "Error with cURL Submitting to API: ".curl_error($ch); die(); } else { if($json_response->Success=="True") { //SUCCESS echo "Success Getting Customer Information: ".$json_response->Success; //SHOW RESPONSE IN JSON var_dump($json_response); } else if($json_response->Error!="") { //ERROR WITH DATA THAT SENT TO CLEANCLOUD echo "Error Submitting to API: ".$json_response->Error; die(); } }

Use Promo Code

This POST request to https://cleancloudapp.com/api/usePromo allows you use a promo code. This will update the customer's account with their new discount/credit level and the response will contain the discount percentage or credit amount to apply to the customer's order

Parameter Description Required
api_token Your secret API token Y
customerID ID of the Customer Y
promoCode The promo code Y

Add Subscription to Customer Account

This POST request to https://cleancloudapp.com/api/addSubscription allows you to subscribe a customer to a regular subscription created in Stripe and begin charging them. If the Error response is "3D Secure Authentication required", then you will need to prompt the user to authenticate, then send again with subscriptionConfirmed = 1 if authentication was successful.

Parameter Description Required
api_token Your secret API token Y
customerID ID of the Customer Y
subscriptionID plan ID of subscription e.g. plan_JNIndsfsdfvc Y
subscriptionConfirmed Only set to 1 if 3D Secure Authentication was triggered by previous response and was successfully authenticated

Add Credit Card to Customer Account

This POST request to https://cleancloudapp.com/api/addCard allows you to add a credit card to a customer account by sending in the card token

Parameter Description Required
api_token Your secret API token Y
customerID ID of the Customer Y
type 1 = Stripe save card
2 = Stripe request setup intent secret
3 = Clearent Save Card
Y
paymentMethodID The payment method ID or token for the tokenized card from Stripe / Clearent