# BR-DE-22 Embedded attachment filenames must be unique

XRechnung requires every embedded document filename attribute to be unique within the invoice.

## Problem Description

XRechnung requires every embedded document filename attribute to be unique within the invoice.

> **ERROR**: XRechnung 3.0

## Context and Significance

Duplicate attachment names make downstream document handling ambiguous and can cause recipient portals to reject otherwise valid XML.

## Solution

Rename duplicate attachments before export, for example terms.pdf and timesheet.pdf instead of two files named attachment.pdf.

- validate
- convert

## Valid Examples

- invoice-terms.pdf and delivery-note.pdf

## Invalid Examples

- Two embedded files both named attachment.pdf

## Code Examples

### Valid XML
```
<cac:AdditionalDocumentReference>
  <cbc:ID>DOC-1</cbc:ID>
  <cac:Attachment>
    <cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" filename="terms.pdf">UjBsR09E...</cbc:EmbeddedDocumentBinaryObject>
  </cac:Attachment>
</cac:AdditionalDocumentReference>
<cac:AdditionalDocumentReference>
  <cbc:ID>DOC-2</cbc:ID>
  <cac:Attachment>
    <cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" filename="timesheet.pdf">UjBsR09E...</cbc:EmbeddedDocumentBinaryObject>
  </cac:Attachment>
</cac:AdditionalDocumentReference>
```

### Invalid XML
```
<!-- Two embedded documents share the same filename attribute -->
<cac:AdditionalDocumentReference>
  <cbc:ID>DOC-1</cbc:ID>
  <cac:Attachment>
    <cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" filename="attachment.pdf">UjBsR09E...</cbc:EmbeddedDocumentBinaryObject>
  </cac:Attachment>
</cac:AdditionalDocumentReference>
<cac:AdditionalDocumentReference>
  <cbc:ID>DOC-2</cbc:ID>
  <cac:Attachment>
    <cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" filename="attachment.pdf">UjBsR09E...</cbc:EmbeddedDocumentBinaryObject>
  </cac:Attachment>
</cac:AdditionalDocumentReference>
```

## Affected Fields

- [BG-24 Additional supporting documents](/resources/xrechnung)
- [EmbeddedDocumentBinaryObject filename](/resources/xrechnung)

## Related Rules

- [BR-DE-21](/resources/kosit-validator-errors/br-de-21-specification-identifier-syntax)

## Validation Tools

- [Official KoSIT Validator](https://erechnungsvalidator.service-bw.de/): Validate your XRechnung files against all BR-DE rules.
- [Convert PDF to XRechnung](/pdf-to-xrechnung): Automatic validation error fixes when converting.

## Related Resources

- [Official Specification](https://xeinkauf.de/xrechnung/)
- [Test Suite](https://github.com/itplr-kosit/xrechnung-testsuite)
- [Complete Error List](/resources/kosit-validator-errors): Overview of all German XRechnung validation rules.
