Atualizar ou criar cliente
curl --request PUT \
--url https://api.example.com/v1/customers/{customerId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "João Silva",
"phoneNumber": "+5511999999999",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
}
}
'import requests
url = "https://api.example.com/v1/customers/{customerId}"
payload = {
"name": "João Silva",
"phoneNumber": "+5511999999999",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'João Silva',
phoneNumber: '+5511999999999',
email: 'joao.silva@test.com',
document: {type: 'Cpf', number: '22380370044', country: 'BR'},
billingAddress: {
street: 'Avenida Paulista',
number: '1111',
apartment: 'Sala 100',
neighborhood: 'Bela Vista',
city: 'São Paulo',
state: 'SP',
country: 'BR',
postalCode: '01311-200',
longitude: -46.653408,
latitude: -23.56475
}
})
};
fetch('https://api.example.com/v1/customers/{customerId}', 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.example.com/v1/customers/{customerId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'João Silva',
'phoneNumber' => '+5511999999999',
'email' => 'joao.silva@test.com',
'document' => [
'type' => 'Cpf',
'number' => '22380370044',
'country' => 'BR'
],
'billingAddress' => [
'street' => 'Avenida Paulista',
'number' => '1111',
'apartment' => 'Sala 100',
'neighborhood' => 'Bela Vista',
'city' => 'São Paulo',
'state' => 'SP',
'country' => 'BR',
'postalCode' => '01311-200',
'longitude' => -46.653408,
'latitude' => -23.56475
]
]),
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://api.example.com/v1/customers/{customerId}"
payload := strings.NewReader("{\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.example.com/v1/customers/{customerId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/customers/{customerId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}Customers
Atualizar ou criar cliente
Atualiza ou cria um cliente com os dados informados.
PUT
/
v1
/
customers
/
{customerId}
Atualizar ou criar cliente
curl --request PUT \
--url https://api.example.com/v1/customers/{customerId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "João Silva",
"phoneNumber": "+5511999999999",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
}
}
'import requests
url = "https://api.example.com/v1/customers/{customerId}"
payload = {
"name": "João Silva",
"phoneNumber": "+5511999999999",
"email": "joao.silva@test.com",
"document": {
"type": "Cpf",
"number": "22380370044",
"country": "BR"
},
"billingAddress": {
"street": "Avenida Paulista",
"number": "1111",
"apartment": "Sala 100",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"country": "BR",
"postalCode": "01311-200",
"longitude": -46.653408,
"latitude": -23.56475
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'João Silva',
phoneNumber: '+5511999999999',
email: 'joao.silva@test.com',
document: {type: 'Cpf', number: '22380370044', country: 'BR'},
billingAddress: {
street: 'Avenida Paulista',
number: '1111',
apartment: 'Sala 100',
neighborhood: 'Bela Vista',
city: 'São Paulo',
state: 'SP',
country: 'BR',
postalCode: '01311-200',
longitude: -46.653408,
latitude: -23.56475
}
})
};
fetch('https://api.example.com/v1/customers/{customerId}', 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.example.com/v1/customers/{customerId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'João Silva',
'phoneNumber' => '+5511999999999',
'email' => 'joao.silva@test.com',
'document' => [
'type' => 'Cpf',
'number' => '22380370044',
'country' => 'BR'
],
'billingAddress' => [
'street' => 'Avenida Paulista',
'number' => '1111',
'apartment' => 'Sala 100',
'neighborhood' => 'Bela Vista',
'city' => 'São Paulo',
'state' => 'SP',
'country' => 'BR',
'postalCode' => '01311-200',
'longitude' => -46.653408,
'latitude' => -23.56475
]
]),
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://api.example.com/v1/customers/{customerId}"
payload := strings.NewReader("{\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.example.com/v1/customers/{customerId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/customers/{customerId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"João Silva\",\n \"phoneNumber\": \"+5511999999999\",\n \"email\": \"joao.silva@test.com\",\n \"document\": {\n \"type\": \"Cpf\",\n \"number\": \"22380370044\",\n \"country\": \"BR\"\n },\n \"billingAddress\": {\n \"street\": \"Avenida Paulista\",\n \"number\": \"1111\",\n \"apartment\": \"Sala 100\",\n \"neighborhood\": \"Bela Vista\",\n \"city\": \"São Paulo\",\n \"state\": \"SP\",\n \"country\": \"BR\",\n \"postalCode\": \"01311-200\",\n \"longitude\": -46.653408,\n \"latitude\": -23.56475\n }\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"target": "<string>",
"message": "<string>"
}
]
}Parâmetros de caminho
Identificador da cliente
Corpo
application/json
Dados de atualização
Nome do cliente
Exemplo:
"João Silva"
Número de telefone do cliente
Exemplo:
"+5511999999999"
Email do cliente
Exemplo:
"joao.silva@test.com"
Dados do documento
Show child attributes
Show child attributes
Dados do endereço
Show child attributes
Show child attributes
Resposta
No Content
Esta página foi útil?
⌘I