Create a Customer
Learn how to create or add a customer
There are two ways a customer can be added to your organisation — Banking and Payment. We also refer to them as "sources".
Source | Description |
---|---|
Banking | This is for customers that are added manually either via the Bloc Dashboard or via the API as outlined on this page. |
Payment | This is for customers that are automatically added when they make payment via Payment Links or passed through the Checkout API. |
On this page, you'll learn how to create a customer manually with banking
as the source. To view how to pass customer details via payments, go to the Checkout API.
Adding a customer
To create a customer, you need to pass information such as first name, last name, email, phone number, customer type and BVN.
All of the parameters are required to successfully create/add a customer.
curl --request POST \
--url https://api.blochq.io/v1/customers \
--header 'accept: application/json' \
--header 'authorization: Bearer sk_live_64520e0201478f5cd412865f64520e0201478f5cd4128660' \
--header 'content-type: application/json' \
--data '
{
"email": "[email protected]",
"phone_number": "08012345678",
"bvn": "00000000000",
"first_name": "Ayo",
"last_name": "Oladeji",
"customer_type": "Personal"
}
'
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.blochq.io/v1/customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer {secretKey}'
request.body = "{\"email\":\"[email protected]\",\"phone_number\":\"08012345678\",\"first_name\":\"Ayo\",\"bvn\":\"00000000000\",\"last_name\":\"Oladeji\",\"customer_type\":\"Personal\"}"
response = http.request(request)
puts response.read_body
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.blochq.io/v1/customers', [
'body' => '{"email":"[email protected]","phone_number":"08012345678","first_name":"Ayo","bvn":"00000000000","last_name":"Oladeji","customer_type":"Personal"}',
'headers' => [
'accept' => 'application/json',
'authorization' => 'Bearer {secretKey}',
'content-type' => 'application/json',
],
]);
echo $response->getBody();
import requests
url = "https://api.blochq.io/v1/customers"
payload = {
"email": "[email protected]",
"phone_number": "08012345678",
"first_name": "Ayo",
"bvn": "00000000000",
"last_name": "Oladeji",
"customer_type": "Personal"
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"authorization": "Bearer {secretKey}"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Important to Note:
Make sure that the BVN, first name and last name are valid. If they are not, you will not be able to do a lot with the customer.
Here's what a successful response looks like:
{
"success": true,
"data": {
"id": "644c946fb075737360d7a26d",
"full_name": "Oladeji Ayo",
"phone_number": "08012345678",
"organization_id": "{organizationID}",
"environment": "live",
"email": "[email protected]",
"country": "",
"group": "main",
"status": "active",
"created_at": "2023-04-29T03:52:15.544312495Z",
"updated_at": "0001-01-01T00:00:00Z",
"SyncData": {
"ID": null,
"Provider": ""
},
"first_name": "Ayo",
"last_name": "Oladeji",
"kyc_tier": "0",
"bvn": "00000000000",
"date_of_birth": "0001-01-01T00:00:00Z",
"customer_type": "personal",
"source": "Banking",
"address": {
"street": ""
}
},
"message": "Customer added successfully"
}
Updating a customer
To update a customer, all you need to do is pass the information you want to update with the customer_id
of the customer.
In the sample below, we want to change the customer's email address from [email protected] to [email protected]
curl --request PUT \
--url https://api.blochq.io/v1/customers/645474848c1ad9e3a7730a0a \
--header 'accept: application/json' \
--header 'authorization: Bearer sk_live_64520e0201478f5cd412865f64520e0201478f5cd4128660' \
--header 'content-type: application/json' \
--data '
{
"email": "[email protected]"
}
'
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.blochq.io/v1/customers/645474848c1ad9e3a7730a0a")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request["authorization"] = 'Bearer {secretKey}'
request.body = "{\"email\":\"[email protected]\"}"
response = http.request(request)
puts response.read_body
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('PUT', 'https://api.blochq.io/v1/customers/645474848c1ad9e3a7730a0a', [
'body' => '{"email":"[email protected]"}',
'headers' => [
'accept' => 'application/json',
'authorization' => 'Bearer {secretKey}',
'content-type' => 'application/json',
],
]);
echo $response->getBody();
import requests
url = "https://api.blochq.io/v1/customers/645474848c1ad9e3a7730a0a"
payload = {"email": "[email protected]"}
headers = {
"accept": "application/json",
"content-type": "application/json",
"authorization": "Bearer {secretKey}"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)
Important to Note:
You can only update the following customer information — first name, last name, email, phone number, and customer type.
Deleting a customer
You cannot delete a customer that's been added to the Bloc Dashboard. However, you can archive the customer details. Archiving makes all linked accounts and cards automatically inactive.
You can also choose to unarchive a customer if you wish to.
Updated over 1 year ago