Skip to main content

Overview

The Alta Multes API returns standardized error codes in the tRetorn object. All responses include a CodiRetorn (return code) and optional DescRetorn (description).

Standard Response Format

<tRetorn xmlns="http://schemas.datacontract.org/2004/07/WcfMultesPDA">
  <CodiRetorn>0</CodiRetorn>
  <DescRetorn/>
</tRetorn>

General Error Code Patterns

Across all endpoints, these error code patterns apply:
CodeMeaningAction
0SuccessOperation completed successfully
1WarningOperation succeeded with conditions (see endpoint details)
-1Application ErrorEndpoint-specific error (see below)
-2 to -8Specific ErrorsEndpoint-specific errors (see below)
-9000Uncontrolled ExceptionGeneral exception or unexpected error
Other negativeDatabase ErrorDatabase operation failed
Always check the CodiRetorn value. A negative value indicates an error, even if the HTTP status is 200.

Endpoint-Specific Error Codes

AltaMulta (Register Infraction)

Endpoint: POST /AltaMulta
CodeMeaningDetails
0SuccessInfraction registered successfully
-1Database Insert FailedCould not add infraction to database
-9000Uncontrolled ExceptionGeneral error
Other negativeDatabase ErrorDatabase operation error
Common causes of errors:
  • XML fields not in alphabetical order
  • Invalid expedition number (outside assigned range)
  • Missing required fields
  • Invalid field values or formats
  • Text not in uppercase
<!-- Error response example -->
<tRetorn xmlns="http://schemas.datacontract.org/2004/07/WcfMultesPDA">
  <CodiRetorn>-1</CodiRetorn>
  <DescRetorn>Error al grabar la multa</DescRetorn>
</tRetorn>

AltaAnulada (Cancel Infraction)

Endpoint: GET /AltaAnulada
CodeMeaningDetails
0SuccessCancellation recorded (but see notes below)
1Already CancelledInfraction with this number already cancelled (possibly different municipality)
-1Database Save FailedCould not save cancellation to database
-9000Uncontrolled ExceptionGeneral error
Other negativeDatabase ErrorDatabase operation error
Important: Even with CodiRetorn=0, the cancellation may not be processed if:
  • Infraction has a date/proposal or no balance available
  • Infraction is transferred
  • Infraction is in a blocked executive file
  • An appeal or recourse has been submitted
  • The infraction has a sanction and payment deadline has expired
Cancellations are processed asynchronously from an intermediate database.

Consulta (Query Infraction)

Endpoint: GET /Consulta
CodeMeaningDetails
0SuccessInfraction found and returned
NegativeErrorDatabase error or infraction not found
Returns: MultaExtended object with infraction details

ObtenirRang (Get Expedition Range)

Endpoint: GET /ObtenirRang
CodeMeaningDetails
0SuccessRange assigned successfully
-1Application ErrorCould not assign range
-9000Uncontrolled ExceptionGeneral error
Common causes:
  • Invalid IMEI (not registered)
  • Device already has an active range
  • No available ranges for the municipality
<!-- Success response with range -->
<Rang xmlns="http://schemas.datacontract.org/2004/07/WcfMultesPDA">
  <Retorn>
    <CodiRetorn>0</CodiRetorn>
    <DescRetorn/>
  </Retorn>
  <Minrang1>1590621</Minrang1>
  <MaxRang1>1590630</MaxRang1>
  <MinRang2>1590631</MinRang2>
  <MaxRang2>1590640</MaxRang2>
</Rang>

FerLogin (Agent Login)

Endpoint: GET /FerLogin
CodeMeaningDetails
0SuccessAuthentication successful
-1Device Not FoundIMEI not registered or password not set
-2Agent MismatchAgent does not belong to device’s municipality
-3Wrong PasswordIncorrect password provided
-4Password Change FailedDatabase error updating password
-9000Uncontrolled ExceptionGeneral error
Other negativeDatabase ErrorDatabase operation error
<!-- Success response -->
<LoginResult xmlns="http://schemas.datacontract.org/2004/07/WcfMultesPDA">
  <Retorn>
    <CodiRetorn>0</CodiRetorn>
    <DescRetorn/>
  </Retorn>
  <Client>088</Client>
  <DiaiHora>04/03/2026 14:30:00</DiaiHora>
  <Canviar>false</Canviar>
</LoginResult>

CanviPassword (Change Password)

