Skip to main content

Upload Document

curl -X POST https://api.example.com/api/upload \
  -H "Content-Type: multipart/form-data" \
  -F "file=@/path/to/document.pdf" \
  -F "folder=soat" \
  -F "placa=ABC123"
Uploads a PDF document for a specific vehicle and document type.

HTTP Request

POST /api/upload

Content Type

multipart/form-data

Form Data Parameters

file
file
required
PDF file to upload (max 10 MB)
folder
string
required
Document type folder. Must be one of: soat, rtm, polizas, tarjeta_propiedad
placa
string
required
Vehicle license plate number (will be sanitized)

Response

path
string
Storage path where the file was uploaded
message
string
Success message

Success Response

{
  "path": "soat/ABC123_2026.pdf",
  "message": "Archivo subido correctamente"
}

Error Responses

Missing File
{
  "error": "No se proporcionó archivo"
}
Missing Parameters
{
  "error": "Folder y placa son requeridos"
}
Invalid Folder
{
  "error": "Folder no válido"
}
Invalid File Type
{
  "error": "Solo se permiten archivos PDF"
}

Implementation Details

  • Files are stored in the vehiculos_docs bucket in Supabase Storage
  • File names are generated as {sanitizedPlaca}_{currentYear}.pdf
  • The upsert: true option allows overwriting existing files
  • Files are cached for 1 hour (cacheControl: '3600')
  • Only alphanumeric characters and hyphens are allowed in the sanitized placa

Delete Document

curl -X DELETE https://api.example.com/api/upload \
  -H "Content-Type: application/json" \
  -d '{
    "path": "soat/ABC123_2026.pdf"
  }'
Deletes a previously uploaded document from storage.

HTTP Request

DELETE /api/upload

Request Body

path
string
required
Storage path of the file to delete (e.g., “soat/ABC123_2026.pdf”)

Response

message
string
Success message

Success Response

{
  "message": "Archivo eliminado correctamente"
}

Error Responses

Missing Path
{
  "error": "Path es requerido"
}
Deletion Failed
{
  "error": "Detailed error message from Supabase"
}

Implementation Details

  • Files are removed from the vehiculos_docs bucket in Supabase Storage
  • The path must match the exact storage path returned when the file was uploaded
  • If the file doesn’t exist, the operation may still return success

Build docs developers (and LLMs) love