Skip to content

Import a CSV batch

Register many cases and their drafts from one file; the failed rows come back as a CSV to fix.

This is the recipe the MCP server gives AI assistants, as is. It is in English because models follow it best that way; the assistant answers you in your language.

An assistant reads it with docs({uri:"docs://recipes/import-a-csv-batch"})

docs://recipes/import-a-csv-batch
docs://recipes/import-a-csv-batch — turn a spreadsheet of procesos into cases and DRAFT notifications

Use when the lawyer has many cases to notify at once (a cobranza list, a portfolio) in a
spreadsheet. One case? Use docs://recipes/send-an-article-8-notification instead.
An import makes cases and DRAFTS only: never a recipient, never a send, never a credit. Sending
the batch is the lawyer's act in the panel: docs://recipes/send-a-batch.

1. whoami({})
   → orgId, scopes
   scopes lack "cases:write"? Stop: the token cannot import.
   skip if you already hold orgId

2. Build the file: UTF-8 CSV, `;` or `,` separated, one proceso per row, at most 2000 rows and
   2 MB. The template is on https://www.notificado.co/importar. Required columns:
     radicado;juzgado;correo_juzgado;demandado;correo;providencia;fecha_providencia
   Optional: documentos, demandante, cliente, ciudad, especialidad, clase_proceso, termino_dias,
   mensaje, fuente_correo, detalle_fuente, soportes_correo, motivo_sin_soporte.
   An unknown or repeated column refuses the WHOLE file — never add a column of your own.
   documentos and soportes_correo take document ids from uploads (step 4 of
   docs://recipes/send-an-article-8-notification), separated by `|`.
   fuente_correo is one of comunicaciones_previas | camara_de_comercio | rut | contrato |
   web_oficial | otro; give exactly one of soportes_correo and motivo_sin_soporte with it.

3. manage_resource({resource:"imports", action:"requestImportUpload", params:{filename:"<file.csv>", size:<bytes>}})
   → key, url, contentType, expiresAt
   PUT the file's bytes to url with header Content-Type: <contentType> before expiresAt
   (url may be a path: prefix it with the server origin, e.g. https://www.notificado.co).

4. manage_resource({resource:"imports", action:"confirmImportUpload", params:{key:"<key>", filename:"<file.csv>"}})
   → import.id, status "queued"
   Refused? The PUT never landed, the file is not UTF-8 or is over 2 MB — read the fix line.

5. manage_resource({resource:"imports", action:"listImports", params:{orgId:"<orgId>", importId:"<import.id>"}})
   → status queued | running | completed | failed, total, drafted, errored
   queued or running? Check again after 10 seconds, at most 10 times, then tell the lawyer it is
   still running and stop.
   failed? The whole file was refused (a header problem, the encoding): quote the reason, stop.

6. manage_resource({resource:"imports", action:"getImport", params:{orgId:"<orgId>", importId:"<import.id>"}})
   → the import's counts, and rows[]: one per line, done (caseId, notificationId) or error ([{ field, code }])
   skip if errored is 0

7. manage_resource({resource:"imports", action:"importErrorCsv", params:{orgId:"<orgId>", importId:"<import.id>"}})
   → the failed rows as a CSV, with linea and errores columns
   Hand it to the lawyer to fix; the fixed file is a NEW import (steps 3 to 5). Never re-import
   the rows that already became drafts: each would become a second draft on the same case.
   skip if errored is 0

Done when the lawyer knows how many drafts were made and has the error file, if any. Next step is
theirs: docs://recipes/send-a-batch.

Tips
- A row's correo is only what the file proposes. The lawyer swears each address when sending.
- Dates in fecha_providencia are YYYY-MM-DD; a radicado is 23 digits, dashes allowed.
- A row whose radicado the firm already has reuses that case (warning case_reused) rather than
  creating a second one.

All recipes · Connect an assistant