Post cfdi
curl --request POST \
--url https://apisandbox.facturama.mx/api-lite/4/cfdis \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"NameId": "1",
"Currency": "MXN",
"Folio": "100",
"Serie": "FA",
"CfdiType": "I",
"PaymentForm": "03",
"PaymentMethod": "PUE",
"OrderNumber": "TEST-001",
"ExpeditionPlace": "78000",
"Date": "2024-02-20T12:00:00",
"PaymentConditions": "CREDITO A SIETE DIAS",
"Observations": "Elemento Observaciones solo visible en PDF",
"Exportation": "01",
"LogoUrl": "http://tu_dominio.com/imagen.jpg",
"Issuer": {
"Rfc": "EKU9003173C9",
"Name": "ESCUELA KEMPER URGATE",
"FiscalRegime": "601"
},
"Receiver": {
"Rfc": "URE180429TM6",
"CfdiUse": "G01",
"Name": "UNIVERSIDAD ROBOTICA ESPAÑOLA",
"FiscalRegime": "601",
"TaxZipCode": "86991"
},
"Items": [
{
"ProductCode": "10101504",
"IdentificationNumber": "EDL",
"Description": "Estudios de laboratorio",
"Unit": "NO APLICA",
"UnitCode": "MTS",
"UnitPrice": 50,
"Quantity": 2,
"Subtotal": 100,
"TaxObject": "02",
"Taxes": [
{
"Total": 16,
"Name": "IVA",
"Base": 100,
"Rate": 0.16,
"IsRetention": false
}
],
"Total": 116
}
]
}
'import requests
url = "https://apisandbox.facturama.mx/api-lite/4/cfdis"
payload = {
"NameId": "1",
"Currency": "MXN",
"Folio": "100",
"Serie": "FA",
"CfdiType": "I",
"PaymentForm": "03",
"PaymentMethod": "PUE",
"OrderNumber": "TEST-001",
"ExpeditionPlace": "78000",
"Date": "2024-02-20T12:00:00",
"PaymentConditions": "CREDITO A SIETE DIAS",
"Observations": "Elemento Observaciones solo visible en PDF",
"Exportation": "01",
"LogoUrl": "http://tu_dominio.com/imagen.jpg",
"Issuer": {
"Rfc": "EKU9003173C9",
"Name": "ESCUELA KEMPER URGATE",
"FiscalRegime": "601"
},
"Receiver": {
"Rfc": "URE180429TM6",
"CfdiUse": "G01",
"Name": "UNIVERSIDAD ROBOTICA ESPAÑOLA",
"FiscalRegime": "601",
"TaxZipCode": "86991"
},
"Items": [
{
"ProductCode": "10101504",
"IdentificationNumber": "EDL",
"Description": "Estudios de laboratorio",
"Unit": "NO APLICA",
"UnitCode": "MTS",
"UnitPrice": 50,
"Quantity": 2,
"Subtotal": 100,
"TaxObject": "02",
"Taxes": [
{
"Total": 16,
"Name": "IVA",
"Base": 100,
"Rate": 0.16,
"IsRetention": False
}
],
"Total": 116
}
]
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
NameId: '1',
Currency: 'MXN',
Folio: '100',
Serie: 'FA',
CfdiType: 'I',
PaymentForm: '03',
PaymentMethod: 'PUE',
OrderNumber: 'TEST-001',
ExpeditionPlace: '78000',
Date: '2024-02-20T12:00:00',
PaymentConditions: 'CREDITO A SIETE DIAS',
Observations: 'Elemento Observaciones solo visible en PDF',
Exportation: '01',
LogoUrl: 'http://tu_dominio.com/imagen.jpg',
Issuer: {Rfc: 'EKU9003173C9', Name: 'ESCUELA KEMPER URGATE', FiscalRegime: '601'},
Receiver: {
Rfc: 'URE180429TM6',
CfdiUse: 'G01',
Name: 'UNIVERSIDAD ROBOTICA ESPAÑOLA',
FiscalRegime: '601',
TaxZipCode: '86991'
},
Items: [
{
ProductCode: '10101504',
IdentificationNumber: 'EDL',
Description: 'Estudios de laboratorio',
Unit: 'NO APLICA',
UnitCode: 'MTS',
UnitPrice: 50,
Quantity: 2,
Subtotal: 100,
TaxObject: '02',
Taxes: [{Total: 16, Name: 'IVA', Base: 100, Rate: 0.16, IsRetention: false}],
Total: 116
}
]
})
};
fetch('https://apisandbox.facturama.mx/api-lite/4/cfdis', 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://apisandbox.facturama.mx/api-lite/4/cfdis",
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([
'NameId' => '1',
'Currency' => 'MXN',
'Folio' => '100',
'Serie' => 'FA',
'CfdiType' => 'I',
'PaymentForm' => '03',
'PaymentMethod' => 'PUE',
'OrderNumber' => 'TEST-001',
'ExpeditionPlace' => '78000',
'Date' => '2024-02-20T12:00:00',
'PaymentConditions' => 'CREDITO A SIETE DIAS',
'Observations' => 'Elemento Observaciones solo visible en PDF',
'Exportation' => '01',
'LogoUrl' => 'http://tu_dominio.com/imagen.jpg',
'Issuer' => [
'Rfc' => 'EKU9003173C9',
'Name' => 'ESCUELA KEMPER URGATE',
'FiscalRegime' => '601'
],
'Receiver' => [
'Rfc' => 'URE180429TM6',
'CfdiUse' => 'G01',
'Name' => 'UNIVERSIDAD ROBOTICA ESPAÑOLA',
'FiscalRegime' => '601',
'TaxZipCode' => '86991'
],
'Items' => [
[
'ProductCode' => '10101504',
'IdentificationNumber' => 'EDL',
'Description' => 'Estudios de laboratorio',
'Unit' => 'NO APLICA',
'UnitCode' => 'MTS',
'UnitPrice' => 50,
'Quantity' => 2,
'Subtotal' => 100,
'TaxObject' => '02',
'Taxes' => [
[
'Total' => 16,
'Name' => 'IVA',
'Base' => 100,
'Rate' => 0.16,
'IsRetention' => false
]
],
'Total' => 116
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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://apisandbox.facturama.mx/api-lite/4/cfdis"
payload := strings.NewReader("{\n \"NameId\": \"1\",\n \"Currency\": \"MXN\",\n \"Folio\": \"100\",\n \"Serie\": \"FA\",\n \"CfdiType\": \"I\",\n \"PaymentForm\": \"03\",\n \"PaymentMethod\": \"PUE\",\n \"OrderNumber\": \"TEST-001\",\n \"ExpeditionPlace\": \"78000\",\n \"Date\": \"2024-02-20T12:00:00\",\n \"PaymentConditions\": \"CREDITO A SIETE DIAS\",\n \"Observations\": \"Elemento Observaciones solo visible en PDF\",\n \"Exportation\": \"01\",\n \"LogoUrl\": \"http://tu_dominio.com/imagen.jpg\",\n \"Issuer\": {\n \"Rfc\": \"EKU9003173C9\",\n \"Name\": \"ESCUELA KEMPER URGATE\",\n \"FiscalRegime\": \"601\"\n },\n \"Receiver\": {\n \"Rfc\": \"URE180429TM6\",\n \"CfdiUse\": \"G01\",\n \"Name\": \"UNIVERSIDAD ROBOTICA ESPAÑOLA\",\n \"FiscalRegime\": \"601\",\n \"TaxZipCode\": \"86991\"\n },\n \"Items\": [\n {\n \"ProductCode\": \"10101504\",\n \"IdentificationNumber\": \"EDL\",\n \"Description\": \"Estudios de laboratorio\",\n \"Unit\": \"NO APLICA\",\n \"UnitCode\": \"MTS\",\n \"UnitPrice\": 50,\n \"Quantity\": 2,\n \"Subtotal\": 100,\n \"TaxObject\": \"02\",\n \"Taxes\": [\n {\n \"Total\": 16,\n \"Name\": \"IVA\",\n \"Base\": 100,\n \"Rate\": 0.16,\n \"IsRetention\": false\n }\n ],\n \"Total\": 116\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://apisandbox.facturama.mx/api-lite/4/cfdis")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"NameId\": \"1\",\n \"Currency\": \"MXN\",\n \"Folio\": \"100\",\n \"Serie\": \"FA\",\n \"CfdiType\": \"I\",\n \"PaymentForm\": \"03\",\n \"PaymentMethod\": \"PUE\",\n \"OrderNumber\": \"TEST-001\",\n \"ExpeditionPlace\": \"78000\",\n \"Date\": \"2024-02-20T12:00:00\",\n \"PaymentConditions\": \"CREDITO A SIETE DIAS\",\n \"Observations\": \"Elemento Observaciones solo visible en PDF\",\n \"Exportation\": \"01\",\n \"LogoUrl\": \"http://tu_dominio.com/imagen.jpg\",\n \"Issuer\": {\n \"Rfc\": \"EKU9003173C9\",\n \"Name\": \"ESCUELA KEMPER URGATE\",\n \"FiscalRegime\": \"601\"\n },\n \"Receiver\": {\n \"Rfc\": \"URE180429TM6\",\n \"CfdiUse\": \"G01\",\n \"Name\": \"UNIVERSIDAD ROBOTICA ESPAÑOLA\",\n \"FiscalRegime\": \"601\",\n \"TaxZipCode\": \"86991\"\n },\n \"Items\": [\n {\n \"ProductCode\": \"10101504\",\n \"IdentificationNumber\": \"EDL\",\n \"Description\": \"Estudios de laboratorio\",\n \"Unit\": \"NO APLICA\",\n \"UnitCode\": \"MTS\",\n \"UnitPrice\": 50,\n \"Quantity\": 2,\n \"Subtotal\": 100,\n \"TaxObject\": \"02\",\n \"Taxes\": [\n {\n \"Total\": 16,\n \"Name\": \"IVA\",\n \"Base\": 100,\n \"Rate\": 0.16,\n \"IsRetention\": false\n }\n ],\n \"Total\": 116\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apisandbox.facturama.mx/api-lite/4/cfdis")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"NameId\": \"1\",\n \"Currency\": \"MXN\",\n \"Folio\": \"100\",\n \"Serie\": \"FA\",\n \"CfdiType\": \"I\",\n \"PaymentForm\": \"03\",\n \"PaymentMethod\": \"PUE\",\n \"OrderNumber\": \"TEST-001\",\n \"ExpeditionPlace\": \"78000\",\n \"Date\": \"2024-02-20T12:00:00\",\n \"PaymentConditions\": \"CREDITO A SIETE DIAS\",\n \"Observations\": \"Elemento Observaciones solo visible en PDF\",\n \"Exportation\": \"01\",\n \"LogoUrl\": \"http://tu_dominio.com/imagen.jpg\",\n \"Issuer\": {\n \"Rfc\": \"EKU9003173C9\",\n \"Name\": \"ESCUELA KEMPER URGATE\",\n \"FiscalRegime\": \"601\"\n },\n \"Receiver\": {\n \"Rfc\": \"URE180429TM6\",\n \"CfdiUse\": \"G01\",\n \"Name\": \"UNIVERSIDAD ROBOTICA ESPAÑOLA\",\n \"FiscalRegime\": \"601\",\n \"TaxZipCode\": \"86991\"\n },\n \"Items\": [\n {\n \"ProductCode\": \"10101504\",\n \"IdentificationNumber\": \"EDL\",\n \"Description\": \"Estudios de laboratorio\",\n \"Unit\": \"NO APLICA\",\n \"UnitCode\": \"MTS\",\n \"UnitPrice\": 50,\n \"Quantity\": 2,\n \"Subtotal\": 100,\n \"TaxObject\": \"02\",\n \"Taxes\": [\n {\n \"Total\": 16,\n \"Name\": \"IVA\",\n \"Base\": 100,\n \"Rate\": 0.16,\n \"IsRetention\": false\n }\n ],\n \"Total\": 116\n }\n ]\n}"
response = http.request(request)
puts response.read_body"<string>"Authorizations
HTTP Basic authentication with Facturama username and password.
Body
Issuance CFDI without requiring Client and Product catalogs.
Gets or sets the Place of Issue (postal code from which the voucher is issued)
1[0-9]{5}Gets or sets folio: Atributo para control interno del contribuyente que expresa el folio del comprobante, acepta una cadena de 1 a 40 caracteres.
1 - 40[^|]{1,40}Gets or sets required attribute to express the tax voucher effect for the issuing taxpayer: income, expense, or transfer
1I|E|T|N|PGets or sets the Tax Entity that issues the CFDI.
Show child attributes
Show child attributes
Gets or sets the client to whom the CFDI will be issued, Required Attribute
Show child attributes
Show child attributes
Gets or sets attribute to specify the name to be displayed in the PDF (default 1 = invoice) [ See the "CFDI Names" documentation ]
Gets or sets logo URL, e.g. https://domain.com/my-logo.png
(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|jpeg|png)Gets or sets the issuance date (optional) of the voucher per ISO 8601 standard
^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$Gets or sets the (optional) reference to an existing Series at the Branch
25[a-zA-Z0-9]{1,25}Gets or sets atributo opcional para incorporar al menos los cuatro últimos digitos del número de cuenta con la que se realizó el pago.
4^\d{1,4}?$Gets or sets tipo de cambio de la moneda en caso de ser diferente de MXN
Gets or sets atributo para expresar la moneda utilizada para expresar los montos en 3 caracteres según la especificación del estándar internacional ISO 4217
3Gets or sets atributo requerido para expresar si el comprobante ampara una operación de exportación. Se elige del catálogo del SAT 01|02|03|04
0[1234]Gets or sets (Opcional).
[^|]{1,100}Gets or sets nodo Información Global
Show child attributes
Show child attributes
Gets or sets cfdis Relacionados empleado para las notas de credito, etc.
Show child attributes
Show child attributes
Gets or sets atributo obligatorio y de catálogo, para expresar la forma de pago de los bienes o servicios amparados por el comprobante. Se entiende como método de pago leyendas tales como: 01, 02, 03, 99
01|02|03|04|05|06|08|12|13|14|15|17|23|24|25|26|27|28|29|30|31|99Gets or sets atributo obligatorio y de catálogo, para expresar el método de pago de los bienes o servicios amparados por el comprobante. Se entiende como método de pago leyendas tales como: PPD, PUE
PUE|PPDGets or sets nodo requerido para enlistar los conceptos cubiertos por el comprobante.
Show child attributes
Show child attributes
Gets or sets complementos aplicables al cfdi 4.0.
Show child attributes
Show child attributes
Gets or sets descripcion no fiscal del pdf
Gets or sets numero de Orden, propiedad no fiscal (opcional)
100Gets or sets nombre del banco, propiedad no fiscal (opcional)
50Response
The response is of type file.
curl --request POST \
--url https://apisandbox.facturama.mx/api-lite/4/cfdis \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"NameId": "1",
"Currency": "MXN",
"Folio": "100",
"Serie": "FA",
"CfdiType": "I",
"PaymentForm": "03",
"PaymentMethod": "PUE",
"OrderNumber": "TEST-001",
"ExpeditionPlace": "78000",
"Date": "2024-02-20T12:00:00",
"PaymentConditions": "CREDITO A SIETE DIAS",
"Observations": "Elemento Observaciones solo visible en PDF",
"Exportation": "01",
"LogoUrl": "http://tu_dominio.com/imagen.jpg",
"Issuer": {
"Rfc": "EKU9003173C9",
"Name": "ESCUELA KEMPER URGATE",
"FiscalRegime": "601"
},
"Receiver": {
"Rfc": "URE180429TM6",
"CfdiUse": "G01",
"Name": "UNIVERSIDAD ROBOTICA ESPAÑOLA",
"FiscalRegime": "601",
"TaxZipCode": "86991"
},
"Items": [
{
"ProductCode": "10101504",
"IdentificationNumber": "EDL",
"Description": "Estudios de laboratorio",
"Unit": "NO APLICA",
"UnitCode": "MTS",
"UnitPrice": 50,
"Quantity": 2,
"Subtotal": 100,
"TaxObject": "02",
"Taxes": [
{
"Total": 16,
"Name": "IVA",
"Base": 100,
"Rate": 0.16,
"IsRetention": false
}
],
"Total": 116
}
]
}
'import requests
url = "https://apisandbox.facturama.mx/api-lite/4/cfdis"
payload = {
"NameId": "1",
"Currency": "MXN",
"Folio": "100",
"Serie": "FA",
"CfdiType": "I",
"PaymentForm": "03",
"PaymentMethod": "PUE",
"OrderNumber": "TEST-001",
"ExpeditionPlace": "78000",
"Date": "2024-02-20T12:00:00",
"PaymentConditions": "CREDITO A SIETE DIAS",
"Observations": "Elemento Observaciones solo visible en PDF",
"Exportation": "01",
"LogoUrl": "http://tu_dominio.com/imagen.jpg",
"Issuer": {
"Rfc": "EKU9003173C9",
"Name": "ESCUELA KEMPER URGATE",
"FiscalRegime": "601"
},
"Receiver": {
"Rfc": "URE180429TM6",
"CfdiUse": "G01",
"Name": "UNIVERSIDAD ROBOTICA ESPAÑOLA",
"FiscalRegime": "601",
"TaxZipCode": "86991"
},
"Items": [
{
"ProductCode": "10101504",
"IdentificationNumber": "EDL",
"Description": "Estudios de laboratorio",
"Unit": "NO APLICA",
"UnitCode": "MTS",
"UnitPrice": 50,
"Quantity": 2,
"Subtotal": 100,
"TaxObject": "02",
"Taxes": [
{
"Total": 16,
"Name": "IVA",
"Base": 100,
"Rate": 0.16,
"IsRetention": False
}
],
"Total": 116
}
]
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
NameId: '1',
Currency: 'MXN',
Folio: '100',
Serie: 'FA',
CfdiType: 'I',
PaymentForm: '03',
PaymentMethod: 'PUE',
OrderNumber: 'TEST-001',
ExpeditionPlace: '78000',
Date: '2024-02-20T12:00:00',
PaymentConditions: 'CREDITO A SIETE DIAS',
Observations: 'Elemento Observaciones solo visible en PDF',
Exportation: '01',
LogoUrl: 'http://tu_dominio.com/imagen.jpg',
Issuer: {Rfc: 'EKU9003173C9', Name: 'ESCUELA KEMPER URGATE', FiscalRegime: '601'},
Receiver: {
Rfc: 'URE180429TM6',
CfdiUse: 'G01',
Name: 'UNIVERSIDAD ROBOTICA ESPAÑOLA',
FiscalRegime: '601',
TaxZipCode: '86991'
},
Items: [
{
ProductCode: '10101504',
IdentificationNumber: 'EDL',
Description: 'Estudios de laboratorio',
Unit: 'NO APLICA',
UnitCode: 'MTS',
UnitPrice: 50,
Quantity: 2,
Subtotal: 100,
TaxObject: '02',
Taxes: [{Total: 16, Name: 'IVA', Base: 100, Rate: 0.16, IsRetention: false}],
Total: 116
}
]
})
};
fetch('https://apisandbox.facturama.mx/api-lite/4/cfdis', 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://apisandbox.facturama.mx/api-lite/4/cfdis",
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([
'NameId' => '1',
'Currency' => 'MXN',
'Folio' => '100',
'Serie' => 'FA',
'CfdiType' => 'I',
'PaymentForm' => '03',
'PaymentMethod' => 'PUE',
'OrderNumber' => 'TEST-001',
'ExpeditionPlace' => '78000',
'Date' => '2024-02-20T12:00:00',
'PaymentConditions' => 'CREDITO A SIETE DIAS',
'Observations' => 'Elemento Observaciones solo visible en PDF',
'Exportation' => '01',
'LogoUrl' => 'http://tu_dominio.com/imagen.jpg',
'Issuer' => [
'Rfc' => 'EKU9003173C9',
'Name' => 'ESCUELA KEMPER URGATE',
'FiscalRegime' => '601'
],
'Receiver' => [
'Rfc' => 'URE180429TM6',
'CfdiUse' => 'G01',
'Name' => 'UNIVERSIDAD ROBOTICA ESPAÑOLA',
'FiscalRegime' => '601',
'TaxZipCode' => '86991'
],
'Items' => [
[
'ProductCode' => '10101504',
'IdentificationNumber' => 'EDL',
'Description' => 'Estudios de laboratorio',
'Unit' => 'NO APLICA',
'UnitCode' => 'MTS',
'UnitPrice' => 50,
'Quantity' => 2,
'Subtotal' => 100,
'TaxObject' => '02',
'Taxes' => [
[
'Total' => 16,
'Name' => 'IVA',
'Base' => 100,
'Rate' => 0.16,
'IsRetention' => false
]
],
'Total' => 116
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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://apisandbox.facturama.mx/api-lite/4/cfdis"
payload := strings.NewReader("{\n \"NameId\": \"1\",\n \"Currency\": \"MXN\",\n \"Folio\": \"100\",\n \"Serie\": \"FA\",\n \"CfdiType\": \"I\",\n \"PaymentForm\": \"03\",\n \"PaymentMethod\": \"PUE\",\n \"OrderNumber\": \"TEST-001\",\n \"ExpeditionPlace\": \"78000\",\n \"Date\": \"2024-02-20T12:00:00\",\n \"PaymentConditions\": \"CREDITO A SIETE DIAS\",\n \"Observations\": \"Elemento Observaciones solo visible en PDF\",\n \"Exportation\": \"01\",\n \"LogoUrl\": \"http://tu_dominio.com/imagen.jpg\",\n \"Issuer\": {\n \"Rfc\": \"EKU9003173C9\",\n \"Name\": \"ESCUELA KEMPER URGATE\",\n \"FiscalRegime\": \"601\"\n },\n \"Receiver\": {\n \"Rfc\": \"URE180429TM6\",\n \"CfdiUse\": \"G01\",\n \"Name\": \"UNIVERSIDAD ROBOTICA ESPAÑOLA\",\n \"FiscalRegime\": \"601\",\n \"TaxZipCode\": \"86991\"\n },\n \"Items\": [\n {\n \"ProductCode\": \"10101504\",\n \"IdentificationNumber\": \"EDL\",\n \"Description\": \"Estudios de laboratorio\",\n \"Unit\": \"NO APLICA\",\n \"UnitCode\": \"MTS\",\n \"UnitPrice\": 50,\n \"Quantity\": 2,\n \"Subtotal\": 100,\n \"TaxObject\": \"02\",\n \"Taxes\": [\n {\n \"Total\": 16,\n \"Name\": \"IVA\",\n \"Base\": 100,\n \"Rate\": 0.16,\n \"IsRetention\": false\n }\n ],\n \"Total\": 116\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://apisandbox.facturama.mx/api-lite/4/cfdis")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"NameId\": \"1\",\n \"Currency\": \"MXN\",\n \"Folio\": \"100\",\n \"Serie\": \"FA\",\n \"CfdiType\": \"I\",\n \"PaymentForm\": \"03\",\n \"PaymentMethod\": \"PUE\",\n \"OrderNumber\": \"TEST-001\",\n \"ExpeditionPlace\": \"78000\",\n \"Date\": \"2024-02-20T12:00:00\",\n \"PaymentConditions\": \"CREDITO A SIETE DIAS\",\n \"Observations\": \"Elemento Observaciones solo visible en PDF\",\n \"Exportation\": \"01\",\n \"LogoUrl\": \"http://tu_dominio.com/imagen.jpg\",\n \"Issuer\": {\n \"Rfc\": \"EKU9003173C9\",\n \"Name\": \"ESCUELA KEMPER URGATE\",\n \"FiscalRegime\": \"601\"\n },\n \"Receiver\": {\n \"Rfc\": \"URE180429TM6\",\n \"CfdiUse\": \"G01\",\n \"Name\": \"UNIVERSIDAD ROBOTICA ESPAÑOLA\",\n \"FiscalRegime\": \"601\",\n \"TaxZipCode\": \"86991\"\n },\n \"Items\": [\n {\n \"ProductCode\": \"10101504\",\n \"IdentificationNumber\": \"EDL\",\n \"Description\": \"Estudios de laboratorio\",\n \"Unit\": \"NO APLICA\",\n \"UnitCode\": \"MTS\",\n \"UnitPrice\": 50,\n \"Quantity\": 2,\n \"Subtotal\": 100,\n \"TaxObject\": \"02\",\n \"Taxes\": [\n {\n \"Total\": 16,\n \"Name\": \"IVA\",\n \"Base\": 100,\n \"Rate\": 0.16,\n \"IsRetention\": false\n }\n ],\n \"Total\": 116\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apisandbox.facturama.mx/api-lite/4/cfdis")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"NameId\": \"1\",\n \"Currency\": \"MXN\",\n \"Folio\": \"100\",\n \"Serie\": \"FA\",\n \"CfdiType\": \"I\",\n \"PaymentForm\": \"03\",\n \"PaymentMethod\": \"PUE\",\n \"OrderNumber\": \"TEST-001\",\n \"ExpeditionPlace\": \"78000\",\n \"Date\": \"2024-02-20T12:00:00\",\n \"PaymentConditions\": \"CREDITO A SIETE DIAS\",\n \"Observations\": \"Elemento Observaciones solo visible en PDF\",\n \"Exportation\": \"01\",\n \"LogoUrl\": \"http://tu_dominio.com/imagen.jpg\",\n \"Issuer\": {\n \"Rfc\": \"EKU9003173C9\",\n \"Name\": \"ESCUELA KEMPER URGATE\",\n \"FiscalRegime\": \"601\"\n },\n \"Receiver\": {\n \"Rfc\": \"URE180429TM6\",\n \"CfdiUse\": \"G01\",\n \"Name\": \"UNIVERSIDAD ROBOTICA ESPAÑOLA\",\n \"FiscalRegime\": \"601\",\n \"TaxZipCode\": \"86991\"\n },\n \"Items\": [\n {\n \"ProductCode\": \"10101504\",\n \"IdentificationNumber\": \"EDL\",\n \"Description\": \"Estudios de laboratorio\",\n \"Unit\": \"NO APLICA\",\n \"UnitCode\": \"MTS\",\n \"UnitPrice\": 50,\n \"Quantity\": 2,\n \"Subtotal\": 100,\n \"TaxObject\": \"02\",\n \"Taxes\": [\n {\n \"Total\": 16,\n \"Name\": \"IVA\",\n \"Base\": 100,\n \"Rate\": 0.16,\n \"IsRetention\": false\n }\n ],\n \"Total\": 116\n }\n ]\n}"
response = http.request(request)
puts response.read_body"<string>"