{
  "openapi": "3.1.0",
  "info": {
    "title": "LimoFarmOut Agent Booking API",
    "version": "1.0.0",
    "description": "Book prepaid chauffeur and limousine jobs on the LimoFarmOut network from your AI agent, assistant or dispatch software. A verified dispatcher or limousine company makes an agent key in their account (AI agents and API). Quote a trip, then book it in one call: with a saved card and within the key's limits the job is paid and published to verified chauffeurs at once; otherwise the account holder gets a link to approve and pay. Status changes are sent to your webhook, signed. Prices include tax. Jobs follow the same rules as on the website: platform fee, cancellation terms, no contacting the passenger outside the platform.",
    "contact": {
      "name": "LimoFarmOut support",
      "email": "support@limofarmout.com",
      "url": "https://app.limofarmout.com/developers.html"
    }
  },
  "servers": [
    {
      "url": "https://app.limofarmout.com"
    }
  ],
  "security": [
    {
      "agentKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "agentKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An agent key (lfo_agent_...) from your account. It works only on /api/v1."
      }
    },
    "schemas": {
      "Trip": {
        "type": "object",
        "description": "Either plain words in `text` (e.g. a WhatsApp-style job post) or fields. Fields win over what is read from the text.",
        "properties": {
          "text": {
            "type": "string",
            "description": "The trip in plain words, e.g. \"Tomorrow 9:00 am, YYZ to Fairmont Royal York, SUV, $130\"."
          },
          "service_type": {
            "type": "string",
            "enum": [
              "transfer",
              "airport_pickup",
              "airport_dropoff",
              "cruise_port",
              "train_station",
              "long_distance",
              "hourly",
              "wedding",
              "prom",
              "corporate",
              "event",
              "night_out",
              "tour",
              "funeral"
            ],
            "description": "Kind of trip. Default transfer."
          },
          "vehicle_type": {
            "type": "string",
            "enum": [
              "sedan",
              "luxury_sedan",
              "suv",
              "luxury_suv",
              "minivan",
              "sprinter",
              "stretch_limo",
              "stretch_suv",
              "party_bus",
              "minibus",
              "coach",
              "jet_sprinter",
              "maybach",
              "rolls_royce",
              "classic_car",
              "other"
            ]
          },
          "pickup_local": {
            "type": "string",
            "format": "date-time",
            "description": "Pickup in the trip's local time, YYYY-MM-DDTHH:MM (no time zone)."
          },
          "timezone": {
            "type": "string",
            "description": "IANA time zone of the pickup, e.g. America/Toronto."
          },
          "pickup_address": {
            "type": "string"
          },
          "dropoff_address": {
            "type": "string"
          },
          "stops": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "hours": {
            "type": "number",
            "description": "For hourly services."
          },
          "city": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2, e.g. CA, US, GB, AE."
          },
          "currency": {
            "type": "string",
            "description": "e.g. cad, usd, gbp, aed. Default: the country's currency when held."
          },
          "payout": {
            "type": "number",
            "description": "What the chauffeur is paid (all in), in the currency's main unit. Optional on quotes: we suggest the local rate when we have one."
          },
          "max_payout": {
            "type": "number",
            "description": "Optional: let the price rise to this if nobody accepts at first."
          },
          "airport_fee": {
            "type": "number",
            "description": "Airport pickup fee passed to the driver. Default 0."
          },
          "passengers": {
            "type": "integer"
          },
          "luggage": {
            "type": "integer"
          },
          "passenger_name": {
            "type": "string"
          },
          "passenger_phone": {
            "type": "string",
            "description": "International format, e.g. +14165550198. Reached through a private line; never shown to the driver."
          },
          "flight_number": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "requirements": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "auto_dispatch": {
            "type": "boolean",
            "description": "Offer the job to one driver at a time (your favourites first, then the nearest available), 3 minutes each, before it opens to everyone. Defaults to your account setting."
          }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string"
          },
          "payout_cents": {
            "type": [
              "integer",
              "null"
            ]
          },
          "fee_cents": {
            "type": [
              "integer",
              "null"
            ]
          },
          "airport_fee_cents": {
            "type": "integer"
          },
          "total_cents": {
            "type": [
              "integer",
              "null"
            ]
          },
          "suggested_payout_cents": {
            "type": [
              "integer",
              "null"
            ]
          },
          "based_on_trips": {
            "type": "integer"
          },
          "needs_payout": {
            "type": "boolean"
          },
          "client_price": {
            "type": [
              "object",
              "null"
            ],
            "description": "What a passenger would pay for this trip on our own booking engine (Onroutz Rate Manager), all in, tax included. Null when there is no published rate for the vehicle and route.",
            "properties": {
              "source": {
                "type": "string"
              },
              "currency": {
                "type": "string"
              },
              "price_cents": {
                "type": "integer"
              },
              "includes_tax": {
                "type": "boolean"
              },
              "fleet": {
                "type": "string"
              },
              "distance": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      },
      "Booking": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "PENDING_PAYMENT",
              "OPEN",
              "QUOTING",
              "ACCEPTED",
              "EN_ROUTE",
              "ON_LOCATION",
              "PASSENGER_ON_BOARD",
              "COMPLETED",
              "PAID",
              "CANCELLED",
              "DISPUTED"
            ]
          },
          "published": {
            "type": "boolean"
          },
          "waiting_for": {
            "type": "string",
            "enum": [
              "no_saved_card",
              "approval_required",
              "over_job_limit",
              "over_daily_limit",
              "card_needs_cardholder"
            ],
            "description": "Set when the account holder must approve and pay: pay_url is the link."
          },
          "pay_url": {
            "type": "string"
          },
          "paid_by": {
            "type": "string",
            "enum": [
              "card",
              "limofarmout"
            ],
            "description": "limofarmout: a company job. Nothing is charged now; LimoFarmOut pays the driver after the trip."
          },
          "manage_url": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "pickup_local": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "payout_cents": {
            "type": "integer"
          },
          "total_cents": {
            "type": "integer"
          },
          "repeated": {
            "type": "boolean",
            "description": "True when the same Idempotency-Key was used before: this is that booking."
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "Event": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "pickup_local": {
            "type": "string"
          },
          "vehicles": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "The job id: use it with /api/v1/bookings/{id}"
                },
                "seq": {
                  "type": "integer"
                },
                "status": {
                  "type": "string"
                },
                "vehicle_type": {
                  "type": "string"
                },
                "passengers": {
                  "type": "integer"
                },
                "payout_cents": {
                  "type": "integer"
                },
                "total_cents": {
                  "type": "integer"
                },
                "driver": {
                  "type": [
                    "object",
                    "null"
                  ]
                },
                "location": {
                  "type": [
                    "object",
                    "null"
                  ],
                  "description": "{lat, lng, at} while on the road"
                }
              }
            }
          },
          "totals": {
            "type": "object",
            "properties": {
              "vehicles": {
                "type": "integer"
              },
              "assigned": {
                "type": "integer"
              },
              "unpaid": {
                "type": "integer"
              },
              "unpaid_cents": {
                "type": "integer"
              },
              "total_cents": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/quotes": {
      "post": {
        "operationId": "quoteTrip",
        "summary": "Price a trip (nothing is saved)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Trip"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The price",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Quote"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid trip details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bookings": {
      "post": {
        "operationId": "bookTrip",
        "summary": "Book a trip: paid and published at once from the saved card, or waiting for the account holder's approval",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Your own order reference. Sending it again returns the same booking, never a second one."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Trip"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The booking",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Booking"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid trip details"
          },
          "429": {
            "description": "A limit was reached (e.g. new accounts keep at most 5 open jobs)"
          }
        }
      },
      "get": {
        "operationId": "listBookings",
        "summary": "Your jobs, newest first",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Jobs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jobs": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Booking"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bookings/{id}": {
      "get": {
        "operationId": "getBooking",
        "summary": "One job with its driver, vehicle, plate, timeline and live driver location (once accepted)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The job as the dispatcher sees it"
          },
          "404": {
            "description": "Not your job"
          }
        },
        "description": "driver_location is {lat, lng, at} while the driver is en route, on location or on the trip, otherwise null. Poll it every 10 to 30 seconds for a live map; status changes also arrive by webhook."
      }
    },
    "/api/v1/bookings/{id}/cancel": {
      "post": {
        "operationId": "cancelBooking",
        "summary": "Cancel a job (the website's cancellation terms apply; the platform fee is kept once a job is published)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cancelled, with any refund"
          }
        }
      }
    },
    "/api/v1/events": {
      "post": {
        "operationId": "createEvent",
        "summary": "Book several vehicles for one event (a wedding, a conference, a group) and pay them in one checkout",
        "description": "Each vehicle becomes its own job, taken by its own driver; follow each one with /api/v1/bookings/{id}. The reply has checkoutUrl: one payment for every vehicle. 2 to 40 vehicles.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Trip"
                  },
                  {
                    "type": "object",
                    "required": [
                      "event_name",
                      "vehicles"
                    ],
                    "properties": {
                      "event_name": {
                        "type": "string",
                        "example": "Patel wedding"
                      },
                      "vehicles": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "required": [
                            "vehicle_type",
                            "count",
                            "payout"
                          ],
                          "properties": {
                            "vehicle_type": {
                              "type": "string",
                              "example": "sedan"
                            },
                            "count": {
                              "type": "integer",
                              "example": 2
                            },
                            "payout": {
                              "type": "number",
                              "description": "Driver price for each vehicle of this type",
                              "example": 150
                            },
                            "passengers": {
                              "type": "integer",
                              "example": 3
                            },
                            "luggage": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The event and its pay link",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "event": {
                      "$ref": "#/components/schemas/Event"
                    },
                    "checkoutUrl": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/events/{id}": {
      "get": {
        "operationId": "getEvent",
        "summary": "An event: every vehicle with its status, driver and live location",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          },
          "404": {
            "description": "Not your event"
          }
        }
      }
    }
  },
  "webhooks": {
    "jobStatus": {
      "post": {
        "summary": "Sent to your webhook address on every status change: job.funded, job.accepted, job.status, job.completed, job.cancelled and more. Header LimoFarmOut-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with your webhook secret>. Answer 2xx; failures are retried for about a day.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "created_at": {
                    "type": "string"
                  },
                  "data": {
                    "type": "object",
                    "properties": {
                      "job": {
                        "$ref": "#/components/schemas/Booking"
                      },
                      "driver": {
                        "type": [
                          "object",
                          "null"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    }
  }
}
