Skip to main content
This guide walks you through requesting CUIS and CUFD codes - the essential first steps for any SIAT integration.

What You’ll Build

You’ll create a complete program that:
  1. Initializes the go-siat SDK
  2. Requests a CUIS (Código Único de Inicio de Sistemas)
  3. Uses the CUIS to request a CUFD (Código Único de Facturación Diaria)
CUIS and CUFD codes are required before you can perform any invoicing operations in SIAT.

Prerequisites

1

Install go-siat

go get github.com/ron86i/go-siat@latest
2

Get your SIAT credentials

You’ll need:
  • API Token: Your SIAT authentication token
  • NIT: Your tax identification number
  • Sistema Code: Your registered system code

Complete Example

Create a new file main.go:
main.go
package main

import (
    "context"
    "fmt"
    "log"

    "github.com/ron86i/go-siat"
    "github.com/ron86i/go-siat/pkg/config"
    "github.com/ron86i/go-siat/pkg/models"
)

func main() {
    // 1. Initialize the SIAT SDK
    s, err := siat.New("https://pilotosiatservicios.impuestos.gob.bo/v2", nil)
    if err != nil {
        log.Fatalf("Error: %v", err)
    }

    codigosService := s.Codigos

    // 2. Build CUIS request using the builder pattern
    cuisReq := models.Codigos.NewCuisRequest().
        WithCodigoAmbiente(1).
        WithCodigoModalidad(1).
        WithCodigoPuntoVenta(0).
        WithCodigoSucursal(0).
        WithCodigoSistema("ABC123DEF").
        WithNit(123456789).
        Build()

    ctx := context.Background()
    cfg := config.Config{Token: "TU_TOKEN_API"}

    // 3. Request CUIS
    resp, err := codigosService.SolicitudCuis(ctx, cfg, cuisReq)
    if err != nil {
        log.Fatalf("Error al solicitar CUIS: %v", err)
    }

    if resp != nil && resp.Body.Content.RespuestaCuis.Transaccion {
        fmt.Printf("CUIS obtenido: %s\n", resp.Body.Content.RespuestaCuis.Codigo)

        // 4. With the CUIS, request a CUFD
        cufdReq := models.Codigos.NewCufdRequest().
            WithCodigoAmbiente(1).
            WithCodigoModalidad(1).
            WithCodigoPuntoVenta(0).
            WithCodigoSucursal(0).
            WithCodigoSistema("ABC123DEF").
            WithNit(123456789).
            WithCuis(resp.Body.Content.RespuestaCuis.Codigo).
            Build()

        cufdResp, err := codigosService.SolicitudCufd(ctx, cfg, cufdReq)
        if err == nil && cufdResp.Body.Content.RespuestaCufd.Transaccion {
            fmt.Printf("CUFD obtenido: %s (Control: %s)\n",
                cufdResp.Body.Content.RespuestaCufd.Codigo,
                cufdResp.Body.Content.RespuestaCufd.CodigoControl)
        }
    }
}

Understanding the Code

Let’s break down each step:

Step 1: Initialize the SDK

s, err := siat.New("https://pilotosiatservicios.impuestos.gob.bo/v2", nil)
  • First parameter: SIAT base URL (use pilot URL for testing)
  • Second parameter: HTTP client (nil uses default with 15s timeout)
  • Returns a siatServices struct with access to all modules

Step 2: Build a CUIS Request

cuisReq := models.Codigos.NewCuisRequest().
    WithCodigoAmbiente(1).        // 1=Testing, 2=Production
    WithCodigoModalidad(1).        // Modality code
    WithCodigoPuntoVenta(0).       // Point of sale code (0=main office)
    WithCodigoSucursal(0).         // Branch code (0=main branch)
    WithCodigoSistema("ABC123DEF"). // Your system code
    WithNit(123456789).            // Your NIT
    Build()
