Enviar a SUNAT
curl --request POST \
--url https://json.ricardofuentes.dev/api/v1/facturacion/enviar \
--header 'Content-Type: application/json' \
--data '
{
"xml_firmado": "<string>",
"ambiente": "<string>"
}
'import requests
url = "https://json.ricardofuentes.dev/api/v1/facturacion/enviar"
payload = {
"xml_firmado": "<string>",
"ambiente": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({xml_firmado: '<string>', ambiente: '<string>'})
};
fetch('https://json.ricardofuentes.dev/api/v1/facturacion/enviar', 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://json.ricardofuentes.dev/api/v1/facturacion/enviar",
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([
'xml_firmado' => '<string>',
'ambiente' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://json.ricardofuentes.dev/api/v1/facturacion/enviar"
payload := strings.NewReader("{\n \"xml_firmado\": \"<string>\",\n \"ambiente\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://json.ricardofuentes.dev/api/v1/facturacion/enviar")
.header("Content-Type", "application/json")
.body("{\n \"xml_firmado\": \"<string>\",\n \"ambiente\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://json.ricardofuentes.dev/api/v1/facturacion/enviar")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"xml_firmado\": \"<string>\",\n \"ambiente\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"codigo_respuesta": "0",
"descripcion": "La factura fue aceptada",
"cdr": "base64_encoded_cdr...",
"hash_cdr": "def456..."
}
}
API Facturación
Enviar a SUNAT
Envía un comprobante firmado a SUNAT y obtiene la respuesta
POST
/
api
/
v1
/
facturacion
/
enviar
Enviar a SUNAT
curl --request POST \
--url https://json.ricardofuentes.dev/api/v1/facturacion/enviar \
--header 'Content-Type: application/json' \
--data '
{
"xml_firmado": "<string>",
"ambiente": "<string>"
}
'import requests
url = "https://json.ricardofuentes.dev/api/v1/facturacion/enviar"
payload = {
"xml_firmado": "<string>",
"ambiente": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({xml_firmado: '<string>', ambiente: '<string>'})
};
fetch('https://json.ricardofuentes.dev/api/v1/facturacion/enviar', 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://json.ricardofuentes.dev/api/v1/facturacion/enviar",
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([
'xml_firmado' => '<string>',
'ambiente' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://json.ricardofuentes.dev/api/v1/facturacion/enviar"
payload := strings.NewReader("{\n \"xml_firmado\": \"<string>\",\n \"ambiente\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://json.ricardofuentes.dev/api/v1/facturacion/enviar")
.header("Content-Type", "application/json")
.body("{\n \"xml_firmado\": \"<string>\",\n \"ambiente\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://json.ricardofuentes.dev/api/v1/facturacion/enviar")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"xml_firmado\": \"<string>\",\n \"ambiente\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"codigo_respuesta": "0",
"descripcion": "La factura fue aceptada",
"cdr": "base64_encoded_cdr...",
"hash_cdr": "def456..."
}
}
Body
string
required
XML firmado del comprobante
string
default:"beta"
Ambiente de envío:
beta (pruebas) o produccionEjemplo de petición
cURL
curl -X POST https://json.ricardofuentes.dev/api/v1/facturacion/enviar \
-H "Authorization: Bearer tu_token" \
-H "Content-Type: application/json" \
-d '{
"xml_firmado": "<?xml version=\"1.0\"?>...",
"ambiente": "beta"
}'
{
"success": true,
"data": {
"codigo_respuesta": "0",
"descripcion": "La factura fue aceptada",
"cdr": "base64_encoded_cdr...",
"hash_cdr": "def456..."
}
}
⌘I