# auth.md

## Authenticating with the Yatix API

Last updated: 2026-09-11

- Site: https://yatix.com
- API base URL: https://api.yatix.com/api/v1
- Scheme: self-issued JWT, sent as an `Authorization: Bearer` header
- Login body: **four required fields** - `email`, `password`, `realm`, `aud`
- Agent self-registration: **not offered** (see "Getting credentials" below)

This file exists so that an agent author does not have to guess. Read the
"What Yatix does not have" section before you write any OAuth code - the
answer is probably that the endpoint you are looking for is not here.

Three details trip up most first attempts, so they are stated up front:
`realm` and `aud` are mandatory on login (section 2); there is no
`/api/v1/auth/profile` - profile endpoints are per-realm (section 3); and the
refresh field is spelled `refresh`, not `refreshToken` (section 4).

---

## 1. You may not need a token at all

A large part of the Yatix catalogue is readable with **no credentials** -
product search and transfer search, the region and destination content
records, the blog, exchange rates and more. If your agent only browses and
quotes, stop here and make unauthenticated GET requests.

### Where the list of those endpoints lives

**Not in this document.** The service index at
https://yatix.com/developers/api enumerates the endpoints that answer without
credentials, with a note on each one saying what it really returns. It is
the single authoritative inventory, and this file deliberately keeps no
second copy of it: one list in one place cannot disagree with itself. An
earlier revision of this section did carry its own list, it was shorter than
the service index, and the two contradicted each other - which is the whole
reason the inventory now lives in exactly one place.

Service health (also unauthenticated, and outside the versioned API):

```
GET https://api.yatix.com/health
```

### Two things a `200` does not mean

**It does not mean there is data.** `/public/bundles` is live but currently
returns an empty list (`data: []`, `pagination.total: 0`). A `200` with
nothing in it is the correct answer, not an auth failure, so do not go
looking for a token.

**It does not mean the record is published.** The content and blog endpoints
return unpublished records unless you filter them out, and an unpublished
record is not something Yatix sells. Measured today:

- `GET https://api.yatix.com/api/v1/content/regions` returns 3 regions. Two are published
  (Singapore, Malaysia); the UAE record is `unpublished`.
- `GET https://api.yatix.com/api/v1/content/destinations` returns 17 records. Ten are
  published, all in Malaysia; the other seven are unpublished UAE emirates.
  `?status=published` returns the ten.
- `GET https://api.yatix.com/api/v1/blog/public` returns 187 articles, 2 of them drafts.
  `?status=published` returns the 185 live ones.

Pass `status=published`, or read `status` on every record you intend to act
on. Note the asymmetry, because the two halves fail in opposite directions:

- **Destination drafts fail open.** The slug lookup behind
  `https://yatix.com/destinations/<slug>` does not filter on `status`, so an
  unpublished city renders a complete, ordinary-looking guide. A page that
  loads is not evidence that the place is sellable.
- **Blog drafts fail closed.**
  `GET https://api.yatix.com/api/v1/blog/public/slug/<slug>` answers `404` for a draft, so a
  draft article has no live page to link even by accident.

The same caveat, in the same terms, is in the service index, in the ARD
manifest and in the `browse-destinations` Agent Skill. If one of them ever
says otherwise, the service index is the one to believe.

### The discovery documents, and what each really contains

- https://yatix.com/developers/api - the API service index. The authoritative endpoint
  inventory. It is HTML meant for a human reader, so parse it only as a last
  resort; prefer the two machine-readable documents below for structure, and
  come here for coverage.
- https://yatix.com/.well-known/api-catalog - an RFC 9727 API catalog, served as an
  RFC 9264 linkset. It does **not** enumerate endpoints, and carries no
  endpoint information of any kind: three links, being one `item` link
  identifying the API, plus `status` and `service-doc`. Follow the `item`
  link and you land on https://yatix.com/developers/api, which is where the endpoints
  are.
- https://yatix.com/.well-known/ai-catalog.json - the ARD manifest, JSON, with a
  described entry per resource. It is a **subset**, not an inventory: five of
  its entries are API endpoints (`/content/regions`, `/content/destinations`,
  `/public/bundles`, `/blog/public`, `/exchange-rates`) and the rest are not
  API endpoints at all, such as the sitemap and the traveller-facing search
  page. Read it for a structured description of the main catalogue
  resources; do not read the absence of a path from it as that path not
  existing.

Two Agent Skills at https://yatix.com/.well-known/agent-skills/ - `search-experiences`
and `browse-destinations` - cover the same public endpoints as task-level
instructions, including the query parameters each one accepts.

Sending an `Authorization` header to any of these endpoints is harmless but
pointless. Do not acquire credentials you do not need.

---

## 2. Obtaining a token

Everything else requires a JWT. Tokens are issued by Yatix itself - there is
no third-party identity provider in this path - by exchanging credentials at
a single endpoint:

```http
POST /api/v1/auth/login HTTP/1.1
Host: api.yatix.com
Content-Type: application/json

{
  "email": "<account email>",
  "password": "<account password>",
  "realm": "customer",
  "aud": "customer"
}
```

