Skip to main content

FEL API cURL Examples

Complete collection of cURL commands for all FEL API endpoints.

Base URLs

Production:

BASE_URL="https://fel.rpapos.com/api/fel"

Development:

BASE_URL="https://fel-dev.rpapos.com/api/fel"

Local:

BASE_URL="http://localhost:5000/api/fel"

1. Health Check

GET - Check if API is running

curl -X GET "${BASE_URL}" \
-H "Content-Type: application/json"

Response:

JjjL
RPAfelApi api/fel v1

2. Get Authentication Token

POST /api/fel/GetToken - Get authentication token from certification provider

curl -X POST "${BASE_URL}/GetToken" \
-H "Content-Type: application/json" \
-d '{
"UserName": "GT.000044653948.RPA_TEST",
"Password": "your-password"
}'

Example Response:

{
"Success": true,
"response": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expira_en": "2024-01-01T12:00:00",
"otorgado_a": "GT.000044653948.RPA_TEST"
}
}

Save token for subsequent requests:

TOKEN=$(curl -s -X POST "${BASE_URL}/GetToken" \
-H "Content-Type: application/json" \
-d '{
"UserName": "GT.000044653948.RPA_TEST",
"Password": "your-password"
}' | jq -r '.response.token')

echo "Token: $TOKEN"

3. Generate Certificate to Sign

POST /api/fel/generateCertificateToSign - Generate and sign an electronic invoice certificate

Basic Example

curl -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"ID": "DatosCertificados",
"DatosEmision": {
"ID": "DatosEmision",
"DatosGenerales": {
"Tipo": "FACT",
"FechaHoraEmision": "2024-01-15T10:30:00",
"CodigoMoneda": "GTQ",
"rpaUUID": "550e8400-e29b-41d4-a716-446655440000",
"rpaDE_Empresa": "Digifact",
"rpaCertificador_Usuario": "GT.000044653948.RPA_TEST",
"rpaCertificador_Clave": "your-password",
"rpaFisco_Usuario": ""
},
"Emisor": {
"NITEmisor": "44653948",
"NombreEmisor": "CAFE DESPIERTO, S.A.",
"CodigoEstablecimiento": "1",
"NombreComercial": "CAFE DESPIERTO",
"AfiliacionIVA": "GEN",
"DireccionEmisor": {
"Direccion": "VIA 4 1-17 ZONA 4 GUATEMALA,GUATEMALA",
"CodigoPostal": "01001",
"Municipio": "Guatemala",
"Departamento": "Guatemala",
"Pais": "GT"
}
},
"Receptor": {
"NombreReceptor": "RANGEL,CASTRO,,KENNETH,ZAIDD",
"IDReceptor": "49862952",
"DireccionReceptor": {
"Direccion": "CIUDAD",
"CodigoPostal": "01001",
"Municipio": "Guatemala",
"Departamento": "Guatemala",
"Pais": "GT"
}
},
"Frases": {
"Frase": [
{
"TipoFrase": "1",
"CodigoEscenario": "1"
}
]
},
"Items": {
"Item": [
{
"NumeroLinea": "1",
"BienOServicio": "B",
"Cantidad": "1",
"UnidadMedida": "UNI",
"Descripcion": "Product description",
"PrecioUnitario": "100.00",
"Precio": "100.00",
"Descuento": "0",
"Total": "100.00",
"Impuestos": {
"Impuesto": [
{
"NombreCorto": "IVA",
"CodigoUnidadGravable": "1",
"MontoGravable": "89.29",
"MontoImpuesto": "10.71"
}
]
}
}
]
},
"Totales": {
"GranTotal": "100.00",
"TotalImpuestos": {
"TotalImpuesto": [
{
"NombreCorto": "IVA",
"TotalMontoImpuesto": "10.71"
}
]
}
}
},
"extra": {
"subDomain": "DMO1"
}
}'

Using a JSON File

curl -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d @invoice.json

Example invoice.json:

