---
title: "Create invoice from sales receipts"
description: "Create a CFDI draft from one or more compatible open sales receipts. Inspect the receipts first; they must match on customer, currency, payment form, and payment timing. This operation never stamps or sends the CFDI."
language: en
canonical_url: "https://exac.mx/docs/en/mcp/tools/create_invoice_draft_from_sales_receipts"
md_url: "https://exac.mx/docs/en/mcp/tools/create_invoice_draft_from_sales_receipts.md"
---

# Create invoice from sales receipts

Create a CFDI draft from one or more compatible open sales receipts. Inspect the receipts first; they must match on customer, currency, payment form, and payment timing. This operation never stamps or sends the CFDI.

Tool: `create_invoice_draft_from_sales_receipts`

## Purpose

Create a CFDI draft from compatible open sales receipts.

### Use when

One or more receipts are ready to be invoiced together.

### Do not use when

Receipts do not share the required customer, currency, payment, and timing attributes.

| Detail | Value |
| --- | --- |
| Permissions | invoices:manage + receipts:read |
| Side effects | External side effect |
| Idempotency | Idempotent |

## Input schema

```json
{
  "type": "object",
  "properties": {
    "idempotencyKey": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Unique retry key for this exact operation. Reuse it only when retrying the same request."
    },
    "input": {
      "type": "object",
      "properties": {
        "salesReceiptRefs": {
          "minItems": 1,
          "maxItems": 100,
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^sales_receipt:.*"
          },
          "description": "One or more open receipt documentRefs from search_documents"
        },
        "customer": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "existing"
                },
                "customerId": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "kind",
                "customerId"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "const": "public_general"
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            }
          ]
        },
        "cfdiUse": {
          "enum": [
            "CN01",
            "CP01",
            "D01",
            "D02",
            "D03",
            "D04",
            "D05",
            "D06",
            "D07",
            "D08",
            "D09",
            "D10",
            "G01",
            "G02",
            "G03",
            "I01",
            "I02",
            "I03",
            "I04",
            "I05",
            "I06",
            "I07",
            "I08",
            "S01"
          ],
          "description": "Known SAT CFDI-use code.",
          "x-exac-sat-catalog": "cfdi-uses"
        },
        "acknowledgeReconciliationDifference": {
          "description": "Required only after reviewing a reported fiscal difference",
          "allOf": [
            {
              "type": "boolean"
            }
          ]
        },
        "reconciliationNote": {
          "type": "string",
          "minLength": 1
        },
        "remediation": {
          "type": "object",
          "properties": {
            "customerFiscalIdentity": {
              "type": "object",
              "properties": {
                "rfc": {
                  "type": "string",
                  "minLength": 1
                },
                "taxSystem": {
                  "enum": [
                    "601",
                    "603",
                    "605",
                    "606",
                    "607",
                    "608",
                    "610",
                    "611",
                    "612",
                    "614",
                    "615",
                    "616",
                    "620",
                    "621",
                    "622",
                    "623",
                    "624",
                    "625",
                    "626"
                  ],
                  "description": "Known SAT tax-system code.",
                  "x-exac-sat-catalog": "tax-systems"
                },
                "postalCode": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "additionalProperties": false
            },
            "receiptItems": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "salesReceiptRef": {
                    "type": "string",
                    "pattern": "^sales_receipt:.*"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "index": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "satProductCode": {
                          "type": "string",
                          "minLength": 1
                        },
                        "satUnitCode": {
                          "type": "string",
                          "minLength": 1
                        },
                        "saveToProduct": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "index",
                        "satProductCode",
                        "satUnitCode"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "salesReceiptRef",
                  "items"
                ],
                "additionalProperties": false
              }
            }
          },
          "additionalProperties": false,
          "description": "Supply only when validation reports missing customer or item fiscal identity. Use the receipt reference and zero-based item index reported in details.issues."
        }
      },
      "required": [
        "salesReceiptRefs",
        "customer",
        "cfdiUse"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "idempotencyKey",
    "input"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
```

## Output schema

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "invoice": {
          "type": "object",
          "properties": {
            "simulated": {
              "allOf": [
                {
                  "type": "boolean",
                  "const": true
                }
              ]
            },
            "documentRef": {
              "type": "string",
              "pattern": "^invoice:.+$"
            },
            "kind": {
              "enum": [
                "income",
                "credit_note",
                "transfer",
                "payroll",
                "payment_complement"
              ]
            },
            "status": {
              "const": "draft"
            }
          },
          "required": [
            "documentRef",
            "kind",
            "status"
          ],
          "additionalProperties": false
        },
        "salesReceiptRefs": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^sales_receipt:.+$"
          }
        },
        "reconciliationDifference": {
          "type": "number"
        }
      },
      "required": [
        "invoice",
        "salesReceiptRefs"
      ],
      "additionalProperties": false
    },
    "error": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "code": {
          "enum": [
            "validation_error",
            "unauthenticated",
            "forbidden",
            "payment_required",
            "not_found",
            "method_not_allowed",
            "conflict",
            "idempotency_conflict",
            "operation_in_progress",
            "recovery_required",
            "migration_required",
            "rate_limited",
            "provider_unavailable",
            "internal"
          ]
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "object",
          "properties": {
            "document": {
              "type": "object",
              "properties": {
                "documentRef": {
                  "type": "string",
                  "pattern": "^(invoice|withholding|sales_receipt|declaration|tax_compliance_opinion|sales_receipt_refund):.+$"
                },
                "editable": {
                  "type": "boolean"
                }
              },
              "required": [
                "documentRef",
                "editable"
              ],
              "additionalProperties": false
            },
            "issues": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        }
                      ]
                    }
                  },
                  "message": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  }
                },
                "required": [
                  "path",
                  "message"
                ],
                "additionalProperties": false
              }
            },
            "retryable": {
              "type": "boolean"
            },
            "retryAfterSeconds": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "reason": {
              "type": "string"
            },
            "balanceMinor": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "topUpUrl": {
              "type": "string"
            }
          },
          "additionalProperties": false
        }
      },
      "required": [
        "code",
        "message"
      ],
      "additionalProperties": false
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false,
  "oneOf": [
    {
      "required": [
        "data"
      ]
    },
    {
      "required": [
        "error"
      ]
    }
  ]
}
```

## Related tools

- [`get_document`](/docs/en/mcp/tools/get_document.md) — **Get document**: Retrieve one document by its public documentRef. Sales receipt details include stable lineRef values and remaining refundable amounts for sales receipt refunds.

- [`stamp_invoice`](/docs/en/mcp/tools/stamp_invoice.md) — **Stamp invoice**: Irreversibly stamp an existing CFDI draft. Review the draft first with get_document. Safe retries require reusing the same idempotencyKey.

## Related workflow

[See the canonical workflows in the introduction](/docs/en.md)

## Equivalent REST operations

- [`POST /v1/invoices/from-sales-receipts`](/docs/en/api/documents/invoices/create-invoice-draft-from-sales-receipts.md)

Complete documentation: https://exac.mx/docs/en.md
Agent documentation index: https://exac.mx/docs/en/llms.txt
