Creates a withholding CFDI
curl --request POST \
--url https://apisandbox.facturama.mx/2/retenciones \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"FolioInt": "0001",
"FechaExp": "2024-04-17T12:00:01",
"CveRetenc": "01",
"LugarExpRetenc": "78000",
"Emisor": {
"RFCEmisor": "EKU9003173C9",
"NomDenRazSocE": "ESCUELA KEMPER URGATE",
"RegimenFiscalE": "601"
},
"Receptor": {
"Nacionalidad": "Nacional",
"Nacional": {
"RFCRecep": "CACX7605101P8",
"NomDenRazSocR": "XOCHILT CASAS CHAVEZ",
"DomicilioFiscalR": "36257"
}
},
"Periodo": {
"MesIni": "01",
"MesFin": "01",
"Ejerc": "2023"
},
"Totales": {
"montoTotOperacion": "1681.06",
"montoTotGrav": "1681.06",
"montoTotExent": "0.00",
"montoTotRet": "151.29",
"ImpRetenidos": [
{
"BaseRet": "1681.06",
"Impuesto": "01",
"MontoRet": "16.81",
"TipoPagoRet": "04"
},
{
"BaseRet": "268.96",
"Impuesto": "02",
"MontoRet": "134.48",
"TipoPagoRet": "01"
}
]
}
}
'import requests
url = "https://apisandbox.facturama.mx/2/retenciones"
payload = {
"FolioInt": "0001",
"FechaExp": "2024-04-17T12:00:01",
"CveRetenc": "01",
"LugarExpRetenc": "78000",
"Emisor": {
"RFCEmisor": "EKU9003173C9",
"NomDenRazSocE": "ESCUELA KEMPER URGATE",
"RegimenFiscalE": "601"
},
"Receptor": {
"Nacionalidad": "Nacional",
"Nacional": {
"RFCRecep": "CACX7605101P8",
"NomDenRazSocR": "XOCHILT CASAS CHAVEZ",
"DomicilioFiscalR": "36257"
}
},
"Periodo": {
"MesIni": "01",
"MesFin": "01",
"Ejerc": "2023"
},
"Totales": {
"montoTotOperacion": "1681.06",
"montoTotGrav": "1681.06",
"montoTotExent": "0.00",
"montoTotRet": "151.29",
"ImpRetenidos": [
{
"BaseRet": "1681.06",
"Impuesto": "01",
"MontoRet": "16.81",
"TipoPagoRet": "04"
},
{
"BaseRet": "268.96",
"Impuesto": "02",
"MontoRet": "134.48",
"TipoPagoRet": "01"
}
]
}
}
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({
FolioInt: '0001',
FechaExp: '2024-04-17T12:00:01',
CveRetenc: '01',
LugarExpRetenc: '78000',
Emisor: {
RFCEmisor: 'EKU9003173C9',
NomDenRazSocE: 'ESCUELA KEMPER URGATE',
RegimenFiscalE: '601'
},
Receptor: {
Nacionalidad: 'Nacional',
Nacional: {
RFCRecep: 'CACX7605101P8',
NomDenRazSocR: 'XOCHILT CASAS CHAVEZ',
DomicilioFiscalR: '36257'
}
},
Periodo: {MesIni: '01', MesFin: '01', Ejerc: '2023'},
Totales: {
montoTotOperacion: '1681.06',
montoTotGrav: '1681.06',
montoTotExent: '0.00',
montoTotRet: '151.29',
ImpRetenidos: [
{BaseRet: '1681.06', Impuesto: '01', MontoRet: '16.81', TipoPagoRet: '04'},
{BaseRet: '268.96', Impuesto: '02', MontoRet: '134.48', TipoPagoRet: '01'}
]
}
})
};
fetch('https://apisandbox.facturama.mx/2/retenciones', 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/2/retenciones",
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([
'FolioInt' => '0001',
'FechaExp' => '2024-04-17T12:00:01',
'CveRetenc' => '01',
'LugarExpRetenc' => '78000',
'Emisor' => [
'RFCEmisor' => 'EKU9003173C9',
'NomDenRazSocE' => 'ESCUELA KEMPER URGATE',
'RegimenFiscalE' => '601'
],
'Receptor' => [
'Nacionalidad' => 'Nacional',
'Nacional' => [
'RFCRecep' => 'CACX7605101P8',
'NomDenRazSocR' => 'XOCHILT CASAS CHAVEZ',
'DomicilioFiscalR' => '36257'
]
],
'Periodo' => [
'MesIni' => '01',
'MesFin' => '01',
'Ejerc' => '2023'
],
'Totales' => [
'montoTotOperacion' => '1681.06',
'montoTotGrav' => '1681.06',
'montoTotExent' => '0.00',
'montoTotRet' => '151.29',
'ImpRetenidos' => [
[
'BaseRet' => '1681.06',
'Impuesto' => '01',
'MontoRet' => '16.81',
'TipoPagoRet' => '04'
],
[
'BaseRet' => '268.96',
'Impuesto' => '02',
'MontoRet' => '134.48',
'TipoPagoRet' => '01'
]
]
]
]),
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/2/retenciones"
payload := strings.NewReader("{\n \"FolioInt\": \"0001\",\n \"FechaExp\": \"2024-04-17T12:00:01\",\n \"CveRetenc\": \"01\",\n \"LugarExpRetenc\": \"78000\",\n \"Emisor\": {\n \"RFCEmisor\": \"EKU9003173C9\",\n \"NomDenRazSocE\": \"ESCUELA KEMPER URGATE\",\n \"RegimenFiscalE\": \"601\"\n },\n \"Receptor\": {\n \"Nacionalidad\": \"Nacional\",\n \"Nacional\": {\n \"RFCRecep\": \"CACX7605101P8\",\n \"NomDenRazSocR\": \"XOCHILT CASAS CHAVEZ\",\n \"DomicilioFiscalR\": \"36257\"\n }\n },\n \"Periodo\": {\n \"MesIni\": \"01\",\n \"MesFin\": \"01\",\n \"Ejerc\": \"2023\"\n },\n \"Totales\": {\n \"montoTotOperacion\": \"1681.06\",\n \"montoTotGrav\": \"1681.06\",\n \"montoTotExent\": \"0.00\",\n \"montoTotRet\": \"151.29\",\n \"ImpRetenidos\": [\n {\n \"BaseRet\": \"1681.06\",\n \"Impuesto\": \"01\",\n \"MontoRet\": \"16.81\",\n \"TipoPagoRet\": \"04\"\n },\n {\n \"BaseRet\": \"268.96\",\n \"Impuesto\": \"02\",\n \"MontoRet\": \"134.48\",\n \"TipoPagoRet\": \"01\"\n }\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/2/retenciones")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"FolioInt\": \"0001\",\n \"FechaExp\": \"2024-04-17T12:00:01\",\n \"CveRetenc\": \"01\",\n \"LugarExpRetenc\": \"78000\",\n \"Emisor\": {\n \"RFCEmisor\": \"EKU9003173C9\",\n \"NomDenRazSocE\": \"ESCUELA KEMPER URGATE\",\n \"RegimenFiscalE\": \"601\"\n },\n \"Receptor\": {\n \"Nacionalidad\": \"Nacional\",\n \"Nacional\": {\n \"RFCRecep\": \"CACX7605101P8\",\n \"NomDenRazSocR\": \"XOCHILT CASAS CHAVEZ\",\n \"DomicilioFiscalR\": \"36257\"\n }\n },\n \"Periodo\": {\n \"MesIni\": \"01\",\n \"MesFin\": \"01\",\n \"Ejerc\": \"2023\"\n },\n \"Totales\": {\n \"montoTotOperacion\": \"1681.06\",\n \"montoTotGrav\": \"1681.06\",\n \"montoTotExent\": \"0.00\",\n \"montoTotRet\": \"151.29\",\n \"ImpRetenidos\": [\n {\n \"BaseRet\": \"1681.06\",\n \"Impuesto\": \"01\",\n \"MontoRet\": \"16.81\",\n \"TipoPagoRet\": \"04\"\n },\n {\n \"BaseRet\": \"268.96\",\n \"Impuesto\": \"02\",\n \"MontoRet\": \"134.48\",\n \"TipoPagoRet\": \"01\"\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apisandbox.facturama.mx/2/retenciones")
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 \"FolioInt\": \"0001\",\n \"FechaExp\": \"2024-04-17T12:00:01\",\n \"CveRetenc\": \"01\",\n \"LugarExpRetenc\": \"78000\",\n \"Emisor\": {\n \"RFCEmisor\": \"EKU9003173C9\",\n \"NomDenRazSocE\": \"ESCUELA KEMPER URGATE\",\n \"RegimenFiscalE\": \"601\"\n },\n \"Receptor\": {\n \"Nacionalidad\": \"Nacional\",\n \"Nacional\": {\n \"RFCRecep\": \"CACX7605101P8\",\n \"NomDenRazSocR\": \"XOCHILT CASAS CHAVEZ\",\n \"DomicilioFiscalR\": \"36257\"\n }\n },\n \"Periodo\": {\n \"MesIni\": \"01\",\n \"MesFin\": \"01\",\n \"Ejerc\": \"2023\"\n },\n \"Totales\": {\n \"montoTotOperacion\": \"1681.06\",\n \"montoTotGrav\": \"1681.06\",\n \"montoTotExent\": \"0.00\",\n \"montoTotRet\": \"151.29\",\n \"ImpRetenidos\": [\n {\n \"BaseRet\": \"1681.06\",\n \"Impuesto\": \"01\",\n \"MontoRet\": \"16.81\",\n \"TipoPagoRet\": \"04\"\n },\n {\n \"BaseRet\": \"268.96\",\n \"Impuesto\": \"02\",\n \"MontoRet\": \"134.48\",\n \"TipoPagoRet\": \"01\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"Id": "ySkHAp4rTzkXOciMRUBSJg2",
"FolioInt": "0001",
"FechaExp": "2024-04-17T12:00:01",
"CveRetenc": "01",
"LugarExpRetenc": "78000",
"Emisor": {
"RfcEmisor": "EKU9003173C9",
"NomDenRazSocE": "ESCUELA KEMPER URGATE",
"RegimenFiscalE": "601"
},
"Receptor": {
"Nacionalidad": "Nacional",
"Nacional": {
"RfcRecep": "CACX7605101P8",
"NomDenRazSocR": "XOCHILT CASAS CHAVEZ",
"DomicilioFiscalR": "36257"
}
},
"Periodo": {
"MesIni": 1,
"MesFin": 1,
"Ejerc": 2023
},
"Totales": {
"MontoTotOperacion": 1681.06,
"MontoTotGrav": 1681.06,
"MontoTotExent": 0,
"MontoTotRet": 151.29,
"ImpRetenidos": [
{
"BaseRet": 1681.06,
"Impuesto": "01",
"MontoRet": 16.81,
"TipoPagoRet": "04"
},
{
"BaseRet": 268.96,
"Impuesto": "02",
"MontoRet": 134.48,
"TipoPagoRet": "01"
}
]
},
"Complemento": {
"TimbreFiscalDigital": {
"Version": "1.1",
"UUID": "7b5b2ba5-b6dd-4c8f-a2a6-ed21a4dc2035",
"FechaTimbrado": "2024-04-17T12:00:39",
"SelloCFD": "pRBGjyeSv1tyAhkivX7rb5ReYWYmJ2zSJjSCtPTRVY7vQKWNJFVn1wslgGWGvrN...",
"NoCertificadoSAT": "30001000000500003456",
"SelloSAT": "GHk166lO/GTyEWjT4X2CiNd1EDSF97qPwj5U0tDgMTCX5ksg/LRynOQk6e1DBN...",
"RfcProvCertif": "SPR190613I52"
}
},
"CadenaOriginal": "||2.0|30001000000500003416|0001|2024-04-17T12:00:01|78000|01|EKU9003173C9|...",
"IsCanceled": false,
"Sello": "pRBGjyeSv1tyAhkivX7rb5ReYWYmJ2zSJjSCtPTRVY7vQKWNJFVn1wslgGWGvrN..."
}Authorizations
HTTP Basic authentication with Facturama username and password.
Body
CFDI 4.0 Withholdings
Required attribute for the expression of the date and time of issuance of the withholding and payment information document. Expressed in the form yyyy-mmddThh:mm:ssTZD-6, per ISO 8601.
1^(20[1-9][0-9])-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])$Required attribute to express the withholding key and payment information according to the catalog published online by SAT.
10[1-9]|1[0-9]|2[0-6]Required node to express the information of the issuing taxpayer of the electronic document of withholdings and payment information.
Show child attributes
Show child attributes
Required node to express the receiver taxpayer information.
Show child attributes
Show child attributes
Required node to express the period covered by the withholding and payment information document.
Show child attributes
Show child attributes
Required node to express the total withholdings and payment information made in the period covered by the document.
Show child attributes
Show child attributes
Required attribute to include the postal code of the place of issuance of the voucher covering withholdings and payment information.
1Optional attribute for the taxpayer's internal control that expresses the folio of the document covering the withholding and payment information. Allows numbers and/or letters.
20[0-9a-zA-Z]{1,20}Optional attribute for the taxpayer's internal control, This field has the same functionality as the FolioInt field (it is an alias)
20[0-9a-zA-Z]{1,20}Optional attribute that expresses the description of the withholding and payment information in case the CveRetenc attribute has the value for 'another type of withholdings'.
100Optional node where the Digital Tax Stamp complement will be included mandatorily and the complementary nodes determined by SAT, in accordance with the specific provisions for a sector or specific activity.
Show child attributes
Show child attributes
Unique Facturama identifier
Original string of the withholding
Indicates whether the withholding is cancelled
Digital seal of the CFDI (read-only)
Response
CFDI 4.0 Withholdings
Required attribute for the expression of the date and time of issuance of the withholding and payment information document. Expressed in the form yyyy-mmddThh:mm:ssTZD-6, per ISO 8601.
1^(20[1-9][0-9])-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])$Required attribute to express the withholding key and payment information according to the catalog published online by SAT.
10[1-9]|1[0-9]|2[0-6]Required node to express the information of the issuing taxpayer of the electronic document of withholdings and payment information.
Show child attributes
Show child attributes
Required node to express the receiver taxpayer information.
Show child attributes
Show child attributes
Required node to express the period covered by the withholding and payment information document.
Show child attributes
Show child attributes
Required node to express the total withholdings and payment information made in the period covered by the document.
Show child attributes
Show child attributes
Required attribute to include the postal code of the place of issuance of the voucher covering withholdings and payment information.
1Optional attribute for the taxpayer's internal control that expresses the folio of the document covering the withholding and payment information. Allows numbers and/or letters.
20[0-9a-zA-Z]{1,20}Optional attribute for the taxpayer's internal control, This field has the same functionality as the FolioInt field (it is an alias)
20[0-9a-zA-Z]{1,20}Optional attribute that expresses the description of the withholding and payment information in case the CveRetenc attribute has the value for 'another type of withholdings'.
100Optional node where the Digital Tax Stamp complement will be included mandatorily and the complementary nodes determined by SAT, in accordance with the specific provisions for a sector or specific activity.
Show child attributes
Show child attributes
Unique Facturama identifier
Original string of the withholding
Indicates whether the withholding is cancelled
Digital seal of the CFDI (read-only)
curl --request POST \
--url https://apisandbox.facturama.mx/2/retenciones \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"FolioInt": "0001",
"FechaExp": "2024-04-17T12:00:01",
"CveRetenc": "01",
"LugarExpRetenc": "78000",
"Emisor": {
"RFCEmisor": "EKU9003173C9",
"NomDenRazSocE": "ESCUELA KEMPER URGATE",
"RegimenFiscalE": "601"
},
"Receptor": {
"Nacionalidad": "Nacional",
"Nacional": {
"RFCRecep": "CACX7605101P8",
"NomDenRazSocR": "XOCHILT CASAS CHAVEZ",
"DomicilioFiscalR": "36257"
}
},
"Periodo": {
"MesIni": "01",
"MesFin": "01",
"Ejerc": "2023"
},
"Totales": {
"montoTotOperacion": "1681.06",
"montoTotGrav": "1681.06",
"montoTotExent": "0.00",
"montoTotRet": "151.29",
"ImpRetenidos": [
{
"BaseRet": "1681.06",
"Impuesto": "01",
"MontoRet": "16.81",
"TipoPagoRet": "04"
},
{
"BaseRet": "268.96",
"Impuesto": "02",
"MontoRet": "134.48",
"TipoPagoRet": "01"
}
]
}
}
'import requests
url = "https://apisandbox.facturama.mx/2/retenciones"
payload = {
"FolioInt": "0001",
"FechaExp": "2024-04-17T12:00:01",
"CveRetenc": "01",
"LugarExpRetenc": "78000",
"Emisor": {
"RFCEmisor": "EKU9003173C9",
"NomDenRazSocE": "ESCUELA KEMPER URGATE",
"RegimenFiscalE": "601"
},
"Receptor": {
"Nacionalidad": "Nacional",
"Nacional": {
"RFCRecep": "CACX7605101P8",
"NomDenRazSocR": "XOCHILT CASAS CHAVEZ",
"DomicilioFiscalR": "36257"
}
},
"Periodo": {
"MesIni": "01",
"MesFin": "01",
"Ejerc": "2023"
},
"Totales": {
"montoTotOperacion": "1681.06",
"montoTotGrav": "1681.06",
"montoTotExent": "0.00",
"montoTotRet": "151.29",
"ImpRetenidos": [
{
"BaseRet": "1681.06",
"Impuesto": "01",
"MontoRet": "16.81",
"TipoPagoRet": "04"
},
{
"BaseRet": "268.96",
"Impuesto": "02",
"MontoRet": "134.48",
"TipoPagoRet": "01"
}
]
}
}
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({
FolioInt: '0001',
FechaExp: '2024-04-17T12:00:01',
CveRetenc: '01',
LugarExpRetenc: '78000',
Emisor: {
RFCEmisor: 'EKU9003173C9',
NomDenRazSocE: 'ESCUELA KEMPER URGATE',
RegimenFiscalE: '601'
},
Receptor: {
Nacionalidad: 'Nacional',
Nacional: {
RFCRecep: 'CACX7605101P8',
NomDenRazSocR: 'XOCHILT CASAS CHAVEZ',
DomicilioFiscalR: '36257'
}
},
Periodo: {MesIni: '01', MesFin: '01', Ejerc: '2023'},
Totales: {
montoTotOperacion: '1681.06',
montoTotGrav: '1681.06',
montoTotExent: '0.00',
montoTotRet: '151.29',
ImpRetenidos: [
{BaseRet: '1681.06', Impuesto: '01', MontoRet: '16.81', TipoPagoRet: '04'},
{BaseRet: '268.96', Impuesto: '02', MontoRet: '134.48', TipoPagoRet: '01'}
]
}
})
};
fetch('https://apisandbox.facturama.mx/2/retenciones', 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/2/retenciones",
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([
'FolioInt' => '0001',
'FechaExp' => '2024-04-17T12:00:01',
'CveRetenc' => '01',
'LugarExpRetenc' => '78000',
'Emisor' => [
'RFCEmisor' => 'EKU9003173C9',
'NomDenRazSocE' => 'ESCUELA KEMPER URGATE',
'RegimenFiscalE' => '601'
],
'Receptor' => [
'Nacionalidad' => 'Nacional',
'Nacional' => [
'RFCRecep' => 'CACX7605101P8',
'NomDenRazSocR' => 'XOCHILT CASAS CHAVEZ',
'DomicilioFiscalR' => '36257'
]
],
'Periodo' => [
'MesIni' => '01',
'MesFin' => '01',
'Ejerc' => '2023'
],
'Totales' => [
'montoTotOperacion' => '1681.06',
'montoTotGrav' => '1681.06',
'montoTotExent' => '0.00',
'montoTotRet' => '151.29',
'ImpRetenidos' => [
[
'BaseRet' => '1681.06',
'Impuesto' => '01',
'MontoRet' => '16.81',
'TipoPagoRet' => '04'
],
[
'BaseRet' => '268.96',
'Impuesto' => '02',
'MontoRet' => '134.48',
'TipoPagoRet' => '01'
]
]
]
]),
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/2/retenciones"
payload := strings.NewReader("{\n \"FolioInt\": \"0001\",\n \"FechaExp\": \"2024-04-17T12:00:01\",\n \"CveRetenc\": \"01\",\n \"LugarExpRetenc\": \"78000\",\n \"Emisor\": {\n \"RFCEmisor\": \"EKU9003173C9\",\n \"NomDenRazSocE\": \"ESCUELA KEMPER URGATE\",\n \"RegimenFiscalE\": \"601\"\n },\n \"Receptor\": {\n \"Nacionalidad\": \"Nacional\",\n \"Nacional\": {\n \"RFCRecep\": \"CACX7605101P8\",\n \"NomDenRazSocR\": \"XOCHILT CASAS CHAVEZ\",\n \"DomicilioFiscalR\": \"36257\"\n }\n },\n \"Periodo\": {\n \"MesIni\": \"01\",\n \"MesFin\": \"01\",\n \"Ejerc\": \"2023\"\n },\n \"Totales\": {\n \"montoTotOperacion\": \"1681.06\",\n \"montoTotGrav\": \"1681.06\",\n \"montoTotExent\": \"0.00\",\n \"montoTotRet\": \"151.29\",\n \"ImpRetenidos\": [\n {\n \"BaseRet\": \"1681.06\",\n \"Impuesto\": \"01\",\n \"MontoRet\": \"16.81\",\n \"TipoPagoRet\": \"04\"\n },\n {\n \"BaseRet\": \"268.96\",\n \"Impuesto\": \"02\",\n \"MontoRet\": \"134.48\",\n \"TipoPagoRet\": \"01\"\n }\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/2/retenciones")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"FolioInt\": \"0001\",\n \"FechaExp\": \"2024-04-17T12:00:01\",\n \"CveRetenc\": \"01\",\n \"LugarExpRetenc\": \"78000\",\n \"Emisor\": {\n \"RFCEmisor\": \"EKU9003173C9\",\n \"NomDenRazSocE\": \"ESCUELA KEMPER URGATE\",\n \"RegimenFiscalE\": \"601\"\n },\n \"Receptor\": {\n \"Nacionalidad\": \"Nacional\",\n \"Nacional\": {\n \"RFCRecep\": \"CACX7605101P8\",\n \"NomDenRazSocR\": \"XOCHILT CASAS CHAVEZ\",\n \"DomicilioFiscalR\": \"36257\"\n }\n },\n \"Periodo\": {\n \"MesIni\": \"01\",\n \"MesFin\": \"01\",\n \"Ejerc\": \"2023\"\n },\n \"Totales\": {\n \"montoTotOperacion\": \"1681.06\",\n \"montoTotGrav\": \"1681.06\",\n \"montoTotExent\": \"0.00\",\n \"montoTotRet\": \"151.29\",\n \"ImpRetenidos\": [\n {\n \"BaseRet\": \"1681.06\",\n \"Impuesto\": \"01\",\n \"MontoRet\": \"16.81\",\n \"TipoPagoRet\": \"04\"\n },\n {\n \"BaseRet\": \"268.96\",\n \"Impuesto\": \"02\",\n \"MontoRet\": \"134.48\",\n \"TipoPagoRet\": \"01\"\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apisandbox.facturama.mx/2/retenciones")
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 \"FolioInt\": \"0001\",\n \"FechaExp\": \"2024-04-17T12:00:01\",\n \"CveRetenc\": \"01\",\n \"LugarExpRetenc\": \"78000\",\n \"Emisor\": {\n \"RFCEmisor\": \"EKU9003173C9\",\n \"NomDenRazSocE\": \"ESCUELA KEMPER URGATE\",\n \"RegimenFiscalE\": \"601\"\n },\n \"Receptor\": {\n \"Nacionalidad\": \"Nacional\",\n \"Nacional\": {\n \"RFCRecep\": \"CACX7605101P8\",\n \"NomDenRazSocR\": \"XOCHILT CASAS CHAVEZ\",\n \"DomicilioFiscalR\": \"36257\"\n }\n },\n \"Periodo\": {\n \"MesIni\": \"01\",\n \"MesFin\": \"01\",\n \"Ejerc\": \"2023\"\n },\n \"Totales\": {\n \"montoTotOperacion\": \"1681.06\",\n \"montoTotGrav\": \"1681.06\",\n \"montoTotExent\": \"0.00\",\n \"montoTotRet\": \"151.29\",\n \"ImpRetenidos\": [\n {\n \"BaseRet\": \"1681.06\",\n \"Impuesto\": \"01\",\n \"MontoRet\": \"16.81\",\n \"TipoPagoRet\": \"04\"\n },\n {\n \"BaseRet\": \"268.96\",\n \"Impuesto\": \"02\",\n \"MontoRet\": \"134.48\",\n \"TipoPagoRet\": \"01\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"Id": "ySkHAp4rTzkXOciMRUBSJg2",
"FolioInt": "0001",
"FechaExp": "2024-04-17T12:00:01",
"CveRetenc": "01",
"LugarExpRetenc": "78000",
"Emisor": {
"RfcEmisor": "EKU9003173C9",
"NomDenRazSocE": "ESCUELA KEMPER URGATE",
"RegimenFiscalE": "601"
},
"Receptor": {
"Nacionalidad": "Nacional",
"Nacional": {
"RfcRecep": "CACX7605101P8",
"NomDenRazSocR": "XOCHILT CASAS CHAVEZ",
"DomicilioFiscalR": "36257"
}
},
"Periodo": {
"MesIni": 1,
"MesFin": 1,
"Ejerc": 2023
},
"Totales": {
"MontoTotOperacion": 1681.06,
"MontoTotGrav": 1681.06,
"MontoTotExent": 0,
"MontoTotRet": 151.29,
"ImpRetenidos": [
{
"BaseRet": 1681.06,
"Impuesto": "01",
"MontoRet": 16.81,
"TipoPagoRet": "04"
},
{
"BaseRet": 268.96,
"Impuesto": "02",
"MontoRet": 134.48,
"TipoPagoRet": "01"
}
]
},
"Complemento": {
"TimbreFiscalDigital": {
"Version": "1.1",
"UUID": "7b5b2ba5-b6dd-4c8f-a2a6-ed21a4dc2035",
"FechaTimbrado": "2024-04-17T12:00:39",
"SelloCFD": "pRBGjyeSv1tyAhkivX7rb5ReYWYmJ2zSJjSCtPTRVY7vQKWNJFVn1wslgGWGvrN...",
"NoCertificadoSAT": "30001000000500003456",
"SelloSAT": "GHk166lO/GTyEWjT4X2CiNd1EDSF97qPwj5U0tDgMTCX5ksg/LRynOQk6e1DBN...",
"RfcProvCertif": "SPR190613I52"
}
},
"CadenaOriginal": "||2.0|30001000000500003416|0001|2024-04-17T12:00:01|78000|01|EKU9003173C9|...",
"IsCanceled": false,
"Sello": "pRBGjyeSv1tyAhkivX7rb5ReYWYmJ2zSJjSCtPTRVY7vQKWNJFVn1wslgGWGvrN..."
}