{
"ID": "DatosCertificados",
"DatosEmision": {
"ID": "DatosEmision",
"DatosGenerales": {
"Tipo": "FACT",
"FechaHoraEmision": "2024-01-15T10:30:00",
"CodigoMoneda": "GTQ",
"rpaUUID": "550e8400-e29b-41d4-a716-446655440000",
"rpaDE_Empresa": "Digifact",
"rpaCertificador_Usuario": "GT.000044653948.RPA_TEST",
"rpaCertificador_Clave": "your-password",
"rpaFisco_Usuario": ""
},
"Emisor": {
"NITEmisor": "44653948",
"NombreEmisor": "COMPANY NAME, S.A.",
"CodigoEstablecimiento": "1",
"NombreComercial": "COMPANY",
"AfiliacionIVA": "GEN",
"DireccionEmisor": {
"Direccion": "ADDRESS",
"CodigoPostal": "01001",
"Municipio": "Guatemala",
"Departamento": "Guatemala",
"Pais": "GT"
}
},
"Receptor": {
"NombreReceptor": "CUSTOMER NAME",
"IDReceptor": "49862952",
"DireccionReceptor": {
"Direccion": "ADDRESS",
"CodigoPostal": "01001",
"Municipio": "Guatemala",
"Departamento": "Guatemala",
"Pais": "GT"
}
},
"Frases": {
"Frase": [
{
"TipoFrase": "1",
"CodigoEscenario": "1"
}
]
},
"Items": {
"Item": [
{
"NumeroLinea": "1",
"BienOServicio": "B",
"Cantidad": "1",
"UnidadMedida": "UNI",
"Descripcion": "Product description",
"PrecioUnitario": "100.00",
"Precio": "100.00",
"Descuento": "0",
"Total": "100.00",
"Impuestos": {
"Impuesto": [
{
"NombreCorto": "IVA",
"CodigoUnidadGravable": "1",
"MontoGravable": "89.29",
"MontoImpuesto": "10.71"
}
]
}
}
]
},
"Totales": {
"GranTotal": "100.00",
"TotalImpuestos": {
"TotalImpuesto": [
{
"NombreCorto": "IVA",
"TotalMontoImpuesto": "10.71"
}
]
}
}
},
"extra": {
"subDomain": "DMO1"
}
}

With Tip (Propina) in Adenda

curl -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"ID": "DatosCertificados",
"DatosEmision": {
"ID": "DatosEmision",
"DatosGenerales": {
"Tipo": "FACT",
"FechaHoraEmision": "2024-01-15T10:30:00",
"CodigoMoneda": "GTQ",
"rpaUUID": "550e8400-e29b-41d4-a716-446655440000",
"rpaDE_Empresa": "Digifact",
"rpaCertificador_Usuario": "GT.000044653948.RPA_TEST",
"rpaCertificador_Clave": "your-password",
"rpaFisco_Usuario": ""
},
"Emisor": {
"NITEmisor": "44653948",
"NombreEmisor": "RESTAURANT NAME, S.A.",
"CodigoEstablecimiento": "1",
"NombreComercial": "RESTAURANT",
"AfiliacionIVA": "GEN",
"DireccionEmisor": {
"Direccion": "ADDRESS",
"CodigoPostal": "01001",
"Municipio": "Guatemala",
"Departamento": "Guatemala",
"Pais": "GT"
}
},
"Receptor": {
"NombreReceptor": "CUSTOMER NAME",
"IDReceptor": "49862952",
"DireccionReceptor": {
"Direccion": "ADDRESS",
"CodigoPostal": "01001",
"Municipio": "Guatemala",
"Departamento": "Guatemala",
"Pais": "GT"
}
},
"Frases": {
"Frase": [
{
"TipoFrase": "1",
"CodigoEscenario": "1"
}
]
},
"Items": {
"Item": [
{
"NumeroLinea": "1",
"BienOServicio": "S",
"Cantidad": "1",
"UnidadMedida": "UNI",
"Descripcion": "Meal",
"PrecioUnitario": "100.00",
"Precio": "100.00",
"Descuento": "0",
"Total": "100.00",
"Impuestos": {
"Impuesto": [
{
"NombreCorto": "IVA",
"CodigoUnidadGravable": "1",
"MontoGravable": "89.29",
"MontoImpuesto": "10.71"
}
]
}
},
{
"NumeroLinea": "2",
"BienOServicio": "S",
"Cantidad": "1",
"UnidadMedida": "UNI",
"Descripcion": "PROPINA",
"PrecioUnitario": "10.00",
"Precio": "10.00",
"Descuento": "0",
"Total": "10.00",
"Impuestos": {
"Impuesto": []
}
}
]
},
"Totales": {
"GranTotal": "110.00",
"TotalImpuestos": {
"TotalImpuesto": [
{
"NombreCorto": "IVA",
"TotalMontoImpuesto": "10.71"
}
]
}
}
},
"extra": {
"subDomain": "DMO1",
"PropinaAdenda": "1"
}
}'