Replace "ABC123DEF" and 123456789 with your actual system code and NIT.
The builder pattern ensures:
  • Type safety: Can’t pass wrong types
  • Fluent API: Chain methods for readability
  • Immutability: Build() returns an opaque interface

Step 3: Execute the Request

ctx := context.Background()
cfg := config.Config{Token: "TU_TOKEN_API"}

resp, err := codigosService.SolicitudCuis(ctx, cfg, cuisReq)
  • Context: For cancellation and timeouts
  • Config: Contains your API token
  • Request: The built request object

Step 4: Use the CUIS to Request CUFD

Once you have a CUIS, you can request a CUFD:
cufdReq := models.Codigos.NewCufdRequest().
    // ... other parameters ...
    WithCuis(resp.Body.Content.RespuestaCuis.Codigo). // Use obtained CUIS
    Build()

Running the Example

1

Configure your credentials

Edit the code to include your actual:
  • API Token
  • NIT
  • Sistema Code
2

Run the program

go run main.go
3

Expected output

CUIS obtenido: C2FC682B
CUFD obtenido: B2A9F3E1 (Control: XYZ789)

Common Parameters Explained

CodigoAmbiente
int
required
Environment code:
  • 1 = Testing/Pilot
  • 2 = Production
CodigoModalidad
int
required
Modality code:
  • 1 = Electronic Invoicing
  • 2 = Electronic Invoicing with Electronic Sales Note
CodigoSucursal
int
required
Branch code. Use 0 for the main branch.
CodigoPuntoVenta
int
required
Point of sale code. Use 0 for the main office.
CodigoSistema
string
required
Your registered system code in SIAT.
Nit
int64
required
Your tax identification number.

Next Steps

Now that you can request CUIS and CUFD codes, explore other SDK capabilities:

NIT Validation

req := models.Codigos.NewVerificarNitRequest().
    WithNitParaVerificacion(123456789).
    WithCuis("C2FC682B").
    // ... other params
    Build()

resp, err := s.Codigos.VerificarNit(ctx, cfg, req)

Catalog Synchronization

req := models.Sincronizacion.NewSincronizarActividadesRequest().
    WithCodigoAmbiente(1).
    WithNit(123456789).
    WithCodigoSistema("ABC123DEF").
    WithCuis("C2FC682B").
    Build()

resp, err := s.Sincronizacion.SincronizarActividades(ctx, cfg, req)

Point of Sale Operations

req := models.Operaciones.NewRegistroPuntoVentaRequest().
    WithCodigoAmbiente(1).
    WithNit(123456789).
    WithCodigoTipoPuntoVenta(2).
    WithNombrePuntoVenta("Caja 01").
    WithCuis("C2FC682B").
    Build()

resp, err := s.Operaciones.RegistroPuntoVenta(ctx, cfg, req)

Invoice Operations

Learn how to:
  • Generate CUF codes
  • Build and sign invoices
  • Send invoices to SIAT
  • Cancel invoices

Error Handling

Always check the transaction status in responses:
if resp != nil && resp.Body.Content.RespuestaCuis.Transaccion {
    // Success - use the response
    fmt.Println("CUIS:", resp.Body.Content.RespuestaCuis.Codigo)
} else {
    // Failed - check error messages
    fmt.Println("Error:", resp.Body.Content.RespuestaCuis.Mensajes)
}
Store CUIS codes securely - they’re valid for extended periods and required for most SIAT operations.

Troubleshooting

Verify your API token is correct and active:
cfg := config.Config{Token: "YOUR_ACTUAL_TOKEN"}
Ensure your sistema code is registered in SIAT:
  • Contact SIAT support to verify your system registration
  • Check that you’re using the exact code provided during registration
If requests timeout, increase the HTTP client timeout:
client := &http.Client{Timeout: 30 * time.Second}
s, err := siat.New(baseURL, client)
Remember to change CodigoAmbiente when moving to production:
  • Testing: WithCodigoAmbiente(1)
  • Production: WithCodigoAmbiente(2)

Build docs developers (and LLMs) love