Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/eme2dev/Eme2App/llms.txt

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

Presupuestos (quotes) are the starting point of Eme2App’s sales workflow. You can create a budget, share it with a client by email, and — once accepted — convert it directly into a borrador factura with a single API call. Quotes go through their own lifecycle: borradoremitidapagada or cancelada; acceptance also sets the status to aceptada and locks the quote from further editing. All endpoints require a Bearer token with a valid empresa_id. Base path: /api/presupuestos Authorization: Authorization: Bearer <token> with empresa_id embedded.

Endpoint reference

MethodPathDescription
GET/api/presupuestosList quotes (paginated)
POST/api/presupuestosCreate quote
GET/api/presupuestos/proximo-numeroNext available quote number
GET/api/presupuestos/:idGet quote by ID
PUT/api/presupuestos/:idUpdate quote
PUT/api/presupuestos/:id/estadoUpdate quote status
POST/api/presupuestos/:id/aceptarAccept quote → create draft invoice
DELETE/api/presupuestos/:idDelete quote
POST/api/presupuestos/:id/enviar-emailSend PDF by email

GET /api/presupuestos

Returns a paginated list of quotes for the active company. Query parameters
ParameterTypeDescription
pageintegerPage number (default: 1)
pageSizeintegerResults per page (default: company setting)
Response
{
  "datos": [
    {
      "id": "uuid",
      "numero": 12,
      "fecha": "2024-03-10",
      "cliente_id": "uuid",
      "estado": "emitida",
      "incluir_impuestos": true,
      "subtotal": "800.00",
      "iva_monto": "168.00",
      "irpf_monto": "0.00",
      "total": "968.00"
    }
  ],
  "paginacion": { "page": 1, "pageSize": 25, "total": 28 }
}
datos
array
Array of presupuesto objects for the active company.
paginacion
object
Pagination metadata: page, pageSize, and total record count.

POST /api/presupuestos

Creates a new quote in borrador status. Tax amounts (IVA, IRPF) are computed server-side from the article catalogue.
cliente_id
string (UUID)
required
ID of the client for this quote. Must belong to the active company.
numero
integer
required
Quote number. Must be unique within the company. Use GET /api/presupuestos/proximo-numero to fetch the next available value.
fecha
string (YYYY-MM-DD)
Quote date. Defaults to today if omitted.
incluir_impuestos
boolean
Whether to calculate and display taxes (IVA, IRPF). Defaults to true. Set false for net-amount quotes.
notas
string
Free-text notes. Max 1000 characters.
detalles
array
required
Array of quote line items. At least one non-comment line is required.
Response
{
  "id": "b2c3d4e5-0000-0000-0000-000000000002",
  "mensaje": "Presupuesto creado exitosamente"
}
curl example
curl -s -X POST https://api.eme2app.com/api/presupuestos \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "cliente_id": "ccc11111-0000-0000-0000-000000000001",
    "numero": 13,
    "fecha": "2024-04-01",
    "incluir_impuestos": true,
    "notas": "Oferta válida 30 días",
    "detalles": [
      {
        "articulo_id": "aaa00000-0000-0000-0000-000000000001",
        "cantidad": 10,
        "precio_unitario": 80.00,
        "descripcion": "Módulo de desarrollo"
      }
    ]
  }'

GET /api/presupuestos/proximo-numero

Returns the next sequential quote number for the active company. Response
{ "proximo_numero": 14 }

GET /api/presupuestos/:id

Returns a single quote with its header and all line details.

PUT /api/presupuestos/:id

Full update of a quote. Only quotes in borrador state can be edited. The body mirrors POST /api/presupuestos. Existing line items are replaced entirely. Response
{
  "id": "b2c3d4e5-0000-0000-0000-000000000002",
  "mensaje": "Presupuesto actualizado exitosamente"
}

PUT /api/presupuestos/:id/estado

Manually updates the quote status.
estado
string
required
Target status. Allowed values: "borrador", "emitida", "pagada", "cancelada".
Response
{ "mensaje": "Presupuesto actualizado a estado: emitida" }

POST /api/presupuestos/:id/aceptar

Accepts the quote and creates a linked borrador factura in a single operation. The quote is marked aceptada and locked. Quotes in cancelada, aceptada, or convertida states are rejected.
numero
integer
required
Invoice number to assign to the new factura. Use GET /api/facturas/proximo-numero to fetch the next available value.
fecha
string (YYYY-MM-DD)
Invoice date. Defaults to today.
serie_id
string (UUID)
Invoice series to use. Required when the company has usa_series = true.
serie
string
Series code. Alternative to serie_id.
forma_pago_id
string (UUID)
Payment terms for the invoice. If omitted, falls back to the client’s forma_pago_defecto_id.
Response
{
  "id": "a1b2c3d4-0000-0000-0000-000000000009",
  "numero": 44,
  "fecha": "2024-04-02",
  "mensaje": "Presupuesto aceptado. Factura borrador creada."
}
id
string
UUID of the newly created facturas record.
numero
integer
Invoice number assigned to the new factura.
After aceptar, retrieve the full invoice with GET /api/facturas/{id}, review its lines, then confirm it with PUT /api/facturas/{id}/estado ({"estado":"confirmada"}) to generate payment vencimientos.
Error responses
Statusmensaje
400"Este presupuesto no se puede aceptar" (already accepted, cancelled, or converted)
400"Debes indicar un número de factura válido"
400"El número de factura ya existe"
400"Cliente debe tener una forma de pago defecto o debe proporcionar una forma_pago_id"

DELETE /api/presupuestos/:id

Permanently deletes a quote. Only quotes in borrador state can be deleted. Response
{ "mensaje": "Presupuesto eliminado" }

POST /api/presupuestos/:id/enviar-email

Sends the quote PDF to a recipient email address.
destino
string
required
Recipient email address.
pdf_base64
string
required
Base64-encoded PDF generated client-side.
pdf_nombre
string
Attachment filename. Defaults to presupuesto-{numero}.pdf.
asunto
string
Email subject. Defaults to "Presupuesto {numero}".
texto
string
Plain-text email body.
Response
{ "mensaje": "Presupuesto enviado a cliente@empresa.com" }

Build docs developers (and LLMs) love