Skip to main content

Create Trip Data

URL

POST https://api.magicrail.io/trip-data/create

Description

This endpoint allows for the creation of trip data for the authenticated user's trip, including location 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 an exId for the trip in the form of a string.

  • latitude: double precision
  • longitude: double precision
  • elevation: double precision
  • time: time timestamp with time zone
  • tripId: int
  • metadata: Optional metadata for the trip data.
    • notes: string - Additional notes for the trip data.
    • tags: array of strings - Tags associated with the trip data.

Success Response

Description of a successful attempt to create trip data.

  • 🟢 201 Created: Successfully created trip data.

Error Responses

Descriptions of common error responses.

  • 🔴 400 Bad Request: Bad request or authentication error.
  • 🔴 403 Forbidden: Forbidden, permission denied to add data to the trip.
  • 🔴 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": 5.0,
"time": "2023-01-01T12:00:00Z",
"tripId": "trip123",
"metadata": {
"notes": "Sample notes",
"tags": ["outdoor", "adventure"]
}
}' \
https://api.magicrail.io/trip-data/create

Example Response:

{
"tripData": {
"id": "123456",
"latitude": "40.7128",
"longitude": "-74.006",
"elevation": "5",
"time": "2023-01-01T12:00:00Z",
"tripId": "trip123",
"createdAt": "2024-03-05T20:19:57.103Z",
"updatedAt": "2024-03-05T20:19:57.103Z",
"metadata: { tags: [Array], notes: 'Sample notes' }
}
}