# n8n

A workflow of four nodes: birth data in, natal chart from the API, Sun, Moon and rising sign out. It was imported into n8n 2.39.7 and run against production on 2026-09-17, and the output below is what it returned.

Before you start, create a key as described in [A key for an automation](/en/integrations/#a-key-for-an-automation), scoped to `chart`.

## 1. Add the key as a credential

The key goes into n8n's credential store, not into the node, so it does not travel with an exported workflow.

1. In n8n create a new credential of type **Header Auth**.
2. **Name**: `X-Api-Key`.
3. **Value**: your key.
4. Save it as **AstroWay API key**. The workflow below looks the credential up by that name.

## 2. Import the workflow

Download [n8n-natal-chart.json](/integrations/n8n-natal-chart.json), open an empty workflow and paste the file's contents onto the canvas, or use the import from file in the workflow menu.

It contains four nodes:

- **Start**, a Manual Trigger: runs the workflow when you test it.
- **Birth data**, an Edit Fields (Set) node: `date`, `time`, `timezone`, `latitude` and `longitude` for one person.
- **AstroWay chart**, an HTTP Request node: calls `POST /v1/chart`.
- **Big three**, an Edit Fields (Set) node: turns longitudes into sign names.

## 3. Run it

Execute the workflow. **Big three** returns:

```json
{
  "sun": "Taurus",
  "moon": "Capricorn",
  "rising": "Virgo",
  "offset_used": 4
}
```

`offset_used` is the UTC offset the server worked out from `Europe/Kyiv` for 1990-05-15: 4, not the 3 a hand-typed offset would usually say.

## How the HTTP Request node is set up

- **Method**: `POST`.
- **URL**:

  ```
  https://api.astroway.info/v1/chart
  ```

- **Authentication**: Generic Credential Type.
- **Generic Auth Type**: Header Auth, with the credential **AstroWay API key**.
- **Send Body**: on.
- **Body Content Type**: JSON.
- **Specify Body**: Using JSON.

The body is an expression, so values from any earlier node pass through as they are:

```js
{{ JSON.stringify({ date: $json.date, time: $json.time, timezone: $json.timezone, latitude: $json.latitude, longitude: $json.longitude }) }}
```

## How the signs are computed

Each field in **Big three** is an expression. The sign is the longitude divided by 30, rounded down, used as an index:

```js
{{ ['Aries','Taurus','Gemini','Cancer','Leo','Virgo','Libra','Scorpio','Sagittarius','Capricorn','Aquarius','Pisces'][Math.floor($json.data.houses.ascendant / 30)] }}
```

For the Sun and the Moon the longitude comes from `$json.data.planets.find(p => p.name === 'Sun').longitude` and the same with `'Moon'`.

## Put your own data in

Replace **Start** and **Birth data** with the trigger you actually use, a form, a webhook or a new spreadsheet row, and map its fields onto the five names above. Two things to check:

- **`timezone` must not be empty.** An empty value is refused with `400`, so map the field or set it to `auto` when your coordinates are reliable.
- **Coordinates are required.** The API does not geocode a city name; if your form only asks for a place, add a geocoding step before **AstroWay chart**.

<Aside type="note">
A call outside the key's scope stops the run with `403 ENDPOINT_NOT_IN_SCOPE`, and a key over its budget with `429 KEY_BUDGET_EXHAUSTED`. Both are meant to stop it: raise the limit in the dashboard rather than retrying.
</Aside>
