Skip to main content

Create Trip

URL

POST https://api.magicrail.io/trips/create

Description

This endpoint facilitates the creation of a new trip for the authenticated user. Authentication via bearer token is required.

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 form of a string.

  • exId: string

Success Response

Description of a successful attempt to create a trip.

  • 🟢 201 Created: Successfully created a new trip.

Error Responses

Descriptions of common error responses.

  • 🔴 400 Bad Request: Bad request, invalid input data or trip already exists.
  • 🔴 401 Unauthorized: Unauthorized, missing or invalid token.
  • 🔴 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 '{"exId": "best-trip"}' \
https://api.magicrail.io/trips/create

Example Response:

{
"trip": {
"id": "123456",
"userId": "7890",
"exId": "example123",
"createdAt": "2024-03-05T20:19:57.103Z",
"updatedAt": "2024-03-05T20:19:57.103Z"
}
}