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

# Time To Live

> Understanding X-ACCOUNT-KEY expiration and time-to-live (TTL) headers for proactive re-authentication.

## Overview

When end users authenticate with target systems through Maesn, the resulting `X-ACCOUNT-KEY` connection has an expiration tied to the underlying credentials (e.g., OAuth tokens or API keys).

With the Time To Live (TTL) feature, Maesn provides response headers on every authenticated API call that indicate when a connection will expire, allowing you to proactively prompt end users to re-authenticate before their connection becomes invalid.

## Response headers

The following headers are included in responses to authenticated API calls:

| Header | Description |
| :- | :- |
| `X-Account-Key-Expiration-Type` | The expiration behavior of the connection: `fixed`, `extendable`, or `permanent` |
| `X-Account-Key-Expires-At` | ISO 8601 timestamp indicating when the connection will expire and the user must re-authenticate. `null` for some expiration types. |
| `X-Account-Key-Refreshes-Until` | ISO 8601 timestamp indicating when the connection will expire if not refreshed. `null` for some expiration types. |

## Expiration types

Different target systems have different credential lifecycles. The `X-Account-Key-Expiration-Type` header indicates which behavior applies to a given connection.

### fixed

The connection has a fixed maximum lifetime from the time it was created. The user must re-authenticate after this deadline.

* `X-Account-Key-Expires-At`: The absolute expiration timestamp (in UTC) after which re-authentication is required
* `X-Account-Key-Refreshes-Until`: `null`

**Example:** DATEV short token connections expire 11 hours after creation.

### extendable

The connection has a rolling refresh window rather than a fixed expiration date. As long as API calls are made before the refresh deadline, the connection remains valid indefinitely.

* `X-Account-Key-Expires-At`: The absolute maximum lifetime if one exists, otherwise `null`
* `X-Account-Key-Refreshes-Until`: The deadline by which at least one API call must be made to keep the connection valid

> [!TIP]
>
> Maesn automatically refreshes the underlying tokens when you make API calls. You just need to ensure at least one API call is made before the `X-Account-Key-Refreshes-Until` timestamp. Each call extends the refresh deadline. If `X-Account-Key-Expires-At` is `null`, the connection can remain valid indefinitely. If a maximum lifetime exists, re-authentication is required when that date is reached.
>
> To refresh the connection, you can use the [POST /auth/connections/validate](https://docs.maesn.com/api-reference/auth/validate-connection.md) endpoint (not yet available for all systems), or any other API call such as [GET /companies](https://docs.maesn.com/api-reference/auth/get-companies.md).

**Example:** DATEV long token connections have no maximum lifetime (`X-Account-Key-Expires-At` is `null`). As long as you make at least one API call before `X-Account-Key-Refreshes-Until`, the deadline keeps moving forward indefinitely.

### permanent

The connection has no expiration date. This applies to API-key-based systems where credentials remain valid until manually revoked by the user.

* `X-Account-Key-Expires-At`: `null`
* `X-Account-Key-Refreshes-Until`: `null`

## How to use the headers

### Monitor upcoming expirations

Check the `X-Account-Key-Expires-At` header to identify connections approaching their end-of-life. For `fixed` connections, this is the hard deadline. For `extendable` connections with a maximum lifetime, this indicates when the user must re-authenticate regardless of refresh activity.

### Track refresh windows

For `extendable` connections, monitor `X-Account-Key-Refreshes-Until` to ensure at least one API call is made before this deadline. If no API calls are made before this timestamp, the refresh token expires and the user must re-authenticate.

### Proactive re-authentication

Use these headers to build dashboards or notifications that alert you when end user connections are nearing expiration, allowing you to prompt re-authentication before API calls start failing.

## Supported systems

The TTL headers are currently available for the following target systems:

| Target System | Expiration Type | Notes |
| :- | :- | :- |
| DATEV Unternehmen Online | `fixed` | 11-hour lifetime |
| DATEV Unternehmen Online (long token) | `extendable` | Extends on refresh, no maximum lifetime |
| DATEV Rechnungswesen | `fixed` | 11-hour lifetime |
| DATEV Rechnungswesen (long token) | `extendable` | Extends on refresh, no maximum lifetime |
| Exact Online | `extendable` | Extends on refresh, no maximum lifetime |
| Snelstart (production) | `permanent` | No expiration |
| Snelstart (sandbox) | `fixed` | 90-day maximum lifetime |

> [!NOTE]
>
> Support for additional target systems will be added over time. The headers will only be present in responses for supported systems.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.