{
  "openapi": "3.1.0",
  "info": {
    "title": "MyTicket Partner API",
    "version": "1.0.0",
    "description": "Sell your cinema's MyTicket shows from your own website, app or software. Guide: /developers on the MyTicket website. Errors are RFC 9457-style `Problem` documents with stable `type` codes."
  },
  "servers": [
    {
      "url": "http://localhost:3000"
    }
  ],
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "example": "seat_unavailable"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "fields": {
            "type": "object",
            "additionalProperties": {}
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "type",
          "title",
          "status"
        ]
      },
      "Hold": {
        "type": "object",
        "properties": {
          "hold_id": {
            "type": "string",
            "format": "uuid"
          },
          "showing_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "items": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "seat"
                      ]
                    },
                    "seat_key": {
                      "type": "string"
                    },
                    "pool_id": {
                      "type": "null"
                    },
                    "name_ar": {
                      "type": "null"
                    },
                    "category_id": {
                      "type": "string"
                    },
                    "price_iqd": {
                      "type": "integer"
                    },
                    "fee_iqd": {
                      "type": "integer"
                    },
                    "qty": {
                      "type": "number",
                      "enum": [
                        1
                      ]
                    }
                  },
                  "required": [
                    "kind",
                    "seat_key",
                    "pool_id",
                    "name_ar",
                    "category_id",
                    "price_iqd",
                    "fee_iqd",
                    "qty"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "pool"
                      ]
                    },
                    "seat_key": {
                      "type": "null"
                    },
                    "category_id": {
                      "type": "null"
                    },
                    "pool_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name_ar": {
                      "type": "string"
                    },
                    "price_iqd": {
                      "type": "integer"
                    },
                    "fee_iqd": {
                      "type": "integer"
                    },
                    "qty": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    }
                  },
                  "required": [
                    "kind",
                    "seat_key",
                    "category_id",
                    "pool_id",
                    "name_ar",
                    "price_iqd",
                    "fee_iqd",
                    "qty"
                  ]
                }
              ]
            }
          },
          "tickets_total_iqd": {
            "type": "integer"
          },
          "service_fee_total_iqd": {
            "type": "integer"
          },
          "grand_total_iqd": {
            "type": "integer"
          }
        },
        "required": [
          "hold_id",
          "showing_id",
          "status",
          "expires_at",
          "items",
          "tickets_total_iqd",
          "service_fee_total_iqd",
          "grand_total_iqd"
        ]
      },
      "Order": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "ref": {
            "type": "string",
            "example": "MT-K7P2QX"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "paid",
              "failed",
              "expired",
              "cancelled",
              "refunded",
              "partially_refunded"
            ]
          },
          "showing_id": {
            "type": "string",
            "format": "uuid"
          },
          "showing": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "starts_at": {
                "type": "string",
                "format": "date-time"
              },
              "format": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "movie_title_ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "movie_title_en": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "poster_url": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "cinema_name_ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "cinema_branch_ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "hall_name_ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "event_title_ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "event_title_en": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "event_slug": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "venue_name_ar": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "id",
              "starts_at",
              "format",
              "movie_title_ar",
              "movie_title_en",
              "poster_url",
              "cinema_name_ar",
              "cinema_branch_ar",
              "hall_name_ar",
              "event_title_ar",
              "event_title_en",
              "event_slug",
              "venue_name_ar"
            ]
          },
          "tickets_total_iqd": {
            "type": "integer"
          },
          "service_fee_total_iqd": {
            "type": "integer"
          },
          "discount_total_iqd": {
            "type": "integer"
          },
          "grand_total_iqd": {
            "type": "integer"
          },
          "hold_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "The hold behind this order. DELETE /public/holds/{id} cancels both while unpaid."
          },
          "hold_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "payment_status": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "initiated",
              "pending",
              "succeeded",
              "failed",
              "cancelled",
              "refunded",
              null
            ],
            "description": "The latest payment attempt. A declined payment leaves the order pending, so the customer can retry while the hold lasts."
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "seat_key": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "pool_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "uuid"
                },
                "name_ar": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "qty": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "ticket_type": {
                  "type": "string"
                },
                "unit_price_iqd": {
                  "type": "integer"
                },
                "fee_iqd": {
                  "type": "integer"
                }
              },
              "required": [
                "seat_key",
                "pool_id",
                "name_ar",
                "qty",
                "ticket_type",
                "unit_price_iqd",
                "fee_iqd"
              ]
            }
          },
          "refunds": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "kind": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "processing",
                    "succeeded",
                    "failed"
                  ]
                },
                "amount_iqd": {
                  "type": "integer"
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "id",
                "kind",
                "status",
                "amount_iqd",
                "created_at"
              ]
            },
            "description": "Refunds on this order, oldest first. pending and processing: the money is on its way back."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "paid_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "order_id",
          "ref",
          "status",
          "showing_id",
          "showing",
          "tickets_total_iqd",
          "service_fee_total_iqd",
          "discount_total_iqd",
          "grand_total_iqd",
          "hold_id",
          "hold_expires_at",
          "payment_status",
          "items",
          "refunds",
          "created_at",
          "paid_at"
        ]
      },
      "RefundQuote": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "eligible": {
            "type": "boolean"
          },
          "kind": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "customer_request",
              "event_amended",
              null
            ],
            "description": "customer_request: event change of mind, ticket value only. event_amended: full refund after the organiser changed the session."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "order_not_refundable",
              "show_cancelled",
              "cinema_tickets_final",
              "refunds_disabled",
              "window_closed",
              "show_started",
              "no_refundable_tickets",
              null
            ],
            "description": "Why the order is not refundable. show_cancelled: the refund is automatic."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "includes_service_fee": {
            "type": "boolean"
          },
          "tickets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "ticket_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "ref": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "seat_key": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "pool_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "uuid"
                },
                "table_key": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Set on a whole table: its tickets are refunded together or not at all."
                },
                "group_key": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Set on a group purchase (a family ticket): its tickets are refunded together or not at all."
                },
                "ticket_iqd": {
                  "type": "integer"
                },
                "fee_iqd": {
                  "type": "integer"
                },
                "refundable": {
                  "type": "boolean"
                }
              },
              "required": [
                "ticket_id",
                "ref",
                "status",
                "seat_key",
                "pool_id",
                "table_key",
                "group_key",
                "ticket_iqd",
                "fee_iqd",
                "refundable"
              ]
            }
          },
          "refund_total_iqd": {
            "type": "integer"
          }
        },
        "required": [
          "order_id",
          "eligible",
          "kind",
          "reason",
          "deadline",
          "includes_service_fee",
          "tickets",
          "refund_total_iqd"
        ]
      },
      "CustomerRefund": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "order_id": {
            "type": "string",
            "format": "uuid"
          },
          "order_ref": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "pos",
              "show_cancelled",
              "event_cancelled",
              "event_amended",
              "customer_request",
              "late_payment",
              "duplicate_payment",
              "manual",
              "partner_request"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "succeeded",
              "failed"
            ]
          },
          "amount_iqd": {
            "type": "integer"
          },
          "ticket_iqd": {
            "type": "integer"
          },
          "fee_iqd": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "order_item_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "ticket_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "uuid"
                },
                "ticket_ref": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "ticket_iqd": {
                  "type": "integer"
                },
                "fee_iqd": {
                  "type": "integer"
                },
                "snack_iqd": {
                  "type": "integer"
                }
              },
              "required": [
                "order_item_id",
                "ticket_id",
                "ticket_ref",
                "ticket_iqd",
                "fee_iqd",
                "snack_iqd"
              ]
            }
          }
        },
        "required": [
          "id",
          "order_id",
          "order_ref",
          "kind",
          "status",
          "amount_iqd",
          "ticket_iqd",
          "fee_iqd",
          "created_at",
          "items"
        ]
      },
      "ApiCinema": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name_ar": {
            "type": "string"
          },
          "branch_ar": {
            "type": [
              "string",
              "null"
            ]
          },
          "city_id": {
            "type": "string"
          },
          "listed": {
            "type": "boolean",
            "description": "Whether MyTicket's own website and app list this cinema too (set by the platform)."
          },
          "halls": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name_ar": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name_ar"
              ]
            }
          }
        },
        "required": [
          "id",
          "name_ar",
          "branch_ar",
          "city_id",
          "listed",
          "halls"
        ]
      },
      "ApiShowing": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "hall": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name_ar": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "name_ar"
            ]
          },
          "starts_at": {
            "type": "string",
            "format": "date-time"
          },
          "ends_at": {
            "type": "string",
            "format": "date-time"
          },
          "movie": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "title_ar": {
                "type": "string"
              },
              "title_en": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "poster_url": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "runtime_min": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "age_rating": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "id",
              "title_ar",
              "title_en",
              "poster_url",
              "runtime_min",
              "age_rating"
            ]
          },
          "format": {
            "type": [
              "string",
              "null"
            ]
          },
          "version": {
            "type": [
              "string",
              "null"
            ]
          },
          "price_from_iqd": {
            "type": [
              "integer",
              "null"
            ]
          },
          "service_fee_iqd": {
            "type": "integer"
          },
          "seats_available": {
            "type": "integer"
          },
          "bookable": {
            "type": "boolean"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "cancelled",
              "closed",
              "sales_not_open",
              "cutoff",
              "sold_out",
              null
            ],
            "description": "Why it cannot be booked online now; null when bookable."
          }
        },
        "required": [
          "id",
          "hall",
          "starts_at",
          "ends_at",
          "movie",
          "format",
          "version",
          "price_from_iqd",
          "service_fee_iqd",
          "seats_available",
          "bookable",
          "reason"
        ]
      },
      "ApiOrder": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Order"
          },
          {
            "type": "object",
            "properties": {
              "external_reference": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Your own reference, as sent when the order was made."
              },
              "tickets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ApiTicket"
                },
                "description": "Issued once the order is paid; empty before."
              }
            },
            "required": [
              "external_reference",
              "tickets"
            ]
          }
        ]
      },
      "ApiTicket": {
        "type": "object",
        "properties": {
          "ticket_id": {
            "type": "string",
            "format": "uuid"
          },
          "ref": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "valid",
              "used",
              "revoked",
              "refunded",
              "expired",
              "transferred"
            ],
            "description": "transferred: sent to another customer, who holds a new ticket; the gate rejects this one."
          },
          "seat_key": {
            "type": [
              "string",
              "null"
            ]
          },
          "qr": {
            "type": "string",
            "description": "Payload to show as a QR code (level M or better). MyTicket's gate app admits a valid ticket once."
          }
        },
        "required": [
          "ticket_id",
          "ref",
          "status",
          "seat_key",
          "qr"
        ]
      },
      "ApiRefundQuote": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RefundQuote"
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "partner_request",
                  null
                ],
                "description": "partner_request: you refund your own sale, ticket value only."
              }
            }
          }
        ]
      }
    },
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "mtk_ partner API key",
        "description": "A partner API key (`mtk_…`), made in the partner console under API. Shown once; keep it on your server."
      }
    }
  },
  "paths": {
    "/partner-api/v1/cinemas": {
      "get": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Your active cinemas and their halls",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiCinema"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/cinemas/{id}/showings": {
      "get": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "One cinema's shows on a Baghdad day (default today)",
        "description": "Draw the seat map with the public `GET /public/showings/{id}/layout` and `/availability` (no key needed, so a browser can call them), and keep it live with `GET /public/showings/{id}/availability/stream`.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "date",
              "description": "YYYY-MM-DD, Baghdad."
            },
            "required": false,
            "description": "YYYY-MM-DD, Baghdad.",
            "name": "date",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiShowing"
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/holds": {
      "post": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Hold seats for the hold time (7 minutes by default), all or none",
        "description": "The same atomic hold as MyTicket's website: a seat held here cannot be sold anywhere else. A repeat with the same `Idempotency-Key` answers the first hold.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "required": true,
            "name": "idempotency-key",
            "in": "header"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "showing_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "seat_keys": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 50
                    },
                    "minItems": 1,
                    "maxItems": 100
                  }
                },
                "required": [
                  "showing_id",
                  "seat_keys"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Seats held",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Hold"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Error 409",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Error 429",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/holds/{id}": {
      "delete": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Release a hold (and cancel its unpaid order)",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/orders": {
      "post": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Make the pending order of a hold. Totals are worked out by MyTicket.",
        "description": "`return_url` is where the buyer comes back after paying (`?order_id=` is added); it must be on one of the return addresses saved in the partner console, otherwise `validation_failed` with `return_url` = `invalid`. With `customer_phone` (Iraqi), the buyer also gets the tickets on WhatsApp. A second call for the same hold answers the same order.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hold_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "return_url": {
                    "type": "string",
                    "maxLength": 1000,
                    "format": "uri"
                  },
                  "external_reference": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "customer_phone": {
                    "type": "string",
                    "minLength": 6,
                    "maxLength": 32
                  }
                },
                "required": [
                  "hold_id",
                  "return_url"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Order created (or the existing one for this hold)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiOrder"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Error 409",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Error 429",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Your API orders, newest first",
        "parameters": [
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "Rows per page, 1 to 100."
            },
            "required": false,
            "description": "Rows per page, 1 to 100.",
            "name": "limit",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200,
              "description": "`next_cursor` from the previous page; leave out for the first page."
            },
            "required": false,
            "description": "`next_cursor` from the previous page; leave out for the first page.",
            "name": "cursor",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date",
              "description": "First Baghdad day, inclusive."
            },
            "required": false,
            "description": "First Baghdad day, inclusive.",
            "name": "from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date",
              "description": "Last Baghdad day, inclusive."
            },
            "required": false,
            "description": "Last Baghdad day, inclusive.",
            "name": "to",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "description": "Part of the order's ref or of your external reference."
            },
            "required": false,
            "description": "Part of the order's ref or of your external reference.",
            "name": "q",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "Comma-separated; a row matches any of them. One of: pending, paid, failed, expired, cancelled, refunded, partially_refunded."
            },
            "required": false,
            "description": "Comma-separated; a row matches any of them. One of: pending, paid, failed, expired, cancelled, refunded, partially_refunded.",
            "name": "status",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiOrder"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as `cursor` for the next page; null on the last page."
                    },
                    "remaining": {
                      "type": "integer",
                      "description": "Rows matching the filters from this page's first row on. On the first page, the total."
                    }
                  },
                  "required": [
                    "data",
                    "next_cursor",
                    "remaining"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/orders/{id}": {
      "get": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "An order with its tickets. Safe to poll; it never issues tickets.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiOrder"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/orders/{id}/tickets.pdf": {
      "get": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "The order's valid tickets as a PDF (A5, one page each), the same file WhatsApp sends",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "ar",
                "en"
              ],
              "default": "ar"
            },
            "required": false,
            "name": "locale",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/payment-methods": {
      "get": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "The payment gateways switched on",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id"
                        ]
                      }
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/orders/{id}/pay": {
      "post": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Start a payment: send the buyer to `redirect_url`",
        "description": "Tickets are issued only when the gateway confirms the payment to MyTicket. The buyer then comes back to the order's `return_url`; the `order.paid` webhook, or `GET /orders/{id}`, says it is paid. FIB answers `sdk_params` (its app link, code and QR) instead of a page.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string"
                  }
                },
                "required": [
                  "provider"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "payment_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "redirect_url": {
                      "type": "string"
                    },
                    "sdk_params": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "required": [
                    "payment_id",
                    "provider"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Error 409",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Error 429",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/orders/{id}/payment/check": {
      "post": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Ask the gateway now about the order's pending payment (call it when the buyer comes back)",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "204": {
            "description": "The gateway was asked, or nothing is pending"
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/orders/{id}/refund-quote": {
      "get": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "What you can refund on this order: valid tickets, ticket value only, until the show starts",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiRefundQuote"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/partner-api/v1/orders/{id}/refunds": {
      "post": {
        "tags": [
          "partner api"
        ],
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Refund tickets (every refundable one when ticket_ids is left out)",
        "description": "The money goes back through the gateway the buyer paid with; the refund starts `pending` and `refund.succeeded` follows. The service fee is not refunded. A whole table or group ticket is refunded together or not at all.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "name": "id",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            },
            "required": true,
            "name": "idempotency-key",
            "in": "header"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ticket_ids": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "minItems": 1,
                    "maxItems": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerRefund"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Error 409",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Error 429",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {}
}
