Attach NF-e invoices issued through Cubbo's fiscal integration
curl --request POST \
--url https://api.cubbo.com/v1/orders/{order_id}/attach-invoice \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"invoice_type": "WEBMANIA",
"invoices": [
{
"key": "00000000000000000000000000000000000000000000",
"identifier": "SALE987654",
"purpose": "SALE_INVOICE",
"operation_type": "SAIDA",
"operation_nature": "Venda de mercadoria"
}
]
}
'import requests
url = "https://api.cubbo.com/v1/orders/{order_id}/attach-invoice"
payload = {
"invoice_type": "WEBMANIA",
"invoices": [
{
"key": "00000000000000000000000000000000000000000000",
"identifier": "SALE987654",
"purpose": "SALE_INVOICE",
"operation_type": "SAIDA",
"operation_nature": "Venda de mercadoria"
}
]
}
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({
invoice_type: 'WEBMANIA',
invoices: [
{
key: '00000000000000000000000000000000000000000000',
identifier: 'SALE987654',
purpose: 'SALE_INVOICE',
operation_type: 'SAIDA',
operation_nature: 'Venda de mercadoria'
}
]
})
};
fetch('https://api.cubbo.com/v1/orders/{order_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/orders/{order_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([
'invoice_type' => 'WEBMANIA',
'invoices' => [
[
'key' => '00000000000000000000000000000000000000000000',
'identifier' => 'SALE987654',
'purpose' => 'SALE_INVOICE',
'operation_type' => 'SAIDA',
'operation_nature' => 'Venda de mercadoria'
]
]
]),
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/orders/{order_id}/attach-invoice"
payload := strings.NewReader("{\n \"invoice_type\": \"WEBMANIA\",\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"SALE987654\",\n \"purpose\": \"SALE_INVOICE\",\n \"operation_type\": \"SAIDA\",\n \"operation_nature\": \"Venda de mercadoria\"\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/orders/{order_id}/attach-invoice")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"invoice_type\": \"WEBMANIA\",\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"SALE987654\",\n \"purpose\": \"SALE_INVOICE\",\n \"operation_type\": \"SAIDA\",\n \"operation_nature\": \"Venda de mercadoria\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cubbo.com/v1/orders/{order_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 \"invoice_type\": \"WEBMANIA\",\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"SALE987654\",\n \"purpose\": \"SALE_INVOICE\",\n \"operation_type\": \"SAIDA\",\n \"operation_nature\": \"Venda de mercadoria\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"new_invoice_ids": [
7801
]
}
Orders
Attach NF-e invoices issued through Cubbo's fiscal integration
Brazil only. Registers one or more NF-e (Nota Fiscal Eletronica, the Brazilian electronic invoice) that were issued for this order through Cubbo’s fiscal integration. Cubbo then fetches the authorized XML and DANFE for each invoice from the fiscal provider and attaches them to the order so the warehouse can print them and ship. Use this when your store issues NF-e through Cubbo’s integrated fiscal provider and you need to tell Cubbo which invoices belong to the order.
- The order must be in
pending,processing,pickingorpacking; otherwise the request is rejected with 422. - Each invoice needs its 44-digit access key (
key), the identifier you used when issuing it (identifier), apurpose, the operation type (SAIDAoutgoing /ENTRADAincoming) and the operation nature (operation_nature, the CFOP description such as “Venda de mercadoria”). - Keys and identifiers must be unique within the request. If one of the keys already exists in
Cubbo, no new invoice is created: Cubbo refreshes the existing invoices from the fiscal provider
and responds with
update_invoice_idslisting those keys. - An identifier that already belongs to a non-cancelled invoice is rejected. Identifiers of cancelled invoices can be reused.
- Invoices are created as
PREAPPROVEDand move toAPPROVEDonce the fiscal provider confirms them. Read their status in theinvoicesarray ofGET /orders. - Only
invoice_typeWEBMANIAis accepted today.
POST
/
orders
/
{order_id}
/
attach-invoice
Attach NF-e invoices issued through Cubbo's fiscal integration
curl --request POST \
--url https://api.cubbo.com/v1/orders/{order_id}/attach-invoice \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"invoice_type": "WEBMANIA",
"invoices": [
{
"key": "00000000000000000000000000000000000000000000",
"identifier": "SALE987654",
"purpose": "SALE_INVOICE",
"operation_type": "SAIDA",
"operation_nature": "Venda de mercadoria"
}
]
}
'import requests
url = "https://api.cubbo.com/v1/orders/{order_id}/attach-invoice"
payload = {
"invoice_type": "WEBMANIA",
"invoices": [
{
"key": "00000000000000000000000000000000000000000000",
"identifier": "SALE987654",
"purpose": "SALE_INVOICE",
"operation_type": "SAIDA",
"operation_nature": "Venda de mercadoria"
}
]
}
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({
invoice_type: 'WEBMANIA',
invoices: [
{
key: '00000000000000000000000000000000000000000000',
identifier: 'SALE987654',
purpose: 'SALE_INVOICE',
operation_type: 'SAIDA',
operation_nature: 'Venda de mercadoria'
}
]
})
};
fetch('https://api.cubbo.com/v1/orders/{order_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/orders/{order_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([
'invoice_type' => 'WEBMANIA',
'invoices' => [
[
'key' => '00000000000000000000000000000000000000000000',
'identifier' => 'SALE987654',
'purpose' => 'SALE_INVOICE',
'operation_type' => 'SAIDA',
'operation_nature' => 'Venda de mercadoria'
]
]
]),
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/orders/{order_id}/attach-invoice"
payload := strings.NewReader("{\n \"invoice_type\": \"WEBMANIA\",\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"SALE987654\",\n \"purpose\": \"SALE_INVOICE\",\n \"operation_type\": \"SAIDA\",\n \"operation_nature\": \"Venda de mercadoria\"\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/orders/{order_id}/attach-invoice")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"invoice_type\": \"WEBMANIA\",\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"SALE987654\",\n \"purpose\": \"SALE_INVOICE\",\n \"operation_type\": \"SAIDA\",\n \"operation_nature\": \"Venda de mercadoria\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cubbo.com/v1/orders/{order_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 \"invoice_type\": \"WEBMANIA\",\n \"invoices\": [\n {\n \"key\": \"00000000000000000000000000000000000000000000\",\n \"identifier\": \"SALE987654\",\n \"purpose\": \"SALE_INVOICE\",\n \"operation_type\": \"SAIDA\",\n \"operation_nature\": \"Venda de mercadoria\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"new_invoice_ids": [
7801
]
}
Authorizations
Body
application/json
Response
Invoices registered. new_invoice_ids holds the IDs of the invoices created; when every key already existed, it is empty and update_invoice_ids lists the keys that were refreshed instead.