# Bolt

In Bolt a keyed call to AstroWay works only from a **server function**. The Bolt preview runs in a real browser with real CORS, so a request to `api.astroway.info` from the page will not go through, and a key in `VITE_*` would end up in the bundle as well. A server function runs on Bolt's servers and reads the key from the project's secrets.

## 1. Database and key

1. Server functions and secrets in Bolt are tied to a Bolt Cloud database. If the project has none yet, ask Bolt to add one.
2. Create a **Server only** AstroWay key scoped to `chart` with a budget, as described in [A key for an automation](/en/integrations/#a-key-for-an-automation). The budget stops a stranger's client that calls your function at the number you set.

## 2. The prompt

```text title="prompt"
Create a server function named big-three. It reads the secret
ASTROWAY_API_KEY and POSTs the JSON body { date, time, timezone, latitude,
longitude } to https://api.astroway.info/v1/chart with the header
"X-Api-Key: <secret>". Never call api.astroway.info from the browser and
never put the key in a VITE_ variable.

The response is { ok: true, data: {...} } or { ok: false, error: { code,
message } }. On error return the error object with the same HTTP status.
On success return { sun, moon, rising, offset_used } where each sign is
SIGNS[Math.floor(longitude / 30)] with SIGNS = Aries, Taurus, Gemini,
Cancer, Leo, Virgo, Libra, Scorpio, Sagittarius, Capricorn, Aquarius,
Pisces; sun and moon come from data.planets entries named "Sun" and
"Moon", rising from data.houses.ascendant, offset_used from
data.input.timezoneOffset.

Then add a form with date, time, an IANA time zone (default Europe/Kyiv),
latitude and longitude, and show the three signs from the function.
```

Server functions in Bolt Cloud run in the same environment as Supabase Edge Functions, so the finished file is on [Supabase Edge Function](/en/integrations/supabase/). If Bolt generated something else, paste that file.

## 3. The secret

Bolt asks you to add `ASTROWAY_API_KEY` itself once the function is ready. By hand: in the project's top menu click the **database icon → Secrets** and add a secret with that name. Only the project owner sees secrets, and in a team account co-owners and team admins too.

## 4. Check it

Enter `1990-05-15`, `14:30:00`, `Europe/Kyiv`, `50.45`, `30.52`. The right answer: Sun `Taurus`, Moon `Capricorn`, rising `Virgo`, offset `4`. An offset of 3 means the app works out the offset itself instead of sending the zone name. One calculation costs 20 credits; the function's call logs are in the database settings under **Logs**.

**Tip:**
Ready prompts for other apps, and the rules to paste before any of them, are on [Prompts for AI builders](/en/prompts/).

**Note:**
Checked on 2026-11-07: the function from [Supabase](/en/integrations/supabase/) ran locally in Deno against AstroWay production, with the answer above. The steps in the Bolt interface follow its help centre and were not carried out in this check.
