{
    "openapi": "3.0.3",
    "info": {
        "title": "Bebas Topup Reseller API",
        "version": "1.3.0",
        "description": "Authenticate with your secret API key as a Bearer token. ref_id makes POST /v1/orders idempotent. Money values are decimal strings in IDR."
    },
    "servers": [
        {
            "url": "https://api.bebastopup.com/v1"
        }
    ],
    "security": [
        {
            "BearerAuth": []
        }
    ],
    "paths": {
        "/profile": {
            "get": {
                "summary": "Partner profile: level, balance, and daily limits",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "code": {
                                            "type": "string"
                                        },
                                        "message": {
                                            "type": "string"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/Profile"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/services": {
            "get": {
                "summary": "All products and items with your reseller price (no pagination); filters are optional",
                "parameters": [
                    {
                        "name": "filter_product",
                        "in": "query",
                        "description": "Exact brand (product) or category name, case-insensitive.",
                        "schema": {
                            "type": "string",
                            "maxLength": 100
                        }
                    },
                    {
                        "name": "filter_status",
                        "in": "query",
                        "description": "Only items with this status.",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "available",
                                "empty"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "code": {
                                            "type": "string"
                                        },
                                        "message": {
                                            "type": "string"
                                        },
                                        "data": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/services/{item_code}": {
            "get": {
                "summary": "One item",
                "parameters": [
                    {
                        "name": "item_code",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "code": {
                                            "type": "string"
                                        },
                                        "message": {
                                            "type": "string"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/Item"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/orders": {
            "post": {
                "summary": "Create an order (idempotent per ref_id)",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "ref_id",
                                    "item_code",
                                    "target"
                                ],
                                "properties": {
                                    "ref_id": {
                                        "type": "string",
                                        "pattern": "^[A-Za-z0-9._-]{1,64}$"
                                    },
                                    "item_code": {
                                        "type": "string"
                                    },
                                    "target": {
                                        "type": "object",
                                        "description": "Fixed account fields, the same names for every product. Send the ones the item lists in GET /services fields[] (fields[].required marks the mandatory ones); any other field is refused with VALIDATION_ERROR. Numbers are accepted; send values with a leading zero (phone numbers) as strings.",
                                        "properties": {
                                            "user_id": {
                                                "oneOf": [
                                                    {
                                                        "type": "string",
                                                        "maxLength": 255
                                                    },
                                                    {
                                                        "type": "number"
                                                    }
                                                ],
                                                "description": "Account ID or destination number (game ID, phone number, meter number)."
                                            },
                                            "zone_id": {
                                                "oneOf": [
                                                    {
                                                        "type": "string",
                                                        "maxLength": 255
                                                    },
                                                    {
                                                        "type": "number"
                                                    }
                                                ],
                                                "description": "Zone or server of the game account."
                                            },
                                            "username": {
                                                "type": "string",
                                                "maxLength": 255,
                                                "description": "Account username or login choice, when the item asks for it."
                                            },
                                            "order_detail": {
                                                "type": "string",
                                                "maxLength": 255,
                                                "description": "Order detail, when the item asks for it."
                                            },
                                            "additional_id": {
                                                "oneOf": [
                                                    {
                                                        "type": "string",
                                                        "maxLength": 64
                                                    },
                                                    {
                                                        "type": "number"
                                                    }
                                                ],
                                                "description": "Optional extra account data passed to the provider."
                                            }
                                        },
                                        "additionalProperties": false,
                                        "example": {
                                            "user_id": "12345678",
                                            "zone_id": "1234"
                                        }
                                    },
                                    "max_price": {
                                        "type": "string",
                                        "example": "10500.00",
                                        "description": "Refuse the order (PRICE_CHANGED) when the price is higher."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "code": {
                                            "type": "string"
                                        },
                                        "message": {
                                            "type": "string"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/Order"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "code": {
                                            "type": "string"
                                        },
                                        "message": {
                                            "type": "string"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/Order"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/orders/{ref_id}": {
            "get": {
                "summary": "Order status by ref_id",
                "parameters": [
                    {
                        "name": "ref_id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean"
                                        },
                                        "code": {
                                            "type": "string"
                                        },
                                        "message": {
                                            "type": "string"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/Order"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "default": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "BearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "Your secret API key: bt_live_sk_\u2026 or bt_test_sk_\u2026"
            }
        },
        "responses": {
            "Error": {
                "description": "Error",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "success": {
                                    "type": "boolean",
                                    "example": false
                                },
                                "code": {
                                    "type": "string",
                                    "enum": [
                                        "INVALID_API_KEY",
                                        "IP_NOT_ALLOWED",
                                        "ACCOUNT_SUSPENDED",
                                        "RATE_LIMITED",
                                        "VALIDATION_ERROR",
                                        "ITEM_NOT_FOUND",
                                        "ITEM_UNAVAILABLE",
                                        "PRICE_CHANGED",
                                        "INSUFFICIENT_BALANCE",
                                        "DAILY_LIMIT_REACHED",
                                        "OUTSTANDING_RECEIVABLE",
                                        "REF_ID_CONFLICT",
                                        "ORDER_NOT_FOUND",
                                        "NOT_FOUND",
                                        "METHOD_NOT_ALLOWED",
                                        "PAYLOAD_TOO_LARGE",
                                        "INTERNAL_ERROR"
                                    ]
                                },
                                "message": {
                                    "type": "string"
                                },
                                "data": {
                                    "type": "object",
                                    "nullable": true
                                }
                            }
                        }
                    }
                }
            }
        },
        "schemas": {
            "Profile": {
                "type": "object",
                "properties": {
                    "business_name": {
                        "type": "string"
                    },
                    "level": {
                        "type": "string"
                    },
                    "environment": {
                        "type": "string",
                        "enum": [
                            "live",
                            "sandbox"
                        ]
                    },
                    "balance": {
                        "type": "string",
                        "example": "250000.00"
                    },
                    "currency": {
                        "type": "string",
                        "example": "IDR"
                    },
                    "daily_limit": {
                        "type": "object",
                        "nullable": true,
                        "properties": {
                            "amount": {
                                "type": "string",
                                "nullable": true
                            },
                            "count": {
                                "type": "integer",
                                "nullable": true
                            },
                            "used_amount": {
                                "type": "string"
                            },
                            "used_count": {
                                "type": "integer"
                            }
                        }
                    }
                }
            },
            "Item": {
                "type": "object",
                "properties": {
                    "item_code": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "group": {
                        "type": "string",
                        "nullable": true
                    },
                    "price": {
                        "type": "string"
                    },
                    "currency": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "available",
                            "empty"
                        ]
                    }
                }
            },
            "Failure": {
                "type": "object",
                "nullable": true,
                "properties": {
                    "code": {
                        "type": "string",
                        "enum": [
                            "PROVIDER_REJECTED",
                            "PRODUCT_UNAVAILABLE",
                            "CANCELLED_BY_ADMIN",
                            "EXPIRED"
                        ]
                    },
                    "message": {
                        "type": "string",
                        "description": "The provider's message when it gave one."
                    }
                }
            },
            "Order": {
                "type": "object",
                "properties": {
                    "ref_id": {
                        "type": "string",
                        "nullable": true
                    },
                    "order_id": {
                        "type": "string"
                    },
                    "source": {
                        "type": "string",
                        "enum": [
                            "api",
                            "dashboard"
                        ]
                    },
                    "item_code": {
                        "type": "string",
                        "nullable": true
                    },
                    "product": {
                        "type": "string"
                    },
                    "item": {
                        "type": "string"
                    },
                    "target": {
                        "type": "object"
                    },
                    "price": {
                        "type": "string"
                    },
                    "currency": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "processing",
                            "success",
                            "failed"
                        ]
                    },
                    "sn": {
                        "type": "string",
                        "nullable": true
                    },
                    "message": {
                        "type": "string",
                        "nullable": true
                    },
                    "failure": {
                        "$ref": "#/components/schemas/Failure"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "completed_at": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "failed_at": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    }
                }
            }
        }
    }
}