> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.invoice-api.xhub.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.invoice-api.xhub.io/_mcp/server.

# Attach documents to an invoice PDF

POST https://service.invoice-api.xhub.io/api/v1/invoice/attachments
Content-Type: application/json

Embeds one or more files as attachments into an invoice PDF (visible in the Acrobat Attachments pane). For PDF/A-3 carriers (ZUGFeRD/Factur-X) the result stays PDF/A-3 conformant; the `relationship` defaults to `Supplement`.

Reference: https://docs.invoice-api.xhub.io/api-reference/invoices/attachments

## Authentication

- `Authorization` header (bearer token, required) — API Key authentication. Use `sk_live_*` for production or `sk_test_*` for testing.

## Servers

- `https://service.invoice-api.xhub.io` (Invoice API v1 (production), default)
- `/` (Diese Instanz (lokale Entwicklung))

## Request

### Body (application/json)

This endpoint expects an object.

- `pdf` (string, required) — Base64-encoded carrier PDF to embed the attachments into
- `attachments` (list of ApiV1InvoiceAttachmentsPostRequestBodyContentApplicationJsonSchemaAttachmentsItems, required) — Files to embed into the PDF

## Response

### 200

PDF with embedded attachments

- `success` (true, required)
- `data` (string, required) — Base64-encoded result PDF with the attachments embedded
- `pdfA3Conformant` (boolean, required) — True if the carrier was PDF/A-3 and conformance was preserved
- `attachmentCount` (double, required) — Number of attachments embedded

## Errors

### 400 Bad Request Error

Bad Request

- `PostApiV1InvoiceAttachmentsRequestBadRequestError`
  - ErrorResponse: ErrorResponse
  - RequestValidationError: RequestValidationError

### 403 Forbidden Error

Forbidden — missing entitlement

- `error` (string, required) — Error code
- `message` (string, required) — Human-readable error message
- `code` (string, optional) — Machine-readable reason, where one exists — e.g. `UNSUPPORTED_FORMAT_VERSION`, `UNSUPPORTED_FORMAT_PROFILE`, `CONFLICTING_FORMAT_OPTIONS`
- `field` (string, optional) — The request field the error refers to, where one exists

### 413 Content Too Large Error

Attachment(s) exceed the configured size limit

- `error` (string, required) — Error code
- `message` (string, required) — Human-readable error message
- `code` (string, optional) — Machine-readable reason, where one exists — e.g. `UNSUPPORTED_FORMAT_VERSION`, `UNSUPPORTED_FORMAT_PROFILE`, `CONFLICTING_FORMAT_OPTIONS`
- `field` (string, optional) — The request field the error refers to, where one exists

### 429 Too Many Requests Error

Quota exceeded

- `error` ("QUOTA_EXCEEDED", required) — Error code
- `message` (string, required) — Error message
- `quota` (ApiV1InvoiceAttachmentsPostResponsesContentApplicationJsonSchemaQuota, required)

## Types

### ApiV1InvoiceAttachmentsPostRequestBodyContentApplicationJsonSchemaAttachmentsItems

A single embedded file attachment

- `filename` (string, required) — Filename shown in the PDF Attachments pane
- `contentBase64` (string, required) — Base64-encoded file content
- `mimeType` (string, optional) — MIME type of the attachment
- `description` (string, optional) — Human-readable description
- `relationship` (enum, optional) — PDF/A-3 AFRelationship. Defaults to "Supplement" for supporting documents.
  - Allowed values: `Data`, `Source`, `Alternative`, `Supplement`, `Unspecified`

### ErrorResponse

- `error` (string, required) — Error code
- `message` (string, required) — Human-readable error message
- `code` (string, optional) — Machine-readable reason, where one exists — e.g. `UNSUPPORTED_FORMAT_VERSION`, `UNSUPPORTED_FORMAT_PROFILE`, `CONFLICTING_FORMAT_OPTIONS`
- `field` (string, optional) — The request field the error refers to, where one exists

### RequestValidationError

The request body failed the input check. `error` lists every finding; each names the field (`path`) and the rule (`code`). Depending on the code, a finding also carries the limit (`maximum`, `minimum`), the expected type (`expected`), the allowed values (`values`) or the unknown keys (`keys`).

- `success` (false, required)
- `error` (list of RequestValidationErrorErrorItems, required)

### ApiV1InvoiceAttachmentsPostResponsesContentApplicationJsonSchemaQuota

- `current` (double, required) — Current usage count
- `limit` (double, required) — Usage limit
- `period` (string, optional) — Quota period type of the plan quota that was hit, when the rejection carries one ('monthly', 'yearly', ...). Absent whenever the rejection has no period at all — for example a lapsed subscription, where the limit is 0 and no plan quota was involved. This is a period TYPE, never a calendar label such as "2026-03".

### RequestValidationErrorErrorItems

- `code` (string, required) — Rule that failed, e.g. `too_big`, `invalid_type`, `invalid_value`.
- `path` (list of RequestValidationErrorErrorItemsPathItems, required) — Path of the field in the request body, e.g. `["invoice", "seller", "name"]`.
- `message` (string, required)
- `maximum` (double, optional)
- `minimum` (double, optional)
- `inclusive` (boolean, optional)
- `origin` (string, optional)
- `expected` (string, optional)
- `values` (list of any, optional)
- `keys` (list of string, optional)
- `format` (string, optional)

### RequestValidationErrorErrorItemsPathItems

- string
- double

## Examples

**Request**

```json
{
  "pdf": "string",
  "attachments": [
    {
      "filename": "leistungsnachweis.pdf",
      "contentBase64": "string"
    }
  ]
}
```

**Response**

```json
{
  "success": true,
  "data": "string",
  "pdfA3Conformant": true,
  "attachmentCount": 1
}
```

**SDK Code**

```python
import requests

url = "https://service.invoice-api.xhub.io/api/v1/invoice/attachments"

payload = {
    "pdf": "string",
    "attachments": [
        {
            "filename": "leistungsnachweis.pdf",
            "contentBase64": "string"
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://service.invoice-api.xhub.io/api/v1/invoice/attachments';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"pdf":"string","attachments":[{"filename":"leistungsnachweis.pdf","contentBase64":"string"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://service.invoice-api.xhub.io/api/v1/invoice/attachments"

	payload := strings.NewReader("{\n  \"pdf\": \"string\",\n  \"attachments\": [\n    {\n      \"filename\": \"leistungsnachweis.pdf\",\n      \"contentBase64\": \"string\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://service.invoice-api.xhub.io/api/v1/invoice/attachments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"pdf\": \"string\",\n  \"attachments\": [\n    {\n      \"filename\": \"leistungsnachweis.pdf\",\n      \"contentBase64\": \"string\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://service.invoice-api.xhub.io/api/v1/invoice/attachments")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"pdf\": \"string\",\n  \"attachments\": [\n    {\n      \"filename\": \"leistungsnachweis.pdf\",\n      \"contentBase64\": \"string\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://service.invoice-api.xhub.io/api/v1/invoice/attachments', [
  'body' => '{
  "pdf": "string",
  "attachments": [
    {
      "filename": "leistungsnachweis.pdf",
      "contentBase64": "string"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://service.invoice-api.xhub.io/api/v1/invoice/attachments");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"pdf\": \"string\",\n  \"attachments\": [\n    {\n      \"filename\": \"leistungsnachweis.pdf\",\n      \"contentBase64\": \"string\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "pdf": "string",
  "attachments": [
    [
      "filename": "leistungsnachweis.pdf",
      "contentBase64": "string"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://service.invoice-api.xhub.io/api/v1/invoice/attachments")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```