---
title: "Authentication"
description: "How to send a token, how to pick a company, and which routes take no token at all."
---

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

# Authentication

Every request is resolved at the edge before it reaches a handler: who is
calling, and which company they are acting for. Both are settled from the token
you send, so a handler never has to guess.

## Bearer token

Send the access token in the `Authorization` header.

```http
GET /travelers-trip HTTP/1.1
Host: api.nicer.travel
Authorization: Bearer <access-token>
```

An expired or malformed token is 401 before any work happens. Nothing in the API
takes credentials in a query string.

## Getting a token

Access tokens are issued when a person signs in to Nicer with their phone number
and a one-time code.

- **Building on top of a Nicer app** — the app already holds the signed-in
  user's access token. Pass it straight through.
- **Building a server-to-server integration** — credentials are issued per
  integration. Ask your Nicer contact; do not embed a personal token in a
  backend.

> **Tokens are people**
>
> A token always represents a person, never an application. Whatever the caller
> can do in the portal is exactly what the API will let them do — no more.

## Choosing a company

Most work happens inside a company. When your token names exactly one company it
is used automatically. When it names several, name the one you mean:

```http
x-nicer-company: <company-slug>
```

Naming a company you do not belong to returns 403 `ERROR_DO_NOT_HAVE_PERMISSION`.
If a route needs a company and none can be resolved, it fails immediately with
`ERROR_COMPANY_REQUIRED` rather than operating on nothing.

Travelers have no company at all, which is why trip-scoped routes take the
company from the trip after checking access, instead of from the caller.

## What each route requires

Every operation in the reference states what it accepts. There are five shapes:

| Requirement | Caller | Company |
| --- | --- | --- |
| Signed-in user | required | optional |
| Company user | required | required |
| Optional user | optional | optional |
| Public with company | optional | required |
| Public | not used | not used |

## Routes that take no token

Some routes deliberately accept an anonymous caller.

**Lookups.** City, venue, flight-number, exchange-rate and travel-reference
searches are open. They return reference data, never anything about a company or
a trip.

**The booking channel.** Search, details and quoting accept an anonymous caller
that names a company with `x-nicer-company`, so a company's own website can
search and quote without signing anyone in.

**Links sent to travelers.** Reading an itinerary, approving a segment, choosing
between options, paying an order and filling in a profile form all work without
a token, so a traveler can act on a link before they have an account. Reading
the trip itself does not: that needs a token and membership of the trip.

> **Ids in those links are credentials**
>
> For link-based routes the id in the URL is the only thing standing between the
> resource and the world. Treat itinerary, order and profile form links as
> secrets: do not put them in analytics, referrers or shared logs.

Source: https://docs.nicer.travel/developers/authentication/index.mdx
