{
    "openapi": "3.1.0",
    "info": {
        "title": "SMMFlash Compat API",
        "version": "1.0.0",
        "description": "SMM panel compatible API for bots that use action=... protocol."
    },
    "servers": [
        {
            "url": "https://smmflash.ru",
            "description": "Site root URL"
        }
    ],
    "tags": [
        {
            "name": "Compat",
            "description": "SMM-compatible action endpoint"
        }
    ],
    "paths": {
        "/api": {
            "post": {
                "tags": [
                    "Compat"
                ],
                "summary": "Execute SMM-compatible action",
                "description": "Compatibility layer for SMM panel bots.\n\nSend POST form fields: key, action, and action-specific parameters.\nSupported actions: balance, services, add, status, refill, cancel.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/x-www-form-urlencoded": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "key",
                                    "action"
                                ],
                                "properties": {
                                    "key": {
                                        "type": "string",
                                        "description": "API token from user profile"
                                    },
                                    "action": {
                                        "type": "string",
                                        "enum": [
                                            "balance",
                                            "services",
                                            "add",
                                            "status",
                                            "refill",
                                            "cancel"
                                        ]
                                    },
                                    "service": {
                                        "type": "integer",
                                        "description": "Required for add"
                                    },
                                    "link": {
                                        "type": "string",
                                        "description": "Required for add"
                                    },
                                    "quantity": {
                                        "type": "integer",
                                        "description": "Required for add"
                                    },
                                    "order": {
                                        "type": "integer",
                                        "description": "Single local order ID"
                                    },
                                    "orders": {
                                        "type": "string",
                                        "description": "CSV local order IDs, e.g. 12,13,14"
                                    }
                                }
                            },
                            "examples": {
                                "balance": {
                                    "summary": "Check balance",
                                    "value": {
                                        "key": "smf_...",
                                        "action": "balance"
                                    }
                                },
                                "createOrder": {
                                    "summary": "Create order",
                                    "value": {
                                        "key": "smf_...",
                                        "action": "add",
                                        "service": 9,
                                        "link": "https://t.me/your_channel/123",
                                        "quantity": 1000
                                    }
                                },
                                "cancelOrder": {
                                    "summary": "Cancel order",
                                    "value": {
                                        "key": "smf_...",
                                        "action": "cancel",
                                        "order": 123
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Action result",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/CompatBalanceResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatAddResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatStatusResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatRefillResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatCancelResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatServicesResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatErrorResponse"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v2": {
            "post": {
                "tags": [
                    "Compat"
                ],
                "summary": "Execute SMM-compatible action",
                "description": "Compatibility layer for SMM panel bots.\n\nSend POST form fields: key, action, and action-specific parameters.\nSupported actions: balance, services, add, status, refill, cancel.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/x-www-form-urlencoded": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "key",
                                    "action"
                                ],
                                "properties": {
                                    "key": {
                                        "type": "string",
                                        "description": "API token from user profile"
                                    },
                                    "action": {
                                        "type": "string",
                                        "enum": [
                                            "balance",
                                            "services",
                                            "add",
                                            "status",
                                            "refill",
                                            "cancel"
                                        ]
                                    },
                                    "service": {
                                        "type": "integer",
                                        "description": "Required for add"
                                    },
                                    "link": {
                                        "type": "string",
                                        "description": "Required for add"
                                    },
                                    "quantity": {
                                        "type": "integer",
                                        "description": "Required for add"
                                    },
                                    "order": {
                                        "type": "integer",
                                        "description": "Single local order ID"
                                    },
                                    "orders": {
                                        "type": "string",
                                        "description": "CSV local order IDs, e.g. 12,13,14"
                                    }
                                }
                            },
                            "examples": {
                                "balance": {
                                    "summary": "Check balance",
                                    "value": {
                                        "key": "smf_...",
                                        "action": "balance"
                                    }
                                },
                                "createOrder": {
                                    "summary": "Create order",
                                    "value": {
                                        "key": "smf_...",
                                        "action": "add",
                                        "service": 9,
                                        "link": "https://t.me/your_channel/123",
                                        "quantity": 1000
                                    }
                                },
                                "cancelOrder": {
                                    "summary": "Cancel order",
                                    "value": {
                                        "key": "smf_...",
                                        "action": "cancel",
                                        "order": 123
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Action result",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/CompatBalanceResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatAddResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatStatusResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatRefillResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatCancelResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatServicesResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/CompatErrorResponse"
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "CompatErrorResponse": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "string",
                        "example": "Invalid API key."
                    }
                }
            },
            "CompatBalanceResponse": {
                "type": "object",
                "required": [
                    "balance",
                    "currency"
                ],
                "properties": {
                    "balance": {
                        "type": "string",
                        "example": "1523.5000"
                    },
                    "currency": {
                        "type": "string",
                        "example": "RUB"
                    }
                }
            },
            "CompatAddResponse": {
                "type": "object",
                "required": [
                    "order"
                ],
                "properties": {
                    "order": {
                        "type": "integer",
                        "example": 123
                    }
                }
            },
            "CompatStatusResponse": {
                "type": "object",
                "properties": {
                    "charge": {
                        "type": "string",
                        "example": "45.0000"
                    },
                    "start_count": {
                        "type": "integer",
                        "nullable": true,
                        "example": 100
                    },
                    "status": {
                        "type": "string",
                        "example": "In progress"
                    },
                    "remains": {
                        "type": "integer",
                        "nullable": true,
                        "example": 900
                    },
                    "currency": {
                        "type": "string",
                        "example": "RUB"
                    }
                }
            },
            "CompatRefillResponse": {
                "type": "object",
                "properties": {
                    "refill": {
                        "type": "string",
                        "example": "45678"
                    }
                }
            },
            "CompatCancelResponse": {
                "type": "object",
                "properties": {
                    "cancel": {
                        "type": "string",
                        "example": "1"
                    }
                }
            },
            "CompatServiceItem": {
                "type": "object",
                "properties": {
                    "service": {
                        "type": "integer",
                        "example": 9
                    },
                    "name": {
                        "type": "string",
                        "example": "Telegram Views"
                    },
                    "type": {
                        "type": "string",
                        "example": "default"
                    },
                    "rate": {
                        "type": "string",
                        "example": "45.0000"
                    },
                    "min": {
                        "type": "integer",
                        "example": 100
                    },
                    "max": {
                        "type": "integer",
                        "example": 100000
                    },
                    "dripfeed": {
                        "type": "integer",
                        "example": 0
                    },
                    "refill": {
                        "type": "integer",
                        "example": 1
                    },
                    "cancel": {
                        "type": "integer",
                        "example": 1
                    },
                    "provider_service_id": {
                        "type": "integer",
                        "example": 2812
                    }
                }
            },
            "CompatServicesResponse": {
                "type": "array",
                "items": {
                    "$ref": "#/components/schemas/CompatServiceItem"
                }
            }
        }
    }
}