Customers
Create a customer
Creates a new customer.
POST
/
customers
Create a customer
curl --request POST \
--url https://pay.chargily.net/test/api/v2/customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"email": "<string>",
"phone": "<string>",
"address": {
"country": "<string>",
"state": "<string>",
"address": "<string>"
},
"metadata": [
{}
]
}
'import requests
url = "https://pay.chargily.net/test/api/v2/customers"
payload = {
"name": "<string>",
"email": "<string>",
"phone": "<string>",
"address": {
"country": "<string>",
"state": "<string>",
"address": "<string>"
},
"metadata": [{}]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
email: '<string>',
phone: '<string>',
address: {country: '<string>', state: '<string>', address: '<string>'},
metadata: [{}]
})
};
fetch('https://pay.chargily.net/test/api/v2/customers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://pay.chargily.net/test/api/v2/customers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'email' => '<string>',
'phone' => '<string>',
'address' => [
'country' => '<string>',
'state' => '<string>',
'address' => '<string>'
],
'metadata' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://pay.chargily.net/test/api/v2/customers"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"email\": \"<string>\",\n \"phone\": \"<string>\",\n \"address\": {\n \"country\": \"<string>\",\n \"state\": \"<string>\",\n \"address\": \"<string>\"\n },\n \"metadata\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://pay.chargily.net/test/api/v2/customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"email\": \"<string>\",\n \"phone\": \"<string>\",\n \"address\": {\n \"country\": \"<string>\",\n \"state\": \"<string>\",\n \"address\": \"<string>\"\n },\n \"metadata\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pay.chargily.net/test/api/v2/customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"email\": \"<string>\",\n \"phone\": \"<string>\",\n \"address\": {\n \"country\": \"<string>\",\n \"state\": \"<string>\",\n \"address\": \"<string>\"\n },\n \"metadata\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "01hj0p5s3ygy2mx1czg2wzcc4x",
"entity": "customer",
"livemode": false,
"name": "Hocine Saad",
"email": null,
"phone": null,
"address": {
"country": "Algeria",
"state": "Tizi-Ouzou",
"address": "123 Main Street"
},
"metadata": null,
"created_at": 1702977791,
"updated_at": 1702977791
}
Body parameters
The name of the customer.
The email of the customer.
The phone number of the customer.
The address of the customer
Show address
Show address
Two-letter country code (ISO 3166-1 alpha-2), eg: “dz”.
The state of the customer.
The address line of the customer.
A Set of key-value pairs that can be used to store additional information
about the product.
Returns
If the request is successful, it returns a customer object.{
"id": "01hj0p5s3ygy2mx1czg2wzcc4x",
"entity": "customer",
"livemode": false,
"name": "Hocine Saad",
"email": null,
"phone": null,
"address": {
"country": "Algeria",
"state": "Tizi-Ouzou",
"address": "123 Main Street"
},
"metadata": null,
"created_at": 1702977791,
"updated_at": 1702977791
}
Previous
Update a customerUpdates the information of a customer by defining the values for the passed parameters. Any parameters not supplied will remain unaltered.
Next
⌘I
Create a customer
curl --request POST \
--url https://pay.chargily.net/test/api/v2/customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"email": "<string>",
"phone": "<string>",
"address": {
"country": "<string>",
"state": "<string>",
"address": "<string>"
},
"metadata": [
{}
]
}
'import requests
url = "https://pay.chargily.net/test/api/v2/customers"
payload = {
"name": "<string>",
"email": "<string>",
"phone": "<string>",
"address": {
"country": "<string>",
"state": "<string>",
"address": "<string>"
},
"metadata": [{}]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
email: '<string>',
phone: '<string>',
address: {country: '<string>', state: '<string>', address: '<string>'},
metadata: [{}]
})
};
fetch('https://pay.chargily.net/test/api/v2/customers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://pay.chargily.net/test/api/v2/customers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'email' => '<string>',
'phone' => '<string>',
'address' => [
'country' => '<string>',
'state' => '<string>',
'address' => '<string>'
],
'metadata' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://pay.chargily.net/test/api/v2/customers"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"email\": \"<string>\",\n \"phone\": \"<string>\",\n \"address\": {\n \"country\": \"<string>\",\n \"state\": \"<string>\",\n \"address\": \"<string>\"\n },\n \"metadata\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://pay.chargily.net/test/api/v2/customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"email\": \"<string>\",\n \"phone\": \"<string>\",\n \"address\": {\n \"country\": \"<string>\",\n \"state\": \"<string>\",\n \"address\": \"<string>\"\n },\n \"metadata\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://pay.chargily.net/test/api/v2/customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"email\": \"<string>\",\n \"phone\": \"<string>\",\n \"address\": {\n \"country\": \"<string>\",\n \"state\": \"<string>\",\n \"address\": \"<string>\"\n },\n \"metadata\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "01hj0p5s3ygy2mx1czg2wzcc4x",
"entity": "customer",
"livemode": false,
"name": "Hocine Saad",
"email": null,
"phone": null,
"address": {
"country": "Algeria",
"state": "Tizi-Ouzou",
"address": "123 Main Street"
},
"metadata": null,
"created_at": 1702977791,
"updated_at": 1702977791
}