Skip to main content
POST
/
v1
/
customers
Criação de novo customer para cobrança
curl --request POST \
  --url https://api.malga.io/v1/customers \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: <api-key>' \
  --header 'X-Client-Id: <api-key>' \
  --data '
{
  "name": "Customer test",
  "email": "jose2@gmail.com",
  "phoneNumber": "21 98889999099",
  "document": {
    "number": "97055503019",
    "type": "cpf",
    "country": "BR"
  },
  "address": {
    "country": "BR",
    "state": "Rio de Janeiro",
    "city": "Rio de Janeiro",
    "district": "Leblon",
    "zipCode": "25650011",
    "street": "Av Geraldo Cardoso",
    "streetNumber": "205",
    "complement": "Apto 203"
  },
  "billingAddress": {
    "country": "BR",
    "state": "Rio de Janeiro",
    "city": "Rio de Janeiro",
    "district": "Leblon",
    "zipCode": "25650011",
    "street": "Av Geraldo Cardoso",
    "streetNumber": "205",
    "complement": "Apto 203"
  },
  "deliveryAddress": {
    "country": "BR",
    "state": "Rio de Janeiro",
    "city": "Rio de Janeiro",
    "district": "Leblon",
    "zipCode": "25650011",
    "street": "Av Geraldo Cardoso",
    "streetNumber": "205",
    "complement": "Apto 203"
  }
}
'
import requests

url = "https://api.malga.io/v1/customers"

payload = {
"name": "Customer test",
"email": "jose2@gmail.com",
"phoneNumber": "21 98889999099",
"document": {
"number": "97055503019",
"type": "cpf",
"country": "BR"
},
"address": {
"country": "BR",
"state": "Rio de Janeiro",
"city": "Rio de Janeiro",
"district": "Leblon",
"zipCode": "25650011",
"street": "Av Geraldo Cardoso",
"streetNumber": "205",
"complement": "Apto 203"
},
"billingAddress": {
"country": "BR",
"state": "Rio de Janeiro",
"city": "Rio de Janeiro",
"district": "Leblon",
"zipCode": "25650011",
"street": "Av Geraldo Cardoso",
"streetNumber": "205",
"complement": "Apto 203"
},
"deliveryAddress": {
"country": "BR",
"state": "Rio de Janeiro",
"city": "Rio de Janeiro",
"district": "Leblon",
"zipCode": "25650011",
"street": "Av Geraldo Cardoso",
"streetNumber": "205",
"complement": "Apto 203"
}
}
headers = {
"X-Client-Id": "<api-key>",
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'X-Client-Id': '<api-key>',
'X-Api-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Customer test',
email: 'jose2@gmail.com',
phoneNumber: '21 98889999099',
document: {number: '97055503019', type: 'cpf', country: 'BR'},
address: {
country: 'BR',
state: 'Rio de Janeiro',
city: 'Rio de Janeiro',
district: 'Leblon',
zipCode: '25650011',
street: 'Av Geraldo Cardoso',
streetNumber: '205',
complement: 'Apto 203'
},
billingAddress: {
country: 'BR',
state: 'Rio de Janeiro',
city: 'Rio de Janeiro',
district: 'Leblon',
zipCode: '25650011',
street: 'Av Geraldo Cardoso',
streetNumber: '205',
complement: 'Apto 203'
},
deliveryAddress: {
country: 'BR',
state: 'Rio de Janeiro',
city: 'Rio de Janeiro',
district: 'Leblon',
zipCode: '25650011',
street: 'Av Geraldo Cardoso',
streetNumber: '205',
complement: 'Apto 203'
}
})
};