With CUI Identification Type

curl -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"ID": "DatosCertificados",
"DatosEmision": {
"ID": "DatosEmision",
"DatosGenerales": {
"Tipo": "FACT",
"FechaHoraEmision": "2024-01-15T10:30:00",
"CodigoMoneda": "GTQ",
"rpaUUID": "550e8400-e29b-41d4-a716-446655440000",
"rpaDE_Empresa": "Digifact",
"rpaCertificador_Usuario": "GT.000044653948.RPA_TEST",
"rpaCertificador_Clave": "your-password",
"rpaFisco_Usuario": ""
},
"Emisor": {
"NITEmisor": "44653948",
"NombreEmisor": "COMPANY NAME, S.A.",
"CodigoEstablecimiento": "1",
"NombreComercial": "COMPANY",
"AfiliacionIVA": "GEN",
"DireccionEmisor": {
"Direccion": "ADDRESS",
"CodigoPostal": "01001",
"Municipio": "Guatemala",
"Departamento": "Guatemala",
"Pais": "GT"
}
},
"Receptor": {
"NombreReceptor": "CUSTOMER NAME",
"IDReceptor": "2260269730101",
"TipoEspecial": "CUI",
"DireccionReceptor": {
"Direccion": "ADDRESS",
"CodigoPostal": "01001",
"Municipio": "Guatemala",
"Departamento": "Guatemala",
"Pais": "GT"
}
},
"Frases": {
"Frase": [
{
"TipoFrase": "1",
"CodigoEscenario": "1"
}
]
},
"Items": {
"Item": [
{
"NumeroLinea": "1",
"BienOServicio": "B",
"Cantidad": "1",
"UnidadMedida": "UNI",
"Descripcion": "Product description",
"PrecioUnitario": "100.00",
"Precio": "100.00",
"Descuento": "0",
"Total": "100.00",
"Impuestos": {
"Impuesto": [
{
"NombreCorto": "IVA",
"CodigoUnidadGravable": "1",
"MontoGravable": "89.29",
"MontoImpuesto": "10.71"
}
]
}
}
]
},
"Totales": {
"GranTotal": "100.00",
"TotalImpuestos": {
"TotalImpuesto": [
{
"NombreCorto": "IVA",
"TotalMontoImpuesto": "10.71"
}
]
}
}
},
"extra": {
"subDomain": "DMO1",
"TipoEspecial": "CUI"
}
}'

Using Different Providers

Infile:

curl -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"DatosEmision": {
"DatosGenerales": {
"rpaDE_Empresa": "Infile",
...
}
}
}'

Fegora:

curl -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"DatosEmision": {
"DatosGenerales": {
"rpaDE_Empresa": "Fegora",
...
}
}
}'

GuateFactura:

curl -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"DatosEmision": {
"DatosGenerales": {
"rpaDE_Empresa": "GuateFactura",
...
}
}
}'

Example Success Response:

