# Adjuntos

La API de ReallyQuickEmails permite enviar correos con archivos adjuntos usando el endpoint `POST /send-email`. Los adjuntos se especifican en el campo `attachments` del cuerpo de la solicitud.

## Estructura del adjunto

Cada elemento del arreglo `attachments` acepta los siguientes campos:

| Campo         | Tipo     | Requerido   | Descripcion                                                                         |
| ------------- | -------- | ----------- | ----------------------------------------------------------------------------------- |
| `filename`    | `string` | Si          | Nombre del archivo con extension (ej. `"factura.pdf"`).                             |
| `url`         | `string` | Condicional | URL publica del archivo. Requerido si no se usa `content`.                          |
| `content`     | `string` | Condicional | Contenido del archivo codificado en base64. Requerido si no se usa `url`.           |
| `contentType` | `string` | No          | Tipo MIME del archivo. Se auto-detecta a partir del `filename` si no se especifica. |

Cada adjunto debe incluir `filename` y exactamente uno de `url` o `content`.

## Tipos permitidos

Solo se permiten los siguientes tipos MIME:

* `application/pdf`
* `text/calendar`

Si el tipo MIME del archivo no coincide con uno de estos, la API retorna un error.

## Limites

| Limite                      | Valor         |
| --------------------------- | ------------- |
| Cantidad maxima de adjuntos | 10 por correo |
| Tamano maximo por archivo   | 10 MB         |
| Tamano maximo total         | 10 MB         |

## Adjuntos por URL

Cuando se usa el campo `url`, el servidor descarga el archivo antes de enviarlo. Se aplican las siguientes medidas de seguridad:

* **Proteccion SSRF:** Las URLs que apuntan a direcciones IP privadas o reservadas son bloqueadas.
* **Timeout:** La descarga esta sujeta a un tiempo limite. Si el servidor remoto no responde a tiempo, la solicitud falla.

## Adjuntos por base64

Cuando se usa el campo `content`, el valor debe ser el contenido del archivo codificado en base64 sin prefijos (sin `data:...;base64,`). Solo el string base64 crudo.

## Ejemplos

### Adjunto por URL

```bash
curl -X POST https://api.reallyquickemails.com/send-email \
  -H "Content-Type: application/json" \
  -H "x-project-id: proj_abc123" \
  -d '{
    "recipient": "cliente@ejemplo.com",
    "sender": "ventas@mitienda.com",
    "senderName": "Mi Tienda",
    "subject": "Tu factura de octubre",
    "templateId": "factura-mensual",
    "attachments": [
      {
        "filename": "factura-octubre-2025.pdf",
        "url": "https://storage.ejemplo.com/facturas/factura-octubre-2025.pdf"
      }
    ]
  }'
```

Respuesta:

```json
{
  "success": true,
  "messageId": "0102018e-abcd-1234-5678-9abcdef01234",
  "activityId": "d4e5f6a7-b8c9-0123-def4-567890abcdef",
  "message": "Email sent successfully",
  "attachments_sent": 1
}
```

### Adjunto por base64

```bash
curl -X POST https://api.reallyquickemails.com/send-email \
  -H "Content-Type: application/json" \
  -H "x-project-id: proj_abc123" \
  -d '{
    "recipient": "cliente@ejemplo.com",
    "sender": "ventas@mitienda.com",
    "senderName": "Mi Tienda",
    "subject": "Invitacion a reunion",
    "html": "<p>Te invitamos a una reunion de equipo.</p>",
    "attachments": [
      {
        "filename": "reunion.ics",
        "content": "QkVHSU46VkNBTEVOREFSClZFUlNJT046Mi4wCkJFR0lOOlZFVkVOVApEVFNUQVJUOjIwMjUxMDE2VDE1MDAwMFoKRFRFTkQ6MjAyNTEwMTZUMTYwMDAwWgpTVU1NQVJZOlJldW5pb24gZGUgZXF1aXBvCkVORDpWRVZFTlQKRU5EOlZDQUxFTkRBUg==",
        "contentType": "text/calendar"
      }
    ]
  }'
```

Respuesta:

```json
{
  "success": true,
  "messageId": "0102018e-efgh-5678-9012-3456abcdef78",
  "activityId": "e5f6a7b8-c9d0-1234-ef56-7890abcdef01",
  "message": "Email sent successfully",
  "attachments_sent": 1
}
```

### Multiples adjuntos

```bash
curl -X POST https://api.reallyquickemails.com/send-email \
  -H "Content-Type: application/json" \
  -H "x-project-id: proj_abc123" \
  -d '{
    "recipient": "cliente@ejemplo.com",
    "sender": "ventas@mitienda.com",
    "senderName": "Mi Tienda",
    "subject": "Documentos del proyecto",
    "templateId": "documentos-proyecto",
    "attachments": [
      {
        "filename": "contrato.pdf",
        "url": "https://storage.ejemplo.com/docs/contrato.pdf"
      },
      {
        "filename": "agenda.ics",
        "content": "QkVHSU46VkNBTEVOREFSClZFUlNJT046Mi4wCkVORDpWQ0FMRU5EQVI=",
        "contentType": "text/calendar"
      }
    ]
  }'
```

Respuesta:

```json
{
  "success": true,
  "messageId": "0102018e-ijkl-9012-3456-7890abcdef12",
  "activityId": "f6a7b8c9-d0e1-2345-f678-90abcdef0123",
  "message": "Email sent successfully",
  "attachments_sent": 2
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://reallyquickemails.gitbook.io/reallyquickemails-docs/guias/attachments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
