# Example requests

This site shows example request between your project backend and Move SDK API.

### Create a new user

Use your Move SDK Project Id and your API Key as Basic Auth to register a new User. The `userId` may be any arbitrary string, only **:** is forbidden. The maximum length of `userId` is 100 characters.

Request:

```http
POST https://sdk.dolph.in/v20/user
content-type: application/json
Authorization: Basic {PROJECT_ID}:{API_KEY}

{
  "userId": "string"
}
```

Response:

```json
{
  "accessToken": "{ACCESS_TOKEN}", // allows communication with MOVE SDK back-end
  "refreshToken": "{REFRESH_TOKEN}", // allows Move App to renew access token
  "userId": "{USER_ID}", 
  "audience": "{NAME_OF_API_KEY}", 
  "projectId": {PROJECT_ID}
}
```

Initialize your Move SDK App with these tokens.

### Create a new user (authCode)

Use your Move SDK Project Id and your API Key as Basic Auth to register a new User. The `userId` may be any arbitrary string, only **:** is forbidden. The maximum length of `userId` is 100 characters.

Request:

```http
POST https://sdk.dolph.in/v20/user/authcode
content-type: application/json
Authorization: Basic {PROJECT_ID}:{API_KEY}

{
  "userId": "string"
}
```

Response:

```json
{
  "authCode": "{AUTHENTICATION_CODE}"
}
```

### **Fetch user timeline**

Fetch user timeline easily with:

Request:

```http
GET https://sdk.dolph.in/v20/timeline?userId={USER_ID}&projectId={PROJECT_ID}
content-type: application/json
Authorization: Basic {PROJECT_ID}:{API_KEY}
```

Response:

```json
[
  {
    "projectId": {PROJECT_ID},
    "userId": "{USER_ID}",
    "startTs": "2022-10-16T08:06:00Z",
    "endTs": "2022-10-16T09:41:00Z",
    "type": "IDLE",
    "features": {
      "source": {
        "id": "",
        "name": "timeline"
      }
    }
  },
  {
    "projectId": {PROJECT_ID},
    "userId": "{USER_ID}",
    "startTs": "2022-10-17T05:58:00Z",
    "endTs": "2022-10-17T06:03:00Z",
    "type": "CYCLING",
    "features": {
      "startLocation": {
        "lat": 48.328016,
        "lon": 16.204514,
        "timeZone": "Europe/Vienna"
      },
      "endLocation": {
        "lat": 48.3338,
        "lon": 16.20949,
        "timeZone": "Europe/Vienna"
      },
      "source": {
        "id": "585497",
        "name": "trip"
      },
      "gpsStats": {
        "distance": 947,
        "maxSpeed": 23,
        "averageSpeed": 13
      },
      "metas": {},
      "dangerousAreas": {
        "areas": []
      }
    }
  }
]
```

Every timeline item has the following properties:

* projectId: Move SDK Project ID
* userId: Id of specific User
* startTs: start timestamp as an ISO 8601 date time
* endTs: end timestamp as an ISO 8601 date time
* type: Mode of transport

### Fetch specific timeline items

Convert the `startTs`  of a given timeline item to a UNIX timestamp to fetch a specific timeline item. For example,&#x20;

* in the user timeline you find a timeline item with `startTs` in UTC time

  ```
  "startTs":"2022-04-12T16:25:00Z"
  ```
* Conversion into unix timestamp (UTC) is "1649780700" - this is your START\_TS for fetching the specific timeline item.
* Please note, if you want to display the trip in human readable form, you may want to translate the startTs to the local timezone (which you can find in "startLocation / timeZone"; e.g. "Europe/Vienna").

Request:

```http
GET https://sdk.dolph.in/v20/timeline/{START_TS}?userId={USER_ID}&projectId={PROJECT_ID}
content-type: application/json
Authorization: Basic {PROJECT_ID}:{API_KEY}
```

Response:

