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

# Email Invoice

> Authenticate with either a Supabase session (member of the invoice's organization) or an API key belonging to that same organization with the write:invoices scope. Sends the stamped XML and PDF as email attachments to the receptor. If `to` is omitted, resolves the destination email from the Customer registered in the organization matching the invoice's rfcReceptor.

Sends the stamped CFDI to the receptor by email, with the XML and PDF attached. Like [Cancel Invoice](/api-reference/invoices/cancel) and [Download XML](/api-reference/invoices/download-xml), this is a **flat** route — it does not carry `/organizations/{organizationId}/` in the URL. The invoice's `uuid` (its folio fiscal, globally unique across all organizations) is enough to resolve the owning organization server-side, combined with the caller's own auth context (session or API key).

If you don't pass a `to` address, Timbrix tries to resolve one automatically from the [Customer](/api-reference/customers/get) registered in your organization with the invoice's `rfcReceptor`. If no such customer exists, or it has no email on file, and you didn't send `to` either, the request fails with `400 Bad Request`.

The email body includes the folio fiscal, series/folio, `tipoComprobante`, issuer RFC, receptor RFC, and total — the XML and PDF are attached as files.

## Authentication

Accepts **either**:

* A Supabase Bearer session (`Authorization: Bearer <token>`) — the authenticated user must be a member of the invoice's organization.
* An API key (`X-API-Key: sk_...`) with the `write:invoices` scope — the key's own organization must match the invoice's organization, or the request is rejected with `403 Forbidden`.

## Path Parameters

| Parameter | Type          | Required | Description                                                                                              |
| --------- | ------------- | -------- | -------------------------------------------------------------------------------------------------------- |
| `uuid`    | string (UUID) | Yes      | Folio fiscal UUID (`uuidFiscal`) of the invoice to send — globally unique, not scoped to an organization |

## Request Body

| Field | Type   | Required | Description                                                                                                                            |
| ----- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `to`  | string | No       | Destination email address. If omitted, Timbrix resolves it from the Customer matching the invoice's `rfcReceptor` in your organization |

## Example Request

```bash cURL theme={null}
curl -X POST https://api.timbrix.mx/invoices/d3bfbc57-44af-4390-a064-f0afab85e5df/email \
  -H "Authorization: Bearer <your_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "contabilidad@cliente.com"
  }'
```

```typescript TypeScript SDK theme={null}
const result = await timbrix.invoices.sendEmail(
  "d3bfbc57-44af-4390-a064-f0afab85e5df",
  { to: "contabilidad@cliente.com" }
)
console.log(result.status)
```

```bash CLI theme={null}
timbrix invoices email d3bfbc57-44af-4390-a064-f0afab85e5df --to contabilidad@cliente.com
```

<Note>
  `to` is optional in every client — omit it to let Timbrix resolve the
  receptor's email from the matching Customer record instead.
</Note>

## Example Response

```json theme={null}
{
  "id": "6a1b2c3d-4e5f-4890-9abc-def012345678",
  "invoiceId": "0f2a1c3e-1a2b-4c3d-9e8f-1234567890ab",
  "sentTo": "contabilidad@cliente.com",
  "status": "sent",
  "sentBy": "9f8e7d6c-5b4a-3210-fedc-ba9876543210",
  "createdAt": "2026-08-09T15:50:03.412Z"
}
```

| Field       | Type           | Description                                                                     |
| ----------- | -------------- | ------------------------------------------------------------------------------- |
| `id`        | string         | Email send record ID                                                            |
| `invoiceId` | string         | Timbrix invoice record ID (not the folio fiscal UUID)                           |
| `sentTo`    | string         | Resolved destination address — either the `to` you sent or the Customer's email |
| `status`    | string         | `sent` or `failed`                                                              |
| `sentBy`    | string \| null | Timbrix user ID who triggered the send — `null` for API-key-authenticated calls |
| `createdAt` | string         | ISO 8601 timestamp the send was recorded                                        |

## Common Errors

### 400 Bad Request

No `to` was sent and no email could be resolved from a Customer matching the invoice's `rfcReceptor`.

```json theme={null}
{
  "statusCode": 400,
  "message": "No se encontró un correo del receptor; especifica el campo 'to'",
  "error": "BAD_REQUEST"
}
```

### 401 Unauthorized

Missing or invalid Bearer token / API key.

### 403 Forbidden

The authenticated user is not a member of the invoice's organization, or the API key does not have the `write:invoices` scope / belongs to a different organization than the one that owns the invoice.

### 404 Not Found

`uuid` does not match any invoice, or does not belong to the caller's organization.

### 503 Service Unavailable

Sending the email failed after retries.

```json theme={null}
{
  "statusCode": 503,
  "message": "No se pudo enviar el correo del CFDI, intenta de nuevo más tarde",
  "error": "INVOICE_EMAIL_SEND_FAILED"
}
```


## OpenAPI

````yaml POST /invoices/{uuid}/email
openapi: 3.1.0
info:
  title: Timbrix API
  description: >-
    REST API with OAuth2 server for managing organizations, members, and
    webhooks
  version: '1.0'
  contact: {}
servers:
  - url: https://api.timbrix.mx
    description: Production
security: []
tags:
  - name: organizations
    description: Organization management endpoints
  - name: oauth
    description: OAuth2 authentication and authorization
  - name: webhooks
    description: Webhook configuration and delivery
  - name: users
    description: User information endpoints
  - name: api-keys
    description: API Keys management and validation
paths:
  /invoices/{uuid}/email:
    post:
      tags:
        - invoices
      summary: Send the stamped CFDI (XML + PDF) by email to the receptor
      description: >-
        Authenticate with either a Supabase session (member of the invoice's
        organization) or an API key belonging to that same organization with the
        write:invoices scope. Sends the stamped XML and PDF as email attachments
        to the receptor. If `to` is omitted, resolves the destination email from
        the Customer registered in the organization matching the invoice's
        rfcReceptor.
      operationId: InvoicesController_sendEmail
      parameters:
        - name: uuid
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendInvoiceEmailDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceEmailSendResultDto'
        '400':
          description: >-
            No `to` was sent and no email could be resolved from a Customer
            matching the invoice's rfcReceptor
        '403':
          description: Caller does not belong to the invoice's organization
        '404':
          description: uuid does not match any invoice
        '503':
          description: Sending the email failed after retries (INVOICE_EMAIL_SEND_FAILED)
      security:
        - apiKey: []
        - bearer: []
components:
  schemas:
    SendInvoiceEmailDto:
      type: object
      properties:
        to:
          type: string
          example: contabilidad@cliente.com
          description: >-
            Destination email address. If omitted, resolved from the Customer
            matching the invoice's rfcReceptor in the organization.
    InvoiceEmailSendResultDto:
      type: object
      properties:
        id:
          type: string
        invoiceId:
          type: string
        sentTo:
          type: string
        status:
          type: string
          enum:
            - sent
            - failed
        sentBy:
          type: object
        createdAt:
          format: date-time
          type: string
      required:
        - id
        - invoiceId
        - sentTo
        - status
        - createdAt
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: 'API Key for authentication (format: sk_...)'
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````