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

# Quickstart

> The typical call sequence: start the app, sell a voucher, close the shift.

## App start

**1. Log in (only if there is no valid session)**

[`POST /login_check`](https://docs.tunimobile.com/api/auth/login) sets the `BEARER` and `refresh_token` cookies.

**2. Load the profile**

[`POST /user/do_action`](https://docs.tunimobile.com/api/account/profile) with `action: get_profile`.

**3. Load the balance**

[`POST /user/do_action`](https://docs.tunimobile.com/api/account/balance) with `action: get_credit`.

**4. Register the device**

[`POST /terminal/do_action`](https://docs.tunimobile.com/api/terminal/register) with `action: checkApiKey`. The terminal is created on first use.

## Selling a voucher

**1. Generate the voucher**

[`printVoucher`](https://docs.tunimobile.com/api/vouchers/generate) returns the voucher data. Print it right away. **The shop balance is debited here.**

**2. Confirm the print**

[`confirmVoucher`](https://docs.tunimobile.com/api/vouchers/confirm) once the printer reports success.

If the ticket did not print, call [`reprintVoucher`](https://docs.tunimobile.com/api/vouchers/reprint), print again, then [`confirmReprintVoucher`](https://docs.tunimobile.com/api/vouchers/confirm-reprint).

If the customer wants a copy later, call [`duplicateVoucher`](https://docs.tunimobile.com/api/vouchers/duplicate), print, then [`confirmReprintVoucher`](https://docs.tunimobile.com/api/vouchers/confirm-reprint).

> [!NOTE]
>
> Only `printVoucher` debits the balance. Confirm, reprint, duplicate and confirm-reprint never debit it again.

## Other calls

| When | Call |
| - | - |
| Show sales history | [`POST /vouchers`](https://docs.tunimobile.com/api/vouchers/history) |
| End of shift | [`POST /session/`](https://docs.tunimobile.com/api/sessions/rotate) closes the current session and opens a new one |
| A call returns `401 Expired JWT Token` | [`POST /token/refresh`](https://docs.tunimobile.com/api/auth/refresh), then retry once |
| User logs out | [`GET /user/logout`](https://docs.tunimobile.com/api/auth/logout) |

## Overview

```text theme={null}
App start
  ├─ POST /login_check                    (only if no valid session)
  ├─ POST /user/do_action      get_profile
  ├─ POST /user/do_action      get_credit
  └─ POST /terminal/do_action  checkApiKey  (registers the device on first use)

Selling a voucher
  ├─ printVoucher            → print the returned data
  ├─ confirmVoucher          → after the printer reports success
  │
  ├─ (print failed?) reprintVoucher → print again → confirmReprintVoucher
  └─ (customer wants a copy later?) duplicateVoucher → print → confirmReprintVoucher

Other
  ├─ POST /vouchers          history
  ├─ POST /session/          close the current session and open a new one
  ├─ POST /token/refresh     whenever a call returns 401 "Expired JWT Token"
  └─ GET  /user/logout
```


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