# Set a startpoint in JavaScript for Directions

**URL:** https://ask.openrouteservice.org/t/set-a-startpoint-in-javascript-for-directions/7042
**Category:** openrouteservice
**Created:** [February 24, 2025, 4:24pm UTC](https://ask.openrouteservice.org/t/set-a-startpoint-in-javascript-for-directions/7042 "2025-02-24T16:24:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ralf\_Nowak](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/ralf_nowak/32/3584_2.png) [@Ralf\_Nowak](https://ask.openrouteservice.org/u/Ralf_Nowak)
#### Post date: [February 24, 2025, 4:24pm UTC](https://ask.openrouteservice.org/t/set-a-startpoint-in-javascript-for-directions/7042/1 "2025-02-24T16:24:39Z")

</div>

Hello,

I use the Directions service. How can I enter a starting point?

I have embedded a javascript in an html page and need to specify a start point when passing it.

The function looks like this:

```javascript
let request = new XMLHttpRequest();

request.open('POST', "https://api.openrouteservice.org/v2/directions/driving-hgv/geojson");

request.setRequestHeader('Accept', 'application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8');
request.setRequestHeader('Content-Type', 'application/json');
request. setRequestHeader('Authorization', 'api-key');

request.onreadystatechange = function () {
 if (this. readyState === 4) {
 console.log('Status:', this.status);
 console.log('Headers:', this.getAllResponseHeaders());
 console.log('Body:', this.responseText);
 }
};

const body = '{"coordinates":[[7.4578615,53.4836767],[8.686507,49.41943],[8.687872,49.420318]], "language": "de-de"}';

request.send(body);

```

Thank you for your help.

See you  
Ralf

---

<div class="post-metadata">

### Author: ![amandus](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/amandus/32/669_2.png) [@amandus](https://ask.openrouteservice.org/u/amandus)
#### Post date: [February 27, 2025, 9:45am UTC](https://ask.openrouteservice.org/t/set-a-startpoint-in-javascript-for-directions/7042/2 "2025-02-27T09:45:17Z")

</div>

Hi @Ralf_Nowak,

- The `coordinates` array should contain all points for the route.
- The **first** coordinate is the **starting point**.
- The **last** coordinate is the **end point**.
- Any coordinates **in between** are **waypoints** that are visited in order.

```auto
"coordinates": [
  [longitude1, latitude1], // Start point
  [longitude2, latitude2], // Waypoint 1
  [longitude3, latitude3], // Waypoint 2
  [longitudeN, latitudeN] // End point
]

```

Best regards
