Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/BladimirGS/judicial-backend/llms.txt

Use this file to discover all available pages before exploring further.

This endpoint registers a new second-instance appeal in the system. A single request captures the appeal metadata, the court of origin (penal) or community details (indígena), and at least one relación — a pairing of an offended party and a defendant, each linked to one or more offenses. On success the server returns a system-generated folio number and the assigned sala. The request body is a discriminated union on idMateria:
  • idMateria: 5Penal appeal — requires court-of-origin fields (idApelacion, idTipoApelacion, idJuzgado, expedienteCausa, fechaAuto, idTipoEscrito).
  • idMateria: 6Indígena appeal — requires community fields (idMunicipio, idLocalidad, idEtnia, lugarHechos).
Folio generation is handled server-side by the PA_INS_PCF_FolioTramite stored procedure. The generated folio is returned in the response as folioOficialia and can be used immediately to look up the appeal via GET /api/apelaciones/detalle.

POST /api/apelaciones

Authentication

This endpoint requires a valid JWT. Include Authorization: Bearer <token> in every request. Requests without a valid token return 401 Unauthorized.

Request Body

All fields marked required must be present. Conditionally required fields are only validated when idMateria matches the indicated value.

Common fields (both materias)

idMateria
integer
required
Discriminator for the appeal type. Use 5 for penal and 6 for indígena. All other integers are rejected with a validation error.
idMagistrado
integer
ID of the magistrate to assign to this appeal. Optional — the sala assignment procedure may set one automatically.
esReposicion
boolean
Set to true if this appeal is a repositioning (reposición) rather than a first-time appeal. Defaults to false when omitted.
relaciones
RelacionPayload[]
required
Array of case relations. At least one relation is required. Each relation links an offended party to a defendant and one or more offenses.

Penal-only fields (idMateria: 5)

idApelacion
integer
required
ID of the top-level appeal catalog entry (from data.apelaciones).
idTipoApelacion
integer
required
ID of the appeal sub-type (from GET /:idApelacion/tipos-apelacion).
fechaAuto
string
required
Date of the originating court order in YYYY-MM-DD format (e.g. "2024-01-15").
expedienteCausa
string
required
Case file number from the court of origin (e.g. "CAUSA-001").
idTipoEscrito
integer
required
ID from the tiposEscritos catalog — the type of written brief being filed.
idJuzgado
integer
required
ID of the originating court (from data.juzgados).
folioOficio
string
Office folio reference string. Optional.
expedienteAcumulado
string
Accumulated case file identifier. Optional. Maximum 10 characters.
fojas
integer
Number of pages in the submitted brief. Optional.
observaciones
string
Free-text observations about the appeal. Optional.

Indígena-only fields (idMateria: 6)

idMunicipio
integer
required
ID from the municipios catalog.
idLocalidad
integer
required
ID from the localidades catalog (obtained via GET /:idMunicipio/localidades).
idEtnia
integer
required
ID from the etnias catalog.
otroEtnia
string
Free-text ethnic group description. Required when idEtnia === 17 (“Otro”).
lugarHechos
string
required
Description of the location where the events occurred (e.g. "Comunidad San Juan Copala").
asunto
string
Brief description of the matter under appeal. Optional.

Response — 201 Created

status
string
"success"
message
string
"Apelación registrada correctamente"
data
object
data.id
integer
Internal database ID assigned to the newly created appeal record.
data.folioOficialia
string
The system-generated folio number (e.g. "2024-PCF-042"). Use this value to retrieve the full appeal detail via GET /api/apelaciones/detalle?folioOficialia=<folio>.
data.sala
string
The description of the assigned sala (courtroom), determined by the PA_SEL_AsignacionTocaSala stored procedure.

Error Responses

HTTP StatusReasonDescription
400 Bad RequestValidation failureOne or more required fields are missing or have the wrong type. The response body includes a errors object mapping field names to messages.
400 Bad RequestNo sala availableThe sala-assignment stored procedure returned IdSala <= 0, meaning no courtroom could be assigned for the given parameters.
401 UnauthorizedMissing or invalid JWTAuthentication failed.

Example Request — Penal Appeal

curl -X POST 'http://localhost:4000/api/apelaciones' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "idMateria": 5,
    "idMagistrado": 1,
    "esReposicion": false,
    "idApelacion": 1,
    "idTipoApelacion": 1,
    "fechaAuto": "2024-03-10",
    "expedienteCausa": "CAUSA-001",
    "idTipoEscrito": 1,
    "idJuzgado": 2,
    "folioOficio": "OF-2024-001",
    "fojas": 15,
    "relaciones": [
      {
        "ofendido": {
          "nombre": "María López",
          "menorEdad": false,
          "idTipoParte": 1,
          "idSexo": 2
        },
        "procesado": {
          "nombre": "Juan Pérez",
          "direccion": "Calle Reforma 123",
          "menorEdad": false,
          "idTipoParte": 2,
          "idSexo": 1
        },
        "delitoRelaciones": [
          { "idDelito": 4 }
        ]
      }
    ]
  }'

Example Response

{
  "status": "success",
  "message": "Apelación registrada correctamente",
  "data": {
    "id": 87,
    "folioOficialia": "2024-PCF-042",
    "sala": "Primera Sala Penal"
  }
}

Example Request — Indígena Appeal

curl -X POST 'http://localhost:4000/api/apelaciones' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "idMateria": 6,
    "idMagistrado": 2,
    "esReposicion": false,
    "idMunicipio": 3,
    "idLocalidad": 10,
    "idEtnia": 5,
    "lugarHechos": "Comunidad Yosoyuxi",
    "asunto": "Conflicto de tierras comunales",
    "relaciones": [
      {
        "ofendido": {
          "nombre": "Comunidad Yosoyuxi",
          "menorEdad": false,
          "idTipoParte": 1,
          "idSexo": 1
        },
        "procesado": {
          "nombre": "Pedro González",
          "menorEdad": false,
          "idTipoParte": 2,
          "idSexo": 1
        },
        "delitoRelaciones": [
          { "idDelito": 12 }
        ]
      }
    ]
  }'
The folio number returned in data.folioOficialia is generated by the [dbo].[PA_INS_PCF_FolioTramite] SQL Server stored procedure. The procedure writes an entry to the folio registry table and returns an NVARCHAR(10) output parameter. If the procedure returns an empty result the API responds with HTTP 500 and error code SP_FOLIO_TRAMITE_NO_RESULT.

Build docs developers (and LLMs) love