Customers
The Customers API allows you create and manage customers on your integration.
Bunce creates customers for you from your providers, or you can create and manage them using the Dashboard or API.
Create a customer
Post
bash
https://api.bunce.so/v1/customers
Creates a new customer.
If successful, your response includes a copy of the new customer entity.
Request
Body Parameters required
customer_id string required | Customer's ID in your database |
email string<email> required | Customer's email address |
first_name string required | Customer's first name |
last_name string required | Customer's last name |
phone_no string required | Customer's phone number |
devices array<{ device_type: string; device_token: string; }> nullable | Customer's devices |
Devices Field
The devices
field is an optional array of device objects. Each device object should contain the following fields:
device_type
(string): The type of device (e.g.,ios
,android
).device_token
(string): The token associated with the device.
Example:
json
{
"devices": [
{
"device_type": "ios",
"device_token": "123456"
},
{
"device_type": "android",
"device_token": "654321"
}
]
}
bash
curl --request POST \
--url https://api.bunce.so/v1/customers \
--header 'Content-Type: application/json' \
--header 'X-Authorization: sk_live_************************' \
--data '{
"customer_id" : "0000",
"first_name": "John",
"last_name": "Doe",
"email": "johndoe@example.com",
"phone_no": "+23481999999999",
"devices": [
{
"device_type": "ios",
"device_token": "123456"
},
{
"device_type": "android",
"device_token": "654321"
}
]
}'
go
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
url := "https://api.bunce.so/v1/customers"
payload := strings.NewReader("{\n \"customer_id\": \"0000\", \n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"email\": \"johndoe@example.com\",\n \"phone_no\": \"+23481999999999\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Authorization", "sk_live_************************")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
js
import from 'node-fetch'
let = 'https://api.bunce.so/v1/customers'
let = {
: 'POST',
: {
'X-Authorization': 'sk_live_************************',
'Content-Type': 'application/json',
},
: '{"customer_id" : "0000","first_name":"John","last_name":"Doe","email":"johndoe@example.com","phone_no":"+23481999999999"}',
}
(, )
.then(() => .json())
.then(() => .())
.catch(() => .('error:' + ))
php
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"customer_id" : "0000",
"first_name": "John",
"last_name": "Doe",
"email": "johndoe@example.com",
"phone_no": "+23481999999999",
"devices": [
{
"device_type": "ios",
"device_token": "123456"
},
{
"device_type": "android",
"device_token": "654321"
}
]
}');
$request->setRequestUrl('https://api.bunce.so/v1/customers');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'X-Authorization' => 'sk_live_************************',
'Content-Type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
java
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.bunce.so/v1/customers"))
.header("X-Authorization", "sk_live_************************")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"customer_id\": \"0000\", \n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"email\": \"johndoe@example.com\",\n \"phone_no\": \"+23481999999999\"\n}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Response
json
{
"data": {
"customer_id": "0000",
"first_name": "John",
"last_name": "Doe",
"email": "johndoe@example.com",
"phone_no": "+23481999999999",
"customer_created_at": "2023-12-17T09:45:51.929682+01:00"
},
"message": "Customer created successfully",
"success": true
}