**All four fields are required.** `realm` and `aud` are not optional extras:
omitting either one returns `400` with `code: "VALIDATION_ERROR"` before your
credentials are even looked at. Permitted values:

| Field | Required | Permitted values |
| --- | --- | --- |
| `email` | yes | a valid email address |
| `password` | yes | minimum 6 characters |
| `realm` | yes | `internal`, `partner`, `customer` |
| `aud` | yes | `admin`, `support`, `vendor`, `customer`, `content_writer` |

The two are not independent - `realm` selects which population of accounts is
searched, and `aud` must be one the account is allowed to use, or login fails
`401` with "Client not allowed". The working combinations are:

- `realm: "customer"` with `aud: "customer"` - end-user accounts.
- `realm: "partner"` with `aud: "vendor"` - supplier/vendor accounts.
- `realm: "internal"` with `aud: "admin"`, `"support"` or `"content_writer"` -
  Yatix staff.

**A third-party agent wants `realm: "customer"`, `aud: "customer"`.** The other
two realms are Yatix's own staff and contracted suppliers; a credential issued
to you will be a customer-realm one unless you were told otherwise. The email
address alone does not decide this - an account is keyed on the pair of email
and realm - so sending the wrong `realm` returns `401 Invalid credentials` even
when the password is right.

A successful response is wrapped in the standard Yatix envelope:

```json
{
  "success": true,
  "data": {
    "token": "<JWT>",
    "refresh": "<refresh token>",
    "user": { "id": "...", "email": "...", "realm": "...", "roles": ["..."] }
  }
}
```

Read the JWT from `data.token` and the refresh token from **`data.refresh`**.
The field is `refresh`, not `refreshToken`; section 4 explains what to do with
it. Treat the JWT as opaque: do not parse its claims, and do not make behaviour
depend on them. There is no public JWKS endpoint - these tokens are verified by
the Yatix API and by nothing else, so there is no way (and no need) for your
agent to validate one locally.

One case returns `200` with no token: an `internal`-realm login from an
unrecognised device answers `{"success":true,"data":{"requiresMfa":true,...}}`
instead. Customer-realm logins are not subject to this, but check for `token`
before assuming you have one.

---

## 3. Using the token

Send it as a bearer token on every request:

```http
GET /api/v1/customer/auth/profile HTTP/1.1
Host: api.yatix.com
Authorization: Bearer <JWT>
```

As curl:

```sh
curl -H "Authorization: Bearer $YATIX_TOKEN" \
  https://api.yatix.com/api/v1/customer/auth/profile
```

The token goes in the header only. Do not put it in a query string, a URL
path, or a request body - those get logged.

### Profile endpoints are per-realm

**There is no `/api/v1/auth/profile`.** The `/api/v1/auth/*` prefix carries the
credential operations only (login, refresh, logout, revoke-all, push-token,
Google linking, password reset). "Who am I" lives under the prefix belonging to
the realm the token was issued for:

| Realm / audience | Profile endpoint |
| --- | --- |
| `customer` / `customer` | `GET /api/v1/customer/auth/profile` |
| `partner` / `vendor` | `GET /api/v1/vendors/profile` |
| `internal` / `admin` | `GET /api/v1/admin/profile` |
| `internal` / `content_writer` | `GET /api/v1/content-writer/profile` |

Use the row matching the `realm`/`aud` you logged in with. A customer token
sent to `/api/v1/vendors/profile` is rejected `403` - the endpoint checks the
realm and audience, not just the signature. The customer endpoint likewise
rejects a non-customer token, so `GET /api/v1/customer/auth/profile` is the
right smoke test that a customer-realm token works.

This split runs through the whole API: the customer-facing resources an agent
is likely to want sit under `/api/v1/customer/*`, `/api/v1/cart`,
`/api/v1/bookings` and `/api/v1/reviews`, not under `/api/v1/auth/*`.

---

## 4. Expiry and refresh

Tokens expire. The exact lifetime is not published and may change, so do not
hard-code one; drive refresh off the response instead.

When a request returns `401`, exchange the refresh token you were given at
login (`data.refresh`) for a new access token:

```http
POST /api/v1/auth/refresh HTTP/1.1
Host: api.yatix.com
Content-Type: application/json

{ "refresh": "<refresh token>" }
```

**The field is `refresh`.** A body of `{"refreshToken": ...}` fails `400`
`VALIDATION_ERROR` every time: unrecognised keys are stripped before the body
is checked, so `refreshToken` is discarded and the request is then simply
missing its required `refresh`. The error names the missing field, not the one
you sent - so read it carefully rather than assuming the token was rejected.

The response carries both halves of a new pair:

```json
{ "success": true, "data": { "token": "<new JWT>", "refresh": "<new refresh token>" } }
```

**Refresh tokens rotate.** The one you sent is revoked the moment it is
redeemed, so you must store `data.refresh` from the response and use that next
time. Replaying a spent refresh token returns `401` and there is no way back to
it - you have to log in again. If your agent runs more than one request in
parallel, serialise refreshes behind a single lock, or a second concurrent
refresh will spend the token the first one is already using.

