Register the inbound NF-e issued for a return (Brazil)
curl --request POST \
--url https://api.cubbo.com/v1/returns/{return_id}/attach-invoice \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"invoices": [
{
"key": "00000000000000000000000000000000000000000000",
"identifier": "RET-98765-M",
"purpose": "RETURN_INVOICE",
"operation_type": "ENTRADA",
"operation_nature": "Retorno de mercadoria nao entregue",
"total_value": "116.56"
}
]
}
'import requests
url = "https://api.cubbo.com/v1/returns/{return_id}/attach-invoice"
payload = { "invoices": [
{
"key": "00000000000000000000000000000000000000000000",
"identifier": "RET-98765-M",
"purpose": "RETURN_INVOICE",
"operation_type": "ENTRADA",
"operation_nature": "Retorno de mercadoria nao entregue",
"total_value": "116.56"
}
] }
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({
invoices: [
{
key: '00000000000000000000000000000000000000000000',
identifier: 'RET-98765-M',
purpose: 'RETURN_INVOICE',
operation_type: 'ENTRADA',
operation_nature: 'Retorno de mercadoria nao entregue',
total_value: '116.56'
}
]
})
};
fetch('https://api.cubbo.com/v1/returns/{return_id}/attach-invoice', 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.cubbo.com/v1/returns/{return_id}/attach-invoice",
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([
'invoices' => [
[
'key' => '00000000000000000000000000000000000000000000',
'identifier' => 'RET-98765-M',
'purpose' => 'RETURN_INVOICE',
'operation_type' => 'ENTRADA',
'operation_nature' => 'Retorno de mercadoria nao entregue',
'total_value' => '116.56'
]
]
]),
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.cubbo.com/v1/returns/{return_id}/attach-invoice"
payload := strings.NewReader("{\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"RET-98765-M\",\n \"purpose\": \"RETURN_INVOICE\",\n \"operation_type\": \"ENTRADA\",\n \"operation_nature\": \"Retorno de mercadoria nao entregue\",\n \"total_value\": \"116.56\"\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://api.cubbo.com/v1/returns/{return_id}/attach-invoice")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"RET-98765-M\",\n \"purpose\": \"RETURN_INVOICE\",\n \"operation_type\": \"ENTRADA\",\n \"operation_nature\": \"Retorno de mercadoria nao entregue\",\n \"total_value\": \"116.56\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cubbo.com/v1/returns/{return_id}/attach-invoice")
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 \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"RET-98765-M\",\n \"purpose\": \"RETURN_INVOICE\",\n \"operation_type\": \"ENTRADA\",\n \"operation_nature\": \"Retorno de mercadoria nao entregue\",\n \"total_value\": \"116.56\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"new_invoice_ids": [
880001
]
}Returns
Register the inbound NF-e issued for a return (Brazil)
Brazil only, for stores whose NF-e are issued through Cubbo’s fiscal provider. After your
store issues the inbound NF-e (Nota Fiscal Eletrônica de entrada) for a returned order, call
this endpoint with the invoice references so Cubbo can link them to the return and fetch the
authorized document. Each item is linked according to its purpose:
RETURN_INVOICE: the NF-e that documents the goods coming back from the customer; linked to the return.REPLENISHMENT_INVOICE: the NF-e that documents the stock re-entering the warehouse; linked to the return’s stock re-entry (replenishment_idin the awaiting-invoice list).
Behaviors:
- The return’s stock re-entry must be in the put-away stage (the same condition that lists
it under
GET /returns/awaiting-invoice); otherwise 422. - If every
keyyou send is already registered, nothing is created: Cubbo re-syncs the existing invoices and answers 200 withnew_invoice_ids: []and the matched keys inupdate_invoice_ids. - An
identifierthat is already used by a non-cancelled invoice is rejected (422). You may reuse an identifier whose previous invoice was cancelled. - Duplicate keys or identifiers within the same request are rejected (422).
- Invoices are stored as pre-approved and confirmed asynchronously with the fiscal provider.
- Your API credentials need the permission to update orders.
POST
/
returns
/
{return_id}
/
attach-invoice
Register the inbound NF-e issued for a return (Brazil)
curl --request POST \
--url https://api.cubbo.com/v1/returns/{return_id}/attach-invoice \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"invoices": [
{
"key": "00000000000000000000000000000000000000000000",
"identifier": "RET-98765-M",
"purpose": "RETURN_INVOICE",
"operation_type": "ENTRADA",
"operation_nature": "Retorno de mercadoria nao entregue",
"total_value": "116.56"
}
]
}
'import requests
url = "https://api.cubbo.com/v1/returns/{return_id}/attach-invoice"
payload = { "invoices": [
{
"key": "00000000000000000000000000000000000000000000",
"identifier": "RET-98765-M",
"purpose": "RETURN_INVOICE",
"operation_type": "ENTRADA",
"operation_nature": "Retorno de mercadoria nao entregue",
"total_value": "116.56"
}
] }
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({
invoices: [
{
key: '00000000000000000000000000000000000000000000',
identifier: 'RET-98765-M',
purpose: 'RETURN_INVOICE',
operation_type: 'ENTRADA',
operation_nature: 'Retorno de mercadoria nao entregue',
total_value: '116.56'
}
]
})
};
fetch('https://api.cubbo.com/v1/returns/{return_id}/attach-invoice', 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.cubbo.com/v1/returns/{return_id}/attach-invoice",
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([
'invoices' => [
[
'key' => '00000000000000000000000000000000000000000000',
'identifier' => 'RET-98765-M',
'purpose' => 'RETURN_INVOICE',
'operation_type' => 'ENTRADA',
'operation_nature' => 'Retorno de mercadoria nao entregue',
'total_value' => '116.56'
]
]
]),
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.cubbo.com/v1/returns/{return_id}/attach-invoice"
payload := strings.NewReader("{\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"RET-98765-M\",\n \"purpose\": \"RETURN_INVOICE\",\n \"operation_type\": \"ENTRADA\",\n \"operation_nature\": \"Retorno de mercadoria nao entregue\",\n \"total_value\": \"116.56\"\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://api.cubbo.com/v1/returns/{return_id}/attach-invoice")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"RET-98765-M\",\n \"purpose\": \"RETURN_INVOICE\",\n \"operation_type\": \"ENTRADA\",\n \"operation_nature\": \"Retorno de mercadoria nao entregue\",\n \"total_value\": \"116.56\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cubbo.com/v1/returns/{return_id}/attach-invoice")
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 \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"RET-98765-M\",\n \"purpose\": \"RETURN_INVOICE\",\n \"operation_type\": \"ENTRADA\",\n \"operation_nature\": \"Retorno de mercadoria nao entregue\",\n \"total_value\": \"116.56\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"new_invoice_ids": [
880001
]
}Authorizations
Body
application/json
Response
Invoices registered (or already present and re-synced).