Endpoint: GET /CanviPassword
CodeMeaningDetails
0SuccessPassword changed successfully
-1Device Not FoundIMEI not registered or new password not provided
-2Agent MismatchAgent does not belong to device’s municipality
-3Wrong Old PasswordCurrent password is incorrect
-4Database Update FailedCould not update password in database
-9000Uncontrolled ExceptionGeneral error
Other negativeDatabase ErrorDatabase operation error

ObtenirEscuts (Get Municipality Emblems)

Endpoint: GET /ObtenirEscuts
CodeMeaningDetails
0SuccessEmblems returned (or no changes if pForsar=false)
-1Invalid DeviceIMEI number is not correct
-2No EmblemsMunicipality has no associated emblems
-9000Uncontrolled ExceptionGeneral error
Other negativeDatabase ErrorDatabase operation error

ObtenirActualitzacions (Get Updates)

Endpoint: GET /ObtenirActualitzacions
CodeMeaningDetails
0SuccessUpdates retrieved successfully
-9000Uncontrolled ExceptionGeneral error
Returns: Actualitzacions object with master file updates and a Seguent (next) parameter for pagination.
Make successive calls with the Seguent value from the previous response until it returns empty, indicating no more updates.

BuscarPrecintat (Check Vehicle Seal)

Endpoint: POST /BuscarPrecintat
CodeMeaningDetails
0SuccessQuery completed
-1Application ErrorError checking seal status
-9000Uncontrolled ExceptionGeneral error

BuscarFitxer (Download File)

Endpoint: POST /BuscarFitxer
CodeMeaningDetails
0SuccessFile downloaded successfully
-9000Uncontrolled ExceptionGeneral error or file not found

ComprovarSoftware (Check Software)

Endpoint: POST /ComprovarSoftware
CodeMeaningDetails
0SuccessSoftware version checked
-1Executable Not FoundRequested executable not available
-9000Uncontrolled ExceptionGeneral error
Other negativeDatabase ErrorDatabase operation error

Error Handling Best Practices

1. Always Check Return Code

import xml.etree.ElementTree as ET

def check_response(xml_response):
    root = ET.fromstring(xml_response)
    ns = {'ns': 'http://schemas.datacontract.org/2004/07/WcfMultesPDA'}
    
    code = int(root.find('.//ns:CodiRetorn', ns).text)
    desc = root.find('.//ns:DescRetorn', ns).text or ''
    
    if code < 0:
        raise Exception(f"API Error {code}: {desc}")
    elif code == 1:
        # Warning - operation succeeded with conditions
        print(f"Warning: {desc}")
    
    return code, desc

2. Handle Specific Error Codes

def handle_login_error(code, desc):
    if code == -1:
        return "Device not registered. Contact ORGT."
    elif code == -2:
        return "Agent does not belong to this municipality."
    elif code == -3:
        return "Incorrect password."
    elif code == -4:
        return "Database error. Try again later."
    elif code == -9000:
        return f"System error: {desc}"
    else:
        return f"Unknown error {code}: {desc}"

3. Retry Logic for Transient Errors

import time

def call_api_with_retry(func, max_retries=3):
    for attempt in range(max_retries):
        try:
            code, desc = func()
            
            # Retry on database errors
            if code < 0 and code != -9000 and code not in [-1, -2, -3, -4]:
                if attempt < max_retries - 1:
                    time.sleep(2 ** attempt)  # Exponential backoff
                    continue
            
            return code, desc
            
        except Exception as e:
            if attempt == max_retries - 1:
                raise
            time.sleep(2 ** attempt)

4. Log All Errors

Always log the full error response including CodiRetorn and DescRetorn for debugging and audit purposes.
import logging

def log_api_error(endpoint, code, desc, request_data=None):
    logging.error(
        f"API Error - Endpoint: {endpoint}, Code: {code}, "
        f"Description: {desc}, Request: {request_data}"
    )

Common Error Scenarios

XML Field Ordering Error (AltaMulta)

Symptom: -1 return code when submitting infractions Cause: XML fields not in alphabetical order Solution: Ensure fields are sorted alphabetically (cdagen first, viapen last)

IMEI Not Registered

Symptom: -1 return code on login or range requests Cause: Device IMEI not registered with ORGT Solution: Contact ORGT to register the IMEI

Certificate Authentication Failed

Symptom: HTTPS connection error before reaching the API Cause: Certificate not installed on ORGT servers or incorrect client certificate Solution: Verify certificate with ORGT, ensure using correct cert files

Invalid Expedition Number

Symptom: -1 return code when creating infraction Cause: Expedition number outside assigned range Solution: Request a new range using ObtenirRang

Next Steps

Build docs developers (and LLMs) love