Create Customer
Create a new customer record in your Solar Proof account via the API.
POST
https://solarproof.com.au/apidata.php
Description
Creates a new customer in your Solar Proof account. The customer will be associated with the user
specified by the useremail
parameter. After successful creation, the API returns the
new customer's ID which can be used for subsequent API calls.
Important: The
useremail
must correspond to an existing user
in your Solar Proof account. If left empty, the customer will be assigned to the API key owner.
Request Parameters
Authentication: Include your API key in the URL query string
?api_key=YOUR_API_KEY
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
api_key |
string | Required | Your Solar Proof API key |
action |
string | Required | Must be set to "createcustomer" |
Request Body (JSON)
Send a JSON object in the request body with a data
key containing the following fields:
Field | Type | Required | Description |
---|---|---|---|
apikey |
string | Required | Your Solar Proof API key (can also be in URL) |
action |
string | Required | Must be "createcustomer" |
useremail |
string | Optional | Email of the user who will own this customer (defaults to API key owner) |
firstname |
string | Required | Customer's first name |
surname |
string | Required | Customer's last name |
email |
string | Required | Customer's email address |
phone1 |
string | Required | Primary phone number |
phone2 |
string | Optional | Secondary phone number |
type |
string | Required | Customer type: "RESIDENTIAL" , "COMMERCIAL" , or "LARGE-SCALE" |
companyname |
string | Optional | Company name (for commercial customers) |
companyphone |
string | Optional | Company phone number |
gststatus |
integer | Optional | GST registration status: 1 = registered, 0 = not registered |
Response
Success Response (200 OK)
Response Body
JSON
{
"Message": "Customer created successfully!",
"id": "79459"
}
Field | Type | Description |
---|---|---|
Message |
string | Success message |
id |
string | The ID of the newly created customer |
Error Response (4xx/5xx)
Error Response
JSON
{
"code": "INVALID_PARAMETERS",
"message": "Required field 'firstname' is missing"
}
Error Code | Description |
---|---|
INVALID_API_KEY |
The provided API key is invalid or missing |
INVALID_PARAMETERS |
Required parameters are missing or invalid |
USER_NOT_FOUND |
The specified useremail does not exist |
DUPLICATE_EMAIL |
A customer with this email already exists |
Example Request
cURL
bash
curl -X POST "https://solarproof.com.au/apidata.php?api_key=YOUR_API_KEY&action=createcustomer" \
-H "Content-Type: application/json" \
-d '{
"data": {
"apikey": "YOUR_API_KEY",
"action": "createcustomer",
"useremail": "",
"firstname": "John",
"surname": "Smith",
"phone1": "0412345678",
"phone2": "0298765432",
"email": "john.smith@example.com",
"gststatus": 1,
"companyname": "Smith Solar Solutions",
"companyphone": "1300123456",
"type": "RESIDENTIAL"
}
}'
JavaScript (Fetch)
javascript
const apiKey = 'YOUR_API_KEY';
const url = `https://solarproof.com.au/apidata.php?api_key=${apiKey}&action=createcustomer`;
const customerData = {
data: {
apikey: apiKey,
action: 'createcustomer',
useremail: '',
firstname: 'John',
surname: 'Smith',
phone1: '0412345678',
phone2: '0298765432',
email: 'john.smith@example.com',
gststatus: 1,
companyname: 'Smith Solar Solutions',
companyphone: '1300123456',
type: 'RESIDENTIAL'
}
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(customerData)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
PHP
php
<?php
$apiKey = 'YOUR_API_KEY';
$url = "https://solarproof.com.au/apidata.php?api_key={$apiKey}&action=createcustomer";
$data = [
'data' => [
'apikey' => $apiKey,
'action' => 'createcustomer',
'useremail' => '',
'firstname' => 'John',
'surname' => 'Smith',
'phone1' => '0412345678',
'phone2' => '0298765432',
'email' => 'john.smith@example.com',
'gststatus' => 1,
'companyname' => 'Smith Solar Solutions',
'companyphone' => '1300123456',
'type' => 'RESIDENTIAL'
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
?>
Python
python
import requests
import json
api_key = 'YOUR_API_KEY'
url = f'https://solarproof.com.au/apidata.php?api_key={api_key}&action=createcustomer'
customer_data = {
'data': {
'apikey': api_key,
'action': 'createcustomer',
'useremail': '',
'firstname': 'John',
'surname': 'Smith',
'phone1': '0412345678',
'phone2': '0298765432',
'email': 'john.smith@example.com',
'gststatus': 1,
'companyname': 'Smith Solar Solutions',
'companyphone': '1300123456',
'type': 'RESIDENTIAL'
}
}
response = requests.post(
url,
headers={'Content-Type': 'application/json'},
data=json.dumps(customer_data)
)
print(response.json())