Create a Customer
Following endpoint will help you create a customer in Slotify using customer create endpoint:
Authentication
This endpoint needs app token for authentication.
Method | POST |
---|---|
Endpoint | v1/customers |
Headers | Accept: application/json |
Authorization: Bearer <base64_encoded_token> | |
Token type | App |
Query Parameters
This endpoint supports query parameters:
Field | Value | Description |
---|---|---|
include | meta,app,address | can include meta, app and address for customer |
search | email, first_name, last_name | you can search customer with their email, first or last name |
Request Body:
This endpoint requires following parameters to be sent via post body:
Param Name | Required | Description |
---|---|---|
true | Email for customer | |
first_name | true | First name of the customer |
last_name | true | Last name of the customer |
dob | false | Date of birth of customer |
phone | false | Phone number of customer |
notes | false | Notes for your customer |
avatar | false | Image link to customer image |
timezone | false | Timezone for your customer |
gender | false | Gender of your customer |
address | false | Address object that contains city, country, state, address1 and postal_code |
Example Request:
Following code shows how to send request to create a customer in Slotify api.
- PHP
- CURL
- JSON
$endpoint = 'https://api.slotify.ca/v1/customers';
$owner_token = base64_encode('app_token');
$data = array(
'first_name' => 'John',
'last_name' => 'Doe',
'email' => '[email protected]'
);
$post_data = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $endpoint,
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 => $post_data,
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . $owner_token,
'Accept: application/json',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
if(curl_errno($curl)) {
echo 'Error: ' . curl_error($curl);
} else {
echo $response;
}
curl_close($curl);
curl -X POST \
https://api.slotify.ca/v1/customers \
-H 'Authorization: Bearer <AppTokenEncodedBase64>' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"first_name": "Dedric",
"last_name": "Hayes",
"email": "[email protected]"
}'
{
"email": "[email protected]",
"last_name": "Hayes",
"first_name": "Dedric"
}
Example Response:
Following response will be provided by Slotify server when this endpoint is called:
- 201 Created
- 400 Bad Request
- 401 Unauthorized
{
"success": true,
"data": {
"name": "John Doe",
"dob": "1985-04-15",
"uuid": "8d6b241b-bd03-408e-825c-51f35e06a1da",
"phone": "699-868-4715",
"email": "[email protected]",
"notes": null,
"gender": "unknown",
"avatar": "https://cdn.fakercloud.com/avatars/djsherman_128.jpg",
"timezone": "America/New_York",
"last_name": "Doe",
"first_name": "John",
"created_at": "2024-04-29T23:15:14+00:00",
"updated_at": "2024-04-29T23:15:14+00:00"
}
}
{
"success": false,
"errors": {
"last_name": "This field is required",
"first_name": "This field is required",
"email": "This field is required"
}
}
{
"code": 401,
"message": "Unauthorized"
}