$ curl -sS https://api.facturia.cl/v1/documents \
-H "Authorization: Bearer sk_test_9lQpV3fA2mKcRt7wZxYb1Nde" \
-H "Facturia-Empresa: 77928532-4" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"tipo_dte": 33,
"receptor": { "rut": "76543212-K" },
"items": [
{ "description": "Desarrollo a medida",
"quantity": 1, "unit_price": 1100000 },
{ "description": "Capacitación", "exempt": true,
"quantity": 1, "unit_price": 64000 }
]
}'// JavaScript · sin SDK: la API es HTTP y nada más
const res = await fetch('https://api.facturia.cl/v1/documents', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + process.env.FACTURIA_KEY,
'Facturia-Empresa': '77928532-4',
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
tipo_dte: 33,
receptor: { rut: '76543212-K' },
items: [
{ description: 'Desarrollo a medida',
quantity: 1, unit_price: 1100000 },
{ description: 'Capacitación', exempt: true,
quantity: 1, unit_price: 64000 },
] }),
});# Python · requests: la API es HTTP y nada más
import os, uuid, requests
res = requests.post("https://api.facturia.cl/v1/documents",
headers={
"Authorization": "Bearer " + os.environ["FACTURIA_KEY"],
"Facturia-Empresa": "77928532-4",
"Idempotency-Key": str(uuid.uuid4()),
"Content-Type": "application/json",
},
json={
"tipo_dte": 33,
"receptor": {"rut": "76543212-K"},
"items": [
{"description": "Desarrollo a medida",
"quantity": 1, "unit_price": 1100000},
{"description": "Capacitación", "exempt": True,
"quantity": 1, "unit_price": 64000},
] })