{
"rpaUUID": "550e8400-e29b-41d4-a716-446655440000",
"Codigo": 0,
"Mensaje": "OK",
"AcuseReciboSAT": "A-1234567890",
"NITCertificador": "12345678",
"NombreCertificador": "DIGIFACT S.A.",
"Autorizacion_Serie": "A",
"Autorizacion_Numero": "123456",
"Autorizacion_Text": "A-123456",
"FechaHoraCertificacion": "2024-01-15T10:30:00Z"
}

4. Void Certificate

POST /api/fel/voidCertificate - Cancel/void an existing certificate

curl -X POST "${BASE_URL}/voidCertificate" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"NumeroDocumentoAAnular": "A-123456",
"NITEmisor": "44653948",
"IDReceptor": "49862952",
"FechaEmisionDocumentoAnular": "2024-01-15T10:30:00",
"FechaHoraAnulacion": "2024-01-15T11:00:00",
"MotivoAnulacion": "Error en facturación",
"Gface": "Digifact",
"rpaCertificador_Usuario": "GT.000044653948.RPA_TEST"
}'

Example Response:

{
"ok": true,
"voidID": "firebase-document-id",
"data": {
"motivoAnulacion": "Error en facturación",
"fechaHoraAnulacion": "2024-01-15T11:00:00",
"fechaEmisionDocumentoAnular": "2024-01-15T10:30:00",
"numeroDocumentoAAnular": "A-123456",
"rpaUUID": "550e8400-e29b-41d4-a716-446655440000",
"serie": "A",
"autorizacion": "A-123456",
"numero": "123456",
"fechaDTE": "2024-01-15T10:30:00",
"nitEface": "12345678",
"nombreEface": "DIGIFACT S.A.",
"nitComprador": "49862952",
"nombreComprador": "CUSTOMER NAME",
"fechaDeCertificacion": "2024-01-15T10:30:00"
}
}

5. Query Payer Info

POST /api/fel/QueryPayerInfo - Query taxpayer information by NIT or CUI

Query by NIT

curl -X POST "${BASE_URL}/QueryPayerInfo" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"IdentificationType": "NIT",
"gface": "Digifact",
"payerId": "49862952",
"EmisorUser": "RPA_TEST",
"EmisorNIT": "44653948"
}'

Query by CUI

curl -X POST "${BASE_URL}/QueryPayerInfo" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"IdentificationType": "CUI",
"gface": "Digifact",
"payerId": "2260269730101",
"EmisorUser": "RPA_TEST"
}'

Without Authorization Header (Auto-generates token)

curl -X POST "${BASE_URL}/QueryPayerInfo" \
-H "Content-Type: application/json" \
-d '{
"IdentificationType": "NIT",
"gface": "Digifact",
"payerId": "49862952",
"EmisorUser": "RPA_TEST",
"EmisorNIT": "44653948"
}'

Example Response:

{
"Success": true,
"TaxPayerId": "49862952",
"TaxPayerName": "RANGEL,CASTRO,,KENNETH,ZAIDD",
"PersonalId": null
}

6. Send Email

POST /api/fel/mailFel - Queue email notifications for a certificate

curl -X POST "${BASE_URL}/mailFel" \
-H "Content-Type: application/json" \
-d '{
"rpaUUID": "550e8400-e29b-41d4-a716-446655440000",
"emails": [
"customer@example.com",
"accounting@example.com"
]
}'

Example Response:

{
"id": "mail-queue-id"
}

7. Get Signed Certificate (Incomplete Endpoint)

POST /api/fel/GetSignedCertificate - Get a signed certificate (endpoint appears incomplete)

curl -X POST "${BASE_URL}/GetSignedCertificate" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{
"Gface": "Digifact",
"Certificador_Usuario": "GT.000044653948.RPA_TEST",
"Autorizacion_Text": "A-123456"
}'

Complete Workflow Example

Here's a complete workflow from getting a token to generating a certificate:

#!/bin/bash

# Set base URL
BASE_URL="https://fel.rpapos.com/api/fel"

