{
  "openapi": "3.0.0",
  "info": {
    "description": "Integrate Miare delivery, support, area and accounting services. Start with the [integration guide](/getting-started). All monetary amounts are Tomans (IRT). Authenticate with Authorization: Token <your API token>. Public documentation does not require a Miare staff login. Outgoing callbacks are documented in the [Webhooks reference](/webhooks).",
    "version": "2.1.0",
    "title": "Miare API",
    "contact": {
      "email": "tech@miare.ir",
      "name": "Miare's Tech Team",
      "url": "https://miare.ir"
    }
  },
  "tags": [
    {
      "name": "delivery",
      "x-displayName": "Delivery",
      "description": "Create and manage trips and courses."
    },
    {
      "name": "support",
      "x-displayName": "Support",
      "description": "Report and resolve issues, including delegated courier issues."
    },
    {
      "name": "area",
      "x-displayName": "Areas",
      "description": "Service coverage and concurrency usage."
    },
    {
      "name": "accounting",
      "x-displayName": "Accounting",
      "description": "Estimates, seller registration, invoices and financial reconciliation."
    }
  ],
  "servers": [],
  "components": {
    "securitySchemes": {
      "auth": {
        "name": "Authorization",
        "type": "apiKey",
        "in": "header",
        "description": "Send Authorization: Token <YOUR PRIVATE TOKEN>."
      }
    },
    "schemas": {
      "Trip": {
        "type": "object",
        "properties": {
          "is_round_trip": {
            "type": "boolean",
            "readOnly": true,
            "description": "Whether this trip requires a return to the pickup location. On creation, true when any course has is_round_course set to true. This is a response field, not a root-level Create Trip request field."
          },
          "rounded_at": {
            "$ref": "#/components/schemas/NullableTimestamp",
            "description": "For accounts with round-trip creation enabled, null until return completion, then the recorded return-completion time. For a batched order, this is the completion time of the shared return. Cancellation or an aborted trip does not count as return completion."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique ID of this trip",
            "example": "40626ed5-9260-4a55-af04-ef9705a41b90"
          },
          "area": {
            "$ref": "#/components/schemas/Area"
          },
          "state": {
            "type": "string",
            "description": "Current state of this trip. Advanced states depend on account configuration.",
            "example": "pickup",
            "enum": [
              "assign_queue",
              "pickup",
              "dropoff",
              "returning",
              "delivered",
              "canceled_by_miare",
              "canceled_by_client",
              "receiving",
              "departing",
              "canceled_by_delay",
              "batched"
            ]
          },
          "pickup": {
            "$ref": "#/components/schemas/Pickup"
          },
          "courses": {
            "type": "array",
            "description": "All of the different courses at which parts of this trip should be dropped off",
            "xml": {
              "name": "course",
              "wrapped": true
            },
            "items": {
              "$ref": "#/components/schemas/Course"
            }
          },
          "created_at": {
            "$ref": "#/components/schemas/Timestamp",
            "description": "The exact moment at which this trip is created for the first time"
          },
          "assigned_at": {
            "$ref": "#/components/schemas/NullableTimestamp",
            "description": "The time this trip was assigned to its current courier"
          },
          "picked_up_at": {
            "$ref": "#/components/schemas/NullableTimestamp",
            "description": "The time at which the courier picked up the items from pickup location"
          },
          "courier": {
            "$ref": "#/components/schemas/Courier"
          },
          "test_mode": {
            "type": "boolean",
            "description": "Whether or not this trip was created in test mode",
            "example": false
          },
          "batch_id": {
            "type": "string",
            "description": "Current batch identifier; equals id before batching and may change while the trip is in progress.",
            "format": "uuid"
          },
          "delivery_cost": {
            "type": "integer",
            "description": "Final delivery cost in Tomans (IRT); null until available.",
            "nullable": true
          },
          "arrived_at": {
            "$ref": "#/components/schemas/NullableTimestamp"
          },
          "departed_at": {
            "$ref": "#/components/schemas/NullableTimestamp"
          },
          "boost": {
            "$ref": "#/components/schemas/Boost"
          }
        },
        "xml": {
          "name": "Trip"
        },
        "x-examples": {
          "Example": {
            "id": "40626ed5-9260-4a55-af04-ef9705a41b90",
            "area": {
              "id": "59",
              "name": "فردوس شرق"
            },
            "state": "assign_queue",
            "pickup": {
              "name": "رستوران بزرگمهر",
              "phone_number": "0212345678",
              "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
              "image": "https://example.com/restaurants/bm_logo.png",
              "location": {
                "latitude": 35.737004,
                "longitude": 51.413569
              },
              "deadline": "2019-04-12T14:12:00+0000"
            },
            "courses": [
              {
                "id": "40626ed5-9260-4a55-af04-ef9705a41b90",
                "bill_number": "DEL-119",
                "name": "علی علوی",
                "phone_number": "09123456789",
                "address": "هران، خیابان استاد معین، پلاک ۱۲",
                "location": {
                  "latitude": 35.737004,
                  "longitude": 51.413569
                },
                "manifest_items": [
                  {
                    "name": "پیتزا پپرونی خانواده",
                    "quantity": 2
                  }
                ],
                "tracking_url": "https://mia.re/t/73c939d1/",
                "dropped_off_at": "2019-04-12T14:06:42+0000",
                "requires_box": false
              }
            ],
            "created_at": "2019-04-12T13:58:42+0000",
            "assigned_at": "2019-04-12T13:59:59+0000",
            "picked_up_at": "2019-04-12T14:10:42+0000",
            "courier": {
              "name": "علی لطفی",
              "image": "https://files.miare.ir/avatars/gheuIej.jpg",
              "location_updated_at": "2019-08-24T14:15:22Z",
              "location": {
                "latitude": 35.737004,
                "longitude": 51.413569
              }
            },
            "test_mode": false
          }
        }
      },
      "Pickup": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The human readable name of the pickup",
            "example": "رستوران بزرگمهر"
          },
          "phone_number": {
            "type": "string",
            "description": "The phone number associated with the source which will be used by courier and support staffs in order to contact to pickup if necessary",
            "example": "0212345678"
          },
          "address": {
            "type": "string",
            "description": "The human readable address of the source, preferably down to every necessary detail for a human to find the source quickly",
            "example": "تهران، صادقیه، بلوار آیت الله کاشانی"
          },
          "image": {
            "type": "string",
            "format": "uri",
            "description": "A valid URL which points to an image file which should be the logo of the pickup. This image will be used in both support panel, and courier’s application, so make sure that the URL is both reachable and is configured to allow CORS requests",
            "example": "https://example.com/restaurants/bm_logo.png"
          },
          "location": {
            "$ref": "#/components/schemas/Location"
          },
          "deadline": {
            "$ref": "#/components/schemas/Timestamp",
            "description": "Expected package-ready pickup time. Must be in the future when creating or updating a trip."
          }
        },
        "xml": {
          "name": "Pickup"
        }
      },
      "Course": {
        "type": "object",
        "required": [
          "bill_number",
          "name",
          "phone_number",
          "address",
          "requires_box"
        ],
        "properties": {
          "is_round_course": {
            "type": "boolean",
            "readOnly": true,
            "description": "The current stored return requirement for this course. It can change after creation through the Round Trip endpoint."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The unique identifier of this course",
            "example": "40626ed5-9260-4a55-af04-ef9705a41b90"
          },
          "trip_id": {
            "type": "string",
            "format": "uuid",
            "description": "The unique identifier of the trip that the course belongs to",
            "example": "40626ed5-9260-4a55-af04-ef9705a41b90"
          },
          "bill_number": {
            "type": "string",
            "description": "An string field left for you to store sort of a human readable bill number in it which will be used as a reference point among our support team, you and the pickup staffs",
            "example": "DEL-119"
          },
          "name": {
            "type": "string",
            "description": "Name of the dropp-off",
            "example": "علی علوی"
          },
          "phone_number": {
            "type": "string",
            "description": "The phone number associated with the drop-off which will be used by courier and support staffs in order to contact to them if necessary",
            "example": "09123456789"
          },
          "address": {
            "type": "string",
            "description": "The human readable drop-off address, preferably down to every necessary detail for a human to find it quickly",
            "example": "هران، خیابان استاد معین، پلاک ۱۲"
          },
          "location": {
            "$ref": "#/components/schemas/NullableLocation"
          },
          "manifest_items": {
            "type": "array",
            "xml": {
              "name": "manifest_item",
              "wrapped": true
            },
            "description": "The contents of the package to be delivered to the drop-off",
            "items": {
              "$ref": "#/components/schemas/ManifestItem"
            }
          },
          "tracking_url": {
            "type": "string",
            "format": "uri",
            "description": "The URL of Miare Tracking webpage which can be given to user so he/she can follow the courier in real-time",
            "example": "https://www.miare.ir/p/trip_watching/#!/DEMOHASH01"
          },
          "dropped_off_at": {
            "$ref": "#/components/schemas/NullableTimestamp"
          },
          "requires_box": {
            "type": "boolean",
            "description": "The stored box requirement for this course. Older courses without a stored value return false. When enabled, true requires a car or a motorcycle courier with a box for the whole trip. The stored value remains visible while enforcement is disabled.",
            "example": false
          },
          "payment": {
            "$ref": "#/components/schemas/Payment"
          },
          "old_trip_id": {
            "type": "string",
            "description": "Original trip identifier before batching; the zero UUID when no batching occurred.",
            "format": "uuid"
          }
        },
        "xml": {
          "name": "Course"
        }
      },
      "CourseRequest": {
        "type": "object",
        "required": [
          "bill_number",
          "name",
          "phone_number",
          "address"
        ],
        "properties": {
          "is_round_course": {
            "type": "boolean",
            "default": false,
            "description": "Supported only in Create Trip. Set to true to mark this course as requiring a return to the pickup location. If any course requires a return, the trip has one final return after all deliveries, without adding another course. Omission defaults to false for this course. This feature is not available to all clients: contact Miare to request enablement for your account. Until enabled, requested course returns are ignored. Add Course ignores this field, and Update Trip cannot change it; use the Round Trip endpoint to change the return requirement after creation.",
            "example": true
          },
          "bill_number": {
            "type": "string",
            "description": "An string field left for you to store sort of a human readable bill number in it which will be used as a reference point among our support team, you and the pickup staffs",
            "example": "DEL-119"
          },
          "name": {
            "type": "string",
            "description": "Name of the dropp-off",
            "example": "علی علوی"
          },
          "phone_number": {
            "type": "string",
            "description": "The phone number associated with the drop-off which will be used by courier and support staffs in order to contact to them if necessary",
            "example": "09123456789"
          },
          "address": {
            "type": "string",
            "description": "The human readable drop-off address, preferably down to every necessary detail for a human to find it quickly",
            "example": "تهران، خیابان استاد معین، پلاک ۱۲"
          },
          "delivery_code": {
            "type": "string",
            "pattern": "^\\s*[0-9]{5}\\s*$",
            "description": "Required only when the client/source proof_of_delivery_policy is third_party. Must be exactly 5 digits. Leading/trailing whitespace is ignored before validation and storage. When accepted, this code is stored as the course PoD code and will be used later for delivery verification by the driver. For clients whose PoD policy is none or miare, this field is not required.",
            "example": "98765"
          },
          "location": {
            "$ref": "#/components/schemas/Location"
          },
          "manifest_items": {
            "type": "array",
            "xml": {
              "name": "manifest_item",
              "wrapped": true
            },
            "description": "The contents of the package to be delivered to the drop-off",
            "items": {
              "$ref": "#/components/schemas/ManifestItem"
            }
          },
          "requires_box": {
            "type": "boolean",
            "default": false,
            "description": "Optional; defaults to false. When box requirements are enabled, true requires a car or a motorcycle courier with a box for the whole trip, even if only one course requires it. Existing client service-level restrictions still apply. Confirm availability with Miare: while disabled, true is accepted but stored as false and course-level box requirements are not enforced. Enabling later does not restore ignored requirements. The value cannot be edited after creation; unrelated updates preserve it.",
            "example": false
          },
          "payment": {
            "$ref": "#/components/schemas/Payment"
          }
        },
        "xml": {
          "name": "CourseRequest"
        }
      },
      "Location": {
        "type": "object",
        "properties": {
          "latitude": {
            "type": "number",
            "format": "double",
            "example": 35.737004
          },
          "longitude": {
            "type": "number",
            "format": "double",
            "example": 51.413569
          }
        },
        "xml": {
          "name": "Location"
        },
        "required": [
          "latitude",
          "longitude"
        ]
      },
      "ManifestItem": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Human readable name of the content which will be verified by courier",
            "example": "پیتزا پپرونی خانواده"
          },
          "quantity": {
            "type": "integer",
            "description": "Number of these items in the package.",
            "example": 2
          }
        },
        "xml": {
          "name": "ManifestItem"
        },
        "required": [
          "name",
          "quantity"
        ]
      },
      "Area": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of area",
            "example": "59"
          },
          "name": {
            "type": "string",
            "description": "Textual name of the area",
            "example": "فردوس شرق"
          }
        },
        "xml": {
          "name": "Area"
        }
      },
      "Courier": {
        "type": "object",
        "xml": {
          "name": "Courier"
        },
        "x-examples": {
          "Example": {
            "name": "علی لطفی",
            "image": "https://files.miare.ir/avatars/gheuIej.jpg",
            "location_updated_at": "2019-08-24T14:15:22Z",
            "location": {
              "latitude": 35.737004,
              "longitude": 51.413569
            }
          }
        },
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the driver",
            "example": "علی لطفی"
          },
          "image": {
            "type": "string",
            "format": "uri",
            "description": "A photo of the courier",
            "example": "https://files.miare.ir/avatars/gheuIej.jpg"
          },
          "location_updated_at": {
            "$ref": "#/components/schemas/NullableTimestamp"
          },
          "location": {
            "$ref": "#/components/schemas/Location"
          },
          "phone_number": {
            "type": "string",
            "example": "09123456789"
          }
        },
        "nullable": true
      },
      "FinancialAmounts": {
        "type": "object",
        "required": [
          "total_cost",
          "details"
        ],
        "properties": {
          "total_cost": {
            "type": "integer",
            "description": "Complete batch total at this revision, in Tomans. Authoritative for reconciliation."
          },
          "details": {
            "type": "object",
            "required": [
              "base_cost",
              "cancel_cost",
              "delay_cost",
              "return_cost"
            ],
            "properties": {
              "base_cost": {
                "type": "integer",
                "description": "Base-cost component. In Tomans."
              },
              "cancel_cost": {
                "type": "integer",
                "description": "Late-cancellation component. In Tomans."
              },
              "delay_cost": {
                "type": "integer",
                "description": "Delay component. In Tomans."
              },
              "return_cost": {
                "type": "integer",
                "description": "Return component. In Tomans."
              }
            },
            "description": "Selected pricing components. These may not sum to total_cost because other pricing rules, discounts and rounding can contribute to the total."
          }
        }
      },
      "FinancialChange": {
        "type": "object",
        "required": [
          "type",
          "course_id",
          "trip_id",
          "bill_number",
          "previous_total_cost",
          "change_amount",
          "current_total_cost",
          "occurred_at"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "course_faked"
            ],
            "description": "A course was marked invalid."
          },
          "course_id": {
            "type": "string",
            "format": "uuid",
            "description": "Affected course identifier."
          },
          "trip_id": {
            "type": "string",
            "format": "uuid",
            "description": "Client-visible trip ID, preserving the original trip ID after batching."
          },
          "bill_number": {
            "type": "string",
            "description": "Bill number; may be empty, or null if package information is absent.",
            "nullable": true
          },
          "previous_total_cost": {
            "type": "integer",
            "description": "Batch total before this adjustment, in Tomans."
          },
          "change_amount": {
            "type": "integer",
            "description": "Signed difference current_total_cost - previous_total_cost, in Tomans."
          },
          "current_total_cost": {
            "type": "integer",
            "description": "Batch total immediately after this adjustment, in Tomans."
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "Time the course was marked invalid."
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Constant error code",
            "example": "trip_not_found"
          },
          "detail": {
            "type": "string",
            "description": "Human readable explanation of the error",
            "example": "Could not find trip with id \"wrong_id\""
          }
        },
        "required": [
          "code",
          "detail"
        ]
      },
      "AreaInfo": {
        "description": "This model returns data about each area defined in Miare, and data about your ongoing trips in them.\n\nThese data include:\n\n - `id`: The id of this area\n - `name`: The human readable name of this area\n - `polygon`: The coordinates of this area, in GeoJSON format\n - `max_ongoing_trips`: The maximum number of concurrent trips you can have in this area right now, based on your subscription.\n - `ongoing_trips`: Number of your ongonig trips in this area at the moment.",
        "type": "object",
        "x-examples": {
          "Example": {
            "id": 5,
            "max_ongoing_trips": 7,
            "name": "قلهک",
            "ongoing_trips": 3,
            "polygon": {
              "type": "Polygon",
              "coordinates": [
                [
                  [
                    51.4549231005859,
                    35.6696883542151
                  ],
                  [
                    51.4571858393479,
                    35.6945690813052
                  ],
                  [
                    51.4497587368011,
                    35.6834941116055
                  ],
                  [
                    51.4549231005859,
                    35.6696883542151
                  ]
                ]
              ]
            }
          }
        },
        "properties": {
          "id": {
            "type": "number",
            "minimum": 1,
            "example": 5
          },
          "max_ongoing_trips": {
            "type": "number",
            "description": "The maximum number of concurrent trips that you can have in this area at the moment, based on your subscription.",
            "minimum": 0,
            "example": 7
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "example": "قلهک"
          },
          "ongoing_trips": {
            "type": "number",
            "minimum": 0,
            "example": 3,
            "description": "Count of your trips that are ongoing concurrently right now."
          },
          "polygon": {
            "type": "object",
            "description": "Polygon of area coordinates, in GeoJSON format.",
            "required": [
              "type",
              "coordinates"
            ],
            "properties": {
              "type": {
                "type": "string",
                "minLength": 1,
                "enum": [
                  "Polygon"
                ],
                "example": "Polygon"
              },
              "coordinates": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": {
                      "type": "number",
                      "example": 35.532345
                    }
                  }
                }
              }
            }
          }
        },
        "required": [
          "id",
          "max_ongoing_trips",
          "name",
          "ongoing_trips",
          "polygon"
        ]
      },
      "IssueTimestamp": {
        "type": "string",
        "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(Z|[+-]\\d{4})$",
        "description": "Timestamp with UTC Z or a numeric offset without a colon, for example 2026-11-19T13:00:00+0330."
      },
      "ResolutionAction": {
        "type": "string",
        "enum": [
          "cancel_trip",
          "reject_issue"
        ],
        "description": "cancel_trip accepts the report and cancels the affected trip using existing cancellation/accounting rules; no replacement trip is created. reject_issue closes the issue and notifies the courier without changing trip progress. Only actions offered for the issue may be submitted."
      },
      "SupportIssue": {
        "type": "object",
        "required": [
          "id",
          "trip_id",
          "problem_id",
          "reported_at",
          "reporter_type",
          "resolved_at",
          "resolver_type",
          "resolve_description",
          "picked_at",
          "picker_type",
          "state",
          "messages"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Issue identifier."
          },
          "trip_id": {
            "type": "string",
            "format": "uuid",
            "description": "Client-visible trip ID, preserving the original trip ID after batching."
          },
          "problem_id": {
            "type": "string",
            "format": "uuid",
            "description": "Reported problem identifier."
          },
          "reported_at": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(Z|[+-]\\d{4})$",
            "description": "Timestamp with UTC Z or a numeric offset without a colon, for example 2026-11-19T13:00:00+0330."
          },
          "reporter_type": {
            "type": "string",
            "description": "Reporter type, for example client or miare.",
            "enum": [
              "client",
              "miare"
            ]
          },
          "resolved_at": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(Z|[+-]\\d{4})$",
            "description": "Timestamp with UTC Z or a numeric offset without a colon, for example 2026-11-19T13:00:00+0330.",
            "nullable": true
          },
          "resolver_type": {
            "type": "string",
            "description": "Resolver type, or null while unresolved.",
            "nullable": true,
            "enum": [
              "client",
              "miare",
              null
            ]
          },
          "resolve_description": {
            "type": "string",
            "description": "Resolution description.",
            "nullable": true
          },
          "picked_at": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(Z|[+-]\\d{4})$",
            "description": "Timestamp with UTC Z or a numeric offset without a colon, for example 2026-11-19T13:00:00+0330.",
            "nullable": true
          },
          "picker_type": {
            "type": "string",
            "description": "Support picker type.",
            "nullable": true,
            "enum": [
              "client",
              "miare",
              null
            ]
          },
          "state": {
            "type": "string",
            "description": "Issue state, for example reported.",
            "enum": [
              "reported",
              "picked",
              "resolved"
            ]
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "description": "Message identifier."
                },
                "created_at": {
                  "$ref": "#/components/schemas/IssueTimestamp"
                },
                "sender_type": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "image_url": {
                  "type": "string",
                  "description": "Image URL or an empty string."
                }
              },
              "required": [
                "id",
                "created_at",
                "sender_type",
                "type",
                "message",
                "image_url"
              ]
            },
            "description": "Messages attached to the issue."
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Present on delegated issues only."
          },
          "resolution_actions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/ResolutionAction"
            },
            "description": "Present on delegated issues only."
          },
          "resolution_deadline": {
            "$ref": "#/components/schemas/IssueTimestamp",
            "description": "Present on delegated issues only."
          },
          "resolution_action": {
            "type": "string",
            "enum": [
              "cancel_trip",
              "reject_issue",
              null
            ],
            "nullable": true,
            "description": "Null for closure without a resolution action, including support/courier closure."
          }
        },
        "description": "Issue returned by the support API. Delegated issues additionally include description, resolution_actions, resolution_deadline and resolution_action. The action is null while unresolved or after manual support/courier closure. Reporter/resolver miare includes couriers and support.",
        "example": {
          "id": "ccba8f45-6ef6-409f-a1ee-453219aaa04f",
          "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
          "problem_id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
          "reported_at": "2026-11-19T13:00:00+0330",
          "reporter_type": "miare",
          "resolved_at": null,
          "resolver_type": null,
          "resolve_description": null,
          "picked_at": null,
          "picker_type": null,
          "state": "reported",
          "messages": [
            {
              "id": "9ad24b31-8f1e-4c5e-b488-b715b2825792",
              "created_at": "2026-11-19T13:00:00+0330",
              "sender_type": "miare",
              "type": "text",
              "message": "بسته‌بندی سفارش آسیب دیده است.",
              "image_url": ""
            }
          ],
          "description": "بسته‌بندی سفارش آسیب دیده است.",
          "resolution_actions": [
            "cancel_trip",
            "reject_issue"
          ],
          "resolution_deadline": "2026-11-19T13:10:00+0330",
          "resolution_action": null
        }
      },
      "DelegatedSupportIssue": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SupportIssue"
          },
          {
            "type": "object",
            "required": [
              "description",
              "resolution_actions",
              "resolution_deadline",
              "resolution_action"
            ]
          }
        ],
        "example": {
          "id": "ccba8f45-6ef6-409f-a1ee-453219aaa04f",
          "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
          "problem_id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
          "reported_at": "2026-11-19T13:00:00+0330",
          "reporter_type": "miare",
          "resolved_at": null,
          "resolver_type": null,
          "resolve_description": null,
          "picked_at": null,
          "picker_type": null,
          "state": "reported",
          "messages": [
            {
              "id": "9ad24b31-8f1e-4c5e-b488-b715b2825792",
              "created_at": "2026-11-19T13:00:00+0330",
              "sender_type": "miare",
              "type": "text",
              "message": "بسته‌بندی سفارش آسیب دیده است.",
              "image_url": ""
            }
          ],
          "description": "بسته‌بندی سفارش آسیب دیده است.",
          "resolution_actions": [
            "cancel_trip",
            "reject_issue"
          ],
          "resolution_deadline": "2026-11-19T13:10:00+0330",
          "resolution_action": null
        }
      },
      "SupportIssuePage": {
        "type": "object",
        "required": [
          "data",
          "next",
          "previous",
          "total_count"
        ],
        "properties": {
          "data": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/SupportIssue"
            }
          },
          "next": {
            "type": "string",
            "description": "Next page URL, or an empty string."
          },
          "previous": {
            "type": "string",
            "description": "Previous page URL, or an empty string."
          },
          "total_count": {
            "type": "integer",
            "minimum": 0
          }
        },
        "example": {
          "data": [
            {
              "id": "ccba8f45-6ef6-409f-a1ee-453219aaa04f",
              "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
              "problem_id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
              "reported_at": "2026-11-19T13:00:00+0330",
              "reporter_type": "miare",
              "resolved_at": null,
              "resolver_type": null,
              "resolve_description": null,
              "picked_at": null,
              "picker_type": null,
              "state": "reported",
              "messages": [
                {
                  "id": "9ad24b31-8f1e-4c5e-b488-b715b2825792",
                  "created_at": "2026-11-19T13:00:00+0330",
                  "sender_type": "miare",
                  "type": "text",
                  "message": "بسته‌بندی سفارش آسیب دیده است.",
                  "image_url": ""
                }
              ],
              "description": "بسته‌بندی سفارش آسیب دیده است.",
              "resolution_actions": [
                "cancel_trip",
                "reject_issue"
              ],
              "resolution_deadline": "2026-11-19T13:10:00+0330",
              "resolution_action": null
            }
          ],
          "next": "",
          "previous": "",
          "total_count": 1
        }
      },
      "ResolveDelegatedIssueRequest": {
        "type": "object",
        "required": [
          "resolution_action"
        ],
        "properties": {
          "resolution_action": {
            "$ref": "#/components/schemas/ResolutionAction"
          },
          "resolve_description": {
            "type": "string",
            "nullable": true,
            "description": "Optional for both actions, including reject_issue. Omitted/null/blank values are accepted. Supplied strings are trimmed; rejection uses generic notification text when no explanation is provided."
          }
        },
        "example": {
          "resolution_action": "reject_issue"
        }
      },
      "ResolveOwnIssueRequest": {
        "type": "object",
        "properties": {
          "resolve_description": {
            "type": "string",
            "nullable": true
          }
        },
        "not": {
          "required": [
            "resolution_action"
          ]
        },
        "description": "Existing non-delegated flow: only reports created by the authenticated client can be resolved. Omit resolution_action."
      },
      "Timestamp": {
        "type": "string",
        "description": "Serialized timestamp. Responses may use Z or +HHMM; request timestamps must include a timezone.",
        "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:?\\d{2})$"
      },
      "NullableTimestamp": {
        "type": "string",
        "description": "Serialized timestamp. Responses may use Z or +HHMM; request timestamps must include a timezone.",
        "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:?\\d{2})$",
        "nullable": true
      },
      "PickupRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The human readable name of the pickup",
            "example": "رستوران بزرگمهر"
          },
          "phone_number": {
            "type": "string",
            "description": "The phone number associated with the source which will be used by courier and support staffs in order to contact to pickup if necessary",
            "example": "0212345678"
          },
          "address": {
            "type": "string",
            "description": "The human readable address of the source, preferably down to every necessary detail for a human to find the source quickly",
            "example": "تهران، صادقیه، بلوار آیت الله کاشانی"
          },
          "image": {
            "type": "string",
            "format": "uri",
            "description": "A valid URL which points to an image file which should be the logo of the pickup. This image will be used in both support panel, and courier’s application, so make sure that the URL is both reachable and is configured to allow CORS requests",
            "example": "https://example.com/restaurants/bm_logo.png"
          },
          "location": {
            "$ref": "#/components/schemas/Location"
          },
          "deadline": {
            "$ref": "#/components/schemas/Timestamp",
            "description": "Expected package-ready pickup time. Must be in the future when creating or updating a trip."
          },
          "seller_id": {
            "type": "string",
            "description": "Required for proxy invoicing: register this client-scoped seller before creating the trip.",
            "maxLength": 64
          }
        },
        "xml": {
          "name": "Pickup"
        },
        "required": [
          "name",
          "phone_number",
          "address",
          "image",
          "location",
          "deadline"
        ]
      },
      "Payment": {
        "type": "object",
        "properties": {
          "payment_type": {
            "type": "string",
            "description": "Payment method; currently cash.",
            "enum": [
              "cash"
            ]
          },
          "price": {
            "type": "integer",
            "description": "Declared package value in Tomans (IRT), separate from delivery cost. Checked per course; equality with the effective client limit is allowed. A value over the limit rejects the whole trip or new course.",
            "minimum": 0
          }
        },
        "required": [
          "price"
        ]
      },
      "AddCourseRequest": {
        "type": "object",
        "required": [
          "bill_number",
          "name",
          "phone_number",
          "address"
        ],
        "properties": {
          "bill_number": {
            "type": "string",
            "description": "An string field left for you to store sort of a human readable bill number in it which will be used as a reference point among our support team, you and the pickup staffs",
            "example": "DEL-119"
          },
          "name": {
            "type": "string",
            "description": "Name of the dropp-off",
            "example": "علی علوی"
          },
          "phone_number": {
            "type": "string",
            "description": "The phone number associated with the drop-off which will be used by courier and support staffs in order to contact to them if necessary",
            "example": "09123456789"
          },
          "address": {
            "type": "string",
            "description": "The human readable drop-off address, preferably down to every necessary detail for a human to find it quickly",
            "example": "تهران، خیابان استاد معین، پلاک ۱۲"
          },
          "delivery_code": {
            "type": "string",
            "pattern": "^\\s*[0-9]{5}\\s*$",
            "description": "Required only when the client/source proof_of_delivery_policy is third_party. Must be exactly 5 digits. Leading/trailing whitespace is ignored before validation and storage. When accepted, this code is stored as the course PoD code and will be used later for delivery verification by the driver. For clients whose PoD policy is none or miare, this field is not required.",
            "example": "98765"
          },
          "location": {
            "$ref": "#/components/schemas/Location"
          },
          "manifest_items": {
            "type": "array",
            "xml": {
              "name": "manifest_item",
              "wrapped": true
            },
            "description": "The contents of the package to be delivered to the drop-off",
            "items": {
              "$ref": "#/components/schemas/ManifestItem"
            }
          },
          "requires_box": {
            "type": "boolean",
            "default": false,
            "description": "Optional; defaults to false. When box requirements are enabled, true requires a car or a motorcycle courier with a box for the whole trip, even if only one course requires it. Existing client service-level restrictions still apply. Confirm availability with Miare: while disabled, true is accepted but stored as false and course-level box requirements are not enforced. Enabling later does not restore ignored requirements. The value cannot be edited after creation; unrelated updates preserve it.",
            "example": false
          },
          "payment": {
            "$ref": "#/components/schemas/Payment"
          }
        },
        "xml": {
          "name": "CourseRequest"
        },
        "description": "Add Course ignores is_round_course. Use Round Trip to change the return requirement."
      },
      "BoostRequest": {
        "type": "object",
        "properties": {
          "level": {
            "type": "integer",
            "description": "A current boost level, or 0 to cancel. Fetch valid levels periodically.",
            "minimum": 0
          }
        },
        "required": [
          "level"
        ]
      },
      "Boost": {
        "type": "object",
        "properties": {
          "level": {
            "type": "integer",
            "description": "Active boost level; 0 means no boost."
          },
          "amount": {
            "type": "integer",
            "description": "Price increase in Tomans (IRT)."
          }
        },
        "required": [
          "level",
          "amount"
        ]
      },
      "CreateTripRequest": {
        "type": "object",
        "properties": {
          "pickup": {
            "$ref": "#/components/schemas/PickupRequest"
          },
          "courses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CourseRequest"
            },
            "minItems": 1
          },
          "boost": {
            "$ref": "#/components/schemas/CreateBoostRequest"
          }
        },
        "required": [
          "pickup",
          "courses"
        ]
      },
      "CreateBoostRequest": {
        "type": "object",
        "properties": {
          "level": {
            "type": "integer",
            "description": "A current boost level, or 0 to cancel. Fetch valid levels periodically.",
            "minimum": 0,
            "nullable": true
          }
        },
        "required": [
          "level"
        ]
      },
      "UpdateCourseRequest": {
        "type": "object",
        "required": [
          "bill_number",
          "name",
          "phone_number",
          "address"
        ],
        "properties": {
          "bill_number": {
            "type": "string",
            "description": "An string field left for you to store sort of a human readable bill number in it which will be used as a reference point among our support team, you and the pickup staffs",
            "example": "DEL-119"
          },
          "name": {
            "type": "string",
            "description": "Name of the dropp-off",
            "example": "علی علوی"
          },
          "phone_number": {
            "type": "string",
            "description": "The phone number associated with the drop-off which will be used by courier and support staffs in order to contact to them if necessary",
            "example": "09123456789"
          },
          "address": {
            "type": "string",
            "description": "The human readable drop-off address, preferably down to every necessary detail for a human to find it quickly",
            "example": "تهران، خیابان استاد معین، پلاک ۱۲"
          },
          "location": {
            "$ref": "#/components/schemas/Location"
          },
          "manifest_items": {
            "type": "array",
            "xml": {
              "name": "manifest_item",
              "wrapped": true
            },
            "description": "The contents of the package to be delivered to the drop-off",
            "items": {
              "$ref": "#/components/schemas/ManifestItem"
            }
          }
        },
        "xml": {
          "name": "CourseRequest"
        }
      },
      "UpdateTripRequest": {
        "type": "object",
        "properties": {
          "pickup": {
            "$ref": "#/components/schemas/UpdatePickupRequest"
          },
          "courses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UpdateCourseRequest"
            }
          },
          "boost": {
            "$ref": "#/components/schemas/CreateBoostRequest"
          }
        },
        "required": [
          "pickup",
          "courses",
          "boost"
        ]
      },
      "RoundTripRequest": {
        "type": "object",
        "properties": {
          "is_round_trip": {
            "type": "boolean",
            "description": "Require or remove one final return to the pickup location."
          }
        },
        "required": [
          "is_round_trip"
        ]
      },
      "BoostLevel": {
        "type": "object",
        "properties": {
          "level": {
            "type": "integer",
            "minimum": 1
          },
          "amount": {
            "type": "integer",
            "description": "Price increase in Tomans (IRT)."
          }
        },
        "required": [
          "level",
          "amount"
        ]
      },
      "TripPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Trip"
            }
          },
          "next": {
            "type": "string",
            "description": "Next page URL, or null.",
            "nullable": true
          },
          "previous": {
            "type": "string",
            "description": "Previous page URL, or null.",
            "nullable": true
          },
          "total_count": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "data",
          "next",
          "previous",
          "total_count"
        ]
      },
      "Problem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "description_required": {
            "type": "boolean"
          },
          "reporter_type": {
            "type": "string",
            "enum": [
              "client",
              "miare"
            ],
            "description": "Problem reporter category. Only client problems can be reported by API clients. The older prose called this for_reporter_type; the wire field is reporter_type."
          }
        },
        "required": [
          "id",
          "title",
          "reporter_type",
          "description_required"
        ]
      },
      "ReportIssueRequest": {
        "type": "object",
        "properties": {
          "trip_id": {
            "type": "string",
            "description": "Provide trip_id or course_id. trip_id takes precedence when both are supplied.",
            "format": "uuid",
            "nullable": true
          },
          "course_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "problem_id": {
            "type": "string",
            "description": "Use a problem for the client reporter type.",
            "format": "uuid"
          },
          "description": {
            "type": "string",
            "description": "Required when the selected problem requires a description.",
            "maxLength": 256,
            "nullable": true
          }
        },
        "required": [
          "problem_id"
        ],
        "anyOf": [
          {
            "required": [
              "trip_id"
            ],
            "properties": {
              "trip_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          },
          {
            "required": [
              "course_id"
            ],
            "properties": {
              "course_id": {
                "type": "string",
                "format": "uuid"
              }
            }
          }
        ]
      },
      "AppendMessageRequest": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Text to append to an unresolved issue.",
            "maxLength": 256
          }
        },
        "required": [
          "message"
        ]
      },
      "Estimate": {
        "type": "object",
        "properties": {
          "price": {
            "type": "integer",
            "description": "Estimated course delivery cost, in Tomans. Excludes trip-level costs and boost."
          },
          "status": {
            "type": "string"
          },
          "area_coverage": {
            "type": "boolean"
          }
        },
        "required": [
          "price",
          "status",
          "area_coverage"
        ]
      },
      "SellerRequest": {
        "type": "object",
        "properties": {
          "person_type": {
            "type": "string",
            "enum": [
              "individual",
              "legal"
            ]
          },
          "name": {
            "type": "string",
            "nullable": true,
            "maxLength": 255
          },
          "national_id": {
            "type": "string",
            "description": "Required for an individual. A legal seller needs national_id or economic_id.",
            "nullable": true,
            "maxLength": 16
          },
          "registration_number": {
            "type": "string",
            "nullable": true,
            "maxLength": 16
          },
          "economic_id": {
            "type": "string",
            "description": "A legal seller needs national_id or economic_id.",
            "nullable": true,
            "maxLength": 16
          },
          "address": {
            "type": "string",
            "maxLength": 4096
          },
          "postal_code": {
            "type": "string",
            "nullable": true,
            "maxLength": 10
          },
          "phone_number": {
            "type": "string",
            "nullable": true,
            "maxLength": 20
          }
        },
        "required": [
          "person_type",
          "address"
        ],
        "description": "For individuals national_id is required; legal sellers need national_id or economic_id. On update, omitted optional fields retain their values and null clears them when validation permits."
      },
      "Seller": {
        "type": "object",
        "properties": {
          "person_type": {
            "type": "string",
            "enum": [
              "individual",
              "legal"
            ]
          },
          "name": {
            "type": "string",
            "nullable": true,
            "maxLength": 255
          },
          "national_id": {
            "type": "string",
            "description": "Required for an individual. A legal seller needs national_id or economic_id.",
            "nullable": true,
            "maxLength": 16
          },
          "registration_number": {
            "type": "string",
            "nullable": true,
            "maxLength": 16
          },
          "economic_id": {
            "type": "string",
            "description": "A legal seller needs national_id or economic_id.",
            "nullable": true,
            "maxLength": 16
          },
          "address": {
            "type": "string",
            "maxLength": 4096
          },
          "postal_code": {
            "type": "string",
            "nullable": true,
            "maxLength": 10
          },
          "phone_number": {
            "type": "string",
            "nullable": true,
            "maxLength": 20
          },
          "seller_id": {
            "type": "string",
            "maxLength": 64
          },
          "created_at": {
            "$ref": "#/components/schemas/Timestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/Timestamp"
          }
        },
        "required": [
          "person_type",
          "name",
          "national_id",
          "registration_number",
          "economic_id",
          "address",
          "postal_code",
          "phone_number",
          "seller_id",
          "created_at",
          "updated_at"
        ]
      },
      "InvoiceReady": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ready"
            ]
          },
          "batch_id": {
            "type": "string",
            "format": "uuid"
          },
          "revision": {
            "type": "integer",
            "minimum": 0
          },
          "revisions_count": {
            "type": "integer",
            "description": "Highest available revision number; not the number of revisions.",
            "minimum": 0
          },
          "invoice_number": {
            "type": "string",
            "description": "Adjustments append -RNN to the original invoice number."
          },
          "document_type": {
            "type": "string",
            "enum": [
              "original",
              "adjustment"
            ]
          },
          "download_url": {
            "type": "string",
            "description": "Temporary private download URL; expires in five minutes.",
            "format": "uri"
          },
          "expires_at": {
            "$ref": "#/components/schemas/Timestamp"
          }
        },
        "required": [
          "status",
          "batch_id",
          "revision",
          "revisions_count",
          "invoice_number",
          "document_type",
          "download_url",
          "expires_at"
        ]
      },
      "InvoiceProcessing": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "processing"
            ]
          },
          "batch_id": {
            "type": "string",
            "format": "uuid"
          },
          "revision": {
            "type": "integer",
            "minimum": 0
          },
          "revisions_count": {
            "type": "integer",
            "description": "Highest available revision number; not the number of revisions.",
            "minimum": 0
          },
          "retry_after": {
            "type": "integer",
            "description": "Seconds to wait before polling again.",
            "minimum": 0
          }
        },
        "required": [
          "status",
          "batch_id",
          "revision",
          "revisions_count",
          "retry_after"
        ]
      },
      "FinancialDetail": {
        "type": "object",
        "required": [
          "batch_id",
          "revision",
          "trip_ids",
          "course_ids",
          "bill_numbers",
          "state",
          "financials",
          "changes"
        ],
        "properties": {
          "batch_id": {
            "type": "string",
            "format": "uuid",
            "description": "Stable accounting batch identifier across revisions; may differ from original trip IDs."
          },
          "revision": {
            "type": "integer",
            "description": "Per-batch revision: 0 initially; increasing positive values for adjustments.",
            "minimum": 0
          },
          "trip_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid",
              "description": "Client-visible trip ID."
            },
            "description": "Unique original client-visible trip IDs, retained after batching.",
            "uniqueItems": true
          },
          "course_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid",
              "description": "Course identifier."
            },
            "description": "Courses associated with this calculation; adjustments include invalidated courses for traceability."
          },
          "bill_numbers": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "Unique non-empty bill numbers, not positionally aligned with trip_ids or course_ids.",
            "uniqueItems": true
          },
          "state": {
            "type": "string",
            "enum": [
              "calculated",
              "changed"
            ],
            "description": "Financial state, separate from trip lifecycle state."
          },
          "financials": {
            "$ref": "#/components/schemas/FinancialAmounts"
          },
          "changes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FinancialChange"
            },
            "description": "Cumulative adjustment history; empty for the initial calculation."
          }
        },
        "description": "Available for enabled client accounts with a configured webhook. financial_calculated reports initial accounting; eligible deleted trips have zero amounts. financial_adjusted reports a non-zero financial change after a course is marked invalid. Deduplicate by (batch_id, revision), retain the highest revision and use the complete total rather than reapplying cumulative changes. Revisions can arrive out of order, including before revision 0. Any non-2xx response or network failure is retried with a 10-second request timeout. Default retry delays are 30,120,300,900,1800 seconds and are configurable. Retries use the stored payload. Recover latest data using GET https://www.miare.ir/api/accounting/financial-detail/{batch_id}/ with the client token; the response omits event. Invoice PDF readiness is independent.",
        "oneOf": [
          {
            "properties": {
              "state": {
                "enum": [
                  "calculated"
                ]
              },
              "revision": {
                "type": "integer",
                "enum": [
                  0
                ]
              },
              "changes": {
                "type": "array",
                "maxItems": 0
              }
            }
          },
          {
            "properties": {
              "state": {
                "enum": [
                  "changed"
                ]
              },
              "revision": {
                "type": "integer",
                "minimum": 1
              },
              "changes": {
                "type": "array",
                "minItems": 1
              }
            }
          }
        ]
      },
      "NullableLocation": {
        "type": "object",
        "properties": {
          "latitude": {
            "type": "number",
            "format": "double",
            "example": 35.737004
          },
          "longitude": {
            "type": "number",
            "format": "double",
            "example": 51.413569
          }
        },
        "xml": {
          "name": "Location"
        },
        "required": [
          "latitude",
          "longitude"
        ],
        "nullable": true
      },
      "UpdatePickupRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The human readable name of the pickup",
            "example": "رستوران بزرگمهر"
          },
          "phone_number": {
            "type": "string",
            "description": "The phone number associated with the source which will be used by courier and support staffs in order to contact to pickup if necessary",
            "example": "0212345678"
          },
          "address": {
            "type": "string",
            "description": "The human readable address of the source, preferably down to every necessary detail for a human to find the source quickly",
            "example": "تهران، صادقیه، بلوار آیت الله کاشانی"
          },
          "image": {
            "type": "string",
            "format": "uri",
            "description": "A valid URL which points to an image file which should be the logo of the pickup. This image will be used in both support panel, and courier’s application, so make sure that the URL is both reachable and is configured to allow CORS requests",
            "example": "https://example.com/restaurants/bm_logo.png"
          },
          "location": {
            "$ref": "#/components/schemas/Location"
          },
          "deadline": {
            "$ref": "#/components/schemas/Timestamp",
            "description": "Expected package-ready pickup time. Must be in the future when creating or updating a trip."
          }
        },
        "xml": {
          "name": "Pickup"
        },
        "required": [
          "name",
          "phone_number",
          "address",
          "image",
          "location",
          "deadline"
        ]
      }
    }
  },
  "paths": {
    "/trip-management/third-party-api/v2/trips/": {
      "post": {
        "tags": [
          "delivery"
        ],
        "summary": "Create Trip",
        "operationId": "posttrip-management-third-party-api-v2-trips",
        "description": "Creates a new trip and puts it in the assign queue.\n\nRound-trip creation is available only to accounts enabled by Miare, not to all clients.\nContact Miare to request enablement for your account. Until enabled, course return requirements\nin the create request are ignored and the trip is created without a requested return.\n\nEach course can independently require a return to the pickup location.\nIf any course has `is_round_course: true`, the trip requires one final return after all\ndeliveries; a `false` value on another course does not cancel that requirement.\nThis does not require a separate return after each course or add another delivery course.\nThe trip-level response field `is_round_trip` is `true` when any course\nrequires a return. To change the trip's return requirement after creation, use the\n[Round Trip](/api/public/delivery#round-trip) endpoint.\nSetting `is_round_course` is supported only in Create Trip. Add Course ignores this\nfield, and Update Trip cannot change it.\n\nTrip creation will fail if you don't have enough concurrency limit in the area of the pickup location of the given trip in the deadline shift.\n\nFor clients with proxy invoicing enabled, register the seller through the\n[Register or Update Seller](/api/public/accounting#register-or-update-seller) endpoint before creating a\ntrip. For these clients, `pickup.seller_id` is required.\n\nThe maximum declared package value is checked separately for each course using\n`payment.price`, in Tomans (IRT). A value equal to the limit is allowed.\nIf any course exceeds the effective limit, the entire request is rejected and no trip is created.\nThe default cap applies unless a client-specific cap has been configured by Miare.\n\nContact the commercial team to configure a client-specific cap.\n\nThe mixed-course example above applies to clients that can create multi-course trips.\nClients with auto-batching enabled can still send only one course per trip.\n\n### Errors\n| Code | Description |\n|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| parse_error | The request body is not a valid JSON string (has syntax error) |\n| invalid_request_body | Request body does not follow the valid format |\n| concurrency_limit | Client does not have enough concurrency in the area of the pickup location in the shift specified by deadline |\n| service_level_order | Based on the current environmental state, your service level is too low to receive services from Miare. Service limitation error mostly happens due to whether conditions or special occasions. In order to increase your service level or if you need more details about this limitation please contant sales team. |\n| duplicated_bill_number | There is already a course related to trip with states of (`assign_queue`, `pickup`, `dropoff`) with this bill number. |\n| delivery_code_required | `delivery_code` is required for each course when the client/source `proof_of_delivery_policy` is `third_party`. |\n| delivery_code_invalid | `delivery_code` was provided but is not a valid 5-digit code. Leading/trailing whitespace is ignored before validation. |\n| seller_not_registered | Proxy invoicing is enabled and `pickup.seller_id` is missing or is not registered for the authenticated client. Register the seller before creating the trip. |\n| invalid_boost_level | This level is not among the current valid levels. Refer to the [valid boost levels](/api/public/delivery#boost-levels). |\n| declared_package_value_too_high | HTTP 400. A course's `payment.price` exceeds the effective declared-value cap for the client. The entire trip-creation request is rejected. |\n\nThe course index in this example is zero-based (`0` identifies the first course).\nThe cap shown is illustrative; use `code` for error handling, as `detail` may change.",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#create-trip"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTripRequest"
              },
              "example": {
                "pickup": {
                  "seller_id": "nearby-seller-123",
                  "name": "رستوران بزرگمهر",
                  "phone_number": "09123456789",
                  "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                  "image": "https://example.com/restaurants/bm_logo.png",
                  "location": {
                    "latitude": 35.737004,
                    "longitude": 51.413569
                  },
                  "deadline": "2030-01-01T14:00:00+0330"
                },
                "courses": [
                  {
                    "bill_number": "DEL-119",
                    "name": "علی علوی",
                    "phone_number": "09123456789",
                    "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                    "delivery_code": "98765",
                    "is_round_course": true,
                    "requires_box": false,
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "manifest_items": [
                      {
                        "name": "پیتزا پپرونی خانواده",
                        "quantity": 2
                      }
                    ]
                  },
                  {
                    "bill_number": "DEL-120",
                    "name": "مریم رضایی",
                    "phone_number": "09123456789",
                    "address": "تهران، خیابان آزادی، پلاک ۲۰",
                    "delivery_code": "12345",
                    "is_round_course": false,
                    "requires_box": false,
                    "location": {
                      "latitude": 35.7,
                      "longitude": 51.37
                    },
                    "manifest_items": [
                      {
                        "name": "پیتزا مارگاریتا خانواده",
                        "quantity": 1
                      }
                    ]
                  }
                ],
                "boost": {
                  "level": 1
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Trip"
                },
                "example": {
                  "id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "batch_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "is_round_trip": true,
                  "created_at": "2021-11-01T16:59:00+0330",
                  "assigned_at": "2021-11-01T17:00:00+0330",
                  "arrived_at": "2021-11-01T17:02:00+0330",
                  "picked_up_at": "2021-11-01T17:04:00+0330",
                  "departed_at": "2021-11-01T17:06:00+0330",
                  "state": "dropoff",
                  "pickup": {
                    "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                    "deadline": "2021-11-01T20:42:00+0330",
                    "image": "https://example.com/restaurants/bm_logo.png",
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "name": "رستوران بزرگمهر",
                    "phone_number": "09123456789"
                  },
                  "area": {
                    "id": "3",
                    "name": "یوسف آباد"
                  },
                  "devlivery_cost": null,
                  "courier": {
                    "image": "https://image.miare.ir/avatars/123456.jpeg",
                    "location": {
                      "latitude": 35.753691,
                      "longitude": 51.332284
                    },
                    "location_updated_at": "2021-11-01T19:10:13+0330",
                    "name": "علی لطفی",
                    "phone_number": "09379187928"
                  },
                  "courses": [
                    {
                      "id": "7484f530-5e3e-491d-8a4a-9432f6db01d6",
                      "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                      "old_trip_id": "00000000-0000-0000-0000-000000000000",
                      "bill_number": "DEL-119",
                      "name": "علی علوی",
                      "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                      "dropped_off_at": null,
                      "is_round_course": true,
                      "requires_box": false,
                      "phone_number": "09123456789",
                      "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/7484f5305e",
                      "location": {
                        "latitude": 35.737004,
                        "longitude": 51.413569
                      },
                      "manifest_items": [
                        {
                          "name": "پیتزا پپرونی خانواده",
                          "quantity": 2
                        }
                      ],
                      "payment": {
                        "payment_type": "cash",
                        "price": 0
                      }
                    },
                    {
                      "id": "b99435f0-a3e1-4af9-99ba-c9925b3ad2c9",
                      "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                      "old_trip_id": "00000000-0000-0000-0000-000000000000",
                      "bill_number": "DEL-120",
                      "name": "مریم رضایی",
                      "address": "تهران، خیابان آزادی، پلاک ۲۰",
                      "dropped_off_at": null,
                      "is_round_course": false,
                      "requires_box": false,
                      "phone_number": "09123456789",
                      "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/b99435f0a3",
                      "location": {
                        "latitude": 35.7,
                        "longitude": 51.37
                      },
                      "manifest_items": [
                        {
                          "name": "پیتزا مارگاریتا خانواده",
                          "quantity": 1
                        }
                      ],
                      "payment": {
                        "payment_type": "cash",
                        "price": 0
                      }
                    }
                  ],
                  "boost": {
                    "level": 1,
                    "amount": 1000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, including declared_package_value_too_high. No trip/course is created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "curl --request POST \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\" \\\n  --header \"Content-Type: application/json\" \\\n  --data-raw '{\n  \"pickup\": {\n    \"seller_id\": \"nearby-seller-123\",\n    \"name\": \"رستوران بزرگمهر\",\n    \"phone_number\": \"09123456789\",\n    \"address\": \"تهران، صادقیه، بلوار آیت الله کاشانی\",\n    \"image\": \"https://example.com/restaurants/bm_logo.png\",\n    \"location\": {\n      \"latitude\": 35.737004,\n      \"longitude\": 51.413569\n    },\n    \"deadline\": \"2030-01-01T14:00:00+0330\"\n  },\n  \"courses\": [\n    {\n      \"bill_number\": \"DEL-119\",\n      \"name\": \"علی علوی\",\n      \"phone_number\": \"09123456789\",\n      \"address\": \"تهران، خیابان استاد معین، پلاک ۱۲\",\n      \"delivery_code\": \"98765\",\n      \"is_round_course\": true,\n      \"requires_box\": false,\n      \"location\": {\n        \"latitude\": 35.737004,\n        \"longitude\": 51.413569\n      },\n      \"manifest_items\": [\n        {\n          \"name\": \"پیتزا پپرونی خانواده\",\n          \"quantity\": 2\n        }\n      ]\n    },\n    {\n      \"bill_number\": \"DEL-120\",\n      \"name\": \"مریم رضایی\",\n      \"phone_number\": \"09123456789\",\n      \"address\": \"تهران، خیابان آزادی، پلاک ۲۰\",\n      \"delivery_code\": \"12345\",\n      \"is_round_course\": false,\n      \"requires_box\": false,\n      \"location\": {\n        \"latitude\": 35.7,\n        \"longitude\": 51.37\n      },\n      \"manifest_items\": [\n        {\n          \"name\": \"پیتزا مارگاریتا خانواده\",\n          \"quantity\": 1\n        }\n      ]\n    }\n  ],\n  \"boost\": {\n    \"level\": 1\n  }\n}'"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ndata = {'pickup': {'seller_id': 'nearby-seller-123',\n            'name': 'رستوران بزرگمهر',\n            'phone_number': '09123456789',\n            'address': 'تهران، صادقیه، بلوار آیت الله کاشانی',\n            'image': 'https://example.com/restaurants/bm_logo.png',\n            'location': {'latitude': 35.737004, 'longitude': 51.413569},\n            'deadline': '2030-01-01T14:00:00+0330'},\n 'courses': [{'bill_number': 'DEL-119',\n              'name': 'علی علوی',\n              'phone_number': '09123456789',\n              'address': 'تهران، خیابان استاد معین، پلاک ۱۲',\n              'delivery_code': '98765',\n              'is_round_course': True,\n              'requires_box': False,\n              'location': {'latitude': 35.737004, 'longitude': 51.413569},\n              'manifest_items': [{'name': 'پیتزا پپرونی خانواده', 'quantity': 2}]},\n             {'bill_number': 'DEL-120',\n              'name': 'مریم رضایی',\n              'phone_number': '09123456789',\n              'address': 'تهران، خیابان آزادی، پلاک ۲۰',\n              'delivery_code': '12345',\n              'is_round_course': False,\n              'requires_box': False,\n              'location': {'latitude': 35.7, 'longitude': 51.37},\n              'manifest_items': [{'name': 'پیتزا مارگاریتا خانواده', 'quantity': 1}]}],\n 'boost': {'level': 1}}\n\nresponse = requests.post(\n    \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n    json=data,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "get": {
        "tags": [
          "delivery"
        ],
        "summary": "List Trips",
        "operationId": "gettrip-management-third-party-api-v2-trips",
        "description": "Returns list of your trips matching the given conditions.\n\nServer might not have or decide not to send you as many result items as `limit` but it never sends you more than that.\n\n### Errors\n| Code | Description |\n|-------------------|-----------------------------|\n| not_authenticated | Token is missing or invalid |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#list-trips"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "area_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            },
            "description": "**Filter:** The ID of the area of the pickup location. You can find list of available areas in the [List Areas](/api/public/area#list-areas) endpoint"
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "**Filter:** The state of the trip. Should be one of the states specified in [Trip](/concepts#trip) definition"
          },
          {
            "name": "is_round_trip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "**Filter:** Base on is_round_trip of trip"
          },
          {
            "name": "bill_number",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "**Filter:** The `bill_number` of the courses in the trips."
          },
          {
            "name": "from_datetime",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/Timestamp"
            },
            "description": "**Filter:** Minimum acceptable value for trip's `created_at` field. This filter is **inclusive**"
          },
          {
            "name": "to_datetime",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/Timestamp"
            },
            "description": "**Filter:** Maximum acceptable value for trip's `created_at` field. This filter is **inclusive**"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Give results excluding the first **offset** number of objects"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 0
            },
            "description": "Give _at most_ **limit** number of results. The default value is 100"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TripPage"
                },
                "example": {
                  "data": [
                    {
                      "area": {
                        "id": "27",
                        "name": "پونک"
                      },
                      "assigned_at": null,
                      "arrived_at": null,
                      "departed_at": null,
                      "delivery_cost": null,
                      "courier": null,
                      "courses": [
                        {
                          "address": "هران، خیابان استاد معین، پلاک ۱۲",
                          "bill_number": "DEL-119",
                          "dropped_off_at": null,
                          "requires_box": false,
                          "id": "3b0e8576-f802-44f5-8654-d65e11fd3035",
                          "location": {
                            "latitude": 35.753515,
                            "longitude": 51.332119
                          },
                          "manifest_items": [],
                          "name": "علی علوی",
                          "payment": {
                            "payment_type": "cash",
                            "price": 0
                          },
                          "phone_number": "09379187928",
                          "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/3b0e8576f8",
                          "trip_id": "05fd0397-5a78-4852-98e7-9fbc310685c0",
                          "old_trip_id": "00000000-0000-0000-0000-000000000000"
                        }
                      ],
                      "created_at": "2021-09-29T17:07:27+0330",
                      "id": "05fd0397-5a78-4852-98e7-9fbc310685c0",
                      "batch_id": "05fd0397-5a78-4852-98e7-9fbc310685c0",
                      "picked_up_at": null,
                      "pickup": {
                        "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                        "deadline": "2021-09-29T17:19:19+0330",
                        "image": "https://example.com/restaurants/bm_logo.png",
                        "location": {
                          "latitude": 35.753515,
                          "longitude": 51.332119
                        },
                        "name": "بزرگ‌ترین رستوران خاور میانه و حواشی آن تا اقیانوس اطلس",
                        "phone_number": "09379187928"
                      },
                      "state": "canceled_by_miare",
                      "is_round_trip": false,
                      "boost": {
                        "level": 1,
                        "amount": 1000
                      }
                    }
                  ],
                  "next": "https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/?offset=1&limit=1&from_datetime=2020-11-02T14:48:18Z&to_datetime=2021-12-02T14:48:18Z",
                  "previous": "",
                  "total_count": 35
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "curl --request GET \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/?limit=100\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\nresponse = requests.get(\n    \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/?limit=100\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/trip-management/third-party-api/v2/trips/{trip_id}/cancel/": {
      "post": {
        "tags": [
          "delivery"
        ],
        "summary": "Cancel Trip",
        "operationId": "cancel-trip-management-third-party-api-v2-trips-trip_id-cancel",
        "description": "Cancels one of your trips indicated by its ID.\n\nNote that a trip **cannot** be canceled when it has passed 30 seconds since we’ve assigned it to a courier or the courier has already arrived at the source. In special cases that you still need to cancel the trip, please contact our support.\n\nYou can find ID of your trip in the response body of [Create Trip](/api/public/delivery#create-trip) request\n\nThe given trip ID must belong to your client.\n\nResponse body is a serialized trip. For a detailed version of it take a look at the response body\nof [Create Trip](/api/public/delivery#create-trip) request.\n\nSuccessful calls to this endpoint will update the state of the trip to `canceled_by_client`.\n\n### Errors\n| Code | Description |\n|--------------------------|---------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| parse_error | The request body is not a valid JSON string (has syntax error) |\n| invalid_request_body | Request body does not follow the valid format |\n| record_not_found | A trip with the given ID does not belong to your client or doesn't exist at all |\n| canceling_after_deadline | The trip has been in assigned state for more than 30 seconds |\n| canceling_arrived_trip | The trip's courier is already at the source location |\n| canceling_ended_trip | The trip is already ended (delivered) |\n| invalid_state_change | Changing the trip's state from its current state to canceled is not possible |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#cancel-trip"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "trip_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The trip id belonging to the authenticated client."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Trip"
                },
                "example": {
                  "created_at": "2021-11-01T16:59:00+0330",
                  "id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "batch_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "is_round_trip": false,
                  "state": "canceled_by_client",
                  "picked_up_at": null,
                  "assigned_at": null,
                  "arrived_at": null,
                  "departed_at": null,
                  "area": {
                    "id": "3",
                    "name": "یوسف آباد"
                  },
                  "delivery_cost": null,
                  "courier": null,
                  "pickup": {
                    "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                    "deadline": "2021-11-01T20:42:00+0330",
                    "image": "https://example.com/restaurants/bm_logo.png",
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "name": "رستوران بزرگمهر",
                    "phone_number": "09123456789"
                  },
                  "courses": [
                    {
                      "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                      "bill_number": "DEL-119",
                      "dropped_off_at": null,
                      "requires_box": false,
                      "id": "7484f530-5e3e-491d-8a4a-9432f6db01d6",
                      "location": {
                        "latitude": 35.737004,
                        "longitude": 51.413569
                      },
                      "manifest_items": [
                        {
                          "name": "پیتزا پپرونی خانواده",
                          "quantity": 2
                        }
                      ],
                      "name": "test name",
                      "payment": {
                        "payment_type": "cash",
                        "price": 0
                      },
                      "phone_number": "09123456789",
                      "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/7484f5305e",
                      "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                      "old_trip_id": "00000000-0000-0000-0000-000000000000"
                    }
                  ],
                  "boost": {
                    "level": 1,
                    "amount": 1000
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "TRIP_ID=\"your-trip-id\"\n\ncurl --request POST \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/$TRIP_ID/cancel/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ntrip_id = \"your-trip-id\"\n\nresponse = requests.post(\n    f\"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/{trip_id}/cancel/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/trip-management/third-party-api/v2/trips/{trip_id}/round-trip/": {
      "post": {
        "tags": [
          "delivery"
        ],
        "summary": "Round Trip",
        "operationId": "round-trip",
        "description": "Enable or remove the return requirement for the trip indicated by its ID.\nThis endpoint requires account enablement by Miare.\n\nThe return requirement can be changed while the trip is in `assign_queue`,\n`pickup`, `dropoff`, or `returning` state.\nCompleted or canceled trips cannot be changed.\n\nYou can find ID of your trip in the response body of [Create Trip](/api/public/delivery#create-trip) request\n\nThe given trip ID must belong to your client.\n\nResponse body is a serialized trip. For a detailed version of it take a look at the response body\nof [Create Trip](/api/public/delivery#create-trip) request.\n\nRequiring a return does not immediately change the trip state to `returning`.\nThe trip enters `returning` after all deliveries are complete and a return is still\nrequired. Removing the last return requirement after deliveries are complete can end the trip.\n\n### Errors\n| Code | Description |\n|----------------------|----------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| parse_error | The request body is not a valid JSON string (has syntax error) |\n| invalid_request_body | Request body does not follow the valid format |\n| record_not_found | A trip with the given ID does not belong to your client or doesn't exist at all |\n| invalid_state_change | The trip is already completed or canceled, so its return requirement cannot be changed. |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#round-trip"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "trip_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The trip id belonging to the authenticated client."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RoundTripRequest"
              },
              "example": {
                "is_round_trip": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Trip"
                },
                "example": {
                  "created_at": "2021-11-01T16:59:00+0330",
                  "id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "batch_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "state": "returning",
                  "is_round_trip": true,
                  "picked_up_at": null,
                  "assigned_at": null,
                  "arrived_at": null,
                  "departed_at": null,
                  "area": {
                    "id": "3",
                    "name": "یوسف آباد"
                  },
                  "delivery_cost": null,
                  "courier": null,
                  "pickup": {
                    "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                    "deadline": "2021-11-01T20:42:00+0330",
                    "image": "https://example.com/restaurants/bm_logo.png",
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "name": "رستوران بزرگمهر",
                    "phone_number": "09123456789"
                  },
                  "courses": [
                    {
                      "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                      "bill_number": "DEL-119",
                      "dropped_off_at": null,
                      "requires_box": false,
                      "id": "7484f530-5e3e-491d-8a4a-9432f6db01d6",
                      "location": {
                        "latitude": 35.737004,
                        "longitude": 51.413569
                      },
                      "manifest_items": [
                        {
                          "name": "پیتزا پپرونی خانواده",
                          "quantity": 2
                        }
                      ],
                      "name": "test name",
                      "payment": {
                        "payment_type": "cash",
                        "price": 0
                      },
                      "phone_number": "09123456789",
                      "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/7484f5305e",
                      "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                      "old_trip_id": "00000000-0000-0000-0000-000000000000"
                    }
                  ],
                  "boost": {
                    "level": 1,
                    "amount": 1000
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "TRIP_ID=\"your-trip-id\"\n\ncurl --request POST \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/$TRIP_ID/round-trip/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\" \\\n  --header \"Content-Type: application/json\" \\\n  --data-raw '{\n  \"is_round_trip\": true\n}'"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ndata = {'is_round_trip': True}\n\ntrip_id = \"your-trip-id\"\n\nresponse = requests.post(\n    f\"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/{trip_id}/round-trip/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n    json=data,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/trip-management/third-party-api/v2/trips/{trip_id}/boost/": {
      "post": {
        "tags": [
          "delivery"
        ],
        "summary": "Boost Trip",
        "operationId": "boost-trip",
        "description": "Add, cancel, or update a trip's boost level by its ID.\n\nYou can only update trip in the `assign_queue` state.\n\nYou can find ID of your trip in the response body of [Create Trip](/api/public/delivery#create-trip) request\n\nResponse body is a serialized trip. For a detailed version of it take a look at the response body\nof [Create Trip](/api/public/delivery#create-trip) request.\n\n### Errors\n| Code | Description |\n|----------------------|-----------------------------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| parse_error | The request body is not a valid JSON string (has syntax error) |\n| invalid_request_body | Request body does not follow the valid format |\n| record_not_found | A trip with the given ID does not belong to your client or doesn't exist at all |\n| invalid_boost_level | This level is not among the current valid levels. Refer to the [valid boost levels](/api/public/delivery#boost-levels). |\n| invalid_trip_state | The boost cannot be added, changed, or cancelled because the trip is no longer in `assign_queue`. |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#boost-trip"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "trip_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The trip id belonging to the authenticated client."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BoostRequest"
              },
              "example": {
                "level": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Trip"
                },
                "example": {
                  "created_at": "2021-11-01T16:59:00+0330",
                  "id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "batch_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "state": "assign_queue",
                  "is_round_trip": false,
                  "picked_up_at": null,
                  "assigned_at": null,
                  "arrived_at": null,
                  "departed_at": null,
                  "area": {
                    "id": "3",
                    "name": "یوسف آباد"
                  },
                  "delivery_cost": null,
                  "courier": null,
                  "pickup": {
                    "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                    "deadline": "2021-11-01T20:42:00+0330",
                    "image": "https://example.com/restaurants/bm_logo.png",
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "name": "رستوران بزرگمهر",
                    "phone_number": "09123456789"
                  },
                  "courses": [
                    {
                      "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                      "bill_number": "DEL-119",
                      "dropped_off_at": null,
                      "requires_box": false,
                      "id": "7484f530-5e3e-491d-8a4a-9432f6db01d6",
                      "location": {
                        "latitude": 35.737004,
                        "longitude": 51.413569
                      },
                      "manifest_items": [
                        {
                          "name": "پیتزا پپرونی خانواده",
                          "quantity": 2
                        }
                      ],
                      "name": "test name",
                      "payment": {
                        "payment_type": "cash",
                        "price": 0
                      },
                      "phone_number": "09123456789",
                      "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/7484f5305e",
                      "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                      "old_trip_id": "00000000-0000-0000-0000-000000000000"
                    }
                  ],
                  "boost": {
                    "level": 1,
                    "amount": 1000
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "TRIP_ID=\"your-trip-id\"\n\ncurl --request POST \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/$TRIP_ID/boost/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\" \\\n  --header \"Content-Type: application/json\" \\\n  --data-raw '{\n  \"level\": 1\n}'"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ndata = {'level': 1}\n\ntrip_id = \"your-trip-id\"\n\nresponse = requests.post(\n    f\"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/{trip_id}/boost/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n    json=data,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/trip-management/third-party-api/v2/trips/{trip_id}/": {
      "put": {
        "tags": [
          "delivery"
        ],
        "summary": "Update Trip",
        "operationId": "update-trip",
        "description": "Updates an existing trip and it's courses.\n\nThis endpoint cannot change `requires_box`. Existing course values are preserved, including when\n`requires_box` is supplied in the update request.\n\nThis endpoint cannot change `is_round_course`. Use [Round Trip](/api/public/delivery#round-trip) to change the\nreturn requirement after creation.\n\nThis endpoint is deprecated. Please refer to other endpoints.\n\nYou can only update trip in the `assign_queue` or `pickup` states.\n\nThe required `boost` field can only be changed or cancelled while the trip is in the\n`assign_queue` state.\n\nPlease note that in this request, the `boost` field is required, in contrast to the [Create Trip](/api/public/delivery#create-trip) request.\n\nYou can find ID of your trip in the response body of [Create Trip](/api/public/delivery#create-trip) request\n\nResponse body is a serialized trip. For a detailed version of it take a look at the response body\nof [Create Trip](/api/public/delivery#create-trip) request.\n\n### Errors\n| Code | Description |\n|--------------------------|----------------------------------------------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| parse_error | The request body is not a valid JSON string (has syntax error) |\n| invalid_request_body | Request body does not follow the valid format |\n| record_not_found | A trip with the given ID does not belong to your client or doesn't exist at all |\n| too_late | Trip's state is later than `pickup` |\n| duplicated_bill_number | There is already a course related to trip with states of (`assign_queue`, `pickup`, `dropoff`) with this bill number |\n| invalid_boost_level | This level is not among the current valid levels. Refer to the [valid boost levels](/api/public/delivery#boost-levels). |\n| invalid_trip_state | The boost cannot be changed or cancelled because the trip is no longer in `assign_queue`. |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#update-trip"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "deprecated": true,
        "parameters": [
          {
            "name": "trip_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The trip id belonging to the authenticated client."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTripRequest"
              },
              "example": {
                "pickup": {
                  "name": "رستوران بزرگمهر",
                  "phone_number": "09123456789",
                  "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                  "image": "https://example.com/restaurants/bm_logo.png",
                  "location": {
                    "latitude": 35.737004,
                    "longitude": 51.413569
                  },
                  "deadline": "2030-01-01T14:00:00+0330"
                },
                "courses": [
                  {
                    "bill_number": "DEL-119",
                    "name": "علی علوی",
                    "phone_number": "09123456789",
                    "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "manifest_items": [
                      {
                        "name": "پیتزا پپرونی خانواده",
                        "quantity": 2
                      }
                    ]
                  }
                ],
                "boost": {
                  "level": 1
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Trip"
                },
                "example": {
                  "id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "batch_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "is_round_trip": false,
                  "created_at": "2021-11-01T16:59:00+0330",
                  "assigned_at": "2021-11-01T17:00:00+0330",
                  "arrived_at": "2021-11-01T17:02:00+0330",
                  "picked_up_at": "2021-11-01T17:04:00+0330",
                  "departed_at": "2021-11-01T17:06:00+0330",
                  "state": "dropoff",
                  "pickup": {
                    "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                    "deadline": "2021-11-01T20:42:00+0330",
                    "image": "https://example.com/restaurants/bm_logo.png",
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "name": "رستوران بزرگمهر",
                    "phone_number": "09123456789"
                  },
                  "area": {
                    "id": "3",
                    "name": "یوسف آباد"
                  },
                  "devlivery_cost": null,
                  "courier": {
                    "image": "https://image.miare.ir/avatars/123456.jpeg",
                    "location": {
                      "latitude": 35.753691,
                      "longitude": 51.332284
                    },
                    "location_updated_at": "2021-11-01T19:10:13+0330",
                    "name": "علی لطفی",
                    "phone_number": "09379187928"
                  },
                  "courses": [
                    {
                      "id": "7484f530-5e3e-491d-8a4a-9432f6db01d6",
                      "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                      "old_trip_id": "00000000-0000-0000-0000-000000000000",
                      "bill_number": "DEL-119",
                      "name": "علی علوی",
                      "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                      "dropped_off_at": null,
                      "requires_box": false,
                      "phone_number": "09123456789",
                      "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/7484f5305e",
                      "location": {
                        "latitude": 35.737004,
                        "longitude": 51.413569
                      },
                      "manifest_items": [
                        {
                          "name": "پیتزا پپرونی خانواده",
                          "quantity": 2
                        }
                      ],
                      "payment": {
                        "payment_type": "cash",
                        "price": 0
                      }
                    }
                  ],
                  "boost": {
                    "level": 1,
                    "amount": 1000
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "TRIP_ID=\"your-trip-id\"\n\ncurl --request PUT \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/$TRIP_ID/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\" \\\n  --header \"Content-Type: application/json\" \\\n  --data-raw '{\n  \"pickup\": {\n    \"name\": \"رستوران بزرگمهر\",\n    \"phone_number\": \"09123456789\",\n    \"address\": \"تهران، صادقیه، بلوار آیت الله کاشانی\",\n    \"image\": \"https://example.com/restaurants/bm_logo.png\",\n    \"location\": {\n      \"latitude\": 35.737004,\n      \"longitude\": 51.413569\n    },\n    \"deadline\": \"2030-01-01T14:00:00+0330\"\n  },\n  \"courses\": [\n    {\n      \"bill_number\": \"DEL-119\",\n      \"name\": \"علی علوی\",\n      \"phone_number\": \"09123456789\",\n      \"address\": \"تهران، خیابان استاد معین، پلاک ۱۲\",\n      \"location\": {\n        \"latitude\": 35.737004,\n        \"longitude\": 51.413569\n      },\n      \"manifest_items\": [\n        {\n          \"name\": \"پیتزا پپرونی خانواده\",\n          \"quantity\": 2\n        }\n      ]\n    }\n  ],\n  \"boost\": {\n    \"level\": 1\n  }\n}'"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ndata = {'pickup': {'name': 'رستوران بزرگمهر',\n            'phone_number': '09123456789',\n            'address': 'تهران، صادقیه، بلوار آیت الله کاشانی',\n            'image': 'https://example.com/restaurants/bm_logo.png',\n            'location': {'latitude': 35.737004, 'longitude': 51.413569},\n            'deadline': '2030-01-01T14:00:00+0330'},\n 'courses': [{'bill_number': 'DEL-119',\n              'name': 'علی علوی',\n              'phone_number': '09123456789',\n              'address': 'تهران، خیابان استاد معین، پلاک ۱۲',\n              'location': {'latitude': 35.737004, 'longitude': 51.413569},\n              'manifest_items': [{'name': 'پیتزا پپرونی خانواده', 'quantity': 2}]}],\n 'boost': {'level': 1}}\n\ntrip_id = \"your-trip-id\"\n\nresponse = requests.put(\n    f\"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/{trip_id}/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n    json=data,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "get": {
        "tags": [
          "delivery"
        ],
        "summary": "Get Trip",
        "operationId": "get-trip-management-third-party-api-v2-trips-trip_id",
        "description": "Returns information about one of your trips indicated by its ID.\n\nYou can find ID of your trip in the response body of [Create Trip](/api/public/delivery#create-trip) request\n\nThe given trip ID must belong to your client.\n\nResponse body is a serialized trip. For a detailed version of it take a look at the response body\nof [Create Trip](/api/public/delivery#create-trip) request.\n\n### Errors\n| Code | Description |\n|----------------------|---------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| parse_error | The request body is not a valid JSON string (has syntax error) |\n| invalid_request_body | Request body does not follow the valid format |\n| record_not_found | A trip with the given ID does not belong to your client or doesn't exist at all |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#get-trip"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "trip_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The trip id belonging to the authenticated client."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Trip"
                },
                "example": {
                  "created_at": "2021-11-01T16:59:00+0330",
                  "id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "batch_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "state": "canceled_by_client",
                  "is_round_trip": false,
                  "picked_up_at": null,
                  "assigned_at": null,
                  "arrived_at": null,
                  "departed_at": null,
                  "area": {
                    "id": "3",
                    "name": "یوسف آباد"
                  },
                  "delivery_cost": null,
                  "courier": null,
                  "pickup": {
                    "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                    "deadline": "2021-11-01T20:42:00+0330",
                    "image": "https://example.com/restaurants/bm_logo.png",
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "name": "رستوران بزرگمهر",
                    "phone_number": "09123456789"
                  },
                  "courses": [
                    {
                      "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                      "bill_number": "DEL-119",
                      "dropped_off_at": null,
                      "requires_box": false,
                      "id": "7484f530-5e3e-491d-8a4a-9432f6db01d6",
                      "location": {
                        "latitude": 35.737004,
                        "longitude": 51.413569
                      },
                      "manifest_items": [
                        {
                          "name": "پیتزا پپرونی خانواده",
                          "quantity": 2
                        }
                      ],
                      "name": "test name",
                      "payment": {
                        "payment_type": "cash",
                        "price": 0
                      },
                      "phone_number": "09123456789",
                      "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/7484f5305e",
                      "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                      "old_trip_id": "00000000-0000-0000-0000-000000000000"
                    }
                  ],
                  "boost": {
                    "level": 1,
                    "amount": 1000
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "TRIP_ID=\"your-trip-id\"\n\ncurl --request GET \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/$TRIP_ID/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ntrip_id = \"your-trip-id\"\n\nresponse = requests.get(\n    f\"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/{trip_id}/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/trip-management/third-party-api/v2/trips/{trip_id}/courses/": {
      "patch": {
        "tags": [
          "delivery"
        ],
        "summary": "Add Course",
        "operationId": "patch-trip-management-third-party-api-v2-trips-trip_id-courses",
        "description": "Adds a new course to the courses of a trip.\n\nThis endpoint ignores `is_round_course`. Use [Round Trip](/api/public/delivery#round-trip) to change the return\nrequirement after creation.\n\nWhen box requirements are enabled, adding a course with `requires_box: true` to an assigned\ntrip requires the currently assigned courier to be compatible. Otherwise the request is rejected with\nHTTP 409 (`driver_box_required`); the course is not added and the existing assignment is unchanged.\n\nYou can only add a course to a trip in the `assign_queue` or `pickup` states.\n\nThe new course's `payment.price` is checked against the same per-course declared-value\nlimit described in [Create Trip](/api/public/delivery#create-trip). If it exceeds the limit, the request\nis rejected and the course is not added. A value equal to the limit is allowed.\n\nYou can find ID of your trip in the response body of [Create Trip](/api/public/delivery#create-trip) request\n\nResponse body is a serialized trip. For a detailed version of it take a look at the response body\nof [Create Trip](/api/public/delivery#create-trip) request.\n\n### Errors\n| Code | Description |\n|------------------------|----------------------------------------------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| parse_error | The request body is not a valid JSON string (has syntax error) |\n| invalid_request_body | Request body does not follow the valid format |\n| record_not_found | A trip with the given ID does not belong to your client or doesn't exist at all |\n| too_late | Trip's state is later than `pickup` |\n| duplicated_bill_number | There is already a course related to trip with states of (`assign_queue`, `pickup`, `dropoff`) with this bill number |\n| delivery_code_required | `delivery_code` is required when the client/source `proof_of_delivery_policy` is `third_party` |\n| delivery_code_invalid | `delivery_code` was provided but is not a valid 5-digit code. Leading/trailing whitespace is ignored before validation |\n| driver_box_required | HTTP 409. The assigned courier cannot carry a course requiring a box. The course is not added and the existing assignment is unchanged. |\n| declared_package_value_too_high | HTTP 400. The new course's `payment.price` exceeds the effective declared-value cap for the client. The course is not added. |\n\nThe cap shown is illustrative; use `code` for error handling, as `detail` may change.",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#add-course"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "trip_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The trip id belonging to the authenticated client."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddCourseRequest"
              },
              "example": {
                "bill_number": "DEL-120",
                "name": "علی علوی",
                "phone_number": "09123456789",
                "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                "delivery_code": "98765",
                "requires_box": false,
                "location": {
                  "latitude": 35.737004,
                  "longitude": 51.413569
                },
                "manifest_items": [
                  {
                    "name": "پیتزا پپرونی خانواده",
                    "quantity": 2
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Trip"
                },
                "example": {
                  "id": "8e209688-19c9-4982-a755-517408b6a29f",
                  "batch_id": "8e209688-19c9-4982-a755-517408b6a29f",
                  "created_at": "2021-11-01T18:44:19+0330",
                  "picked_up_at": null,
                  "state": "assign_queue",
                  "assigned_at": null,
                  "arrived_at": null,
                  "departed_at": null,
                  "delivery_cost": null,
                  "courier": null,
                  "pickup": {
                    "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                    "deadline": "2021-11-01T20:42:00+0330",
                    "image": "https://example.com/restaurants/bm_logo.png",
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "name": "رستوران بزرگمهر",
                    "phone_number": "09123456789"
                  },
                  "area": {
                    "id": "3",
                    "name": "یوسف آباد"
                  },
                  "courses": [
                    {
                      "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                      "bill_number": "DEL-120",
                      "dropped_off_at": null,
                      "requires_box": false,
                      "id": "c57cb6bc-e1c2-404a-a0d2-a54881fe96ec",
                      "location": {
                        "latitude": 35.737004,
                        "longitude": 51.413569
                      },
                      "manifest_items": [
                        {
                          "name": "پیتزا پپرونی خانواده",
                          "quantity": 2
                        }
                      ],
                      "name": "علی علوی",
                      "payment": {
                        "payment_type": "cash",
                        "price": 0
                      },
                      "phone_number": "09123456789",
                      "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/c57cb6bce1",
                      "trip_id": "8e209688-19c9-4982-a755-517408b6a29f",
                      "old_trip_id": "00000000-0000-0000-0000-000000000000"
                    }
                  ],
                  "boost": {
                    "level": 1,
                    "amount": 1000
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, including declared_package_value_too_high. No trip/course is created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "driver_box_required: the assigned courier is incompatible. The course and assignment are unchanged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "TRIP_ID=\"your-trip-id\"\n\ncurl --request PATCH \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/$TRIP_ID/courses/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\" \\\n  --header \"Content-Type: application/json\" \\\n  --data-raw '{\n  \"bill_number\": \"DEL-120\",\n  \"name\": \"علی علوی\",\n  \"phone_number\": \"09123456789\",\n  \"address\": \"تهران، خیابان استاد معین، پلاک ۱۲\",\n  \"delivery_code\": \"98765\",\n  \"requires_box\": false,\n  \"location\": {\n    \"latitude\": 35.737004,\n    \"longitude\": 51.413569\n  },\n  \"manifest_items\": [\n    {\n      \"name\": \"پیتزا پپرونی خانواده\",\n      \"quantity\": 2\n    }\n  ]\n}'"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ndata = {'bill_number': 'DEL-120',\n 'name': 'علی علوی',\n 'phone_number': '09123456789',\n 'address': 'تهران، خیابان استاد معین، پلاک ۱۲',\n 'delivery_code': '98765',\n 'requires_box': False,\n 'location': {'latitude': 35.737004, 'longitude': 51.413569},\n 'manifest_items': [{'name': 'پیتزا پپرونی خانواده', 'quantity': 2}]}\n\ntrip_id = \"your-trip-id\"\n\nresponse = requests.patch(\n    f\"https://ws.staging.miare.ir/trip-management/third-party-api/v2/trips/{trip_id}/courses/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n    json=data,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/trip-management/third-party-api/v2/courses/{course_id}/": {
      "delete": {
        "tags": [
          "delivery"
        ],
        "summary": "Remove Course",
        "operationId": "delete-trip-management-third-party-api-v2-courses-course_id",
        "description": "Removes the course indicated by the given ID from the courses of its trip.\n\nYou can only remove courses from a trip in the `assign_queue` or `pickup` states which has at least **two** courses.\n\nYou can find ID of your course in the response body of [Create Trip](/api/public/delivery#create-trip) or [Add Course](/api/public/delivery#add-course) requests.\n\nThe given course ID must belong to your client.\n\nResponse body is a serialized trip. For a detailed version of it take a look at the response body\nof [Create Trip](/api/public/delivery#create-trip) request.\n\n### Errors\n| Code | Description |\n|----------------------|-----------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| parse_error | The request body is not a valid JSON string (has syntax error) |\n| invalid_request_body | Request body does not follow the valid format |\n| record_not_found | A course with the given ID does not belong to your client or doesn't exist at all |\n| single_course | The course belongs to a trip that has only one course |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#remove-course"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "course_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The course id belonging to the authenticated client."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Trip"
                },
                "example": {
                  "created_at": "2021-11-01T16:59:00+0330",
                  "id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "batch_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "state": "canceled_by_client",
                  "picked_up_at": null,
                  "assigned_at": null,
                  "arrived_at": null,
                  "departed_at": null,
                  "area": {
                    "id": "3",
                    "name": "یوسف آباد"
                  },
                  "delivery_cost": null,
                  "courier": null,
                  "pickup": {
                    "address": "تهران، صادقیه، بلوار آیت الله کاشانی",
                    "deadline": "2021-11-01T20:42:00+0330",
                    "image": "https://example.com/restaurants/bm_logo.png",
                    "location": {
                      "latitude": 35.737004,
                      "longitude": 51.413569
                    },
                    "name": "رستوران بزرگمهر",
                    "phone_number": "09123456789"
                  },
                  "courses": [
                    {
                      "address": "تهران، خیابان استاد معین، پلاک ۱۲",
                      "bill_number": "DEL-119",
                      "dropped_off_at": null,
                      "requires_box": false,
                      "id": "7484f530-5e3e-491d-8a4a-9432f6db01d6",
                      "location": {
                        "latitude": 35.737004,
                        "longitude": 51.413569
                      },
                      "manifest_items": [
                        {
                          "name": "پیتزا پپرونی خانواده",
                          "quantity": 2
                        }
                      ],
                      "name": "test name",
                      "payment": {
                        "payment_type": "cash",
                        "price": 0
                      },
                      "phone_number": "09123456789",
                      "tracking_url": "https://www.staging.miare.ir/p/trip_watching/#!/7484f5305e",
                      "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                      "old_trip_id": "00000000-0000-0000-0000-000000000000"
                    }
                  ],
                  "boost": {
                    "level": 1,
                    "amount": 1000
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "COURSE_ID=\"your-course-id\"\n\ncurl --request DELETE \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/courses/$COURSE_ID/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ncourse_id = \"your-course-id\"\n\nresponse = requests.delete(\n    f\"https://ws.staging.miare.ir/trip-management/third-party-api/v2/courses/{course_id}/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/trip-management/third-party-api/v2/boost-levels/": {
      "get": {
        "tags": [
          "delivery"
        ],
        "summary": "Boost Levels",
        "operationId": "boost-levels",
        "description": "Returns the current valid boosting levels along with the corresponding price increase for each level in\nTomans (IRT).\n\nPlease note that boosting levels are dynamic and set by the commercial team, though they change infrequently. It is\nessential to periodically fetch them from this endpoint.\n\nBoost levels always start at 1 and are continuous. If you see a level 3, levels 1 and 2 are also available.\n\nLevel 0 is not included in this list but can be used in requests and updates to cancel a boost.\n\nBoost availability is configured separately for each account. Receiving this list does not mean that\nBoosting is enabled for your account; Boost requests from accounts without access are rejected.\n\nThe response is an array of all the current available levels.\n\nThe details of the properties for each object are as follows:\n\n### Errors\n| Code | Description |\n|-------------------|-----------------------------|\n| not_authenticated | Token is missing or invalid |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#boost-levels"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BoostLevel"
                  }
                },
                "example": [
                  {
                    "level": 1,
                    "amount": 1000
                  },
                  {
                    "level": 2,
                    "amount": 2000
                  },
                  {
                    "level": 3,
                    "amount": 3000
                  }
                ]
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "curl --request GET \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/boost-levels/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\nresponse = requests.get(\n    \"https://ws.staging.miare.ir/trip-management/third-party-api/v2/boost-levels/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/support/third-party-api/v2/problems/": {
      "get": {
        "tags": [
          "support"
        ],
        "summary": "List Problems",
        "operationId": "list-problems",
        "description": "Returns list of Miare problems. Each `issue` is categorized based on its `problem`. API clients\nshould store a mapping\nof Miare's problems and theirs.\n\nThe response is an array of all the problems you may face in your webhook calls.\nThe details about properties of each object is as follows:\n\n### Errors\n| Code | Description |\n|-------------------|-----------------------------|\n| not_authenticated | Token is missing or invalid |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#list-problems"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Problem"
                  }
                },
                "example": [
                  {
                    "id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
                    "title": "مجموعه سفارش را به کوریر تحویل نداده است",
                    "reporter_type": "miare",
                    "description_required": false
                  },
                  {
                    "id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
                    "title": "مشتری سفارش را تحویل نگرفته است",
                    "reporter_type": "client",
                    "description_required": true
                  }
                ]
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "curl --request GET \"https://ws.staging.miare.ir/support/third-party-api/v2/problems/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\nresponse = requests.get(\n    \"https://ws.staging.miare.ir/support/third-party-api/v2/problems/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/support/third-party-api/v2/issues/": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Report Issue",
        "operationId": "report-issue",
        "description": "Creates an issue with given data.\n\n**note:** both **trip_id** and **course_id** can **NOT** be null at the same time. if both are\nprovided, **trip_id** will be considered and **course_id** will be ignored.\n\nThe success response is the serialized created issue.\nThe details about properties of each object is as follows:\n\n### Errors\n| Code | Description |\n|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| trip_not_ongoing | The trip is not in a situation to be able to accept new issues. Currently the trips requested before 3 hours from now are considered as not ongoing |\n| forbidden_problem | The relative problem of `problem_id` is not `for_reporter_type` of client |\n| description_required | The relative problem of `problem_id` is forcing `description` field on it's issues |\n| long_description | The description value of the request is longer than the defined limit |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#report-issue"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportIssueRequest"
              },
              "example": {
                "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                "problem_id": "728cfd38-3267-4bd0-bcec-c4fc904cebda"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportIssue"
                },
                "example": {
                  "id": "ccba8f45-6ef6-409f-a1ee-453219aaa04f",
                  "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "problem_id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
                  "reported_at": "2021-11-01T18:44:19+0330",
                  "reporter_type": "client",
                  "resolved_at": null,
                  "resolver_type": null,
                  "resolve_description": null,
                  "picked_at": null,
                  "picker_type": null,
                  "state": "reported",
                  "messages": [
                    {
                      "id": "9ad24b31-8f1e-4c5e-b488-b715b2825792",
                      "created_at": "2021-11-02T14:48:18+0330",
                      "sender_type": "miare",
                      "type": "text",
                      "message": "سلام! پشتیبان میاره هستم. ",
                      "image_url": ""
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "curl --request POST \"https://ws.staging.miare.ir/support/third-party-api/v2/issues/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\" \\\n  --header \"Content-Type: application/json\" \\\n  --data-raw '{\n  \"trip_id\": \"b3951922-4f3e-43dc-a051-a9b765b2cbe7\",\n  \"problem_id\": \"728cfd38-3267-4bd0-bcec-c4fc904cebda\"\n}'"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ndata = {'trip_id': 'b3951922-4f3e-43dc-a051-a9b765b2cbe7',\n 'problem_id': '728cfd38-3267-4bd0-bcec-c4fc904cebda'}\n\nresponse = requests.post(\n    \"https://ws.staging.miare.ir/support/third-party-api/v2/issues/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n    json=data,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      },
      "get": {
        "tags": [
          "support"
        ],
        "summary": "List Issues",
        "operationId": "list-issues",
        "description": "Returns issues of your trips matching the given conditions, including courier-reported\nissues delegated to your account.\n\nTo retrieve a reported issue, filter by its trip ID and match `id` in the results.\nThere is no single-issue GET endpoint. Use `resolved=false` to list only open issues.\n\nServer might not have or decide not to send you as many result items as `limit` but it never sends you more than that.\n\n### Errors\n| Code | Description |\n|-------------------|-----------------------------|\n| not_authenticated | Token is missing or invalid |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#list-issues"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "reporter_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "**Filter:** The value of the user type that has reported the issue"
          },
          {
            "name": "picker_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "**Filter:** The value of the user type that has picked the issue"
          },
          {
            "name": "reported_from_datetime",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/Timestamp"
            },
            "description": "**Filter:** Minimum acceptable value for issue's `reported_at` field. This filter is **inclusive**"
          },
          {
            "name": "reported_to_datetime",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/Timestamp"
            },
            "description": "**Filter:** Maximum acceptable value for issue's `reported_at` field. This filter is **inclusive**"
          },
          {
            "name": "resolved",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "**Filter:** The value of issues's `resolved_at` comparing to `null`"
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "**Filter:** The value of issues's `state`. Acceptable values of state are available [here](/concepts#issue)"
          },
          {
            "name": "picked",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "**Filter:** The value of issues's `picked_at` comparing to `null`"
          },
          {
            "name": "trip_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "**Filter:** The UUID of the trip that the issue is reported for (one trip per request)"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Give results excluding the first **offset** number of objects"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 0
            },
            "description": "Give _at most_ **limit** number of results. The default value is 100"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportIssuePage"
                },
                "example": {
                  "data": [
                    {
                      "id": "ccba8f45-6ef6-409f-a1ee-453219aaa04f",
                      "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                      "problem_id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
                      "reported_at": "2026-11-19T13:00:00+0330",
                      "reporter_type": "miare",
                      "resolved_at": null,
                      "resolver_type": null,
                      "resolve_description": null,
                      "picked_at": null,
                      "picker_type": null,
                      "state": "reported",
                      "messages": [
                        {
                          "id": "9ad24b31-8f1e-4c5e-b488-b715b2825792",
                          "created_at": "2026-11-19T13:00:00+0330",
                          "sender_type": "miare",
                          "type": "text",
                          "message": "بسته‌بندی سفارش آسیب دیده است.",
                          "image_url": ""
                        }
                      ],
                      "description": "بسته‌بندی سفارش آسیب دیده است.",
                      "resolution_actions": [
                        "cancel_trip",
                        "reject_issue"
                      ],
                      "resolution_deadline": "2026-11-19T13:10:00+0330",
                      "resolution_action": null
                    }
                  ],
                  "next": "",
                  "previous": "",
                  "total_count": 1
                }
              }
            }
          },
          "400": {
            "description": "Invalid filters or pagination.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Account is not an eligible API v2 integration client.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "curl --request GET \"https://ws.staging.miare.ir/support/third-party-api/v2/issues/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\nresponse = requests.get(\n    \"https://ws.staging.miare.ir/support/third-party-api/v2/issues/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/support/third-party-api/v2/issues/{issue_id}/resolve/": {
      "patch": {
        "tags": [
          "support"
        ],
        "summary": "Resolve Issue",
        "operationId": "resolve-issue",
        "description": "Resolve an issue delegated to your account by choosing one of its offered actions.\nThe action runs synchronously; HTTP `200` returns the updated [Issue object](/guides/support#issue-object).\n\nFor ordinary, non-delegated issues, omit `resolution_action`; the existing rule\nthat clients can resolve only their own reports still applies.\n\nRepeating the same action and explanation succeeds without applying the action again.\nA different decision, or an issue already closed by support, the courier or automatic handling,\nreturns a conflict. Submit new commands before `resolution_deadline`.\n\nThe courier conversation reply is limited to 1024 characters. The full trimmed\nexplanation remains available in `resolve_description`.\n\nThe complete response schema is the [Issue object](/guides/support#issue-object).\nCompletion is also sent as `trip_issue_resolved`.\n\nErrors contain `code` and `detail` properties.\n\n### Errors\n| HTTP status | Code | Description |\n|-------------|------|-------------|\n| 401 | `not_authenticated` | Token is missing or invalid. |\n| 403 | `not_owner` | The issue belongs to another client, or an ordinary issue was not reported by you. |\n| 403 | `delegated_issue_requires_resolution_action` | A delegated issue was submitted without `resolution_action`. |\n| 404 | `issue_not_found` | No issue exists for the supplied UUID. |\n| 400 | `invalid_resolution_action` | Unknown action key or action not offered for this issue. |\n| 409 | `issue_not_delegated` | A resolution action was submitted for an ordinary issue. |\n| 409 | `delegation_deadline_expired` | A new client decision arrived after its deadline. |\n| 409 | `resolution_conflict` | The issue has already been resolved with a different decision or by another party. |\n| 403 | `already_resolved` | An ordinary issue has already been resolved. |\n\n`cancel_trip` can also return errors from [Cancel Trip](/api/public/delivery#cancel-trip), such as a\ntrip that can no longer be canceled. A failed action leaves the issue unresolved.",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#resolve-issue"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "issue_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The issue id belonging to the authenticated client."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ResolveDelegatedIssueRequest"
                  },
                  {
                    "$ref": "#/components/schemas/ResolveOwnIssueRequest"
                  }
                ]
              },
              "examples": {
                "cancel_trip": {
                  "value": {
                    "resolution_action": "cancel_trip"
                  }
                },
                "reject_issue": {
                  "value": {
                    "resolution_action": "reject_issue"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportIssue"
                },
                "example": {
                  "id": "ccba8f45-6ef6-409f-a1ee-453219aaa04f",
                  "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "problem_id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
                  "reported_at": "2026-11-19T13:00:00+0330",
                  "reporter_type": "miare",
                  "resolved_at": "2026-11-19T13:02:00+0330",
                  "resolver_type": "client",
                  "resolve_description": null,
                  "picked_at": null,
                  "picker_type": null,
                  "state": "resolved",
                  "messages": [
                    {
                      "id": "9ad24b31-8f1e-4c5e-b488-b715b2825792",
                      "created_at": "2026-11-19T13:00:00+0330",
                      "sender_type": "miare",
                      "type": "text",
                      "message": "بسته‌بندی سفارش آسیب دیده است.",
                      "image_url": ""
                    },
                    {
                      "id": "d1c03c54-1b27-4ab7-ae72-a48046cc99bb",
                      "created_at": "2026-11-19T13:02:00+0330",
                      "sender_type": "client",
                      "type": "text",
                      "message": "ادعای شما رد شد.",
                      "image_url": ""
                    }
                  ],
                  "description": "بسته‌بندی سفارش آسیب دیده است.",
                  "resolution_actions": [
                    "cancel_trip",
                    "reject_issue"
                  ],
                  "resolution_deadline": "2026-11-19T13:10:00+0330",
                  "resolution_action": "reject_issue"
                }
              }
            }
          },
          "400": {
            "description": "invalid_resolution_action: unknown action or not offered for the issue; malformed requests also return validation errors.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "not_authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "not_owner, delegated_issue_requires_resolution_action, or already_resolved for ordinary issues.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "issue_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "issue_not_delegated, delegation_deadline_expired, resolution_conflict, or existing cancellation eligibility errors.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "ISSUE_ID=\"your-issue-id\"\n\ncurl --request PATCH \"https://ws.staging.miare.ir/support/third-party-api/v2/issues/$ISSUE_ID/resolve/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\" \\\n  --header \"Content-Type: application/json\" \\\n  --data-raw '{\n  \"resolution_action\": \"reject_issue\"\n}'"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ndata = {'resolution_action': 'reject_issue'}\n\nissue_id = \"your-issue-id\"\n\nresponse = requests.patch(\n    f\"https://ws.staging.miare.ir/support/third-party-api/v2/issues/{issue_id}/resolve/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n    json=data,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/support/third-party-api/v2/issues/{issue_id}/pick/": {
      "patch": {
        "tags": [
          "support"
        ],
        "summary": "Pick Issue",
        "operationId": "pick-issue",
        "description": "Picks an issue that means the issue is being checked by the client.\nDelegated issues do not use this endpoint; submit a [resolution action](/api/public/support#resolve-issue) directly.\n\nThe success response is the serialized updated issue. For a detailed version of it take a look at\nthe response body\nof [Report Issue](/api/public/support#report-issue) request.\n\n### Errors\n| Code | Description |\n|-------------------|-------------------------------|\n| not_authenticated | Token is missing or invalid |\n| already_resolved | The issue is already resolved |\n| already_picked | The issue is already picked |\n| issue_delegated_to_client | Use the resolve endpoint with a resolution action for a delegated issue. |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#pick-issue"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "issue_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The issue id belonging to the authenticated client."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportIssue"
                },
                "example": {
                  "id": "ccba8f45-6ef6-409f-a1ee-453219aaa04f",
                  "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "problem_id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
                  "reported_at": "2021-11-01T18:44:19+0330",
                  "reporter_type": "client",
                  "resolved_at": null,
                  "resolver_type": null,
                  "resolve_description": null,
                  "picked_at": "2021-11-02T14:48:18+0330",
                  "picker_type": "client",
                  "state": "picked",
                  "messages": []
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "ISSUE_ID=\"your-issue-id\"\n\ncurl --request PATCH \"https://ws.staging.miare.ir/support/third-party-api/v2/issues/$ISSUE_ID/pick/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\nissue_id = \"your-issue-id\"\n\nresponse = requests.patch(\n    f\"https://ws.staging.miare.ir/support/third-party-api/v2/issues/{issue_id}/pick/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/support/third-party-api/v2/issues/{issue_id}/messages/": {
      "patch": {
        "tags": [
          "support"
        ],
        "summary": "Append Message",
        "operationId": "append-message",
        "description": "Appends a new message to an unresolved issue.\n\nCurrently only messages with text type are supported.\n\nThe success response is the serialized created issue. For a detailed version of it take a look at\nthe response body\nof [Report Issue](/api/public/support#report-issue) request.\n\n### Errors\n| Code | Description |\n|-------------------|-------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| already_resolved | The issue is already resolved |\n| long_message | The message value of the request is longer than the defined limit |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#append-message"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "issue_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The issue id belonging to the authenticated client."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppendMessageRequest"
              },
              "example": {
                "message": "با مشتری نهایی تماس گرفته شد و گفتن که به لابی تحویل بدین"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportIssue"
                },
                "example": {
                  "id": "ccba8f45-6ef6-409f-a1ee-453219aaa04f",
                  "trip_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "problem_id": "728cfd38-3267-4bd0-bcec-c4fc904cebda",
                  "reported_at": "2021-11-01T18:44:19+0330",
                  "reporter_type": "client",
                  "resolved_at": null,
                  "resolver_type": null,
                  "resolve_description": null,
                  "picked_at": null,
                  "picker_type": null,
                  "state": "reported",
                  "messages": [
                    {
                      "id": "9c212393-8ac3-4917-ac7a-844f76c361f2",
                      "created_at": "2021-11-01T18:46:19+0330",
                      "type": "text",
                      "message": "با مشتری نهایی تماس گرفته شد و گفتن که به لابی تحویل بدین",
                      "sender_type": "client",
                      "image_url": ""
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "ISSUE_ID=\"your-issue-id\"\n\ncurl --request PATCH \"https://ws.staging.miare.ir/support/third-party-api/v2/issues/$ISSUE_ID/messages/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\" \\\n  --header \"Content-Type: application/json\" \\\n  --data-raw '{\n  \"message\": \"با مشتری نهایی تماس گرفته شد و گفتن که به لابی تحویل بدین\"\n}'"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ndata = {'message': 'با مشتری نهایی تماس گرفته شد و گفتن که به لابی تحویل بدین'}\n\nissue_id = \"your-issue-id\"\n\nresponse = requests.patch(\n    f\"https://ws.staging.miare.ir/support/third-party-api/v2/issues/{issue_id}/messages/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n    json=data,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/area/third-party-api/v2/areas/": {
      "get": {
        "tags": [
          "area"
        ],
        "summary": "List Areas",
        "operationId": "get-area-third-party-api-v2-areas",
        "description": "Returns list of Miare areas and your usage of concurrency in each area.\n\nThe response is an array of all of the active areas in the Miare whether you have any trips or\nconcurrency in it or not.\nThe details about properties of each objects is as follows:\n\nBased on [GeoJson.org](https://geojson.org/geojson-spec.html#positions)'s convention, the order of coordinates in the coordinates inner arrays is **longitude**, **latitude**.\n\n### Errors\n| Code | Description |\n|-------------------|-----------------------------|\n| not_authenticated | Token is missing or invalid |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#list-areas"
        },
        "servers": [
          {
            "url": "https://ws.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://ws.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AreaInfo"
                  }
                },
                "example": [
                  {
                    "id": 27,
                    "max_ongoing_trips": 20,
                    "name": "پونک",
                    "ongoing_trips": 8,
                    "polygon": {
                      "type": "Polygon",
                      "coordinates": [
                        [
                          [
                            51.3318602487183,
                            35.7511077950424
                          ],
                          [
                            51.3329908968811,
                            35.7402265889212
                          ],
                          [
                            51.3408319127502,
                            35.7456830619354
                          ],
                          [
                            51.3318602487183,
                            35.7511077950424
                          ]
                        ]
                      ]
                    }
                  }
                ]
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "curl --request GET \"https://ws.staging.miare.ir/area/third-party-api/v2/areas/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\nresponse = requests.get(\n    \"https://ws.staging.miare.ir/area/third-party-api/v2/areas/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/api/accounting/estimate/price/": {
      "get": {
        "tags": [
          "accounting"
        ],
        "summary": "Estimate Price",
        "operationId": "estimate-price",
        "description": "Estimates the delivery cost of the course based on the distance between the given source and\ndestination.\n\nThe output price is not accurate; it might be affected by the applied conditions at the request time.\n\nThe output price is only the **course**'s cost. The final cost includes a **trip** cost as well.\nFor more information contant the sales team.\n\nThis estimate does **not** include Boost. Include the `amount` of the selected boost\nlevel when calculating the total delivery cost, together with the other trip-level costs described above.\n\n### Errors\n| Code | Description |\n|-------------------|--------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| invalid | The given query params are not valid |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#estimate-price"
        },
        "servers": [
          {
            "url": "https://www.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://www.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "source",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Latitude and Longitude of the source of the course. The **order** matters"
          },
          {
            "name": "destination",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Latitude and Longitude of the destination of the course. The **order** matters"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Estimate"
                },
                "example": {
                  "price": 5000,
                  "status": "ok",
                  "area_coverage": true
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "curl --request GET \"https://www.staging.miare.ir/api/accounting/estimate/price/?source=35.737004,51.413569&destination=35.740000,51.420000\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\nresponse = requests.get(\n    \"https://www.staging.miare.ir/api/accounting/estimate/price/?source=35.737004,51.413569&destination=35.740000,51.420000\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/api/accounting/sellers/{seller_id}/": {
      "put": {
        "tags": [
          "accounting"
        ],
        "summary": "Register or Update Seller",
        "operationId": "register-or-update-seller",
        "description": "Registers the legal identity of a seller for proxy invoicing, or updates an existing seller\nwith the same `seller_id`. Seller identifiers are unique within the authenticated client.\n\nThis endpoint is available only for clients with proxy invoicing enabled. Register the seller\nbefore using its ID as `pickup.seller_id` in the\n[Create Trip](/api/public/delivery#create-trip) request.\n\nBoth creation and update return HTTP 201. When updating, omitted optional fields keep their\nexisting values; sending an optional field as `null` clears it when validation permits.\n\n### Errors\n| Code | Description |\n|-----------------------|------------------------------------------------------------------------------------------------------|\n| not_authenticated | Token is missing or invalid |\n| invalid_request_body | Request body or seller legal data is invalid |\n| not_found | Proxy invoicing is not enabled for the authenticated client |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#register-or-update-seller"
        },
        "servers": [
          {
            "url": "https://www.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://www.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "seller_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 64
            },
            "description": "The seller id belonging to the authenticated client."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SellerRequest"
              },
              "example": {
                "person_type": "legal",
                "name": "فروشگاه نمونه",
                "national_id": "14001234567",
                "registration_number": "12345",
                "economic_id": "411111111111",
                "address": "تهران، نشانی فروشگاه",
                "postal_code": "1234567890",
                "phone_number": "02112345678"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Seller"
                },
                "example": {
                  "seller_id": "nearby-seller-123",
                  "person_type": "legal",
                  "name": "فروشگاه نمونه",
                  "national_id": "14001234567",
                  "registration_number": "12345",
                  "economic_id": "411111111111",
                  "address": "تهران، نشانی فروشگاه",
                  "postal_code": "1234567890",
                  "phone_number": "02112345678",
                  "created_at": "2026-08-17T10:00:00+0330",
                  "updated_at": "2026-08-17T10:00:00+0330"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "SELLER_ID=\"nearby-seller-123\"\n\ncurl --request PUT \"https://www.staging.miare.ir/api/accounting/sellers/$SELLER_ID/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\" \\\n  --header \"Content-Type: application/json\" \\\n  --data-raw '{\n  \"person_type\": \"legal\",\n  \"name\": \"فروشگاه نمونه\",\n  \"national_id\": \"14001234567\",\n  \"registration_number\": \"12345\",\n  \"economic_id\": \"411111111111\",\n  \"address\": \"تهران، نشانی فروشگاه\",\n  \"postal_code\": \"1234567890\",\n  \"phone_number\": \"02112345678\"\n}'"
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\ndata = {'person_type': 'legal',\n 'name': 'فروشگاه نمونه',\n 'national_id': '14001234567',\n 'registration_number': '12345',\n 'economic_id': '411111111111',\n 'address': 'تهران، نشانی فروشگاه',\n 'postal_code': '1234567890',\n 'phone_number': '02112345678'}\n\nseller_id = \"nearby-seller-123\"\n\nresponse = requests.put(\n    f\"https://www.staging.miare.ir/api/accounting/sellers/{seller_id}/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n    json=data,\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/api/accounting/financial-details/{batch_id}/invoice/": {
      "get": {
        "tags": [
          "accounting"
        ],
        "summary": "Get Trip Invoice",
        "operationId": "get-trip-invoice",
        "description": "Returns the latest available proxy-invoice revision for a batch, or a specific revision when\nrequested. The original invoice is revision `0`; later adjustments use increasing revision numbers.\n\nThis endpoint is available only for clients with proxy invoicing enabled. The `batch_id`\nmust belong to the authenticated client. Omit `revision` to request the latest revision.\n\nThe endpoint is read-only. While an invoice is being generated, poll again after the number of\nseconds returned in `retry_after` or the `Retry-After` response header.\n\n### Errors\n| HTTP status | Description |\n|-------------|---------------------------------------------------------------------------------------------------------------|\n| 400 | `revision` is not a non-negative integer |\n| 401 | Token is missing or invalid |\n| 404 | Proxy invoicing is disabled, or the batch is unknown or belongs to another client |\n| 409 | The batch belongs to the client, but no invoice exists or the requested revision is unavailable |\n| 503 | Invoice generation reached a terminal failure |",
        "externalDocs": {
          "description": "Original Miare integration documentation",
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#get-trip-invoice"
        },
        "servers": [
          {
            "url": "https://www.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://www.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The batch id belonging to the authenticated client."
          },
          {
            "name": "revision",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            },
            "description": "Non-negative revision number. Use `0` for the original; omit it for the latest."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceReady"
                },
                "example": {
                  "status": "ready",
                  "batch_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "revision": 2,
                  "revisions_count": 2,
                  "invoice_number": "NBY-1405-40939419-R02",
                  "document_type": "adjustment",
                  "download_url": "https://storage.example.com/private/invoices/NBY-1405-40939419-R02.pdf?...",
                  "expires_at": "2026-08-17T10:05:00+0330"
                }
              }
            }
          },
          "202": {
            "description": "Invoice generation is in progress; poll after retry_after seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceProcessing"
                },
                "example": {
                  "status": "processing",
                  "batch_id": "b3951922-4f3e-43dc-a051-a9b765b2cbe7",
                  "revision": 2,
                  "revisions_count": 2,
                  "retry_after": 5
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds before polling again.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "400": {
            "description": "revision must be a non-negative integer."
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Proxy invoicing is disabled or the batch is unknown or belongs to another client."
          },
          "409": {
            "description": "No invoice exists or the requested revision is unavailable."
          },
          "503": {
            "description": "Invoice generation reached a terminal failure."
          },
          "default": {
            "description": "Application error. Handle code; detail is developer-facing text and can change. See the error codes above.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-code-samples": [
          {
            "lang": "shell",
            "label": "cURL",
            "source": "BATCH_ID=\"your-batch-id\"\n\ncurl --request GET \"https://www.staging.miare.ir/api/accounting/financial-details/$BATCH_ID/invoice/\" \\\n  --header \"Authorization: Token $MIARE_TOKEN\""
          },
          {
            "lang": "python",
            "label": "Python",
            "source": "import os\nimport requests\n\nbatch_id = \"your-batch-id\"\n\nresponse = requests.get(\n    f\"https://www.staging.miare.ir/api/accounting/financial-details/{batch_id}/invoice/\",\n    headers={\"Authorization\": f\"Token {os.environ['MIARE_TOKEN']}\"},\n)\nresponse.raise_for_status()\nprint(response.json())"
          }
        ]
      }
    },
    "/api/accounting/financial-detail/{batch_id}/": {
      "get": {
        "tags": [
          "accounting"
        ],
        "summary": "Get Financial Detail",
        "operationId": "get-financial-detail",
        "description": "Recover the latest financial snapshot for a batch with your API token. Available only for enabled accounts. This returns the financial webhook fields without event. Use the complete financials.total_cost as authoritative; changes is cumulative and must not be added again. Invoice PDF availability is independent.",
        "servers": [
          {
            "url": "https://www.miare.ir",
            "description": "Production"
          },
          {
            "url": "https://www.staging.miare.ir",
            "description": "Staging"
          }
        ],
        "parameters": [
          {
            "name": "batch_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FinancialDetail"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown batch or financial data is not yet available."
          }
        },
        "externalDocs": {
          "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md#financial-events"
        }
      }
    }
  },
  "security": [
    {
      "auth": []
    }
  ],
  "x-documentation-source": {
    "url": "https://git.miare.ir/miare/api-docs/-/blob/696d58bf333cee875ad834836d3f5bacd0e492a0/slate/source/index.html.md",
    "sha256": "97ccf84ab08faa9f57df9bbf959c9a940274c5843b5243b503f22f597329aa62"
  }
}
