Interlaken API
- Create a datasource
- Upload files to a datasource
- Retrieve upload status
- List datasources
- Retrieve a datasource
- Update datasource properties
- Retrieve a datasource version
- Create or update a branch
- Delete a branch
- Supported file formats
- Query a datasource
- Interlaken API errors
- Interlaken API restrictions and limits
- Interlaken API pricing
- Detail strategy
The Interlaken API is in public beta. The API may change before general availability.
The Interlaken API stores your geospatial data in Mapbox Interlaken Database as datasources and lets you query that data. A datasource holds a collection of geospatial features. Every upload to a datasource creates a new, immutable version.
Use the datasource endpoints to create datasources, upload data, and manage branches. Use the query endpoint to find the features in a datasource that meet a spatial condition, such as inside a bounding box or within a distance of a point, and optionally a filter on their properties.
Datasources are also the inputs for the Mapbox Tiling Service v2.
Create a datasource
Creates an empty datasource. You can upload data to it once it exists. Creating a datasource that already exists returns an HTTP 409 Conflict error.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that will own the datasource. |
id | string | The ID of the datasource to create. Up to 64 characters. The only allowed characters are letters, numbers, -, and _. |
access_token | string | A valid Mapbox access token with the datasources:write scope. |
The request body is optional. When you send one, it must be a JSON object with any of the following properties:
| Optional body properties | Type | Description |
|---|---|---|
display_name | string | A human-readable name for the datasource, from 1 to 255 characters. You can change it later with the Update datasource properties endpoint. |
fields | array of objects | Property columns to define up front, each with a name and a type. See Fields. |
detail_strategy | object | Rules that set the zoom levels at which features appear. Can't be changed after the datasource is created. See Detail strategy. |
Fields
Use fields to declare typed property columns before you upload data. Each entry has the following properties:
| Property | Type | Description |
|---|---|---|
name | string | The name of the feature property. |
type | string | The property's data type. One of boolean, double, long, string, list<boolean>, list<double>, list<long>, or list<string>. A list<...> type is a single-level list of that type. |
Example request: Create a datasource
# Create an empty datasource with no optional properties
$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN"
# Create a datasource with a display name, fields, and a detail strategy
$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"display_name": "Street trees",
"fields": [
{ "name": "species", "type": "string" },
{ "name": "height", "type": "double" },
{ "name": "heritage", "type": "boolean" },
{ "name": "min_zoom", "type": "long" }
],
"detail_strategy": {
"rules": [
{ "when": "min_zoom IS NOT NULL", "minzoom": { "field": "min_zoom" } },
{ "when": "heritage = true", "minzoom": 10 },
{ "when": "height >= 20", "minzoom": 13 }
],
"default": { "minzoom": 15 }
}
}'
Response: Create a datasource
If the request is successful, the response has an HTTP 201 Created status and contains the following properties:
| Property | Type | Description |
|---|---|---|
id | string | The ID of the datasource. |
owner | string | The account that owns the datasource. |
display_name | string | The datasource's display name, if you set one. |
Example response: Create a datasource
{
"id": "trees",
"owner": "username",
"display_name": "Street trees"
}
Upload files to a datasource
Each upload adds data to a datasource branch and, once processed, creates a new version that the branch points at. There are two ways to upload a file:
- In a single request (
type=singlepart, the default), for files up to 300 MB. - In parts (
type=multipart), for files larger than 300 MB or when you want to attach metadata to the new version.
The following table compares them:
| Singlepart | Multipart | |
|---|---|---|
| File size | Up to 300 MB | Up to 1 GB in total |
| Requests | One request that sends the whole file | Start the upload, send the file in parts, then commit it |
| Version metadata | Not supported | Optional, sent with the commit |
Both kinds of upload accept GeoJSON, line-delimited GeoJSON, and other common geospatial formats. See Supported file formats.
All uploads are processed asynchronously. The request that queues a file for processing (the singlepart upload request, or the multipart commit request) returns an HTTP 202 Accepted status as soon as the file is queued, with an upload_id. To find out when processing finishes, poll the upload status endpoint with that upload_id until status is completed, failed, or retry.
When you start an upload, you can use the following optional query parameters:
| Optional parameters | Type | Default | Description |
|---|---|---|---|
type | string | singlepart | The kind of upload: singlepart or multipart. |
operation | string | append | What to do with the data. append adds the uploaded features to the branch. overwrite replaces everything on the branch with the uploaded features. |
branch | string | main | The branch to write to. Branch names are 1 to 64 lowercase letters, numbers, -, and _, with at least one character that isn't a number. Create the branch with the Create or update a branch endpoint before you upload to it. |
base | string | The version the branch points at | The version to build on. Can't be combined with operation=overwrite. |
Upload a file in a single request
This is the default kind of upload (type=singlepart). Send the whole file as the body of the request. The file must be 300 MB or smaller. There is no separate commit step: the request queues the file for processing. Because of this, you can't attach metadata to the version a singlepart upload creates. To attach metadata, use a multipart upload and send it when you commit the upload.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource to upload to. |
access_token | string | A valid Mapbox access token with the datasources:write scope. |
Example request: Upload a file in a single request
$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @trees.geojson
Response: Upload a file in a single request
If the file is queued for processing, the response has an HTTP 202 Accepted status and contains the following properties. Poll the upload status endpoint with the upload_id to find out when processing finishes.
| Property | Type | Description |
|---|---|---|
upload_id | string | The ID of the upload. Use it to check the upload status. |
owner | string | The account that owns the datasource. |
id | string | The ID of the datasource. |
upload_type | string | singlepart. |
operation | string | The operation you requested: append or overwrite. |
branch | string | The branch the upload writes to. |
status | string | committed: the file is queued for processing. See upload statuses. |
Example response: Upload a file in a single request
{
"owner": "username",
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"id": "trees",
"upload_type": "singlepart",
"operation": "append",
"branch": "main",
"status": "committed"
}
Upload a file in parts
For files larger than 300 MB, or to attach metadata to the new version, set type=multipart. A multipart upload sends a file in parts across several requests, then commits them. The total size of all parts can be up to 1 GB.
Step 1: Start a multipart upload
Starts a multipart upload and returns its upload_id. Send this request without a body.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource to upload to. |
type | string | multipart. |
access_token | string | A valid Mapbox access token with the datasources:write scope. |
Example request: Start a multipart upload
$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads?type=multipart&access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN"
Response: Start a multipart upload
If the request is successful, the response has an HTTP 200 OK status and contains the following properties:
| Property | Type | Description |
|---|---|---|
upload_id | string | The ID of the upload. Use it in the next two steps. |
owner | string | The account that owns the datasource. |
id | string | The ID of the datasource. |
upload_type | string | multipart. |
branch | string | The branch the upload writes to. |
Example response: Start a multipart upload
{
"owner": "username",
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"id": "trees",
"upload_type": "multipart",
"branch": "main"
}
Step 2: Upload each part
Sends one part of the file as the request body. Each part must have a Content-Length header, and every part except the last must be at least 5 MiB (5,242,880 bytes).
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource. |
upload_id | string | The upload_id from Step 1. |
access_token | string | A valid Mapbox access token with the datasources:write scope. |
The first part is checked to make sure it is a supported file format. If it isn't, the request fails with an HTTP 422 Unprocessable Entity error.
Example request: Upload each part
# Split the file into 100 MB parts, then send them in order
$split -b 100m trees.geojson trees-part-
$for part in trees-part-*; do
curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads/3fa85f64-5717-4562-b3fc-2c963f66afa6?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$part"
done
Response: Upload each part
If the part is accepted, the response has an HTTP 200 OK status and contains the upload_id, owner, and id of the upload.
Example response: Upload each part
{
"owner": "username",
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"id": "trees"
}
Step 3: Commit the upload
Joins the uploaded parts and queues the file for processing. After you commit an upload, you can't add more parts to it.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource. |
upload_id | string | The upload_id from Step 1. |
access_token | string | A valid Mapbox access token with the datasources:write scope. |
The request body is optional. When you send one, it must be a JSON object with a Content-Type: application/json header, and can contain the following property:
| Optional body properties | Type | Description |
|---|---|---|
metadata | object | Your own JSON metadata for the version this upload creates, up to 16 KB and 32 levels deep. If you leave it out, the previous version's metadata is carried forward. If you send it, it replaces the previous metadata. |
Example request: Commit the upload
$curl -X POST "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads/3fa85f64-5717-4562-b3fc-2c963f66afa6/commit?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "metadata": { "source": "city-open-data", "exported": "2026-11-01" } }'
Response: Commit the upload
If the commit is accepted, the file is queued for processing and the response has an HTTP 202 Accepted status and a status of committed. Poll the upload status endpoint with the upload_id to find out when processing finishes.
Example response: Commit the upload
{
"owner": "username",
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"id": "trees",
"status": "committed",
"total_chunks": 1,
"ingested_chunks": 0
}
Retrieve upload status
Returns the current state of an upload. Because uploads are processed asynchronously, poll this endpoint after you upload a file, waiting a few seconds between requests, until status is completed, failed, or retry. When status is completed, version is the new version and the branch points at it.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource. |
upload_id | string | The ID of the upload, returned when you started it. |
access_token | string | A valid Mapbox access token with the datasources:read scope. |
Example request: Retrieve upload status
$curl "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/uploads/3fa85f64-5717-4562-b3fc-2c963f66afa6?access_token=YOUR_MAPBOX_ACCESS_TOKEN"
Response: Retrieve upload status
If the request is successful, the response contains the following properties:
| Property | Type | Description |
|---|---|---|
upload_id | string | The ID of the upload. |
owner | string | The account that owns the datasource. |
id | string | The ID of the datasource. |
upload_type | string | singlepart or multipart. |
operation | string | The operation you requested when you started the upload. |
branch | string | The branch the upload writes to. |
status | string | The upload's status. See upload statuses. |
version | string | The version the upload created. Only present when status is completed. |
total_chunks | integer | The number of chunks to process. |
ingested_chunks | integer | The number of chunks processed so far. |
created_at | string | When the upload started, as an ISO 8601 timestamp. |
updated_at | string | When the upload's status last changed, as an ISO 8601 timestamp. |
error | string | A description of what went wrong. Only present when status is failed or retry. |
Upload statuses
| Status | Description |
|---|---|
processing | A multipart upload has started and is receiving parts. |
committed | The file is queued or being processed. |
completed | Processing finished. version is the new version, and the branch now points at it. |
failed | Processing failed and won't succeed if you try again with the same file. Check error for the reason. |
retry | Processing failed because of a temporary problem. The upload isn't retried automatically; upload the file again. |
Example response: Retrieve upload status
{
"upload_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"owner": "username",
"id": "trees",
"upload_type": "multipart",
"operation": "append",
"branch": "main",
"status": "completed",
"version": "799472732836488995",
"total_chunks": 1,
"ingested_chunks": 1,
"created_at": "2026-11-04T18:40:11.362Z",
"updated_at": "2026-11-04T18:42:30.118Z"
}
List datasources
Lists the datasources that belong to an account. An account with no datasources returns an empty list. Results are returned in pages; see Pagination.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account whose datasources to list. |
access_token | string | A valid Mapbox access token with the datasources:list scope. |
| Optional parameters | Type | Default | Description |
|---|---|---|---|
limit | integer | 100 | The maximum number of datasources to return, from 1 to 500. |
start | string | None (first page) | The cursor for the next page of results, taken from the Link header of the previous response. See Pagination. |
Example request: List datasources
$curl "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME?limit=25&access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN"
Response: List datasources
If the request is successful, the response contains a datasources array. Results are in a consistent but unspecified order. Each datasource in the array has the following properties:
| Property | Type | Description |
|---|---|---|
owner | string | The account that owns the datasource. |
id | string | The ID of the datasource. |
To get a datasource's display name and branches, retrieve the datasource.
Example response: List datasources
{
"datasources": [
{ "owner": "username", "id": "parcels" },
{ "owner": "username", "id": "trees" }
]
}
Pagination
Results are returned in pages. When more results are available, the response includes a Link header with a URL for the next page:
Link: <https://api.mapbox.com/db/v1/datasources/username?limit=25&start=eyJrIjoidHJlZXMifQ&access_token=YOUR_MAPBOX_ACCESS_TOKEN>; rel="next"
To get every datasource, request the rel="next" URL from each response until a response has no Link header.
- Treat the
startvalue as opaque. Don't build, change, or store it. startvalues expire after a short time. If you send one that has expired or is malformed, the response is an HTTP400 Bad Requesterror with the messageInvalid start. Start again from the first page.- Datasources created or deleted while you page through the results aren't guaranteed to appear in the results.
Retrieve a datasource
Returns a datasource's display name, first version, and branches. Use it to find the version each branch points at.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource. |
access_token | string | A valid Mapbox access token with the datasources:read scope. |
Example request: Retrieve a datasource
$curl "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees?access_token=YOUR_MAPBOX_ACCESS_TOKEN"
Response: Retrieve a datasource
If the request is successful, the response contains the following properties:
| Property | Type | Description |
|---|---|---|
owner | string | The account that owns the datasource. |
id | string | The ID of the datasource. |
display_name | string | The datasource's display name, or null if it doesn't have one. |
initial_version | string | The first version created in the datasource. null until the datasource ingest completes |
branches | array of objects | The datasource's branches. Each has a name and the version it points at. |
Example response: Retrieve a datasource
{
"owner": "username",
"id": "trees",
"display_name": "Street trees",
"initial_version": "799472732836488995",
"branches": [
{ "name": "main", "version": "812094471182364207" },
{ "name": "staging", "version": "825317690124553810" }
]
}
Update datasource properties
Updates properties that apply to the whole datasource rather than to one version. The only property you can update is display_name. Updating it doesn't create a new version.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource. |
access_token | string | A valid Mapbox access token with the datasources:write scope. |
The request body must be a JSON object with the following property:
| Body properties | Type | Description |
|---|---|---|
display_name | string or null | Required. The new display name, from 1 to 255 characters. Set it to null to remove the display name. |
Example request: Update datasource properties
$curl -X PUT "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/properties?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "display_name": "Street trees 2026" }'
Response: Update datasource properties
If the request is successful, the response contains the following properties:
| Property | Type | Description |
|---|---|---|
id | string | The ID of the datasource. |
owner | string | The account that owns the datasource. |
display_name | string | The datasource's display name after the update, or null if removed. |
Example response: Update datasource properties
{
"id": "trees",
"owner": "username",
"display_name": "Street trees 2026"
}
Retrieve a datasource version
Returns details about one version of a datasource: how many features it has, their geometry types and bounding box, statistics for each property, and the metadata you attached when you uploaded it.
version must be a numeric version ID. Branch names aren't accepted and return HTTP 404 Not Found. To find the version a branch points at, retrieve the datasource and read branches.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource. |
version | string | The numeric ID of the version, such as 799472732836488995. |
access_token | string | A valid Mapbox access token with the datasources:read scope. |
Example request: Retrieve a datasource version
$curl "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/versions/812094471182364207?access_token=YOUR_MAPBOX_ACCESS_TOKEN"
Response: Retrieve a datasource version
If the request is successful, the response contains the following properties. Statistics that aren't available are null.
| Property | Type | Description |
|---|---|---|
id | string | The ID of the datasource. |
owner | string | The account that owns the datasource. |
display_name | string | The datasource's display name, or null. |
version | string | The ID of the version. |
parent_version | string | The previous version that this version builds on, or null if there is none. |
created_at | string | When the version was created, as an ISO 8601 timestamp in UTC. |
feature_count | integer | The number of features in the version. |
total_size | integer | The total size of the version, in bytes. |
bbox | array of numbers | The bounding box of the version's features, as [west, south, east, north]. |
geometry_types | object | The number of features of each geometry type, keyed by GeoJSON type such as Point or MultiPolygon. |
fields | array of objects | The feature properties in the version. Each has a name and a type, and may include statistics: null_count, min, max, the most common values, and typical_length for text. |
user_metadata | object | The metadata you sent when you committed the upload that created this version, or carried forward from an earlier version. |
memo | string | A memo recorded with the version, or null. |
detail_strategy | object | The datasource's detail strategy, or null if it doesn't have one. Every zoom level is filled in, and a maxzoom of 255 means no limit. |
Example response: Retrieve a datasource version
{
"id": "trees",
"owner": "username",
"display_name": "Street trees",
"version": "812094471182364207",
"parent_version": "799472732836488995",
"created_at": "2026-11-04T18:42:30Z",
"feature_count": 52418,
"total_size": 9842113,
"bbox": [-122.5149, 37.7081, -122.357, 37.8324],
"geometry_types": { "Point": 52418 },
"fields": [
{
"name": "species",
"type": "string",
"null_count": 0,
"values": ["oak", "maple", "sycamore"],
"values_truncated": true,
"typical_length": 6
},
{ "name": "height", "type": "double", "null_count": 112, "min": 1.5, "max": 38.2 }
],
"user_metadata": { "source": "city-open-data", "exported": "2026-11-01" },
"memo": null,
"detail_strategy": {
"rules": [
{ "when": "min_zoom IS NOT NULL", "minzoom": { "field": "min_zoom" }, "maxzoom": 255 },
{ "when": "heritage = true", "minzoom": 10, "maxzoom": 255 },
{ "when": "height >= 20", "minzoom": 13, "maxzoom": 255 }
],
"default": { "minzoom": 15, "maxzoom": 255 }
}
}
Create or update a branch
Most workflows don't need to manage branches directly: uploads write to
main, and main moves to each new version automatically. Use this endpoint
when you need more control, such as staging changes before they reach main
or rolling back to an earlier version. Moving a branch changes the data that
every tileset referencing it uses the next time that tileset is published.
Points a branch at a version. If the branch doesn't exist, it is created. If it exists, it moves to the version you choose. Sending the same request again has no further effect.
Use this endpoint to:
- Promote changes: create a
stagingbranch with this endpoint, upload to it, check the result in a tileset that uses thestagingbranch, then pointmainat the same version. - Roll back: point
mainat an earlier version, such as the versionmainpointed at before a bad upload. - Keep a stable reference: create a branch such as
release-2026-11that stays on a version whilemainmoves on.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource. |
branch | string | The branch name. 1 to 64 lowercase letters, numbers, -, and _, with at least one character that isn't a number. |
access_token | string | A valid Mapbox access token with the datasources:write scope. |
The request body must be a JSON object with the following property:
| Body properties | Type | Description |
|---|---|---|
version | string | Required. The numeric ID of the version to point the branch at. To use the version another branch points at, retrieve the datasource first. |
Example request: Create or update a branch
# Promote the version on the staging branch to main
$curl -X PUT "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/branches/main?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "version": "825317690124553810" }'
Response: Create or update a branch
If the request is successful, the response contains the following properties:
| Property | Type | Description |
|---|---|---|
owner | string | The account that owns the datasource. |
id | string | The ID of the datasource. |
branch | string | The name of the branch. |
version | string | The version the branch now points at. |
If the datasource or the version doesn't exist, the response has an HTTP 404 Not Found status.
Example response: Create or update a branch
{
"owner": "username",
"id": "trees",
"branch": "main",
"version": "825317690124553810"
}
Delete a branch
Deletes a branch. The main branch can't be deleted, and trying returns an HTTP 409 Conflict error.
| Required parameters | Type | Description |
|---|---|---|
owner | string | The Mapbox username of the account that owns the datasource. |
id | string | The ID of the datasource. |
branch | string | The name of the branch to delete. |
access_token | string | A valid Mapbox access token with the datasources:write scope. |
Example request: Delete a branch
$curl -X DELETE "https://api.mapbox.com/db/v1/datasources/YOUR_MAPBOX_USERNAME/trees/branches/staging?access_token=YOUR_SECRET_MAPBOX_ACCESS_TOKEN"
Response: Delete a branch
If the branch is deleted, the response has an HTTP 204 No Content status and no body.
Supported file formats
Each upload is one file. You don't need to tell the API the file's format: it's detected from the file's contents. Coordinates must be longitude and latitude in WGS84 (EPSG:4326).
| Format | Notes |
|---|---|
| GeoJSON | A FeatureCollection or a single Feature. Property values and feature IDs keep their JSON types. A crs member, if present, must name WGS84. |
| Line-delimited GeoJSON | One GeoJSON feature per line. |
| GeoJSON text sequences | GeoJSON features separated by record separator characters (RFC 8142). |
| TopoJSON | |
| FlatGeobuf | |
| KML | An uncompressed .kml file. |
| GPX |
If your data is in another format, such as a Shapefile, GeoPackage, CSV, or GeoParquet, convert it to GeoJSON before you upload it. You can use the GDAL command-line tool ogr2ogr, which can also convert the coordinates to WGS84:
$ogr2ogr -f GeoJSON -t_srs EPSG:4326 output.geojson input.shp
Query a datasource
Returns the features that match the query document in the request body.
| Required parameters | Type | Description |
|---|---|---|
access_token | string | A valid Mapbox access token with the datasources:read scope, from the account that owns the datasource. |
| Optional parameters | Type | Description |
|---|---|---|
continue | string | The _mbx.continue token from the previous response. Send it with the same query document to get the next page. See Paging. |
You can query a datasource created with the datasource endpoints on this page or uploaded with the Data Workbench. To get the ID of data uploaded with the Data Workbench, open it and click Copy ID next to its name.
Query document
The request body is a JSON query document.
| Property | Type | Description |
|---|---|---|
datasource | object | Required. The datasource to query, as {"id": "..."}. Add version to query a specific version. Without it, the API queries the current version. |
spatial | object | Required. Where to look, as exactly one spatial operator. |
filter | array | Which features to keep, as a filter expression. |
result | object | What to return. See Results. Defaults to matching features. |
Coordinates are [longitude, latitude] in WGS84 degrees, as in GeoJSON.
Spatial operators
| Operator | Type | Description |
|---|---|---|
bbox | array | Features touching the box [west, south, east, north]. To search a whole datasource, use [-180, -90, 180, 90]. A box whose west is greater than its east crosses the antimeridian. |
intersects | object | Features touching geometry, boundaries included. |
covers | object | Features that completely contain geometry. |
covered_by | object | Features completely inside geometry. |
within_distance | object | Features within distance of geometry, closest first. unit is m, km, ft, or mi. The distance can be at most 50 km. Each feature returns its distance in _mbx.distance. |
Every operator but bbox takes an object with a geometry:
"spatial": { "intersects": { "geometry": { "type": "Point", "coordinates": [-122.4194, 37.7749] } } }
geometry is a GeoJSON Point, LineString, Polygon, or Multi* geometry, or a Feature that holds one, with at most 10,000 positions. Split a geometry that crosses the antimeridian at ±180°.
Filters
A filter is a Mapbox expression over the datasource's string, number, and boolean properties.
| Expression | Example | Matches features where |
|---|---|---|
== != < <= > >= | ["==", ["get", "category"], "park"] | The comparison is true. |
in, with a list | ["in", ["get", "category"], ["literal", ["park", "cafe"]]] | The property is one of the values. |
in, with text | ["in", "coffee", ["get", "name"]] | The property contains the text, ignoring case. |
has | ["has", "name"] | The property has a value other than null. |
geometry-type | ["==", ["geometry-type"], "Polygon"] | The geometry is that type. Polygon also matches MultiPolygon. |
all any ! | ["all", <filter>, <filter>] | all: every filter matches. any: at least one does. !: the filter doesn't. |
!=, and a == or in inside !, also match features that don't have the property. <, <=, >, and >= never match them, even inside !. A filter can nest 32 levels deep and hold at most 1,000 conditions and 1,000 in values.
Results
| Property | Type | Description |
|---|---|---|
select | array | The properties to return. Defaults to all properties. The feature id is always returned. |
geometry | string | full (default) returns the stored geometry, bbox_center the center point of its bounding box, and none no geometry. |
limit | integer | The most features one response returns, from 1 to 1000. Defaults to 100. |
Paging
While a response includes _mbx.continue, more features may match. To get the next page, send the same query document with that token as the continue parameter. A page can hold fewer than limit features, or none, before the last one. The results end at the first response without _mbx.continue. Paging returns each match exactly once, in no particular order. The token can expire.
A query without a version pins the version that answered its first page, so later pages read the same data even if the datasource changes.
within_distance doesn't page and doesn't accept continue. It returns the limit closest features, and sets _mbx.complete to false if more were in range.
Find property names
A filter or select that names a property the datasource doesn't have returns a 400 error. Its errors[].valid lists the properties the datasource has, and errors[].suggestion the closest match.
Example requests: Query a datasource
# Find the parks in a bounding box, with only their names and categories
$curl -X POST "https://api.mapbox.com/db/v1/spatialquery?access_token=YOUR_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"datasource": { "id": "my-datasource" },
"spatial": { "bbox": [-122.45, 37.75, -122.4, 37.8] },
"filter": ["==", ["get", "category"], "park"],
"result": { "select": ["name", "category"] }
}'
# Find the 2 cafes closest to a point, within 1 km
$curl -X POST "https://api.mapbox.com/db/v1/spatialquery?access_token=YOUR_MAPBOX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"datasource": { "id": "my-datasource" },
"spatial": { "within_distance": { "geometry": { "type": "Point", "coordinates": [-122.4194, 37.7749] }, "distance": 1, "unit": "km" } },
"filter": ["==", ["get", "category"], "cafe"],
"result": { "limit": 2 }
}'
Response: Query a datasource
Results are a GeoJSON FeatureCollection (application/geo+json):
| Property | Type | Description |
|---|---|---|
features | array | The matching features. Each has an id, a geometry, and properties. |
features[]._mbx.distance | number | For within_distance. The feature's distance from the query geometry, in the request's unit. |
_mbx.complete | boolean | false when more features may match. |
_mbx.continue | string | Present while more features may match. See Paging. |
_mbx.version | string | The datasource version the API queried. |
_mbx.distance_cutoff | number | For an incomplete within_distance result. The distance of the furthest feature returned. Features tied at exactly this distance may be missing. |
Example response: Query a datasource
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "4f9c2a51-7d3e-5b8a-9c1f-2e6d8a0b4c37",
"geometry": { "type": "Point", "coordinates": [-122.4346, 37.7764] },
"properties": { "name": "Alamo Square", "category": "park" }
},
{
"type": "Feature",
"id": "b2e81c94-3a6f-5d07-8e2b-91c4f7a3d560",
"geometry": { "type": "Point", "coordinates": [-122.4335, 37.7692] },
"properties": { "name": "Duboce Park", "category": "park" }
}
],
"_mbx": {
"complete": false,
"version": "8094315265395412347",
"continue": "AhQQrcfad1rRr3WAb_s7IHjdI7Li3sbJMOukY06PEQxRho1h"
}
}
Interlaken API errors
The datasource endpoints and the query endpoint return errors in different formats.
Datasource endpoint errors
Error responses contain a message property describing the problem. Errors with a status of 500 or higher always have the message Internal Server Error.
| HTTP status code | Response body message | Description |
|---|---|---|
400 | Varies | A parameter or the request body is invalid, such as an ID that is too long, a branch name with uppercase letters, or base combined with operation=overwrite. The message describes the problem. |
400 | Request body is empty; singlepart uploads send the file with this request | The singlepart upload request didn't include a file. |
400 | Content-Length header is required for multipart uploads | The request for a multipart part didn't include a Content-Length header. |
400 | Invalid start | The start cursor has expired or is malformed. See Pagination. |
401 | Not Authorized - No Token | No access token was used in the request. |
401 | Not Authorized - Invalid Token | Check the access token you used in the request. |
403 | This API requires a token with {scope} scope. | The access token needs the specified scope. |
403 | Forbidden | The access token belongs to a different account than owner. You can only access datasources that your account owns. |
404 | Varies | The datasource, version, or branch doesn't exist. |
404 | Upload not found: {upload_id} | The upload doesn't exist, or belongs to a different datasource. |
409 | Varies | A datasource with this ID already exists. |
409 | The 'main' branch cannot be deleted | You tried to delete the main branch. |
409 | Upload {upload_id} has already been committed | The multipart upload was already committed. You can't add parts to it or commit it again. |
409 | Singlepart uploads are committed when they are created | You tried to commit a singlepart upload. Singlepart uploads don't need a commit. |
409 | No parts uploaded for upload {upload_id}. Upload parts before committing. | You tried to commit a multipart upload before sending any parts. |
409 | Upload {upload_id} has permanently failed: {error} | The upload failed and can't be continued. Start a new upload. |
415 | Commit request body must be sent with Content-Type: application/json. | A commit request had a body without a Content-Type: application/json header. |
422 | Varies, such as Unsupported file format: a bare shapefile component | The file isn't in a supported format. |
429 | Too Many Requests | You have exceeded the rate limit. |
500 | Internal Server Error | Something went wrong on the server. Try again later. |
504 | Internal Server Error | The request took too long. Retry a read request later. A write request that times out can still take effect, so check the result before you retry it, for example with the upload status endpoint or by retrieving the datasource. |
Query endpoint errors
Errors are RFC 9457 Problem Details with a detail message, retryable, and an errors list. One response reports every problem in the query document, up to 100, and detail gives the total when there are several. Each problem has a stable code and a detail. Where they apply, it also has:
at: the invalid field.received: the value sent. The API shortens a long value and setsreceived_truncatedtotrue.suggestion: the closest valid value.validorexpected: the values accepted.limitandactual: the limit exceeded and the measured value.example: a corrected part of the query document.
{
"title": "Bad Request",
"status": 400,
"detail": "Unknown field 'categroy' in filter.",
"retryable": false,
"errors": [
{
"code": "unknown_filter_field",
"detail": "Unknown field 'categroy' in filter.",
"at": "filter[1][1]",
"received": "categroy",
"suggestion": "category",
"valid": ["category", "name", "rating"],
"example": { "filter": ["==", ["get", "category"], "value"] }
}
]
}
code | HTTP status code | Description |
|---|---|---|
invalid_request | 400 | The query document is invalid, or the API didn't issue the continue token. |
invalid_filter, unknown_filter_operator | 400 | The filter isn't a valid expression. |
unknown_filter_field, unknown_select_field | 400 | The datasource doesn't have the property. valid lists the properties it has. |
unfilterable_field | 400 | The property isn't a string, number, or boolean. |
filter_type_mismatch | 400 | The filter compares a property with a value of another type. |
continuation_query_mismatch | 400 | The continue token belongs to a different query document. |
missing_token, invalid_token | 401 | Check the access token. |
token_restricted, insufficient_scope | 403 | The token is restricted, or it doesn't have the datasources:read scope. |
datasource_not_found, version_not_found | 404 | The token's account has no such datasource or version. |
request_too_large | 413 | The request body is over 1 MiB. |
query_too_broad | 413 | The query is over a limit, such as the 50 km within_distance radius. Narrow it. |
query_budget_exhausted | 413 | A within_distance search has too many features in range to rank, or too many features share one location to page past. Narrow the area or add a filter. |
rate_limited | 429 | You exceeded the rate limit. Retry after the X-Rate-Limit-Reset time. |
internal_error | 500 | An unexpected error occurred. |
auth_unavailable | 503 | The API couldn't verify the access token. Retry the request. |
Interlaken API restrictions and limits
Requests are rate limited per access token. If you exceed a limit, you receive an HTTP 429 Too Many Requests error. For information on rate limit headers, see Rate limit headers.
| Endpoint | Requests per minute |
|---|---|
| Create a datasource | 600 |
| Upload files to a datasource | 600 |
| Retrieve upload status | 2,000 |
| List datasources | 2,000 |
| Retrieve a datasource | 2,000 |
| Update datasource properties | 600 |
| Retrieve a datasource version | 2,000 |
| Create or update a branch | 600 |
| Delete a branch | 600 |
| Query a datasource | 100 |
Datasource endpoint limits
| Limit | Value |
|---|---|
| Datasource ID | Up to 64 characters: letters, numbers, -, and _. |
| Branch name | 1 to 64 characters: lowercase letters, numbers, -, and _, with at least one that isn't a number. |
| Display name | 1 to 255 characters. |
| Singlepart upload | 300 MB per file. |
| Multipart upload | 1 GB in total. Every part except the last must be at least 5 MiB (5,242,880 bytes). |
Upload metadata | 16 KB when encoded as JSON, and up to 32 levels of nesting. |
| Detail strategy | Up to 20 rules. Each when expression is up to 256 characters. Zoom levels are 0 to 30. |
| List datasources page size | Up to 500 datasources per page. |
Query endpoint limits
| Limit | Value |
|---|---|
| Request body | 1 MiB. |
| Query geometry | Up to 10,000 positions. |
within_distance radius | Up to 50 km. The geometry can reach at most 500 km from its center. |
| Results | Up to 1,000 features per response. Use paging for more. |
| Caching | Responses set Cache-Control: no-store. |
| Edge precision | Matching first compares stored bounding boxes at single precision, so a query can miss a feature whose edge is within about 1 m of the query's edge. |
Interlaken API pricing
The datasource endpoints and the query endpoint are free during the public beta.
Detail strategy
Detail strategy is an advanced feature, worth considering if you're working with large datasources. You can only set it when you create a datasource.
A detail strategy gives every feature in a datasource a minimum and maximum zoom level, based on its properties. For example, you can show landmark trees from zoom 10 and other trees only from zoom 15. Tilesets built from the datasource include each feature only at the zoom levels its detail strategy allows.
Use a detail strategy when a datasource has more features than a map can usefully show when zoomed out. Leaving minor features out of low zoom levels keeps the map readable, and makes tiles smaller so they load and render faster. Because the zoom levels are stored with the data, every tileset built from the datasource uses them, without repeating the same filters in each recipe or style.
You can only set a detail strategy when you create a datasource, and you can't change it afterward. If you don't set one, every feature appears at every zoom level.
| Property | Type | Description |
|---|---|---|
rules | array of objects | Up to 20 rules, tried in order. See Rules. |
default | object | The minzoom and maxzoom for features that no rule matches. Both are optional. |
Rules
Each rule sets the zoom levels for the features that match it:
| Property | Type | Description |
|---|---|---|
when | string | Required. A filter expression of up to 256 characters that selects features, such as species = 'oak'. |
minzoom | integer or object | Optional. The lowest zoom level at which matching features appear. See Zoom levels. |
maxzoom | integer or object | Optional. The highest zoom level at which matching features appear. See Zoom levels. |
For each feature, rules are tried in the order you list them, and the first rule whose when matches sets the feature's zoom levels. Later rules are ignored for that feature. If no rule matches, default applies. Put your most specific rules first.
If a when expression compares a property that is missing or null on a feature, the rule doesn't match that feature, and the next rule is tried.
Zoom levels
Each minzoom and maxzoom, in a rule or in default, is one of the following:
- A zoom level from
0to30, such as12. If a rule sets both,maxzoomcan't be lower thanminzoom. - A property reference, such as
{ "field": "min_zoom" }, that reads the zoom level from each feature's own property. The property must be declared infieldsas alongordouble. Decimal values are rounded down, so3.7becomes3.
A zoom level that you leave out, or a property reference that is null or outside 0 to 30 for a feature, uses the built-in default: minzoom 0, or no maxzoom limit. This applies even inside a rule, so a rule's missing maxzoom doesn't fall back to the maxzoom in default.
If a property reference gives a feature a maxzoom lower than its minzoom, the feature keeps its minzoom and has no maxzoom limit.
Write a when expression
A when expression compares feature properties with values. Every property it uses must be declared in fields in the same request, and each value must match the property's type. The request is rejected if an expression refers to an undeclared property, compares a property with a value of the wrong type, or can't be parsed.
| Operator | Example | Matches features where |
|---|---|---|
= (or ==) | species = 'oak' | species is oak. |
!= (or <>) | species != 'oak' | species is something other than oak. |
<, <=, >, >= | height >= 20 | height is 20 or more. |
BETWEEN ... AND ... | height BETWEEN 10 AND 20 | height is from 10 to 20, inclusive. |
IN (...), NOT IN (...) | species IN ('oak', 'maple') | species is oak or maple. |
LIKE, NOT LIKE | species LIKE 'pine%' | species starts with pine. |
IS NULL, IS NOT NULL | min_zoom IS NOT NULL | min_zoom has a value. |
AND, OR, NOT, and parentheses | heritage = true OR (height > 25 AND species = 'oak') | Both conditions, either condition, or the opposite of a condition. |
When writing expressions:
- Put text values in single quotes:
species = 'oak'. Double quotes are for property names, not values, sospecies = "oak"is rejected. - Write numbers without quotes (
height > 20) and boolean values astrueorfalse(heritage = true). LIKEonly supports%at the end of the value, to match text that starts with a prefix.'%oak'and'o%k'aren't supported.- Operator keywords such as
AND,IN, andLIKEaren't case-sensitive. Property names and text values are.
Example: Detail strategy
This detail strategy for a datasource of street trees uses a min_zoom property when a tree has one, shows heritage and tall trees earlier than others, and shows every other tree from zoom 15:
{
"rules": [
{ "when": "min_zoom IS NOT NULL", "minzoom": { "field": "min_zoom" } },
{ "when": "heritage = true", "minzoom": 10 },
{ "when": "height >= 20", "minzoom": 13 }
],
"default": { "minzoom": 15 }
}
| Feature properties | Rule that matches | Zoom levels |
|---|---|---|
{ "min_zoom": 8, "heritage": true } | First | 8 and higher |
{ "heritage": true, "height": 30 } | Second | 10 and higher |
{ "heritage": false, "height": 22 } | Third | 13 and higher |
{ "heritage": false, "height": 6 } | None (default) | 15 and higher |