Create Affiliate Link
curl --request POST \
--url https://api.centralcart.io/v1/webstore/affiliate/links \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-store-domain: <x-store-domain>' \
--data '
{
"name": "Campanha do YouTube",
"ref_code": "joao-yt"
}
'import requests
url = "https://api.centralcart.io/v1/webstore/affiliate/links"
payload = {
"name": "Campanha do YouTube",
"ref_code": "joao-yt"
}
headers = {
"x-store-domain": "<x-store-domain>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-store-domain': '<x-store-domain>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: 'Campanha do YouTube', ref_code: 'joao-yt'})
};
fetch('https://api.centralcart.io/v1/webstore/affiliate/links', 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.centralcart.io/v1/webstore/affiliate/links",
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' => 'Campanha do YouTube',
'ref_code' => 'joao-yt'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-store-domain: <x-store-domain>"
],
]);
$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.centralcart.io/v1/webstore/affiliate/links"
payload := strings.NewReader("{\n \"name\": \"Campanha do YouTube\",\n \"ref_code\": \"joao-yt\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-store-domain", "<x-store-domain>")
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.centralcart.io/v1/webstore/affiliate/links")
.header("x-store-domain", "<x-store-domain>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Campanha do YouTube\",\n \"ref_code\": \"joao-yt\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.centralcart.io/v1/webstore/affiliate/links")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-store-domain"] = '<x-store-domain>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Campanha do YouTube\",\n \"ref_code\": \"joao-yt\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"ref_code": "<string>",
"url": "<string>",
"sales": 123,
"revenue": 123,
"d7_visits": 123
}{
"errors": [
{
"message": "Sessão inválida ou expirada.",
"code": "CUSTOMER_UNAUTHENTICATED"
}
]
}{
"errors": [
{
"message": "Afiliado não encontrado"
}
]
}{
"errors": [
{
"message": "Já existe um link com este código."
}
]
}Afiliados
Create Affiliate Link
Cria um link de indicação com código próprio.
O
ref_code aceita letras, números, hífen e underline, é gravado em minúsculas e precisa ser único na loja. A loja define o limite de links por afiliado.POST
/
webstore
/
affiliate
/
links
Create Affiliate Link
curl --request POST \
--url https://api.centralcart.io/v1/webstore/affiliate/links \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-store-domain: <x-store-domain>' \
--data '
{
"name": "Campanha do YouTube",
"ref_code": "joao-yt"
}
'import requests
url = "https://api.centralcart.io/v1/webstore/affiliate/links"
payload = {
"name": "Campanha do YouTube",
"ref_code": "joao-yt"
}
headers = {
"x-store-domain": "<x-store-domain>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-store-domain': '<x-store-domain>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: 'Campanha do YouTube', ref_code: 'joao-yt'})
};
fetch('https://api.centralcart.io/v1/webstore/affiliate/links', 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.centralcart.io/v1/webstore/affiliate/links",
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' => 'Campanha do YouTube',
'ref_code' => 'joao-yt'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-store-domain: <x-store-domain>"
],
]);
$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.centralcart.io/v1/webstore/affiliate/links"
payload := strings.NewReader("{\n \"name\": \"Campanha do YouTube\",\n \"ref_code\": \"joao-yt\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-store-domain", "<x-store-domain>")
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.centralcart.io/v1/webstore/affiliate/links")
.header("x-store-domain", "<x-store-domain>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Campanha do YouTube\",\n \"ref_code\": \"joao-yt\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.centralcart.io/v1/webstore/affiliate/links")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-store-domain"] = '<x-store-domain>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Campanha do YouTube\",\n \"ref_code\": \"joao-yt\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"ref_code": "<string>",
"url": "<string>",
"sales": 123,
"revenue": 123,
"d7_visits": 123
}{
"errors": [
{
"message": "Sessão inválida ou expirada.",
"code": "CUSTOMER_UNAUTHENTICATED"
}
]
}{
"errors": [
{
"message": "Afiliado não encontrado"
}
]
}{
"errors": [
{
"message": "Já existe um link com este código."
}
]
}Autorizações
access_token do comprador, devolvido por POST /webstore/auth/verify.
Cabeçalhos
Domínio da sua loja (ex: sualoja.centralcart.ai)
Corpo
application/json
Resposta
Link criado
Link pronto para compartilhar.
Vendas acumuladas por este link.
Receita acumulada por este link.
Visitas dos últimos 7 dias. Só vem preenchido em GET /webstore/affiliate/me com include_visits=true; nos demais casos é null.
⌘I