Skip to main content

Add Location

URL

POST https://api.magicrail.io/locations

Description

This endpoint allows for the creation of standalone location data for the authenticated user, including latitude, longitude, elevation, and time details.

Authentication

Bearer Token required

Headers

Ensure these headers are included in the request.

  • Content-Type: application/json
  • Authorization: Bearer TOKEN

Request Body

Provide the location details in the form of JSON.

  • latitude: double precision - Latitude of the location.
  • longitude: double precision - Longitude of the location.
  • elevation: double precision - Elevation of the location (optional).
  • time: timestamp with time zone - Time of the recorded location.
  • metadata: Optional metadata for the location.
    • description: string - Description of the location.
    • accuracy: integer - Accuracy of the location data.
    • activity: string - Activity type associated with the location.

Success Response

Description of a successful attempt to create location data.

  • 🟢 201 Created: Successfully created location data.

Error Responses

Descriptions of common error responses.

  • 🔴 400 Bad Request: Bad request or authentication error.
  • 🔴 500 Internal Server Error: Internal server error.

Example Call and Response

An example showing how to make a request and an example response.

Example Call:

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer TOKEN" \
-d '{
"latitude": 40.7128,
"longitude": -74.0060,
"elevation": 10.5,
"time": "2024-07-10T12:34:56Z",
"metadata": {
"description": "New York City",
"accuracy": 10,
"activity": "walking"
}
}' \
https://api.magicrail.io/locations

Example Response:

{
"location": {
"id": "123456",
"latitude": "40.7128",
"longitude": "-74.0060",
"elevation": "10.5",
"time": "2024-07-10T12:34:56Z",
"metadata": {
"description": "New York City",
"accuracy": 10,
"activity": "walking"
},
"createdAt": "2024-07-10T12:34:56Z",
"updatedAt": "2024-07-10T12:34:56Z",
"userId": "user123"
}
}