Refresh once per failure, retry the original request once, and if that also
fails treat it as terminal: stop and surface the error. Do not loop, and do not
re-run the login flow on a timer.

A `403` means the credential is valid but not permitted to do that. Refreshing
will not fix it - do not retry.

Do not confuse `/api/v1/auth/refresh` with the separate customer-app endpoint
`/api/v1/customer/auth/refresh`, which is not the same route and does take the
field spelled `refreshToken`. If you logged in at `/api/v1/auth/login`, refresh
at `/api/v1/auth/refresh` with `refresh`, and keep the pair matched.

To give a token back when you are done with it - at the end of a session, or
when you believe one has leaked - revoke the refresh token:

```http
POST /api/v1/auth/logout HTTP/1.1
Host: api.yatix.com
Content-Type: application/json

{ "refresh": "<refresh token>" }
```

Same field name, same `400` if you spell it `refreshToken`. This revokes that
one refresh token; the access token already issued stays valid until it
expires, so discard your copy. `POST /api/v1/auth/revoke-all` revokes every
refresh token for the account - it takes no body but does require a valid
`Authorization: Bearer` header.

### Reading failures

Every error uses one envelope, so you can branch on it directly:

```json
{ "success": false, "error": "<human-readable message>", "code": "<CODE>" }
```

| Status | `code` | What it means for your agent |
| --- | --- | --- |
| 400 | `VALIDATION_ERROR` | The body is malformed - a missing `realm`/`aud`, or `refreshToken` where `refresh` was wanted. Fix the request; retrying it unchanged will not help. |
| 401 | `AUTHENTICATION_ERROR` | Bad credentials, wrong `realm` for the email, missing/expired token, or a spent refresh token. Refresh once, then re-authenticate. |
| 403 | `AUTHORIZATION_ERROR` | Valid credential, wrong realm/audience/role for this endpoint. Do not retry. |
| 404 | - | The route does not exist. Check it against this document. |
| 429 | `RATE_LIMIT_ERROR` (may be absent) | Back off. Rate-limited replies keep `success: false` and `error`, but some limiters emit their own body with no `code` - branch on the status, not the code. Password reset in particular allows 3 requests per 15 minutes. |

Note that `400` and `401` both come back from `/auth/login`, and they mean
different things: `400` says your request shape is wrong, `401` says your
credentials are. Treating a `400` as an auth failure and retrying with new
credentials is the most common way to get nowhere.

---

## 5. What Yatix does not have

Stated explicitly, because an agent that assumes otherwise will spend its
time fetching 404s:

- **No OAuth 2.0 authorization server.** There is no `/oauth/authorize`, no
  `/oauth/token`, no authorization-code or client-credentials grant, no PKCE,
  no scopes, and no `jwks_uri`.
- **No OAuth discovery documents.** `/.well-known/oauth-authorization-server`
  (RFC 8414) and `/.well-known/oauth-protected-resource` (RFC 9728) are
  deliberately not published, because publishing them would assert an
  authorization server that does not exist.
- **No dynamic client registration** (RFC 7591). There is no endpoint at which
  a client can register itself and receive a client_id/client_secret.
- **No API keys.** Access is by JWT only.
- **No OpenAPI/Swagger description** of the API.

One thing that is easy to misread: yatix.com signs human visitors in with
NextAuth, which can use Google. That makes Yatix an OAuth *client* of Google
for its own website login. It does not make Yatix an identity provider.

There is a `POST /api/v1/auth/google` that takes `{"idToken": "..."}` and
returns a Yatix token, but it is not an opening for a third party: it verifies
the ID token against Yatix's own Google client ID and rejects anything minted
for a different client. You would need to be Yatix's web client, with a real
user completing Google consent in front of a browser, to produce an ID token it
accepts. Treat it as part of the website's sign-in, not as an agent auth path.

---

## 6. Getting credentials

**There is no self-service registration that provisions an agent or API
client.** Yatix does have account-creation endpoints
(`POST /api/v1/auth/register` and `POST /api/v1/customer/auth/register`), but
they exist to sign up human end users of the website, and an account made
through them is an ordinary customer account, not API access. Do not drive
them from an agent: creating
accounts programmatically in order to mint tokens is not a supported path and
will be treated as abuse. Nothing anywhere issues a client_id/client_secret.

API access for an automated client is arranged directly with the operator.
Get in touch and say what you are building:

- Email: customercare@yatix.com
- Help centre: https://yatix.com/help-center

It helps to include: who operates the agent, what it does on a user's behalf,
which endpoints it needs, expected request volume, and whether it acts for one
account or many.

---

## 7. Handling credentials

- Credentials are per-operator. Do not share, resell, or embed them in a
  distributed client, a browser bundle, or a public repository.
- Never ask an end user to paste a Yatix password into your agent in order to
  call `/auth/login` on their behalf unless they initiated that and understand
  it. Prefer holding your own operator credential.
- Store the JWT and refresh token in memory or in a secret store, not on disk
  in plaintext and not in logs.
- Rate limits are mostly not published (the password-reset one in section 4 is
  the exception). Be conservative, back off on errors, and
  cache the unauthenticated catalogue data in section 1 rather than re-fetching
  it per request.
