> 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.

# Read a stored PDF template

GET https://service.invoice-api.xhub.io/api/v1/pdf/templates/{id}

Returns a template of the organization of the API key or a system template, inactive ones included, with the metadata of its images. A template of another organization is 404. Requires an API key with `pdf:template:read` and purpose `user`; session keys get 403 `SESSION_KEY_FORBIDDEN`. Not metered.

Reference: https://docs.invoice-api.xhub.io/api-reference/pdf/get-api-v-1-pdf-templates-by-id

## 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

### Path parameters

- `id` (string, required) — Template id

## Response

### 200

The template

- `id` (string, required) — Template id — use it as `templateId` in `POST /pdf/generate`.
- `organizationId` (string, required)
- `name` (string, required)
- `description` (string, required, nullable)
- `documentType` (string, required)
- `version` (string, required)
- `template` (map from string to any, required) — The stored BlockTemplate.
- `sampleData` (map from string to any, required, nullable)
- `pageSettings` (map from string to any, required, nullable)
- `isDefault` (boolean, required, nullable)
- `isActive` (boolean, required, nullable)
- `countryCode` (string, required, nullable)
- `isSystem` (boolean, required)
- `createdAt` (datetime, required)
- `createdBy` (string, required) — `api-key:<key name>` for templates stored through this API.
- `updatedAt` (datetime, required)
- `updatedBy` (string, required)
- `images` (list of ApiV1PdfTemplatesIdGetResponsesContentApplicationJsonSchemaImagesItems, required) — Images of the template, metadata only.

## Errors

### 400 Bad Request Error

Invalid input — `{ error: [Zod issues with path], success: false }`, without an echo of the request

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

### 401 Unauthorized Error

Unauthorized — missing or invalid API key

- `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

### 403 Forbidden Error

Forbidden — `FORBIDDEN` (the key lacks the entitlement named in `message`) or `SESSION_KEY_FORBIDDEN` (session keys cannot use the template routes)

- `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

### 404 Not Found Error

Template not found in the organization of the API key

- `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

Payload Too Large — `PAYLOAD_TOO_LARGE`: the request body exceeds 2 MiB (2097152 bytes); `limit` names the number

- `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

### 500 Internal Server Error

Internal Server Error

- `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

## Types

### ApiV1PdfTemplatesIdGetResponsesContentApplicationJsonSchemaImagesItems

- `id` (string, required)
- `name` (string, required)
- `mimeType` (string, required)
- `width` (double, required, nullable)
- `height` (double, required, nullable)

### 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

**Response**

```json
{
  "id": "string",
  "organizationId": "string",
  "name": "string",
  "description": "string",
  "documentType": "string",
  "version": "string",
  "template": {},
  "sampleData": {},
  "pageSettings": {},
  "isDefault": true,
  "isActive": true,
  "countryCode": "string",
  "isSystem": true,
  "createdAt": "2024-01-15T09:30:00Z",
  "createdBy": "string",
  "updatedAt": "2024-01-15T09:30:00Z",
  "updatedBy": "string",
  "images": [
    {
      "id": "string",
      "name": "string",
      "mimeType": "string",
      "width": 1.1,
      "height": 1.1
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://service.invoice-api.xhub.io/api/v1/pdf/templates/id"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://service.invoice-api.xhub.io/api/v1/pdf/templates/id';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://service.invoice-api.xhub.io/api/v1/pdf/templates/id"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	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/pdf/templates/id")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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.get("https://service.invoice-api.xhub.io/api/v1/pdf/templates/id")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://service.invoice-api.xhub.io/api/v1/pdf/templates/id', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://service.invoice-api.xhub.io/api/v1/pdf/templates/id");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://service.invoice-api.xhub.io/api/v1/pdf/templates/id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```