Create a customer
curl --request POST \
--url https://api.yuvexpay.com/v1/customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <x-idempotency-key>' \
--data '
{
"name": "Pedro Álvares Cabral",
"email": "user@example.com",
"document": "12345678900",
"documentType": "CPF",
"phone": "+5511999999999",
"externalId": "cust-001",
"metadata": {
"plan": "premium"
}
}
'import requests
url = "https://api.yuvexpay.com/v1/customers"
payload = {
"name": "Pedro Álvares Cabral",
"email": "user@example.com",
"document": "12345678900",
"documentType": "CPF",
"phone": "+5511999999999",
"externalId": "cust-001",
"metadata": { "plan": "premium" }
}
headers = {
"X-Idempotency-Key": "<x-idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Idempotency-Key': '<x-idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Pedro Álvares Cabral',
email: 'user@example.com',
document: '12345678900',
documentType: 'CPF',
phone: '+5511999999999',
externalId: 'cust-001',
metadata: {plan: 'premium'}
})
};
fetch('https://api.yuvexpay.com/v1/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://api.yuvexpay.com/v1/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' => 'Pedro Álvares Cabral',
'email' => 'user@example.com',
'document' => '12345678900',
'documentType' => 'CPF',
'phone' => '+5511999999999',
'externalId' => 'cust-001',
'metadata' => [
'plan' => 'premium'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Idempotency-Key: <x-idempotency-key>"
],
]);
$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://api.yuvexpay.com/v1/customers"
payload := strings.NewReader("{\n \"name\": \"Pedro Álvares Cabral\",\n \"email\": \"user@example.com\",\n \"document\": \"12345678900\",\n \"documentType\": \"CPF\",\n \"phone\": \"+5511999999999\",\n \"externalId\": \"cust-001\",\n \"metadata\": {\n \"plan\": \"premium\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Idempotency-Key", "<x-idempotency-key>")
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://api.yuvexpay.com/v1/customers")
.header("X-Idempotency-Key", "<x-idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Pedro Álvares Cabral\",\n \"email\": \"user@example.com\",\n \"document\": \"12345678900\",\n \"documentType\": \"CPF\",\n \"phone\": \"+5511999999999\",\n \"externalId\": \"cust-001\",\n \"metadata\": {\n \"plan\": \"premium\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yuvexpay.com/v1/customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Idempotency-Key"] = '<x-idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Pedro Álvares Cabral\",\n \"email\": \"user@example.com\",\n \"document\": \"12345678900\",\n \"documentType\": \"CPF\",\n \"phone\": \"+5511999999999\",\n \"externalId\": \"cust-001\",\n \"metadata\": {\n \"plan\": \"premium\"\n }\n}"
response = http.request(request)
puts response.read_body{
"customer": {
"customerId": "<string>",
"name": "<string>",
"email": "<string>",
"document": "<string>",
"phone": "<string>",
"externalId": "<string>",
"isActive": true,
"createdAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": {
"amount": "Must be greater than 0.01"
}
}
}{
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid or revoked API key"
}
}{
"error": {
"code": "IDEMPOTENCY_PAYLOAD_MISMATCH",
"message": "Idempotency key already used with a different request body"
}
}Customers
Create a customer
Create a new customer record. Customers can be associated with payments for tracking and recurring billing.
POST
/
v1
/
customers
Create a customer
curl --request POST \
--url https://api.yuvexpay.com/v1/customers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <x-idempotency-key>' \
--data '
{
"name": "Pedro Álvares Cabral",
"email": "user@example.com",
"document": "12345678900",
"documentType": "CPF",
"phone": "+5511999999999",
"externalId": "cust-001",
"metadata": {
"plan": "premium"
}
}
'import requests
url = "https://api.yuvexpay.com/v1/customers"
payload = {
"name": "Pedro Álvares Cabral",
"email": "user@example.com",
"document": "12345678900",
"documentType": "CPF",
"phone": "+5511999999999",
"externalId": "cust-001",
"metadata": { "plan": "premium" }
}
headers = {
"X-Idempotency-Key": "<x-idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Idempotency-Key': '<x-idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Pedro Álvares Cabral',
email: 'user@example.com',
document: '12345678900',
documentType: 'CPF',
phone: '+5511999999999',
externalId: 'cust-001',
metadata: {plan: 'premium'}
})
};
fetch('https://api.yuvexpay.com/v1/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://api.yuvexpay.com/v1/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' => 'Pedro Álvares Cabral',
'email' => 'user@example.com',
'document' => '12345678900',
'documentType' => 'CPF',
'phone' => '+5511999999999',
'externalId' => 'cust-001',
'metadata' => [
'plan' => 'premium'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Idempotency-Key: <x-idempotency-key>"
],
]);
$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://api.yuvexpay.com/v1/customers"
payload := strings.NewReader("{\n \"name\": \"Pedro Álvares Cabral\",\n \"email\": \"user@example.com\",\n \"document\": \"12345678900\",\n \"documentType\": \"CPF\",\n \"phone\": \"+5511999999999\",\n \"externalId\": \"cust-001\",\n \"metadata\": {\n \"plan\": \"premium\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Idempotency-Key", "<x-idempotency-key>")
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://api.yuvexpay.com/v1/customers")
.header("X-Idempotency-Key", "<x-idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Pedro Álvares Cabral\",\n \"email\": \"user@example.com\",\n \"document\": \"12345678900\",\n \"documentType\": \"CPF\",\n \"phone\": \"+5511999999999\",\n \"externalId\": \"cust-001\",\n \"metadata\": {\n \"plan\": \"premium\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yuvexpay.com/v1/customers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Idempotency-Key"] = '<x-idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Pedro Álvares Cabral\",\n \"email\": \"user@example.com\",\n \"document\": \"12345678900\",\n \"documentType\": \"CPF\",\n \"phone\": \"+5511999999999\",\n \"externalId\": \"cust-001\",\n \"metadata\": {\n \"plan\": \"premium\"\n }\n}"
response = http.request(request)
puts response.read_body{
"customer": {
"customerId": "<string>",
"name": "<string>",
"email": "<string>",
"document": "<string>",
"phone": "<string>",
"externalId": "<string>",
"isActive": true,
"createdAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": {
"amount": "Must be greater than 0.01"
}
}
}{
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid or revoked API key"
}
}{
"error": {
"code": "IDEMPOTENCY_PAYLOAD_MISMATCH",
"message": "Idempotency key already used with a different request body"
}
}Authorizations
YuvexPay API key. Include as Authorization: Bearer ypk_<env>_<kid>_<secret> where <env> is test (sandbox) or live (production). Create and manage keys in the dashboard under Settings > API Keys.
Headers
A unique string to ensure the request is processed only once. Must be unique per request. Valid for 24 hours.
Maximum string length:
100Body
application/json
Your own customer ID.
Maximum string length:
100Required string length:
1 - 200Maximum string length:
255CPF or CNPJ number.
Maximum string length:
20Available options:
CPF, CNPJ Maximum string length:
20Show child attributes
Show child attributes
Response
Customer created.
Show child attributes
Show child attributes
⌘I

