# Build an app with your content and a coding agent

> Give Claude Code or Codex your project's facts, then let it build a map or a site that reads your published content from the API.

You can ask a coding agent such as Claude Code or Codex to build your own map, store locator or website on top of the content you keep in Spatibase. The agent reads your published entries through the Content Delivery API, so it needs a few facts about your project: its address, whether it needs a key, and where to find your content model. The **AI agents** page of every project gives you all of that as one prompt to copy.

## How does it work?

Your app reads the **published** copy of your content from the Content Delivery API. It never changes anything in Spatibase, and drafts never reach it. The coding agent writes the app's code; Spatibase stays the place where editors keep the content up to date.

If your places are still in a file or in the code and you have no project yet, see [Start from your code](https://spatibase.com/docs/build/start-from-your-code/): one prompt that moves them into a new project and rewires your app.

If you want an assistant to edit your content instead (check entries, prepare drafts), see [Connect an AI assistant](https://spatibase.com/docs/ai/connect-an-assistant/).

## Step 1: Check who can read your content

Open the project's **API**, then **Access & keys**:

- **Public:** anyone with the address can read your published entries. Your app needs no key and can call the API straight from the browser.
- **Private:** every request needs a key. Select **Create key**, choose **For a website or app**, and keep the key on your server or in an environment variable, never in code that runs in the browser. Only owners and developers create keys.

See [Access and API keys](https://spatibase.com/docs/publish/access-and-keys/) for details.

## Step 2: Give the agent your project's facts

In the project, open **AI agents**, choose **Build your own app** and open **Give the agent this project's facts**. Use the copy button at the right of the prompt (its tooltip says **Copy the prompt**) and paste it at the start of a session in your coding agent. The copied prompt already holds your project's id, API address and the names of your content types.

The prompt looks like this (here for a private project, with `PROJECT_ID` in place of your project's id):

```text
I am building an app that shows content from my Spatibase project. Use the Spatibase Content Delivery API as the data source. It is read-only and returns published content only.

Project
- Project id: PROJECT_ID
- API base URL: https://api.spatibase.com/delivery/v1/projects/PROJECT_ID
- Access: private. Every request, the typed OpenAPI file included, needs the header "Authorization: Bearer <key>". Read the key from the environment variable SPATIBASE_API_KEY; I will set it myself, so never ask me to paste it.
- Never put the key in browser code, in the repository or in a URL: call the API from server-side code or a small proxy, and send tiles through that proxy too. Where a placeholder is needed, write YOUR_API_KEY.
- Content types right now: store (Store)

Read these first
- This project's typed OpenAPI file, with my real field names and types: https://api.spatibase.com/delivery/v1/projects/PROJECT_ID/openapi.json
- The general OpenAPI file of the API: https://api.spatibase.com/delivery/v1/openapi.json
- The docs, written for AI agents: https://spatibase.com/llms.txt (every docs page is also Markdown, for example https://spatibase.com/docs/reference/delivery-api.md)
Generate TypeScript types or a typed client from the typed OpenAPI file before writing app code. Take field names from it, never guess them.

Endpoints (all GET, relative to the base URL)
- /entries: entries as JSON, paged (limit up to 500). Filters: type, group, q (title search), filter[<field>]=value or filter[<field>][<op>]=value (eq, ne, gt, gte, lt, lte, in, contains, exists), bbox, near + radius (meters), sort (for example title, -publishedAt, distance), include=references
- /entries.geojson: the same entries and filters as a GeoJSON FeatureCollection (up to 5000)
- /entries/<entryId>: one entry
- /tiles.json: TileJSON for vector tiles (tiles at /tiles/{z}/{x}/{y}.pbf, one layer "entries"; filters type, subtypes, group)
- /types, /groups, /groups/<groupKey> (entries in the order I arranged them), /feature-types

Good to know
- An entry has id, type, title, geometry (GeoJSON, can be null) and fields keyed by each field's API key.
- Image URLs are absolute; add ?w=800&fmt=webp to get a resized image.
- Responses are cacheable (ETag and 304; about a minute in the browser, up to five minutes at the CDN). CORS is open. Errors look like { "error": { "code", "message" } }.
- For maps, use MapLibre GL JS with the vector tiles or the GeoJSON, or Leaflet with the GeoJSON.
- Regenerate the types when I tell you I changed my content model.
```

For a public project, the two lines about the key are replaced by one: "Access: public. No key is needed, and the API can be called straight from the browser." A public project's [Data preview](https://spatibase.com/docs/publish/preview-data/) page also has a **Build with AI** button that copies the same prompt with a "What to build" line at the end.

> **Important:** The prompt never contains your real key. Put the key into the `SPATIBASE_API_KEY` environment variable yourself, and do not paste it into the chat.

## Step 3: Ask for what you want to build

Once the agent has the prompt, describe the app. The Spatibase app has ideas with detailed prompts to copy; they show how different the results can be:

- **A store locator with search and "near me":** a list next to a MapLibre map, search with `q`, and a "Near me" button that sorts by distance.
- **A trail or route explorer with line geometry:** line and polygon entries on a Leaflet map with filters and a GPX download.
- **A mobile app for finding places nearby:** React Native with Expo, a map and a distance-sorted list, offline cache with ETag.
- **A curated guide or editorial collection:** one static page per group and entry, in the order you arranged them, with SEO markup.
- **A geo analytics dashboard:** totals per type and region, charts, a heatmap and an area selection that updates every chart.

## Step 4: Check that it works

- Only **published** entries reach your app. If the app shows nothing, mark some entries ready and publish the project first ([Drafts and published content](https://spatibase.com/docs/publish/draft-and-published/)).
- In the project's **API**, **Try it** shows the live answer to any request, so you can compare it with what the app shows.
- Published changes reach the app within a few minutes, because responses are cached (about a minute in the browser, up to five minutes at the edge in front of `api.spatibase.com`).
- After you change your types or fields, ask the agent to regenerate its types from the typed OpenAPI file.

## Building on a free dataset?

Every [free dataset](https://spatibase.com/datasets/) has a **Build with AI** section and a **Copy agent prompt** button (the **?** beside it shows the whole prompt before you copy it), with the prompt already filled in for that dataset: its fields, filters, licence and caveats. There are two:

- **Your own copy:** the agent makes a [temporary project](https://spatibase.com/docs/build/start-from-your-code/#temporary-projects), imports the dataset into it (all of it, or one country or area; a temporary project holds 1,000 entries), adds your own fields, builds the app on that project's API and asks for your email so you can keep it. No account needed to start.
- **Quick prototype:** the prompt from this page, filled in for the public, read-only dataset API.

Each dataset also has a few starter ideas to add to the prompt. The prompts are plain text too, for example [spatibase.com/datasets/airports/prompt.txt](https://spatibase.com/datasets/airports/prompt.txt).

## Can the agent also look at my content directly?

Yes. Claude Code and other agents that support MCP can also connect to your project's assistant address, so they can look at real entries and get the typed API description while they build. See [Connect an AI assistant](https://spatibase.com/docs/ai/connect-an-assistant/#claude-code). A read-only connection is enough for building an app.

## Related

- [Start from your code](https://spatibase.com/docs/build/start-from-your-code/)
- [Free datasets](https://spatibase.com/datasets/), each with a prompt to build on it
- [Quickstart: a map in ten minutes](https://spatibase.com/docs/build/quickstart/)
- [Recipes](https://spatibase.com/docs/build/recipes/)
- [Content Delivery API reference](https://spatibase.com/docs/reference/delivery-api/)
- [GeoJSON and vector tiles](https://spatibase.com/docs/reference/geojson-and-tiles/)
- [Access and API keys](https://spatibase.com/docs/publish/access-and-keys/)