fetch('https://api.malga.io/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.malga.io/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' => 'Customer test',
'email' => 'jose2@gmail.com',
'phoneNumber' => '21 98889999099',
'document' => [
'number' => '97055503019',
'type' => 'cpf',
'country' => 'BR'
],
'address' => [
'country' => 'BR',
'state' => 'Rio de Janeiro',
'city' => 'Rio de Janeiro',
'district' => 'Leblon',
'zipCode' => '25650011',
'street' => 'Av Geraldo Cardoso',
'streetNumber' => '205',
'complement' => 'Apto 203'
],
'billingAddress' => [
'country' => 'BR',
'state' => 'Rio de Janeiro',
'city' => 'Rio de Janeiro',
'district' => 'Leblon',
'zipCode' => '25650011',
'street' => 'Av Geraldo Cardoso',
'streetNumber' => '205',
'complement' => 'Apto 203'
],
'deliveryAddress' => [
'country' => 'BR',
'state' => 'Rio de Janeiro',
'city' => 'Rio de Janeiro',
'district' => 'Leblon',
'zipCode' => '25650011',
'street' => 'Av Geraldo Cardoso',
'streetNumber' => '205',
'complement' => 'Apto 203'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <api-key>",
"X-Client-Id: <api-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.malga.io/v1/customers"

payload := strings.NewReader("{\n \"name\": \"Customer test\",\n \"email\": \"jose2@gmail.com\",\n \"phoneNumber\": \"21 98889999099\",\n \"document\": {\n \"number\": \"97055503019\",\n \"type\": \"cpf\",\n \"country\": \"BR\"\n },\n \"address\": {\n \"country\": \"BR\",\n \"state\": \"Rio de Janeiro\",\n \"city\": \"Rio de Janeiro\",\n \"district\": \"Leblon\",\n \"zipCode\": \"25650011\",\n \"street\": \"Av Geraldo Cardoso\",\n \"streetNumber\": \"205\",\n \"complement\": \"Apto 203\"\n },\n \"billingAddress\": {\n \"country\": \"BR\",\n \"state\": \"Rio de Janeiro\",\n \"city\": \"Rio de Janeiro\",\n \"district\": \"Leblon\",\n \"zipCode\": \"25650011\",\n \"street\": \"Av Geraldo Cardoso\",\n \"streetNumber\": \"205\",\n \"complement\": \"Apto 203\"\n },\n \"deliveryAddress\": {\n \"country\": \"BR\",\n \"state\": \"Rio de Janeiro\",\n \"city\": \"Rio de Janeiro\",\n \"district\": \"Leblon\",\n \"zipCode\": \"25650011\",\n \"street\": \"Av Geraldo Cardoso\",\n \"streetNumber\": \"205\",\n \"complement\": \"Apto 203\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-Client-Id", "<api-key>")
req.Header.Add("X-Api-Key", "<api-key>")
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.malga.io/v1/customers")
.header("X-Client-Id", "<api-key>")
.header("X-Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Customer test\",\n \"email\": \"jose2@gmail.com\",\n \"phoneNumber\": \"21 98889999099\",\n \"document\": {\n \"number\": \"97055503019\",\n \"type\": \"cpf\",\n \"country\": \"BR\"\n },\n \"address\": {\n \"country\": \"BR\",\n \"state\": \"Rio de Janeiro\",\n \"city\": \"Rio de Janeiro\",\n \"district\": \"Leblon\",\n \"zipCode\": \"25650011\",\n \"street\": \"Av Geraldo Cardoso\",\n \"streetNumber\": \"205\",\n \"complement\": \"Apto 203\"\n },\n \"billingAddress\": {\n \"country\": \"BR\",\n \"state\": \"Rio de Janeiro\",\n \"city\": \"Rio de Janeiro\",\n \"district\": \"Leblon\",\n \"zipCode\": \"25650011\",\n \"street\": \"Av Geraldo Cardoso\",\n \"streetNumber\": \"205\",\n \"complement\": \"Apto 203\"\n },\n \"deliveryAddress\": {\n \"country\": \"BR\",\n \"state\": \"Rio de Janeiro\",\n \"city\": \"Rio de Janeiro\",\n \"district\": \"Leblon\",\n \"zipCode\": \"25650011\",\n \"street\": \"Av Geraldo Cardoso\",\n \"streetNumber\": \"205\",\n \"complement\": \"Apto 203\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.malga.io/v1/customers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Client-Id"] = '<api-key>'
request["X-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Customer test\",\n \"email\": \"jose2@gmail.com\",\n \"phoneNumber\": \"21 98889999099\",\n \"document\": {\n \"number\": \"97055503019\",\n \"type\": \"cpf\",\n \"country\": \"BR\"\n },\n \"address\": {\n \"country\": \"BR\",\n \"state\": \"Rio de Janeiro\",\n \"city\": \"Rio de Janeiro\",\n \"district\": \"Leblon\",\n \"zipCode\": \"25650011\",\n \"street\": \"Av Geraldo Cardoso\",\n \"streetNumber\": \"205\",\n \"complement\": \"Apto 203\"\n },\n \"billingAddress\": {\n \"country\": \"BR\",\n \"state\": \"Rio de Janeiro\",\n \"city\": \"Rio de Janeiro\",\n \"district\": \"Leblon\",\n \"zipCode\": \"25650011\",\n \"street\": \"Av Geraldo Cardoso\",\n \"streetNumber\": \"205\",\n \"complement\": \"Apto 203\"\n },\n \"deliveryAddress\": {\n \"country\": \"BR\",\n \"state\": \"Rio de Janeiro\",\n \"city\": \"Rio de Janeiro\",\n \"district\": \"Leblon\",\n \"zipCode\": \"25650011\",\n \"street\": \"Av Geraldo Cardoso\",\n \"streetNumber\": \"205\",\n \"complement\": \"Apto 203\"\n }\n}"

response = http.request(request)
puts response.read_body

Authorizations

X-Client-Id
string
header
required
X-Api-Key
string
header
required

Body

application/json
name
string
required

nome do usuario

email
string
required

email do usuario

phoneNumber
string
required

telefone de contato do usuario

document
object
required
address
object
billingAddress
object
deliveryAddress
object

Response

201

Created.