The products and services synchronization method retrieves the catalog of standardized products and services associated with your economic activities from SIAT.
SincronizarListaProductosServicios
Synchronize the catalog of products and services homologated with SIAT for your registered economic activities.
Request Builder
request := models . Sincronizacion . NewSincronizarListaProductosServiciosRequest ().
WithCodigoAmbiente ( 2 ).
WithCodigoPuntoVenta ( 0 ).
WithCodigoSistema ( "ABC123" ).
WithCodigoSucursal ( 0 ).
WithCuis ( "ABCD1234" ).
WithNit ( 1234567890 ).
Build ()
Parameters
See common parameters for all synchronization requests.
Environment code (1=production, 2=development)
System code assigned by SIAT
CUIS (Código Único de Inicio de Sesión)
Tax identification number (NIT)
Response Structure
type SincronizarListaProductosServiciosResponse struct {
RespuestaListaProductos RespuestaListaProductos
}
type RespuestaListaProductos struct {
Transaccion bool // Operation success indicator
ListaCodigos [] ListaCodigosProductos // List of products/services
}
type ListaCodigosProductos struct {
CodigoActividad uint64 // Economic activity code (CAEB)
CodigoProducto uint64 // Product/service code
DescripcionProducto string // Product/service description
}
Response Fields
RespuestaListaProductos.Transaccion
Indicates if the synchronization was successful
RespuestaListaProductos.ListaCodigos
Array of products and services associated with your activities
ListaCodigosProductos.CodigoActividad
The CAEB code of the economic activity this product/service is associated with
ListaCodigosProductos.CodigoProducto
The unique product/service code assigned by SIAT
ListaCodigosProductos.DescripcionProducto
The standardized description of the product or service
Usage Example
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 () {
cfg := config . Config {
Token : "your-api-token" ,
}
client , err := gosiat . NewSiatClient ( cfg )
if err != nil {
log . Fatal ( err )
}
// Build the synchronization request
request := models . Sincronizacion . NewSincronizarListaProductosServiciosRequest ().
WithCodigoAmbiente ( 2 ).
WithCodigoPuntoVenta ( 0 ).
WithCodigoSistema ( "ABC123" ).
WithCodigoSucursal ( 0 ).
WithCuis ( "ABCD1234" ).
WithNit ( 1234567890 ).
Build ()
// Execute the synchronization
response , err := client . Sincronizacion . SincronizarListaProductosServicios (
context . Background (),
cfg ,
request ,
)
if err != nil {
log . Fatal ( err )
}
// Check if transaction was successful
if ! response . RespuestaListaProductos . Transaccion {
log . Fatal ( "Synchronization failed" )
}
// Process the products/services
fmt . Printf ( "Retrieved %d products/services \n " ,
len ( response . RespuestaListaProductos . ListaCodigos ))
for _ , producto := range response . RespuestaListaProductos . ListaCodigos {
fmt . Printf ( "Activity: %d , Code: %d , Description: %s \n " ,
producto . CodigoActividad ,
producto . CodigoProducto ,
producto . DescripcionProducto )
}
}
Filtering by Activity
You can filter the synchronized products by economic activity:
response , err := client . Sincronizacion . SincronizarListaProductosServicios (
context . Background (),
cfg ,
request ,
)
if err != nil {
log . Fatal ( err )
}
// Filter products for a specific activity
targetActivity := uint64 ( 620100 )
var filteredProducts [] sincronizacion . ListaCodigosProductos
for _ , producto := range response . RespuestaListaProductos . ListaCodigos {
if producto . CodigoActividad == targetActivity {
filteredProducts = append ( filteredProducts , producto )
}
}
fmt . Printf ( "Found %d products for activity %d \n " ,
len ( filteredProducts ), targetActivity )
Building a Product Lookup Map
Create a lookup map for efficient product searches:
response , err := client . Sincronizacion . SincronizarListaProductosServicios (
context . Background (),
cfg ,
request ,
)
if err != nil {
log . Fatal ( err )
}
// Build a map for quick lookups
productMap := make ( map [ uint64 ] sincronizacion . ListaCodigosProductos )
for _ , producto := range response . RespuestaListaProductos . ListaCodigos {
productMap [ producto . CodigoProducto ] = producto
}
// Look up a product by code
productCode := uint64 ( 12345 )
if producto , exists := productMap [ productCode ]; exists {
fmt . Printf ( "Found: %s (Activity: %d ) \n " ,
producto . DescripcionProducto ,
producto . CodigoActividad )
} else {
fmt . Printf ( "Product %d not found \n " , productCode )
}
Caching Strategy
Since product catalogs don’t change frequently, consider caching the results:
type ProductCache struct {
Products [] sincronizacion . ListaCodigosProductos
UpdatedAt time . Time
}
var cache * ProductCache
var cacheMutex sync . RWMutex
func GetProducts ( client * gosiat . SiatClient , cfg config . Config ) ([] sincronizacion . ListaCodigosProductos , error ) {
cacheMutex . RLock ()
if cache != nil && time . Since ( cache . UpdatedAt ) < 24 * time . Hour {
products := cache . Products
cacheMutex . RUnlock ()
return products , nil
}
cacheMutex . RUnlock ()
// Cache expired or doesn't exist, fetch new data
request := models . Sincronizacion . NewSincronizarListaProductosServiciosRequest ().
WithCodigoAmbiente ( 2 ).
WithCodigoPuntoVenta ( 0 ).
WithCodigoSistema ( "ABC123" ).
WithCodigoSucursal ( 0 ).
WithCuis ( "ABCD1234" ).
WithNit ( 1234567890 ).
Build ()
response , err := client . Sincronizacion . SincronizarListaProductosServicios (
context . Background (),
cfg ,
request ,
)
if err != nil {
return nil , err
}
// Update cache
cacheMutex . Lock ()
cache = & ProductCache {
Products : response . RespuestaListaProductos . ListaCodigos ,
UpdatedAt : time . Now (),
}
products := cache . Products
cacheMutex . Unlock ()
return products , nil
}
Error Handling
response , err := client . Sincronizacion . SincronizarListaProductosServicios (
context . Background (),
cfg ,
request ,
)
if err != nil {
log . Printf ( "Failed to synchronize products: %v " , err )
return err
}
if ! response . RespuestaListaProductos . Transaccion {
log . Println ( "SIAT returned transaction failed" )
return fmt . Errorf ( "synchronization transaction failed" )
}
if len ( response . RespuestaListaProductos . ListaCodigos ) == 0 {
log . Println ( "Warning: No products returned" )
}
Activities Synchronize economic activities
Parametric Catalogs Synchronize standard SIAT parametric catalogs