{
    "openapi": "3.0.3",
    "info": {
        "title": "API پنل فروش کانفیگ",
        "version": "1.0.0",
        "description": "آموزش کامل فارسی: https://tishtar.site/api/docs/"
    },
    "servers": [
        {
            "url": "https://tishtar.site/api/v1"
        }
    ],
    "security": [
        {
            "bearer": []
        }
    ],
    "paths": {
        "/ping": {
            "get": {
                "tags": [
                    "شروع سریع"
                ],
                "summary": "آزمایش اتصال",
                "description": "بررسی درست بودن کلید؛ دسترسی‌های کلید را برمی‌گرداند.",
                "operationId": "get_ping",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "pong": true,
                                        "account": 1042,
                                        "key": "k7m2pq",
                                        "scopes": [
                                            "read",
                                            "write"
                                        ],
                                        "time": 1764633600
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearer": []
                    }
                ]
            }
        },
        "/me": {
            "get": {
                "tags": [
                    "حساب، حجم و کیف پول"
                ],
                "summary": "اطلاعات حساب",
                "description": "وضعیت پنل، موجودی (بایت و گیگ)، تعداد کانفیگ‌ها به تفکیک وضعیت، سقف کانفیگ، کیف پول و ربات.\n\nدسترسی لازم: read",
                "operationId": "get_me",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": 1042,
                                        "username": "nova4821",
                                        "state": "active",
                                        "usable": true,
                                        "trial": false,
                                        "sub_reseller": false,
                                        "quota_gb": 500,
                                        "used_gb": 212.4,
                                        "left_gb": 287.6,
                                        "eta_days": 34,
                                        "config_cap": 0,
                                        "configs": {
                                            "total": 148,
                                            "active": 121,
                                            "on_hold": 9,
                                            "expired": 11,
                                            "limited": 5,
                                            "disabled": 2,
                                            "held": 0,
                                            "online": 37
                                        },
                                        "wallet_toman": 250000,
                                        "server_time": 1764633600
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/usage": {
            "get": {
                "tags": [
                    "حساب، حجم و کیف پول"
                ],
                "summary": "مصرف روزانه",
                "description": "مصرف کل پنل در روزهای اخیر.\n\nدسترسی لازم: read",
                "operationId": "get_usage",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "days": [
                                            {
                                                "date": "2026-10-19",
                                                "used_bytes": 9663676416,
                                                "used_gb": 9
                                            },
                                            {
                                                "date": "2026-10-20",
                                                "used_bytes": 4294967296,
                                                "used_gb": 4
                                            }
                                        ],
                                        "total_gb": 13
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "days",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        },
                        "description": "چند روز اخیر (۱ تا ۹۰؛ پیش‌فرض ۳۰)"
                    }
                ]
            }
        },
        "/packs": {
            "get": {
                "tags": [
                    "حساب، حجم و کیف پول"
                ],
                "summary": "بسته‌های حجم و قیمت",
                "description": "بسته‌های شارژ پنل با قیمت هر گیگ (برای زیرنماینده: قیمت فروشنده‌اش).\n\nدسترسی لازم: read",
                "operationId": "get_packs",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "packs": [
                                            {
                                                "gb": 100,
                                                "price_toman": 400000,
                                                "per_gb_toman": 4000,
                                                "bonus_gb": 0,
                                                "popular": false
                                            }
                                        ],
                                        "min_gb": 50,
                                        "max_gb": 10000,
                                        "custom": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/volume/buy": {
            "post": {
                "tags": [
                    "حساب، حجم و کیف پول"
                ],
                "summary": "شارژ پنل از کیف پول",
                "description": "پنل از کیف پول تو شارژ می‌شود و همان لحظه به موجودی پنل اضافه می‌شود. اگر موجودی کیف پول کم باشد، خطای insufficient_wallet با مبلغ کمبود برمی‌گردد.\n\nدسترسی لازم: buy",
                "operationId": "post_volume_buy",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "bought_gb": 100,
                                        "bonus_gb": 0,
                                        "price_toman": 400000,
                                        "left_gb": 387.6,
                                        "wallet_toman": 50000
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "gb": {
                                        "type": "integer",
                                        "description": "چند گیگ"
                                    }
                                },
                                "required": [
                                    "gb"
                                ]
                            },
                            "example": {
                                "gb": 100
                            }
                        }
                    }
                }
            }
        },
        "/volume/checkout": {
            "post": {
                "tags": [
                    "حساب، حجم و کیف پول"
                ],
                "summary": "لینک پرداخت درگاه برای شارژ پنل",
                "description": "لینک پرداخت بانکی برای شارژ پنل (اگر درگاه روشن باشد). بعد از پرداخت، حجم خودکار اضافه می‌شود.\n\nدسترسی لازم: buy",
                "operationId": "post_volume_checkout",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "order_id": "x8k2m",
                                        "pay_url": "https://…",
                                        "price_toman": 760000,
                                        "gb": 200
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "gb": {
                                        "type": "integer",
                                        "description": "چند گیگ"
                                    }
                                },
                                "required": [
                                    "gb"
                                ]
                            },
                            "example": {
                                "gb": 200
                            }
                        }
                    }
                }
            }
        },
        "/wallet": {
            "get": {
                "tags": [
                    "حساب، حجم و کیف پول"
                ],
                "summary": "کیف پول",
                "description": "موجودی و ۵۰ تراکنش آخر کیف پول.\n\nدسترسی لازم: read",
                "operationId": "get_wallet",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "balance_toman": 250000,
                                        "history": [
                                            {
                                                "amount_toman": -400000,
                                                "note": "شارژ پنل ۱۰۰ گیگ",
                                                "at": 1764633600
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/configs": {
            "get": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "فهرست کانفیگ‌ها",
                "description": "با جست‌وجو، فیلتر وضعیت و صفحه‌بندی (تا ۵۰۰ در هر صفحه).\n\nدسترسی لازم: read",
                "operationId": "get_configs",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "items": [
                                            {
                                                "id": "ali-2041",
                                                "name": "ali-2041",
                                                "note": "مشتری اینستاگرام",
                                                "status": "active",
                                                "enabled": true,
                                                "online": false,
                                                "used_bytes": 3221225472,
                                                "total_bytes": 32212254720,
                                                "left_bytes": 28991029248,
                                                "used_gb": 3,
                                                "total_gb": 30,
                                                "left_gb": 27,
                                                "expire_type": "date",
                                                "expire_at": 1767225600,
                                                "days_left": 27,
                                                "duration_seconds": null,
                                                "daily_cap_gb": 0,
                                                "capped_today": false,
                                                "last_online": 1764633600,
                                                "created_at": 1764547200,
                                                "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v"
                                            }
                                        ],
                                        "total": 148,
                                        "page": 1,
                                        "per_page": 100,
                                        "pages": 2,
                                        "server_reachable": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": "active | on_hold | expired | limited | disabled | held | online | ending (رو به اتمام)"
                    },
                    {
                        "name": "q",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": "جست‌وجو در نام، یادداشت و شناسه"
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        },
                        "description": "شماره‌ی صفحه (از ۱)"
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        },
                        "description": "تعداد در هر صفحه (پیش‌فرض ۱۰۰، حداکثر ۵۰۰)"
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": "created_at | name | used_bytes | last_online | days_left؛ با - برای نزولی (پیش‌فرض -created_at)"
                    }
                ]
            },
            "post": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "ساخت کانفیگ",
                "description": "کانفیگ تازه از موجودی پنلت. جواب کامل با لینک اشتراک، کانفیگ‌های تکی و پیام آماده برای مشتری است. هدر Idempotency-Key را بفرست تا اگر درخواست دو بار رسید، دو کانفیگ ساخته نشود.\n\nدسترسی لازم: write",
                "operationId": "post_configs",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "ali-2041",
                                        "name": "ali-2041",
                                        "note": "مشتری اینستاگرام",
                                        "status": "active",
                                        "enabled": true,
                                        "online": false,
                                        "used_bytes": 3221225472,
                                        "total_bytes": 32212254720,
                                        "left_bytes": 28991029248,
                                        "used_gb": 3,
                                        "total_gb": 30,
                                        "left_gb": 27,
                                        "expire_type": "date",
                                        "expire_at": 1767225600,
                                        "days_left": 27,
                                        "duration_seconds": null,
                                        "daily_cap_gb": 0,
                                        "capped_today": false,
                                        "last_online": 1764633600,
                                        "created_at": 1764547200,
                                        "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v",
                                        "devices": 2,
                                        "links": [
                                            {
                                                "protocol": "vless",
                                                "name": "ali-2041",
                                                "uri": "vless://…#ali-2041"
                                            }
                                        ],
                                        "message": "سلام 👋 اشتراک «ali-2041» آماده است…",
                                        "found_on_server": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "description": "نام کانفیگ (یکتا در پنلت؛ خالی = خودکار). حروف، عدد، خط تیره."
                                    },
                                    "gb": {
                                        "type": "number",
                                        "description": "حجم به گیگ؛ ۰ = بدون سقف. اعشار مجاز (۰٫۵ = ۵۱۲ مگ)."
                                    },
                                    "days": {
                                        "type": "integer",
                                        "description": "مدت به روز؛ ۰ یا نفرستادن = بدون تاریخ."
                                    },
                                    "hours": {
                                        "type": "number",
                                        "description": "مدت به ساعت (وقتی days صفر است؛ مثلاً تست ۲۴ ساعته)."
                                    },
                                    "start_on_first_use": {
                                        "type": "boolean",
                                        "description": "زمان از اولین اتصال مشتری شروع شود (پیش‌فرض false)."
                                    },
                                    "devices": {
                                        "type": "integer",
                                        "description": "حداکثر دستگاه هم‌زمان؛ ۰ = بی‌محدودیت (پیش‌فرض ۱)."
                                    },
                                    "daily_cap_gb": {
                                        "type": "number",
                                        "description": "دیگر کاری نمی‌کند (برای سازگاری پذیرفته و نادیده گرفته می‌شود)."
                                    },
                                    "note": {
                                        "type": "string",
                                        "description": "یادداشت برای خودت (حداکثر ۱۲۰ حرف)."
                                    }
                                },
                                "required": [
                                    "gb"
                                ]
                            },
                            "example": {
                                "name": "ali",
                                "gb": 30,
                                "days": 30,
                                "devices": 2,
                                "start_on_first_use": true,
                                "note": "مشتری اینستاگرام"
                            }
                        }
                    }
                }
            }
        },
        "/configs/bulk": {
            "post": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "ساخت گروهی",
                "description": "تا ۵۰ کانفیگ با یک پیشوند (پیشوند-۱، پیشوند-۲، …).\n\nدسترسی لازم: write",
                "operationId": "post_configs_bulk",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "created": [
                                            {
                                                "id": "ali-2041",
                                                "name": "ali-2041",
                                                "note": "مشتری اینستاگرام",
                                                "status": "active",
                                                "enabled": true,
                                                "online": false,
                                                "used_bytes": 3221225472,
                                                "total_bytes": 32212254720,
                                                "left_bytes": 28991029248,
                                                "used_gb": 3,
                                                "total_gb": 30,
                                                "left_gb": 27,
                                                "expire_type": "date",
                                                "expire_at": 1767225600,
                                                "days_left": 27,
                                                "duration_seconds": null,
                                                "daily_cap_gb": 0,
                                                "capped_today": false,
                                                "last_online": 1764633600,
                                                "created_at": 1764547200,
                                                "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v"
                                            }
                                        ],
                                        "count": 10,
                                        "warning": ""
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "prefix": {
                                        "type": "string",
                                        "description": "پیشوند نام"
                                    },
                                    "count": {
                                        "type": "integer",
                                        "description": "تعداد (۱ تا ۵۰)"
                                    },
                                    "gb": {
                                        "type": "number",
                                        "description": "حجم به گیگ؛ ۰ = بدون سقف. اعشار مجاز (۰٫۵ = ۵۱۲ مگ)."
                                    },
                                    "days": {
                                        "type": "integer",
                                        "description": "مدت به روز؛ ۰ یا نفرستادن = بدون تاریخ."
                                    },
                                    "hours": {
                                        "type": "number",
                                        "description": "مدت به ساعت (وقتی days صفر است؛ مثلاً تست ۲۴ ساعته)."
                                    },
                                    "start_on_first_use": {
                                        "type": "boolean",
                                        "description": "زمان از اولین اتصال مشتری شروع شود (پیش‌فرض false)."
                                    },
                                    "devices": {
                                        "type": "integer",
                                        "description": "حداکثر دستگاه هم‌زمان؛ ۰ = بی‌محدودیت (پیش‌فرض ۱)."
                                    },
                                    "daily_cap_gb": {
                                        "type": "number",
                                        "description": "دیگر کاری نمی‌کند (برای سازگاری پذیرفته و نادیده گرفته می‌شود)."
                                    },
                                    "note": {
                                        "type": "string",
                                        "description": "یادداشت برای خودت (حداکثر ۱۲۰ حرف)."
                                    }
                                },
                                "required": [
                                    "prefix",
                                    "count",
                                    "gb"
                                ]
                            },
                            "example": {
                                "prefix": "shop",
                                "count": 10,
                                "gb": 20,
                                "days": 30
                            }
                        }
                    }
                }
            }
        },
        "/configs/{id}": {
            "get": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "جزئیات یک کانفیگ",
                "description": "مصرف، مانده، تاریخ، دستگاه، آخرین اتصال، لینک اشتراک، کانفیگ‌های تکی و پیام آماده.\n\nدسترسی لازم: read",
                "operationId": "get_configs_id_",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "ali-2041",
                                        "name": "ali-2041",
                                        "note": "مشتری اینستاگرام",
                                        "status": "active",
                                        "enabled": true,
                                        "online": false,
                                        "used_bytes": 3221225472,
                                        "total_bytes": 32212254720,
                                        "left_bytes": 28991029248,
                                        "used_gb": 3,
                                        "total_gb": 30,
                                        "left_gb": 27,
                                        "expire_type": "date",
                                        "expire_at": 1767225600,
                                        "days_left": 27,
                                        "duration_seconds": null,
                                        "daily_cap_gb": 0,
                                        "capped_today": false,
                                        "last_online": 1764633600,
                                        "created_at": 1764547200,
                                        "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v",
                                        "devices": 2,
                                        "links": [
                                            {
                                                "protocol": "vless",
                                                "name": "ali-2041",
                                                "uri": "vless://…#ali-2041"
                                            }
                                        ],
                                        "message": "سلام 👋 اشتراک «ali-2041» آماده است…",
                                        "found_on_server": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            },
            "patch": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "تغییر کانفیگ (تمدید، حجم، روز…)",
                "description": "هر فیلدی را بفرستی تغییر می‌کند. برای تمدید معمولاً add_gb و add_days کافی است.\n\nدسترسی لازم: write",
                "operationId": "patch_configs_id_",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "ali-2041",
                                        "name": "ali-2041",
                                        "note": "مشتری اینستاگرام",
                                        "status": "active",
                                        "enabled": true,
                                        "online": false,
                                        "used_bytes": 3221225472,
                                        "total_bytes": 32212254720,
                                        "left_bytes": 28991029248,
                                        "used_gb": 3,
                                        "total_gb": 30,
                                        "left_gb": 27,
                                        "expire_type": "date",
                                        "expire_at": 1767225600,
                                        "days_left": 27,
                                        "duration_seconds": null,
                                        "daily_cap_gb": 0,
                                        "capped_today": false,
                                        "last_online": 1764633600,
                                        "created_at": 1764547200,
                                        "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v",
                                        "devices": 2,
                                        "links": [
                                            {
                                                "protocol": "vless",
                                                "name": "ali-2041",
                                                "uri": "vless://…#ali-2041"
                                            }
                                        ],
                                        "message": "سلام 👋 اشتراک «ali-2041» آماده است…",
                                        "found_on_server": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "add_gb": {
                                        "type": "number",
                                        "description": "افزودن حجم (منفی = کم کردن)"
                                    },
                                    "gb": {
                                        "type": "number",
                                        "description": "حجم کل تازه (۰ = بی‌سقف)"
                                    },
                                    "add_days": {
                                        "type": "integer",
                                        "description": "افزودن روز (منفی = کم کردن)"
                                    },
                                    "days": {
                                        "type": "integer",
                                        "description": "مدت تازه از امروز (۰ = بی‌تاریخ)"
                                    },
                                    "expire_at": {
                                        "type": "integer",
                                        "description": "زمان پایان (ثانیه‌ی یونیکس؛ ۰ = بی‌تاریخ)"
                                    },
                                    "no_expiry": {
                                        "type": "boolean",
                                        "description": "برداشتن تاریخ"
                                    },
                                    "devices": {
                                        "type": "integer",
                                        "description": "تعداد دستگاه"
                                    },
                                    "enabled": {
                                        "type": "boolean",
                                        "description": "روشن یا خاموش"
                                    },
                                    "note": {
                                        "type": "string",
                                        "description": "یادداشت"
                                    },
                                    "daily_cap_gb": {
                                        "type": "number",
                                        "description": "دیگر کاری نمی‌کند (نادیده گرفته می‌شود)."
                                    }
                                }
                            },
                            "example": {
                                "add_gb": 30,
                                "add_days": 30
                            }
                        }
                    }
                }
            },
            "delete": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "حذف کانفیگ",
                "description": "کانفیگ برای همیشه حذف می‌شود.\n\nدسترسی لازم: write",
                "operationId": "delete_configs_id_",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "deleted": "ali-2041"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/configs/{id}/revoke": {
            "post": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "لینک تازه",
                "description": "لینک اشتراک و شناسه‌ی اتصال عوض می‌شود؛ لینک قبلی دیگر کار نمی‌کند (برای وقتی لینک لو رفته).\n\nدسترسی لازم: write",
                "operationId": "post_configs_id_revoke",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "ali-2041",
                                        "name": "ali-2041",
                                        "note": "مشتری اینستاگرام",
                                        "status": "active",
                                        "enabled": true,
                                        "online": false,
                                        "used_bytes": 3221225472,
                                        "total_bytes": 32212254720,
                                        "left_bytes": 28991029248,
                                        "used_gb": 3,
                                        "total_gb": 30,
                                        "left_gb": 27,
                                        "expire_type": "date",
                                        "expire_at": 1767225600,
                                        "days_left": 27,
                                        "duration_seconds": null,
                                        "daily_cap_gb": 0,
                                        "capped_today": false,
                                        "last_online": 1764633600,
                                        "created_at": 1764547200,
                                        "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v",
                                        "devices": 2,
                                        "links": [
                                            {
                                                "protocol": "vless",
                                                "name": "ali-2041",
                                                "uri": "vless://…#ali-2041"
                                            }
                                        ],
                                        "message": "سلام 👋 اشتراک «ali-2041» آماده است…",
                                        "found_on_server": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/configs/{id}/enable": {
            "post": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "روشن کردن",
                "description": "\n\nدسترسی لازم: write",
                "operationId": "post_configs_id_enable",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "ali-2041",
                                        "name": "ali-2041",
                                        "note": "مشتری اینستاگرام",
                                        "status": "active",
                                        "enabled": true,
                                        "online": false,
                                        "used_bytes": 3221225472,
                                        "total_bytes": 32212254720,
                                        "left_bytes": 28991029248,
                                        "used_gb": 3,
                                        "total_gb": 30,
                                        "left_gb": 27,
                                        "expire_type": "date",
                                        "expire_at": 1767225600,
                                        "days_left": 27,
                                        "duration_seconds": null,
                                        "daily_cap_gb": 0,
                                        "capped_today": false,
                                        "last_online": 1764633600,
                                        "created_at": 1764547200,
                                        "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v",
                                        "devices": 2,
                                        "links": [
                                            {
                                                "protocol": "vless",
                                                "name": "ali-2041",
                                                "uri": "vless://…#ali-2041"
                                            }
                                        ],
                                        "message": "سلام 👋 اشتراک «ali-2041» آماده است…",
                                        "found_on_server": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/configs/{id}/disable": {
            "post": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "خاموش کردن",
                "description": "\n\nدسترسی لازم: write",
                "operationId": "post_configs_id_disable",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "ali-2041",
                                        "name": "ali-2041",
                                        "note": "مشتری اینستاگرام",
                                        "status": "active",
                                        "enabled": true,
                                        "online": false,
                                        "used_bytes": 3221225472,
                                        "total_bytes": 32212254720,
                                        "left_bytes": 28991029248,
                                        "used_gb": 3,
                                        "total_gb": 30,
                                        "left_gb": 27,
                                        "expire_type": "date",
                                        "expire_at": 1767225600,
                                        "days_left": 27,
                                        "duration_seconds": null,
                                        "daily_cap_gb": 0,
                                        "capped_today": false,
                                        "last_online": 1764633600,
                                        "created_at": 1764547200,
                                        "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v",
                                        "devices": 2,
                                        "links": [
                                            {
                                                "protocol": "vless",
                                                "name": "ali-2041",
                                                "uri": "vless://…#ali-2041"
                                            }
                                        ],
                                        "message": "سلام 👋 اشتراک «ali-2041» آماده است…",
                                        "found_on_server": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/configs/{id}/qr": {
            "get": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "QR لینک اشتراک",
                "description": "تصویر SVG کد QR (یا با text یکی از کانفیگ‌های تکی همین کانفیگ).\n\nدسترسی لازم: read",
                "operationId": "get_configs_id_qr",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "text": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v",
                                        "svg": "<svg …>"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    },
                    {
                        "name": "text",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": "متن دلخواه (فقط لینک‌های همین کانفیگ)"
                    }
                ]
            }
        },
        "/configs/batch": {
            "post": {
                "tags": [
                    "کانفیگ‌ها"
                ],
                "summary": "کار گروهی",
                "description": "یک کار روی تا ۱۰۰ کانفیگ: enable، disable، delete، add_gb، add_days.\n\nدسترسی لازم: write",
                "operationId": "post_configs_batch",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "done": [
                                            "ali-2041",
                                            "sara"
                                        ],
                                        "failed": [],
                                        "count": 2
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "ids": {
                                        "type": "string",
                                        "description": "شناسه‌ها (یا نام‌ها)",
                                        "items": {
                                            "type": "string"
                                        }
                                    },
                                    "action": {
                                        "type": "string",
                                        "description": "enable | disable | delete | add_gb | add_days"
                                    },
                                    "value": {
                                        "type": "number",
                                        "description": "برای add_gb و add_days"
                                    }
                                },
                                "required": [
                                    "ids",
                                    "action"
                                ]
                            },
                            "example": {
                                "ids": [
                                    "ali-2041",
                                    "sara"
                                ],
                                "action": "add_days",
                                "value": 7
                            }
                        }
                    }
                }
            }
        },
        "/import": {
            "post": {
                "tags": [
                    "ابزارها"
                ],
                "summary": "انتقال مشتری‌ها از پنل‌های دیگر",
                "description": "همان «انتقال مشتری‌ها» مینی‌اپ با op: state، extract، fetch، preview، start، run، result، links، reset (پارامترها مثل مینی‌اپ). برای پنل تستی نیست.\n\nدسترسی لازم: write",
                "operationId": "post_import",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "ok": true,
                                        "pv": {
                                            "total": 2,
                                            "sel": 2
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "op": {
                                        "type": "string",
                                        "description": "مرحله"
                                    },
                                    "src": {
                                        "type": "string",
                                        "description": "xui | marzban | hiddify | sub | list"
                                    },
                                    "way": {
                                        "type": "string",
                                        "description": "api | file | sub | list"
                                    }
                                },
                                "required": [
                                    "op"
                                ]
                            },
                            "example": {
                                "op": "extract",
                                "src": "list",
                                "way": "list",
                                "text": "ali, 25, 18\nsara, 12.5, 0"
                            }
                        }
                    }
                }
            }
        },
        "/logs": {
            "get": {
                "tags": [
                    "ابزارها"
                ],
                "summary": "گزارش درخواست‌ها",
                "description": "آخرین درخواست‌های API این حساب (همه‌ی کلیدها).\n\nدسترسی لازم: read",
                "operationId": "get_logs",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "items": [
                                            {
                                                "at": 1764633600,
                                                "key": "k7m2pq",
                                                "method": "POST",
                                                "path": "/configs",
                                                "status": 200,
                                                "ms": 840,
                                                "ip": "1.2.3.4",
                                                "error": ""
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        },
                        "description": "۱ تا ۲۰۰ (پیش‌فرض ۵۰)"
                    },
                    {
                        "name": "key",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": "فقط یک کلید (شناسه‌ی کلید)"
                    }
                ]
            }
        },
        "/shop": {
            "get": {
                "tags": [
                    "فروشگاه: تنظیمات، پلن و کد تخفیف"
                ],
                "summary": "اطلاعات فروشگاه",
                "description": "نام، روش‌های پرداخت فعال (card = رسید دستی، usdt، trx، ext = درگاه خودت)، پلن‌ها، تست رایگان، نرخ رمزارز.\n\nدسترسی لازم: shop",
                "operationId": "get_shop",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "title": "فروشگاه نیما",
                                        "support": "@nima_support",
                                        "sales_open": true,
                                        "currency": "IRT",
                                        "methods": [
                                            "card",
                                            "usdt",
                                            "trx",
                                            "ext"
                                        ],
                                        "plans": [
                                            {
                                                "id": "p30",
                                                "name": "۳۰ گیگ یک‌ماهه",
                                                "gb": 30,
                                                "days": 30,
                                                "devices": 2,
                                                "price_toman": 180000
                                            }
                                        ],
                                        "trial": {
                                            "enabled": true,
                                            "mb": 500,
                                            "hours": 24
                                        },
                                        "cards": [
                                            {
                                                "number_masked": "XXXX********XXXX",
                                                "name": "نیما"
                                            }
                                        ],
                                        "crypto": {
                                            "address": "T…",
                                            "usdt_rate_toman": 98000,
                                            "trx_rate_toman": 31000,
                                            "trx": true
                                        },
                                        "codes": 2
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/shop/settings": {
            "patch": {
                "tags": [
                    "فروشگاه: تنظیمات، پلن و کد تخفیف"
                ],
                "summary": "تغییر تنظیمات فروشگاه",
                "description": "فقط فیلدهایی که می‌فرستی عوض می‌شوند.\n\nدسترسی لازم: shop",
                "operationId": "patch_shop_settings",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "title": "فروشگاه نیما",
                                        "sales_open": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "title": {
                                        "type": "string",
                                        "description": "نام فروشگاه"
                                    },
                                    "support": {
                                        "type": "string",
                                        "description": "آیدی پشتیبانی تلگرام"
                                    },
                                    "sales": {
                                        "type": "boolean",
                                        "description": "فروش روشن/خاموش"
                                    },
                                    "cards": {
                                        "type": "object",
                                        "description": "تا ۵ حساب برای رسید دستی: [{\"number\":\"…\",\"name\":\"…\"}]",
                                        "items": {
                                            "type": "string"
                                        }
                                    },
                                    "usdt": {
                                        "type": "string",
                                        "description": "آدرس کیف پول TRC20 (برای تتر و ترون)"
                                    },
                                    "trx": {
                                        "type": "boolean",
                                        "description": "پرداخت با ترون"
                                    },
                                    "trial_on": {
                                        "type": "boolean",
                                        "description": "تست رایگان"
                                    },
                                    "trial_mb": {
                                        "type": "integer",
                                        "description": "حجم تست (مگ)"
                                    },
                                    "trial_hours": {
                                        "type": "integer",
                                        "description": "مدت تست (ساعت)"
                                    }
                                }
                            },
                            "example": {
                                "sales": true,
                                "trial_on": true,
                                "trial_mb": 300
                            }
                        }
                    }
                }
            }
        },
        "/shop/plans": {
            "get": {
                "tags": [
                    "فروشگاه: تنظیمات، پلن و کد تخفیف"
                ],
                "summary": "پلن‌ها",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "get_shop_plans",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "plans": [
                                            {
                                                "id": "p30",
                                                "name": "۳۰ گیگ یک‌ماهه",
                                                "gb": 30,
                                                "days": 30,
                                                "devices": 2,
                                                "price_toman": 180000
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "tags": [
                    "فروشگاه: تنظیمات، پلن و کد تخفیف"
                ],
                "summary": "جایگزینی همه‌ی پلن‌ها",
                "description": "تا ۱۲ پلن. id را نگه دار تا لینک‌های سایتت عوض نشود (برای پلن تازه id نفرست).\n\nدسترسی لازم: shop",
                "operationId": "put_shop_plans",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "plans": [
                                            {
                                                "id": "p30",
                                                "name": "۳۰ گیگ یک‌ماهه",
                                                "gb": 30,
                                                "days": 30,
                                                "devices": 2,
                                                "price_toman": 180000
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "plans": {
                                        "type": "object",
                                        "description": "[{\"id\",\"name\",\"gb\",\"days\",\"devices\",\"price_toman\"}]",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                },
                                "required": [
                                    "plans"
                                ]
                            },
                            "example": {
                                "plans": [
                                    {
                                        "id": "p30",
                                        "name": "۳۰ گیگ یک‌ماهه",
                                        "gb": 30,
                                        "days": 30,
                                        "devices": 2,
                                        "price_toman": 180000
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/shop/codes": {
            "get": {
                "tags": [
                    "فروشگاه: تنظیمات، پلن و کد تخفیف"
                ],
                "summary": "کدهای تخفیف",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "get_shop_codes",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "codes": [
                                            {
                                                "code": "YALDA",
                                                "percent": 10,
                                                "used": 3,
                                                "max_uses": 100,
                                                "expires_at": 1767225600,
                                                "enabled": true
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "tags": [
                    "فروشگاه: تنظیمات، پلن و کد تخفیف"
                ],
                "summary": "ساخت کد تخفیف",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "post_shop_codes",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "code": "YALDA"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "code": {
                                        "type": "string",
                                        "description": "۳ تا ۲۰ حرف انگلیسی یا عدد"
                                    },
                                    "percent": {
                                        "type": "integer",
                                        "description": "۱ تا ۹۰"
                                    },
                                    "max_uses": {
                                        "type": "integer",
                                        "description": "ظرفیت (۰ = بی‌سقف)"
                                    },
                                    "days": {
                                        "type": "integer",
                                        "description": "مهلت به روز (۰ = بی‌مهلت)"
                                    }
                                },
                                "required": [
                                    "code",
                                    "percent"
                                ]
                            },
                            "example": {
                                "code": "YALDA",
                                "percent": 10,
                                "max_uses": 100,
                                "days": 7
                            }
                        }
                    }
                }
            }
        },
        "/shop/codes/{id}": {
            "delete": {
                "tags": [
                    "فروشگاه: تنظیمات، پلن و کد تخفیف"
                ],
                "summary": "حذف کد تخفیف",
                "description": "id = خود کد\n\nدسترسی لازم: shop",
                "operationId": "delete_shop_codes_id_",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "deleted": "YALDA"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/shop/codes/check": {
            "post": {
                "tags": [
                    "فروشگاه: تنظیمات، پلن و کد تخفیف"
                ],
                "summary": "بررسی کد تخفیف",
                "description": "قبل از ثبت سفارش، قیمت نهایی را نشان بده.\n\nدسترسی لازم: shop",
                "operationId": "post_shop_codes_check",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "code": "YALDA",
                                        "percent": 10,
                                        "plan_id": "p30",
                                        "price_toman": 180000,
                                        "final_toman": 162000
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "code": {
                                        "type": "string",
                                        "description": ""
                                    },
                                    "plan_id": {
                                        "type": "string",
                                        "description": ""
                                    }
                                },
                                "required": [
                                    "code"
                                ]
                            },
                            "example": {
                                "code": "yalda",
                                "plan_id": "p30"
                            }
                        }
                    }
                }
            }
        },
        "/shop/stats": {
            "get": {
                "tags": [
                    "فروشگاه: تنظیمات، پلن و کد تخفیف"
                ],
                "summary": "گزارش فروش",
                "description": "فروش امروز، ماه، کل و سهم سایت.\n\nدسترسی لازم: shop",
                "operationId": "get_shop_stats",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "today": {
                                            "orders": 4,
                                            "toman": 720000
                                        },
                                        "month": {
                                            "orders": 61,
                                            "toman": 10980000
                                        },
                                        "all": {
                                            "orders": 340,
                                            "toman": 61200000
                                        },
                                        "api_month": {
                                            "orders": 22,
                                            "toman": 3960000
                                        },
                                        "reviewing": 1,
                                        "awaiting": 3,
                                        "customers": 118
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/shop/customers": {
            "post": {
                "tags": [
                    "فروشگاه: مشتری‌ها و سرویس‌ها"
                ],
                "summary": "ساخت یا به‌روز کردن مشتری",
                "description": "برای مشتری تازه، customer_token هم برمی‌گردد (برای فروشگاه آماده؛ فقط همین یک بار).\n\nدسترسی لازم: shop",
                "operationId": "post_shop_customers",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "c7x2kq9m",
                                        "name": "رضا",
                                        "phone": "989121234567",
                                        "email": "reza@example.com",
                                        "external_id": "wp-user-41",
                                        "note": "",
                                        "blocked": false,
                                        "trial_used": false,
                                        "services": 1,
                                        "orders": 2,
                                        "spent_toman": 180000,
                                        "created_at": 1764547200,
                                        "created": true,
                                        "customer_token": "ct_c7x2kq9m_…"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "description": "نام"
                                    },
                                    "phone": {
                                        "type": "string",
                                        "description": "موبایل (۰۹…)"
                                    },
                                    "email": {
                                        "type": "string",
                                        "description": "ایمیل"
                                    },
                                    "external_id": {
                                        "type": "string",
                                        "description": "شناسه‌ی کاربر در سایت تو"
                                    },
                                    "note": {
                                        "type": "string",
                                        "description": "یادداشت"
                                    }
                                }
                            },
                            "example": {
                                "name": "رضا",
                                "phone": "09121234567",
                                "external_id": "wp-user-41"
                            }
                        }
                    }
                }
            },
            "get": {
                "tags": [
                    "فروشگاه: مشتری‌ها و سرویس‌ها"
                ],
                "summary": "فهرست مشتری‌ها",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "get_shop_customers",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "items": [
                                            {
                                                "id": "c7x2kq9m",
                                                "name": "رضا",
                                                "phone": "989121234567",
                                                "email": "reza@example.com",
                                                "external_id": "wp-user-41",
                                                "note": "",
                                                "blocked": false,
                                                "trial_used": false,
                                                "services": 1,
                                                "orders": 2,
                                                "spent_toman": 180000,
                                                "created_at": 1764547200
                                            }
                                        ],
                                        "total": 118,
                                        "page": 1,
                                        "per_page": 50
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": "جست‌وجو در نام، موبایل، ایمیل، شناسه"
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        },
                        "description": ""
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        },
                        "description": "تا ۲۰۰"
                    }
                ]
            }
        },
        "/shop/customers/{id}": {
            "get": {
                "tags": [
                    "فروشگاه: مشتری‌ها و سرویس‌ها"
                ],
                "summary": "یک مشتری",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "get_shop_customers_id_",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "c7x2kq9m",
                                        "name": "رضا",
                                        "phone": "989121234567",
                                        "email": "reza@example.com",
                                        "external_id": "wp-user-41",
                                        "note": "",
                                        "blocked": false,
                                        "trial_used": false,
                                        "services": 1,
                                        "orders": 2,
                                        "spent_toman": 180000,
                                        "created_at": 1764547200
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            },
            "patch": {
                "tags": [
                    "فروشگاه: مشتری‌ها و سرویس‌ها"
                ],
                "summary": "ویرایش یا مسدود کردن مشتری",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "patch_shop_customers_id_",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "c7x2kq9m",
                                        "name": "رضا",
                                        "phone": "989121234567",
                                        "email": "reza@example.com",
                                        "external_id": "wp-user-41",
                                        "note": "",
                                        "blocked": false,
                                        "trial_used": false,
                                        "services": 1,
                                        "orders": 2,
                                        "spent_toman": 180000,
                                        "created_at": 1764547200
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "description": ""
                                    },
                                    "phone": {
                                        "type": "string",
                                        "description": ""
                                    },
                                    "email": {
                                        "type": "string",
                                        "description": ""
                                    },
                                    "external_id": {
                                        "type": "string",
                                        "description": ""
                                    },
                                    "note": {
                                        "type": "string",
                                        "description": ""
                                    },
                                    "blocked": {
                                        "type": "boolean",
                                        "description": "مسدود (سفارش و تست نمی‌گیرد)"
                                    }
                                }
                            },
                            "example": {
                                "blocked": true
                            }
                        }
                    }
                }
            }
        },
        "/shop/customers/{id}/token": {
            "post": {
                "tags": [
                    "فروشگاه: مشتری‌ها و سرویس‌ها"
                ],
                "summary": "توکن تازه‌ی مشتری",
                "description": "توکن قبلی باطل می‌شود.\n\nدسترسی لازم: shop",
                "operationId": "post_shop_customers_id_token",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "customer_id": "c7x2kq9m",
                                        "customer_token": "ct_c7x2kq9m_…"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/shop/customers/{id}/services": {
            "get": {
                "tags": [
                    "فروشگاه: مشتری‌ها و سرویس‌ها"
                ],
                "summary": "سرویس‌های یک مشتری",
                "description": "برای صفحه‌ی «سرویس‌های من» سایتت: مصرف، مانده، روز، لینک اشتراک.\n\nدسترسی لازم: shop",
                "operationId": "get_shop_customers_id_services",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "items": [
                                            {
                                                "id": "s12",
                                                "name": "shop-4821",
                                                "plan": "۳۰ گیگ یک‌ماهه",
                                                "customer_id": "c7x2kq9m",
                                                "created_at": 1764633600,
                                                "trial": false,
                                                "config": {
                                                    "id": "ali-2041",
                                                    "name": "ali-2041",
                                                    "note": "مشتری اینستاگرام",
                                                    "status": "active",
                                                    "enabled": true,
                                                    "online": false,
                                                    "used_bytes": 3221225472,
                                                    "total_bytes": 32212254720,
                                                    "left_bytes": 28991029248,
                                                    "used_gb": 3,
                                                    "total_gb": 30,
                                                    "left_gb": 27,
                                                    "expire_type": "date",
                                                    "expire_at": 1767225600,
                                                    "days_left": 27,
                                                    "duration_seconds": null,
                                                    "daily_cap_gb": 0,
                                                    "capped_today": false,
                                                    "last_online": 1764633600,
                                                    "created_at": 1764547200,
                                                    "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v"
                                                },
                                                "exists": true
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/shop/customers/{id}/trial": {
            "post": {
                "tags": [
                    "فروشگاه: مشتری‌ها و سرویس‌ها"
                ],
                "summary": "تست رایگان",
                "description": "هر مشتری یک بار (طبق تنظیمات تست فروشگاه).\n\nدسترسی لازم: shop",
                "operationId": "post_shop_customers_id_trial",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "s12",
                                        "name": "shop-4821",
                                        "plan": "تست",
                                        "customer_id": "c7x2kq9m",
                                        "created_at": 1764633600,
                                        "trial": true,
                                        "config": {
                                            "id": "ali-2041",
                                            "name": "ali-2041",
                                            "note": "مشتری اینستاگرام",
                                            "status": "active",
                                            "enabled": true,
                                            "online": false,
                                            "used_bytes": 3221225472,
                                            "total_bytes": 32212254720,
                                            "left_bytes": 28991029248,
                                            "used_gb": 3,
                                            "total_gb": 30,
                                            "left_gb": 27,
                                            "expire_type": "date",
                                            "expire_at": 1767225600,
                                            "days_left": 27,
                                            "duration_seconds": null,
                                            "daily_cap_gb": 0,
                                            "capped_today": false,
                                            "last_online": 1764633600,
                                            "created_at": 1764547200,
                                            "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v"
                                        },
                                        "exists": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/shop/services/{id}": {
            "get": {
                "tags": [
                    "فروشگاه: مشتری‌ها و سرویس‌ها"
                ],
                "summary": "یک سرویس",
                "description": "با لینک‌ها و پیام آماده.\n\nدسترسی لازم: shop",
                "operationId": "get_shop_services_id_",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "s12",
                                        "name": "shop-4821",
                                        "plan": "۳۰ گیگ یک‌ماهه",
                                        "customer_id": "c7x2kq9m",
                                        "created_at": 1764633600,
                                        "trial": false,
                                        "config": {
                                            "id": "ali-2041",
                                            "name": "ali-2041",
                                            "note": "مشتری اینستاگرام",
                                            "status": "active",
                                            "enabled": true,
                                            "online": false,
                                            "used_bytes": 3221225472,
                                            "total_bytes": 32212254720,
                                            "left_bytes": 28991029248,
                                            "used_gb": 3,
                                            "total_gb": 30,
                                            "left_gb": 27,
                                            "expire_type": "date",
                                            "expire_at": 1767225600,
                                            "days_left": 27,
                                            "duration_seconds": null,
                                            "daily_cap_gb": 0,
                                            "capped_today": false,
                                            "last_online": 1764633600,
                                            "created_at": 1764547200,
                                            "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v"
                                        },
                                        "exists": true
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/shop/orders": {
            "post": {
                "tags": [
                    "فروشگاه: سفارش و پرداخت"
                ],
                "summary": "ثبت سفارش",
                "description": "با customer_id یا customer (ساخت/به‌روز کردن همزمان). برای تمدید، renew_service_id را بفرست. جواب، اطلاعات پرداخت همان روش را دارد. Idempotency-Key را با شماره‌ی سفارش سایتت بفرست.\n\nدسترسی لازم: shop",
                "operationId": "post_shop_orders",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "o8k2m4p1",
                                        "status": "awaiting_receipt",
                                        "customer_id": "c7x2kq9m",
                                        "source": "api",
                                        "plan": {
                                            "id": "p30",
                                            "name": "۳۰ گیگ یک‌ماهه",
                                            "gb": 30,
                                            "days": 30,
                                            "devices": 2
                                        },
                                        "amount_toman": 162000,
                                        "base_toman": 180000,
                                        "discount_pct": 10,
                                        "code": "YALDA",
                                        "method": "card",
                                        "renew_service_id": null,
                                        "created_at": 1764633600,
                                        "paid_at": null,
                                        "delivered_at": null,
                                        "reject_reason": "",
                                        "external_ref": "",
                                        "meta": {
                                            "site_order": "1042"
                                        },
                                        "payment": {
                                            "type": "card",
                                            "card_number": "XXXXXXXXXXXXXXXX",
                                            "card_name": "نام صاحب حساب",
                                            "amount_toman": 162000,
                                            "amount_rial": 1620000,
                                            "receipt_uploaded": false
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "plan_id": {
                                        "type": "string",
                                        "description": "شناسه‌ی پلن"
                                    },
                                    "method": {
                                        "type": "string",
                                        "description": "card | usdt | trx | ext"
                                    },
                                    "customer_id": {
                                        "type": "string",
                                        "description": "یا customer"
                                    },
                                    "customer": {
                                        "type": "object",
                                        "description": "{\"name\",\"phone\",\"email\",\"external_id\"}"
                                    },
                                    "code": {
                                        "type": "string",
                                        "description": "کد تخفیف"
                                    },
                                    "renew_service_id": {
                                        "type": "string",
                                        "description": "برای تمدید"
                                    },
                                    "meta": {
                                        "type": "object",
                                        "description": "تا ۱۰ کلید دلخواه (مثلاً شماره‌ی سفارش سایت)"
                                    }
                                },
                                "required": [
                                    "plan_id",
                                    "method"
                                ]
                            },
                            "example": {
                                "plan_id": "p30",
                                "method": "card",
                                "customer": {
                                    "name": "رضا",
                                    "phone": "09121234567",
                                    "external_id": "wp-user-41"
                                },
                                "code": "YALDA",
                                "meta": {
                                    "site_order": "1042"
                                }
                            }
                        }
                    }
                }
            },
            "get": {
                "tags": [
                    "فروشگاه: سفارش و پرداخت"
                ],
                "summary": "فهرست سفارش‌ها",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "get_shop_orders",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "items": [
                                            {
                                                "id": "o8k2m4p1",
                                                "status": "awaiting_receipt",
                                                "customer_id": "c7x2kq9m",
                                                "source": "api",
                                                "plan": {
                                                    "id": "p30",
                                                    "name": "۳۰ گیگ یک‌ماهه",
                                                    "gb": 30,
                                                    "days": 30,
                                                    "devices": 2
                                                },
                                                "amount_toman": 162000,
                                                "base_toman": 180000,
                                                "discount_pct": 10,
                                                "code": "YALDA",
                                                "method": "card",
                                                "renew_service_id": null,
                                                "created_at": 1764633600,
                                                "paid_at": null,
                                                "delivered_at": null,
                                                "reject_reason": "",
                                                "external_ref": "",
                                                "meta": {
                                                    "site_order": "1042"
                                                },
                                                "payment": {
                                                    "type": "card",
                                                    "card_number": "XXXXXXXXXXXXXXXX",
                                                    "card_name": "نام صاحب حساب",
                                                    "amount_toman": 162000,
                                                    "amount_rial": 1620000,
                                                    "receipt_uploaded": false
                                                }
                                            }
                                        ],
                                        "total": 22,
                                        "page": 1,
                                        "per_page": 50
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": "یکی از وضعیت‌ها"
                    },
                    {
                        "name": "customer_id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": ""
                    },
                    {
                        "name": "source",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        },
                        "description": "api (پیش‌فرض) یا all (سفارش‌های ربات هم)"
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        },
                        "description": ""
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer"
                        },
                        "description": ""
                    }
                ]
            }
        },
        "/shop/orders/{id}": {
            "get": {
                "tags": [
                    "فروشگاه: سفارش و پرداخت"
                ],
                "summary": "وضعیت سفارش",
                "description": "بعد از تحویل، service با لینک اشتراک دارد.\n\nدسترسی لازم: shop",
                "operationId": "get_shop_orders_id_",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "o8k2m4p1",
                                        "status": "delivered",
                                        "customer_id": "c7x2kq9m",
                                        "source": "api",
                                        "plan": {
                                            "id": "p30",
                                            "name": "۳۰ گیگ یک‌ماهه",
                                            "gb": 30,
                                            "days": 30,
                                            "devices": 2
                                        },
                                        "amount_toman": 162000,
                                        "base_toman": 180000,
                                        "discount_pct": 10,
                                        "code": "YALDA",
                                        "method": "card",
                                        "renew_service_id": null,
                                        "created_at": 1764633600,
                                        "paid_at": 1764634000,
                                        "delivered_at": 1764634010,
                                        "reject_reason": "",
                                        "external_ref": "",
                                        "meta": {
                                            "site_order": "1042"
                                        },
                                        "payment": {
                                            "type": "card",
                                            "card_number": "XXXXXXXXXXXXXXXX",
                                            "card_name": "نام صاحب حساب",
                                            "amount_toman": 162000,
                                            "amount_rial": 1620000,
                                            "receipt_uploaded": false
                                        },
                                        "service": {
                                            "id": "s12",
                                            "name": "shop-4821",
                                            "plan": "۳۰ گیگ یک‌ماهه",
                                            "customer_id": "c7x2kq9m",
                                            "created_at": 1764633600,
                                            "trial": false,
                                            "config": {
                                                "id": "ali-2041",
                                                "name": "ali-2041",
                                                "note": "مشتری اینستاگرام",
                                                "status": "active",
                                                "enabled": true,
                                                "online": false,
                                                "used_bytes": 3221225472,
                                                "total_bytes": 32212254720,
                                                "left_bytes": 28991029248,
                                                "used_gb": 3,
                                                "total_gb": 30,
                                                "left_gb": 27,
                                                "expire_type": "date",
                                                "expire_at": 1767225600,
                                                "days_left": 27,
                                                "duration_seconds": null,
                                                "daily_cap_gb": 0,
                                                "capped_today": false,
                                                "last_online": 1764633600,
                                                "created_at": 1764547200,
                                                "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v"
                                            },
                                            "exists": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/shop/orders/{id}/receipt": {
            "post": {
                "tags": [
                    "فروشگاه: سفارش و پرداخت"
                ],
                "summary": "آپلود رسید پرداخت دستی",
                "description": "image به‌صورت data:image/jpeg;base64,… یا فایل multipart با نام file (حداکثر ۸ مگ؛ JPG، PNG، WEBP). فقط عکس قبول است (note نادیده گرفته می‌شود مگر مدیر رسید متنی را باز کرده باشد). رسید برای تأیید به ربات یا مینی‌اپ تو می‌رود.\n\nدسترسی لازم: shop",
                "operationId": "post_shop_orders_id_receipt",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "o8k2m4p1",
                                        "status": "reviewing",
                                        "customer_id": "c7x2kq9m",
                                        "source": "api",
                                        "plan": {
                                            "id": "p30",
                                            "name": "۳۰ گیگ یک‌ماهه",
                                            "gb": 30,
                                            "days": 30,
                                            "devices": 2
                                        },
                                        "amount_toman": 162000,
                                        "base_toman": 180000,
                                        "discount_pct": 10,
                                        "code": "YALDA",
                                        "method": "card",
                                        "renew_service_id": null,
                                        "created_at": 1764633600,
                                        "paid_at": null,
                                        "delivered_at": null,
                                        "reject_reason": "",
                                        "external_ref": "",
                                        "meta": {
                                            "site_order": "1042"
                                        },
                                        "payment": {
                                            "type": "card",
                                            "card_number": "XXXXXXXXXXXXXXXX",
                                            "card_name": "نام صاحب حساب",
                                            "amount_toman": 162000,
                                            "amount_rial": 1620000,
                                            "receipt_uploaded": false
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "image": {
                                        "type": "string",
                                        "description": "data URI عکس"
                                    },
                                    "note": {
                                        "type": "string",
                                        "description": "شماره‌ی پیگیری یا توضیح"
                                    }
                                }
                            },
                            "example": {
                                "image": "data:image/jpeg;base64,/9j/…",
                                "note": "پیگیری ۱۲۳۴۵۶"
                            }
                        }
                    }
                }
            }
        },
        "/shop/orders/{id}/approve": {
            "post": {
                "tags": [
                    "فروشگاه: سفارش و پرداخت"
                ],
                "summary": "تأیید رسید و تحویل",
                "description": "همان کار دکمه‌ی «تأیید» ربات.\n\nدسترسی لازم: shop",
                "operationId": "post_shop_orders_id_approve",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "o8k2m4p1",
                                        "status": "delivered",
                                        "customer_id": "c7x2kq9m",
                                        "source": "api",
                                        "plan": {
                                            "id": "p30",
                                            "name": "۳۰ گیگ یک‌ماهه",
                                            "gb": 30,
                                            "days": 30,
                                            "devices": 2
                                        },
                                        "amount_toman": 162000,
                                        "base_toman": 180000,
                                        "discount_pct": 10,
                                        "code": "YALDA",
                                        "method": "card",
                                        "renew_service_id": null,
                                        "created_at": 1764633600,
                                        "paid_at": 1764634000,
                                        "delivered_at": 1764634010,
                                        "reject_reason": "",
                                        "external_ref": "",
                                        "meta": {
                                            "site_order": "1042"
                                        },
                                        "payment": {
                                            "type": "card",
                                            "card_number": "XXXXXXXXXXXXXXXX",
                                            "card_name": "نام صاحب حساب",
                                            "amount_toman": 162000,
                                            "amount_rial": 1620000,
                                            "receipt_uploaded": false
                                        },
                                        "service": {
                                            "id": "s12",
                                            "name": "shop-4821",
                                            "plan": "۳۰ گیگ یک‌ماهه",
                                            "customer_id": "c7x2kq9m",
                                            "created_at": 1764633600,
                                            "trial": false,
                                            "config": {
                                                "id": "ali-2041",
                                                "name": "ali-2041",
                                                "note": "مشتری اینستاگرام",
                                                "status": "active",
                                                "enabled": true,
                                                "online": false,
                                                "used_bytes": 3221225472,
                                                "total_bytes": 32212254720,
                                                "left_bytes": 28991029248,
                                                "used_gb": 3,
                                                "total_gb": 30,
                                                "left_gb": 27,
                                                "expire_type": "date",
                                                "expire_at": 1767225600,
                                                "days_left": 27,
                                                "duration_seconds": null,
                                                "daily_cap_gb": 0,
                                                "capped_today": false,
                                                "last_online": 1764633600,
                                                "created_at": 1764547200,
                                                "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v"
                                            },
                                            "exists": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/shop/orders/{id}/reject": {
            "post": {
                "tags": [
                    "فروشگاه: سفارش و پرداخت"
                ],
                "summary": "رد رسید",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "post_shop_orders_id_reject",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "o8k2m4p1",
                                        "status": "rejected",
                                        "customer_id": "c7x2kq9m",
                                        "source": "api",
                                        "plan": {
                                            "id": "p30",
                                            "name": "۳۰ گیگ یک‌ماهه",
                                            "gb": 30,
                                            "days": 30,
                                            "devices": 2
                                        },
                                        "amount_toman": 162000,
                                        "base_toman": 180000,
                                        "discount_pct": 10,
                                        "code": "YALDA",
                                        "method": "card",
                                        "renew_service_id": null,
                                        "created_at": 1764633600,
                                        "paid_at": null,
                                        "delivered_at": null,
                                        "reject_reason": "مبلغ واریزی کم است",
                                        "external_ref": "",
                                        "meta": {
                                            "site_order": "1042"
                                        },
                                        "payment": {
                                            "type": "card",
                                            "card_number": "XXXXXXXXXXXXXXXX",
                                            "card_name": "نام صاحب حساب",
                                            "amount_toman": 162000,
                                            "amount_rial": 1620000,
                                            "receipt_uploaded": false
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "reason": {
                                        "type": "string",
                                        "description": "دلیل (به سایتت در Webhook هم می‌رسد)"
                                    }
                                }
                            },
                            "example": {
                                "reason": "مبلغ واریزی کم است"
                            }
                        }
                    }
                }
            }
        },
        "/shop/orders/{id}/paid": {
            "post": {
                "tags": [
                    "فروشگاه: سفارش و پرداخت"
                ],
                "summary": "پرداخت شد (درگاه خودت)",
                "description": "فقط برای method=ext. اول در سایتت پرداخت را با درگاه verify کن، بعد این را با شماره‌ی پیگیری بزن. ref تکراری قبول نمی‌شود.\n\nدسترسی لازم: shop",
                "operationId": "post_shop_orders_id_paid",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "o8k2m4p1",
                                        "status": "delivered",
                                        "customer_id": "c7x2kq9m",
                                        "source": "api",
                                        "plan": {
                                            "id": "p30",
                                            "name": "۳۰ گیگ یک‌ماهه",
                                            "gb": 30,
                                            "days": 30,
                                            "devices": 2
                                        },
                                        "amount_toman": 162000,
                                        "base_toman": 180000,
                                        "discount_pct": 10,
                                        "code": "YALDA",
                                        "method": "card",
                                        "renew_service_id": null,
                                        "created_at": 1764633600,
                                        "paid_at": 1764634000,
                                        "delivered_at": 1764634010,
                                        "reject_reason": "",
                                        "external_ref": "",
                                        "meta": {
                                            "site_order": "1042"
                                        },
                                        "payment": {
                                            "type": "card",
                                            "card_number": "XXXXXXXXXXXXXXXX",
                                            "card_name": "نام صاحب حساب",
                                            "amount_toman": 162000,
                                            "amount_rial": 1620000,
                                            "receipt_uploaded": false
                                        },
                                        "service": {
                                            "id": "s12",
                                            "name": "shop-4821",
                                            "plan": "۳۰ گیگ یک‌ماهه",
                                            "customer_id": "c7x2kq9m",
                                            "created_at": 1764633600,
                                            "trial": false,
                                            "config": {
                                                "id": "ali-2041",
                                                "name": "ali-2041",
                                                "note": "مشتری اینستاگرام",
                                                "status": "active",
                                                "enabled": true,
                                                "online": false,
                                                "used_bytes": 3221225472,
                                                "total_bytes": 32212254720,
                                                "left_bytes": 28991029248,
                                                "used_gb": 3,
                                                "total_gb": 30,
                                                "left_gb": 27,
                                                "expire_type": "date",
                                                "expire_at": 1767225600,
                                                "days_left": 27,
                                                "duration_seconds": null,
                                                "daily_cap_gb": 0,
                                                "capped_today": false,
                                                "last_online": 1764633600,
                                                "created_at": 1764547200,
                                                "subscription_url": "https://sub.example.com/sub/k3j9x2mq7p4r8t1v"
                                            },
                                            "exists": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "ref": {
                                        "type": "string",
                                        "description": "شماره‌ی پیگیری درگاه"
                                    },
                                    "amount_toman": {
                                        "type": "integer",
                                        "description": "مبلغ پرداخت‌شده (کمتر از مبلغ سفارش رد می‌شود)"
                                    },
                                    "gateway": {
                                        "type": "string",
                                        "description": "zibal، zarinpal، …"
                                    }
                                },
                                "required": [
                                    "ref"
                                ]
                            },
                            "example": {
                                "ref": "789456123",
                                "amount_toman": 162000,
                                "gateway": "zarinpal"
                            }
                        }
                    }
                }
            }
        },
        "/shop/orders/{id}/check": {
            "post": {
                "tags": [
                    "فروشگاه: سفارش و پرداخت"
                ],
                "summary": "بررسی دوباره‌ی پرداخت رمزارز",
                "description": "بررسی خودکار هر ۲ دقیقه هم انجام می‌شود.\n\nدسترسی لازم: shop",
                "operationId": "post_shop_orders_id_check",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "o8k2m4p1",
                                        "status": "awaiting_receipt",
                                        "customer_id": "c7x2kq9m",
                                        "source": "api",
                                        "plan": {
                                            "id": "p30",
                                            "name": "۳۰ گیگ یک‌ماهه",
                                            "gb": 30,
                                            "days": 30,
                                            "devices": 2
                                        },
                                        "amount_toman": 162000,
                                        "base_toman": 180000,
                                        "discount_pct": 10,
                                        "code": "YALDA",
                                        "method": "card",
                                        "renew_service_id": null,
                                        "created_at": 1764633600,
                                        "paid_at": null,
                                        "delivered_at": null,
                                        "reject_reason": "",
                                        "external_ref": "",
                                        "meta": {
                                            "site_order": "1042"
                                        },
                                        "payment": {
                                            "type": "card",
                                            "card_number": "XXXXXXXXXXXXXXXX",
                                            "card_name": "نام صاحب حساب",
                                            "amount_toman": 162000,
                                            "amount_rial": 1620000,
                                            "receipt_uploaded": false
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/shop/orders/{id}/cancel": {
            "post": {
                "tags": [
                    "فروشگاه: سفارش و پرداخت"
                ],
                "summary": "لغو سفارش پرداخت‌نشده",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "post_shop_orders_id_cancel",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "id": "o8k2m4p1",
                                        "status": "cancelled",
                                        "customer_id": "c7x2kq9m",
                                        "source": "api",
                                        "plan": {
                                            "id": "p30",
                                            "name": "۳۰ گیگ یک‌ماهه",
                                            "gb": 30,
                                            "days": 30,
                                            "devices": 2
                                        },
                                        "amount_toman": 162000,
                                        "base_toman": 180000,
                                        "discount_pct": 10,
                                        "code": "YALDA",
                                        "method": "card",
                                        "renew_service_id": null,
                                        "created_at": 1764633600,
                                        "paid_at": null,
                                        "delivered_at": null,
                                        "reject_reason": "",
                                        "external_ref": "",
                                        "meta": {
                                            "site_order": "1042"
                                        },
                                        "payment": {
                                            "type": "card",
                                            "card_number": "XXXXXXXXXXXXXXXX",
                                            "card_name": "نام صاحب حساب",
                                            "amount_toman": 162000,
                                            "amount_rial": 1620000,
                                            "receipt_uploaded": false
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "شناسه یا نام"
                    }
                ]
            }
        },
        "/shop/webhook": {
            "get": {
                "tags": [
                    "خبر خودکار (Webhook)"
                ],
                "summary": "تنظیمات و گزارش ارسال‌ها",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "get_shop_webhook",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "url": "https://mysite.com/hook",
                                        "enabled": true,
                                        "events": [
                                            "order.created",
                                            "order.receipt_uploaded",
                                            "order.paid",
                                            "order.delivered",
                                            "order.rejected",
                                            "order.receipt_requested",
                                            "order.cancelled",
                                            "order.revoked",
                                            "order.hold",
                                            "service.low",
                                            "service.expired",
                                            "panel.low_balance"
                                        ],
                                        "secret_hint": "…a1b2",
                                        "queue": 0,
                                        "failures": 0,
                                        "deliveries": [
                                            {
                                                "at": 1764634010,
                                                "event": "order.delivered",
                                                "status": 200,
                                                "ms": 180,
                                                "error": "",
                                                "attempt": 1
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "tags": [
                    "خبر خودکار (Webhook)"
                ],
                "summary": "تنظیم آدرس و رویدادها",
                "description": "راز (secret) فقط بار اول یا با rotate_secret برمی‌گردد. url خالی = خاموش. رویدادها: order.created، order.receipt_uploaded، order.paid، order.delivered، order.rejected، order.receipt_requested، order.cancelled، order.revoked، order.hold، service.low، service.expired، panel.low_balance\n\nدسترسی لازم: shop",
                "operationId": "put_shop_webhook",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "url": "https://mysite.com/hook",
                                        "enabled": true,
                                        "secret": "whsec_…"
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "url": {
                                        "type": "string",
                                        "description": "آدرس https سایتت"
                                    },
                                    "events": {
                                        "type": "string",
                                        "description": "پیش‌فرض همه",
                                        "items": {
                                            "type": "string"
                                        }
                                    },
                                    "rotate_secret": {
                                        "type": "boolean",
                                        "description": "راز تازه"
                                    }
                                },
                                "required": [
                                    "url"
                                ]
                            },
                            "example": {
                                "url": "https://mysite.com/hook",
                                "events": [
                                    "order.delivered",
                                    "order.rejected",
                                    "service.low"
                                ]
                            }
                        }
                    }
                }
            }
        },
        "/shop/webhook/test": {
            "post": {
                "tags": [
                    "خبر خودکار (Webhook)"
                ],
                "summary": "فرستادن پیام آزمایشی",
                "description": "\n\nدسترسی لازم: shop",
                "operationId": "post_shop_webhook_test",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "example": {
                                    "ok": true,
                                    "data": {
                                        "delivered": true,
                                        "last": {
                                            "at": 1764634010,
                                            "event": "test",
                                            "status": 200,
                                            "ms": 140,
                                            "error": "",
                                            "attempt": 1
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "description": "خطا",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearer": {
                "type": "http",
                "scheme": "bearer",
                "description": "کلید tsk_… از مینی‌اپ ← تنظیمات ← API"
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "properties": {
                    "ok": {
                        "type": "boolean"
                    },
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    }
}