> ## Documentation Index
> Fetch the complete documentation index at: https://docs.emiti.fravelabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Reenviar email al receptor

> Encola el reenvío del KuDE PDF y XML firmado al receptor por email.

Reencola la entrega del Documento Tributario Electrónico por email al receptor. Útil cuando:

* El envío automático falló (estado `email_estado: F`) y querés reintentar.
* El receptor no recibió el email original y pide un reenvío.
* Querés enviar a una dirección distinta a la registrada en el DE.

El email incluye el **KuDE PDF** y el **XML firmado** como adjuntos, junto con los datos del documento en el cuerpo HTML.

## Comportamiento

1. Valida que el DE exista y pertenezca al tenant del JWT (`404` si no).
2. Valida que el DE esté aprobado (`estado = A`). Si está pendiente o rechazado, devuelve `409`.
3. Determina el destinatario: usa el `email` del body si se envió, o el `email_rec` registrado en el DE.
4. Si no hay dirección disponible, devuelve `422 EMAIL_DESTINATARIO_MISSING`.
5. Encola el envío en la cola de email y marca el DE como `email_estado: P` (pendiente).
6. Devuelve `202` con la dirección de destino confirmada.

## Body (opcional)

```json theme={null}
{
  "email": "otro@empresa.com"
}
```

Si omitís el body o enviás `{}`, se usa el `email_rec` registrado en el DE.

## Respuesta exitosa — 202

```json theme={null}
{
  "message": "Email encolado",
  "email_to": "receptor@empresa.com"
}
```

## Errores frecuentes

| Status / código                  | Causa                                              | Acción                                 |
| -------------------------------- | -------------------------------------------------- | -------------------------------------- |
| `404 DE_NOT_FOUND`               | El DE no existe o pertenece a otro tenant.         | Verificar el ID.                       |
| `409 DE_NOT_APPROVED`            | El DE no está aprobado (`estado != A`).            | Solo se puede reenviar un DE aprobado. |
| `422 EMAIL_DESTINATARIO_MISSING` | No hay `email` en el body ni `email_rec` en el DE. | Incluir `{"email": "..."}` en el body. |


## OpenAPI

````yaml POST /v1/de/{de_id}/reenviar-email
openapi: 3.1.0
info:
  title: eMiti API
  description: >-
    API de emisión de Documentos Tributarios Electrónicos (DTE) bajo SIFEN/DNIT
    Paraguay.
  version: 1.1.0
servers:
  - url: https://api.emiti.fravelabs.com
    description: Producción
  - url: https://api.qa.emiti.fravelabs.com
    description: QA
  - url: https://api.dev.emiti.fravelabs.com
    description: Desarrollo (Homologación SIFEN)
security:
  - ApiKeyAuth: []
paths:
  /v1/de/{de_id}/reenviar-email:
    post:
      summary: POST /v1/de/{de_id}/reenviar-email
      operationId: reenviar_email_de_v1_de__de_id__reenviar_email_post
      parameters:
        - required: true
          schema:
            type: string
            title: De Id
          name: de_id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/_ReenviarEmailInput'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    _ReenviarEmailInput:
      properties:
        email:
          anyOf:
            - type: string
              pattern: ^[^@\s]+@[^@\s]+\.[^@\s]+$
            - type: 'null'
          title: Email
          description: Destinatario de email. Si no viene, se usa email_rec del DE.
      type: object
      title: _ReenviarEmailInput
      description: >-
        Body opcional de POST /de/{de_id}/reenviar-email (EMI-35).


        Si `email` viene en el body, sobrescribe el destinatario registrado en
        el DE.

        Si se omite el body o el campo, se usa `de.email_rec`.

        Validación de formato email via pattern (email-validator no está en el
        Layer).
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````