```json
{
  "projectId": {PROJECT_ID},
  "userId": "{USER_ID}",
  "startTs": "2022-10-17T05:58:00Z",
  "endTs": "2022-10-17T06:03:00Z",
  "type": "CYCLING",
  "features": {
    "startLocation": {
      "lat": 48.328016,
      "lon": 16.204514,
      "timeZone": "Europe/Vienna"
    },
    "endLocation": {
      "lat": 48.3338,
      "lon": 16.20949,
      "timeZone": "Europe/Vienna"
    },
    "source": {
      "id": "585497",
      "name": "trip"
    },
    "gpsStats": {
      "distance": 947,
      "maxSpeed": 23,
      "averageSpeed": 13
    },
    "metas": {},
    "dangerousAreas": {
      "areas": []
    }
  }
}
```

### Fetch way points

Some timeline item types like CAR and CYCLING return way points.

Request:

```http
GET https://sdk.dolph.in/v20/timeline/{START_TS}/points?userId={USER_ID}&projectId={PROJECT_ID}&withWayPointInfo=true
content-type: application/json
Authorization: Basic {PROJECT_ID}:{API_KEY}
```

Response:

```json
[
  {
    "lat": 48.31712,
    "lon": 16.2256,
    "timestamp": "2022-09-01T14:50:08Z",
    "wayPointInfo": {
      "speed": 66,
      "speedLimit": 100,
      "wayType": "other",
      "origLat": 48.317138,
      "origLon": 16.225608
    }
  },
  {
    "lat": 48.31711,
    "lon": 16.22608,
    "timestamp": "2022-09-01T14:50:10Z",
    "wayPointInfo": {
      "speed": 67,
      "speedLimit": 100,
      "wayType": "other",
      "origLat": 48.317118,
      "origLon": 16.226084
    }
  }
]
```

Important: The Move SDK always tries to match GPS points to an existing road. For the original way points withWayPointInfo is required.

### Label item

Relabel existing timeline items with a PATCH request:

```http
PATCH https://sdk.dolph.in/timeline/label/{START_TS}/{NEW_MODE_OF_TRANSPORT}?userId={USER_ID}&projectId={PROJECT_ID}
Content-Type: application/json; charset=UTF-8
Authorization: Basic {PROJECT_ID}:{API_KEY}
```

Possible mode of transports:

* UNKNOWN&#x20;
* DRIVING&#x20;
* TRAIN&#x20;
* TRAM
* CAR
* METRO
* FAKETRIP
* WALKING&#x20;
* IDLE&#x20;
* CYCLING

The response to this request is the existing timeline item with the new type.

### Delete item

Delete a single timeline item.

```http
DELETE https://sdk.dolph.in/v20/timeline/{START_TS}?userId={USER_ID}&projectId={PROJECT_ID}
Content-Type: application/json; charset=UTF-8
Authorization: Basic {PROJECT_ID}:{API_KEY}
```

### Fetch last user location

Every user has 4 last locations, in different contexts:

* car-end: last position of his car&#x20;
* timeline-end: end location of last timeline item
* trip-position: updates live during a trip
* user-pos: updates user walking position

```http
GET https://sdk-test.dolph.in/v20/location?projectId={PROJECT_ID}&userId={USER_ID}
Content-Type: application/json; charset=UTF-8
Authorization: Basic {PROJECT_ID}:{API_KEY}
```

Response:

```json
[
  {
    "context": "car-end",
    "lat": 48.322418,
    "lon": 16.203955,
    "timestamp": "2022-10-15T16:29:00Z"
  },
  {
    "context": "timeline-end",
    "lat": 48.3338,
    "lon": 16.20949,
    "timestamp": "2022-10-17T06:03:00Z"
  },
  {
    "context": "trip-position",
    "lat": 48.214684,
    "lon": 16.413719,
    "timestamp": "2022-10-17T07:04:41Z"
  },
  {
    "context": "userpos",
    "lat": 48.214723,
    "lon": 16.413646,
    "timestamp": "2022-10-17T07:03:10Z"
  }
]

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.movesdk.com/move-platform/backend/example-requests.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
