Generar XML
curl --request POST \
--url https://json.ricardofuentes.dev/api/v1/facturacion/xml \
--header 'Content-Type: application/json' \
--data '
{
"tipo": "<string>",
"serie": "<string>",
"numero": 123,
"emisor": {
"emisor.ruc": "<string>"
},
"receptor": {
"receptor.ruc": "<string>"
},
"items": [
{
"items[].descripcion": "<string>",
"items[].cantidad": 123,
"items[].precio_unitario": 123,
"items[].igv": 123
}
]
}
'import requests
url = "https://json.ricardofuentes.dev/api/v1/facturacion/xml"
payload = {
"tipo": "<string>",
"serie": "<string>",
"numero": 123,
"emisor": { "emisor.ruc": "<string>" },
"receptor": { "receptor.ruc": "<string>" },
"items": [
{
"items[].descripcion": "<string>",
"items[].cantidad": 123,
"items[].precio_unitario": 123,
"items[].igv": 123
}
]
}
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({
tipo: '<string>',
serie: '<string>',
numero: 123,
emisor: {'emisor.ruc': '<string>'},
receptor: {'receptor.ruc': '<string>'},
items: [
{
'items[].descripcion': '<string>',
'items[].cantidad': 123,
'items[].precio_unitario': 123,
'items[].igv': 123
}
]
})
};
fetch('https://json.ricardofuentes.dev/api/v1/facturacion/xml', 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/xml",
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([
'tipo' => '<string>',
'serie' => '<string>',
'numero' => 123,
'emisor' => [
'emisor.ruc' => '<string>'
],
'receptor' => [
'receptor.ruc' => '<string>'
],
'items' => [
[
'items[].descripcion' => '<string>',
'items[].cantidad' => 123,
'items[].precio_unitario' => 123,
'items[].igv' => 123
]
]
]),
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/xml"
payload := strings.NewReader("{\n \"tipo\": \"<string>\",\n \"serie\": \"<string>\",\n \"numero\": 123,\n \"emisor\": {\n \"emisor.ruc\": \"<string>\"\n },\n \"receptor\": {\n \"receptor.ruc\": \"<string>\"\n },\n \"items\": [\n {\n \"items[].descripcion\": \"<string>\",\n \"items[].cantidad\": 123,\n \"items[].precio_unitario\": 123,\n \"items[].igv\": 123\n }\n ]\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/xml")
.header("Content-Type", "application/json")
.body("{\n \"tipo\": \"<string>\",\n \"serie\": \"<string>\",\n \"numero\": 123,\n \"emisor\": {\n \"emisor.ruc\": \"<string>\"\n },\n \"receptor\": {\n \"receptor.ruc\": \"<string>\"\n },\n \"items\": [\n {\n \"items[].descripcion\": \"<string>\",\n \"items[].cantidad\": 123,\n \"items[].precio_unitario\": 123,\n \"items[].igv\": 123\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://json.ricardofuentes.dev/api/v1/facturacion/xml")
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 \"tipo\": \"<string>\",\n \"serie\": \"<string>\",\n \"numero\": 123,\n \"emisor\": {\n \"emisor.ruc\": \"<string>\"\n },\n \"receptor\": {\n \"receptor.ruc\": \"<string>\"\n },\n \"items\": [\n {\n \"items[].descripcion\": \"<string>\",\n \"items[].cantidad\": 123,\n \"items[].precio_unitario\": 123,\n \"items[].igv\": 123\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"xml": "<?xml version=\"1.0\"?>...",
"hash": "abc123def456...",
"nombre_archivo": "20123456789-01-F001-1.xml"
}
}
API Facturación
Generar XML
Genera el XML de un comprobante electrónico según el estándar UBL 2.1 de SUNAT
POST
/
api
/
v1
/
facturacion
/
xml
Generar XML
curl --request POST \
--url https://json.ricardofuentes.dev/api/v1/facturacion/xml \
--header 'Content-Type: application/json' \
--data '
{
"tipo": "<string>",
"serie": "<string>",
"numero": 123,
"emisor": {
"emisor.ruc": "<string>"
},
"receptor": {
"receptor.ruc": "<string>"
},
"items": [
{
"items[].descripcion": "<string>",
"items[].cantidad": 123,
"items[].precio_unitario": 123,
"items[].igv": 123
}
]
}
'import requests
url = "https://json.ricardofuentes.dev/api/v1/facturacion/xml"
payload = {
"tipo": "<string>",
"serie": "<string>",
"numero": 123,
"emisor": { "emisor.ruc": "<string>" },
"receptor": { "receptor.ruc": "<string>" },
"items": [
{
"items[].descripcion": "<string>",
"items[].cantidad": 123,
"items[].precio_unitario": 123,
"items[].igv": 123
}
]
}
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({
tipo: '<string>',
serie: '<string>',
numero: 123,
emisor: {'emisor.ruc': '<string>'},
receptor: {'receptor.ruc': '<string>'},
items: [
{
'items[].descripcion': '<string>',
'items[].cantidad': 123,
'items[].precio_unitario': 123,
'items[].igv': 123
}
]
})
};
fetch('https://json.ricardofuentes.dev/api/v1/facturacion/xml', 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/xml",
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([
'tipo' => '<string>',
'serie' => '<string>',
'numero' => 123,
'emisor' => [
'emisor.ruc' => '<string>'
],
'receptor' => [
'receptor.ruc' => '<string>'
],
'items' => [
[
'items[].descripcion' => '<string>',
'items[].cantidad' => 123,
'items[].precio_unitario' => 123,
'items[].igv' => 123
]
]
]),
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/xml"
payload := strings.NewReader("{\n \"tipo\": \"<string>\",\n \"serie\": \"<string>\",\n \"numero\": 123,\n \"emisor\": {\n \"emisor.ruc\": \"<string>\"\n },\n \"receptor\": {\n \"receptor.ruc\": \"<string>\"\n },\n \"items\": [\n {\n \"items[].descripcion\": \"<string>\",\n \"items[].cantidad\": 123,\n \"items[].precio_unitario\": 123,\n \"items[].igv\": 123\n }\n ]\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/xml")
.header("Content-Type", "application/json")
.body("{\n \"tipo\": \"<string>\",\n \"serie\": \"<string>\",\n \"numero\": 123,\n \"emisor\": {\n \"emisor.ruc\": \"<string>\"\n },\n \"receptor\": {\n \"receptor.ruc\": \"<string>\"\n },\n \"items\": [\n {\n \"items[].descripcion\": \"<string>\",\n \"items[].cantidad\": 123,\n \"items[].precio_unitario\": 123,\n \"items[].igv\": 123\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://json.ricardofuentes.dev/api/v1/facturacion/xml")
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 \"tipo\": \"<string>\",\n \"serie\": \"<string>\",\n \"numero\": 123,\n \"emisor\": {\n \"emisor.ruc\": \"<string>\"\n },\n \"receptor\": {\n \"receptor.ruc\": \"<string>\"\n },\n \"items\": [\n {\n \"items[].descripcion\": \"<string>\",\n \"items[].cantidad\": 123,\n \"items[].precio_unitario\": 123,\n \"items[].igv\": 123\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"xml": "<?xml version=\"1.0\"?>...",
"hash": "abc123def456...",
"nombre_archivo": "20123456789-01-F001-1.xml"
}
}
Body
string
required
Tipo de comprobante:
01 (Factura), 03 (Boleta), 07 (Nota de crédito), 08 (Nota de débito)string
required
Serie del comprobante (ej: F001, B001)
number
required
Número correlativo
array
required
Ejemplo de petición
cURL
curl -X POST https://json.ricardofuentes.dev/api/v1/facturacion/xml \
-H "Authorization: Bearer tu_token" \
-H "Content-Type: application/json" \
-d '{
"tipo": "01",
"serie": "F001",
"numero": 1,
"emisor": { "ruc": "20123456789" },
"receptor": { "ruc": "20987654321" },
"items": [
{
"descripcion": "Servicio de consultoría",
"cantidad": 1,
"precio_unitario": 1000.00,
"igv": 180.00
}
]
}'
{
"success": true,
"data": {
"xml": "<?xml version=\"1.0\"?>...",
"hash": "abc123def456...",
"nombre_archivo": "20123456789-01-F001-1.xml"
}
}
⌘I