# Step 1: Get Token
echo "Getting authentication token..."
TOKEN=$(curl -s -X POST "${BASE_URL}/GetToken" \
-H "Content-Type: application/json" \
-d '{
"UserName": "GT.000044653948.RPA_TEST",
"Password": "your-password"
}' | jq -r '.response.token')

if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then
echo "Error: Failed to get token"
exit 1
fi

echo "Token obtained: ${TOKEN:0:20}..."

# Step 2: Generate Certificate
echo "Generating certificate..."
RESPONSE=$(curl -s -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d @invoice.json)

# Check if successful
if echo "$RESPONSE" | jq -e '.Autorizacion_Text' > /dev/null 2>&1; then
AUTORIZACION=$(echo "$RESPONSE" | jq -r '.Autorizacion_Text')
echo "Certificate generated successfully!"
echo "Authorization: $AUTORIZACION"

# Step 3: Send email notification
UUID=$(echo "$RESPONSE" | jq -r '.rpaUUID')
echo "Sending email notification..."
curl -s -X POST "${BASE_URL}/mailFel" \
-H "Content-Type: application/json" \
-d "{
\"rpaUUID\": \"$UUID\",
\"emails\": [\"customer@example.com\"]
}" | jq '.'
else
echo "Error generating certificate:"
echo "$RESPONSE" | jq '.'
exit 1
fi

Error Handling Examples

Handle 400 Bad Request

curl -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d '{}' \
-w "\nHTTP Status: %{http_code}\n"

Handle 401 Unauthorized

curl -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: invalid-token" \
-d @invoice.json \
-w "\nHTTP Status: %{http_code}\n"

Verbose Output for Debugging

curl -v -X POST "${BASE_URL}/generateCertificateToSign" \
-H "Content-Type: application/json" \
-H "Authorization: ${TOKEN}" \
-d @invoice.json \
-w "\n\nHTTP Status: %{http_code}\nTime: %{time_total}s\n"

Pretty Print JSON Responses

Using jq

curl -X POST "${BASE_URL}/GetToken" \
-H "Content-Type: application/json" \
-d '{
"UserName": "GT.000044653948.RPA_TEST",
"Password": "your-password"
}' | jq '.'

Using python

curl -X POST "${BASE_URL}/GetToken" \
-H "Content-Type: application/json" \
-d '{
"UserName": "GT.000044653948.RPA_TEST",
"Password": "your-password"
}' | python -m json.tool

Testing with Different Environments

Test against Development

DEV_URL="https://fel-dev.rpapos.com/api/fel"

curl -X POST "${DEV_URL}/GetToken" \
-H "Content-Type: application/json" \
-d '{
"UserName": "GT.000044653948.RPA_TEST",
"Password": "dev-password"
}'

Test against Local

LOCAL_URL="http://localhost:5000/api/fel"

curl -X POST "${LOCAL_URL}/GetToken" \
-H "Content-Type: application/json" \
-d '{
"UserName": "GT.000044653948.RPA_TEST",
"Password": "local-password"
}'

Notes

  1. Token Expiration: Tokens expire after a certain time. Always check expiration and refresh when needed.

  2. rpaUUID: Must be unique for each document. Use UUID format: 550e8400-e29b-41d4-a716-446655440000

  3. Async Processing: Some providers (Infile, Fegora) may return 406 status if document is already being processed. The API will automatically attempt to retrieve it.

  4. Special NITs: Some NITs require special phrase handling (e.g., "87605473", "96167416", "11700207K", "14945908")

  5. Date Format: Use ISO 8601 format: 2024-01-15T10:30:00 or 2024-01-15T10:30:00Z

  6. Currency: Use GTQ for Guatemalan Quetzal

  7. Document Types:

    • FACT - Invoice
    • NCRE - Credit Note
    • NDEB - Debit Note
    • FESP - Special Invoice
    • FCAM - Exchange Invoice
    • FCAP - Purchase Invoice
    • FPEQ - Small Taxpayer Invoice
    • NABN - Payment Note
    • RECI - Receipt
    • RDON - Donation Receipt