# Conventions (/conventions)

Versions, request and response shapes, formats, paging and identifiers, shared by both APIs.

Both APIs follow the same rules, so code you write for one carries over to the other.

## Versions [#versions]

The version is in the path: `https://api.voyagelabs.ai/v1/...`.

- Within `v1`, fields are only ever added. Your code must ignore fields it doesn't know.
- A field or endpoint is never removed, or changed in meaning, within `v1`. A change like that means `v2`. `v1` keeps running beside it, and its answers carry a `Sunset` header once an end date is set.
- New error codes can be added within `v1`. Handle unknown codes by their `retry` advice.

## Requests [#requests]

- Send the key in the `X-API-Key` header. See [Keys and authentication](/authentication).
- Search endpoints take either query parameters (`GET`) or a JSON body (`POST`) with `Content-Type: application/json`. A body may be up to 16 KB.
- Everything is UTF-8.

## Responses [#responses]

Every JSON answer is one of two shapes. A response has `data` or `error`, never both.

```json title="Success"
{
  "data": { },
  "meta": { "request_id": "req_41ab9c", "mode": "live" }
}
```

```json title="Failure"
{
  "error": {
    "code": "search_not_found",
    "message": "No search with that id. Searches are kept for at least 30 minutes; run the search again.",
    "retry": "never",
    "request_id": "req_41ab9c"
  }
}
```

- `meta.request_id` names the request, and is also in the `X-Request-Id` header.
- `meta.mode` is `live` or `test`, after the key that made the call.
- Finding nothing is a success, with an empty list.
- [Errors](/errors) lists every `code`.

## Formats [#formats]

| Kind | Format | Example |
| --- | --- | --- |
| Dates | `YYYY-MM-DD` | `2027-02-09` |
| Moments | ISO 8601 in UTC, ending `Z` | `2026-12-02T00:20:11Z` |
| Flight times | Local time at the airport, with no offset. A `_utc` twin gives the same moment in UTC. | `"depart": "2027-02-09T10:45:00"`, `"depart_utc": "2027-02-09T18:45:00Z"` |
| Money | A number in the currency's main unit, beside a 3-letter `currency` code | `"total": 2823.38, "currency": "USD"` |
| Durations | Whole units, named in the field | `duration_min`, `age_s`, `retry_after_s` |
| Airports | 3-letter IATA codes | `SFO` |
| Airlines | 2-character codes | `NH` |
| Countries | 2-letter ISO codes | `US` |

## Identifiers [#identifiers]

Ids such as `search_id`, result ids and `request_id` are opaque strings. Store them and pass them back as they are. Never parse them, build them or rely on their length.

## Paging [#paging]

Lists come one page at a time:

1. Ask for a page size with `limit`.
2. If the answer's `next_cursor` is not `null`, pass it back as `cursor` to get the next page.
3. When `next_cursor` is `null`, you have the whole list.

Page a search once it has finished. While a search is still running, the list can change between pages.

## Prices have an age [#prices-have-an-age]

Every search answer says when its prices were found, in `pricing.priced_at`, and how many seconds ago that was, in `pricing.age_s`. Prices go stale as rooms and seats sell. Search again before you show a price once `age_s` is over 240 for flights, or over 900 for hotels.

## Browsers and CORS [#browsers-and-cors]

The APIs answer requests from any web origin. Calls with a live key still belong on your server, because a key in a web page is public. See [Keep live keys on your server](/authentication#keep-live-keys-on-your-server).