{"openapi": "3.0.3", "info": {"title": "LuckyMonkey SMS API", "version": "1.0.0", "description": "REST/JSON API. HTTPS only. Public catalog, Bearer-authenticated balance and orders. 120 authenticated requests/minute/account, 10 purchase requests/minute/account; public 60/minute/IP, invalid keys 30/minute/IP. Keys are scoped, expiring and revocable; password changes invalidate keys. This is not handler_api.php or a 5SIM-compatible endpoint."}, "servers": [{"url": "https://luckymonkey.cc/api/v1"}], "paths": {"/balance": {"get": {"operationId": "getBalance", "description": "Shared website/API wallet. Display strings have four decimals; *_units are exact (1 USD = 1000000 units).", "security": [{"BearerAuth": []}], "parameters": [], "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Balance"}}}}, "400": {"description": "Invalid request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "402": {"description": "Insufficient balance", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Read-only key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "Resource not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "409": {"description": "Conflict or unavailable operation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "413": {"description": "Request too large", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "415": {"description": "Use application/json", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate limit; respect Retry-After", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "503": {"description": "Processing unavailable", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}}, "/countries": {"get": {"operationId": "getCountries", "description": "Active countries with catalog prices. IDs are two-letter country codes.", "security": [], "parameters": [{"name": "limit", "in": "query", "schema": {"type": "integer", "minimum": 1, "maximum": 100, "default": 50}}, {"name": "offset", "in": "query", "schema": {"type": "integer", "minimum": 0, "maximum": 100000, "default": 0}}], "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"type": "object", "required": ["data", "limit", "offset", "next_offset"], "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/Country"}}, "limit": {"type": "integer", "minimum": 0}, "offset": {"type": "integer", "minimum": 0}, "next_offset": {"type": "integer", "nullable": true}}}}}}, "400": {"description": "Invalid request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "402": {"description": "Insufficient balance", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Read-only key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "Resource not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "409": {"description": "Conflict or unavailable operation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "413": {"description": "Request too large", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "415": {"description": "Use application/json", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate limit; respect Retry-After", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "503": {"description": "Processing unavailable", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}}, "/services": {"get": {"operationId": "getServices", "description": "Published services ordered by name. Use each returned ID in /prices.", "security": [], "parameters": [{"name": "limit", "in": "query", "schema": {"type": "integer", "minimum": 1, "maximum": 100, "default": 50}}, {"name": "offset", "in": "query", "schema": {"type": "integer", "minimum": 0, "maximum": 100000, "default": 0}}, {"name": "q", "in": "query", "schema": {"type": "string", "maxLength": 100}}], "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"type": "object", "required": ["data", "limit", "offset", "next_offset"], "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/Service"}}, "limit": {"type": "integer", "minimum": 0}, "offset": {"type": "integer", "minimum": 0}, "next_offset": {"type": "integer", "nullable": true}}}}}}, "400": {"description": "Invalid request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "402": {"description": "Insufficient balance", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Read-only key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "Resource not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "409": {"description": "Conflict or unavailable operation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "413": {"description": "Request too large", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "415": {"description": "Use application/json", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate limit; respect Retry-After", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "503": {"description": "Processing unavailable", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}}, "/prices": {"get": {"operationId": "getPrices", "description": "Current retail quotes and availability. A quote is not a stock reservation. Use price_id and price_version to create an order.", "security": [], "parameters": [{"name": "limit", "in": "query", "schema": {"type": "integer", "minimum": 1, "maximum": 100, "default": 50}}, {"name": "offset", "in": "query", "schema": {"type": "integer", "minimum": 0, "maximum": 100000, "default": 0}}, {"name": "service", "in": "query", "required": true, "schema": {"type": "string", "maxLength": 160}}, {"name": "country", "in": "query", "schema": {"type": "string", "pattern": "^[A-Za-z]{2}$"}}], "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"type": "object", "required": ["data", "limit", "offset", "next_offset"], "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/Price"}}, "limit": {"type": "integer", "minimum": 0}, "offset": {"type": "integer", "minimum": 0}, "next_offset": {"type": "integer", "nullable": true}}}}}}, "400": {"description": "Invalid request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "402": {"description": "Insufficient balance", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Read-only key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "Resource not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "409": {"description": "Conflict or unavailable operation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "413": {"description": "Request too large", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "415": {"description": "Use application/json", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate limit; respect Retry-After", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "503": {"description": "Processing unavailable", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}}, "/orders": {"get": {"operationId": "listOrders", "description": "Only the authenticated account's orders, newest first.", "security": [{"BearerAuth": []}], "parameters": [{"name": "limit", "in": "query", "schema": {"type": "integer", "minimum": 1, "maximum": 100, "default": 50}}, {"name": "offset", "in": "query", "schema": {"type": "integer", "minimum": 0, "maximum": 100000, "default": 0}}, {"name": "status", "in": "query", "schema": {"type": "string", "enum": ["allocating", "allocation_pending", "waiting_sms", "finalizing", "completed", "expired", "failed"]}}], "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"type": "object", "required": ["data", "limit", "offset", "next_offset"], "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/Order"}}, "limit": {"type": "integer", "minimum": 0}, "offset": {"type": "integer", "minimum": 0}, "next_offset": {"type": "integer", "nullable": true}}}}}}, "400": {"description": "Invalid request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "402": {"description": "Insufficient balance", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Read-only key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "Resource not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "409": {"description": "Conflict or unavailable operation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "413": {"description": "Request too large", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "415": {"description": "Use application/json", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate limit; respect Retry-After", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "503": {"description": "Processing unavailable", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}, "post": {"operationId": "createOrder", "description": "Reserve funds and enqueue allocation. Reuse the UUID and same JSON after a timeout; no duplicate debit. The number is initially null.", "security": [{"BearerAuth": []}], "parameters": [{"name": "Idempotency-Key", "in": "header", "required": true, "schema": {"type": "string", "format": "uuid"}}], "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"type": "object", "required": ["data"], "properties": {"data": {"$ref": "#/components/schemas/Order"}}}}}}, "202": {"description": "Accepted", "content": {"application/json": {"schema": {"type": "object", "required": ["data"], "properties": {"data": {"$ref": "#/components/schemas/Order"}}}}}, "headers": {"Location": {"schema": {"type": "string"}, "description": "Relative order status URL"}, "Retry-After": {"schema": {"type": "integer"}, "description": "Poll delay in seconds"}, "Idempotency-Replayed": {"schema": {"type": "string", "enum": ["true", "false"]}}}}, "400": {"description": "Invalid request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "402": {"description": "Insufficient balance", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Read-only key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "Resource not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "409": {"description": "Conflict or unavailable operation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "413": {"description": "Request too large", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "415": {"description": "Use application/json", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate limit; respect Retry-After", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "503": {"description": "Processing unavailable", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}, "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": false, "required": ["price_id", "price_version"], "properties": {"price_id": {"type": "integer", "minimum": 1}, "price_version": {"type": "integer", "minimum": 1}, "max_price": {"type": "string", "pattern": "^[0-9]+(\\.[0-9]{1,6})?$", "example": "1.0000"}}}}}}}}, "/orders/{id}": {"get": {"operationId": "getOrder", "description": "Poll no more than once every five seconds. SMS and refunds are applied automatically by the worker.", "security": [{"BearerAuth": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}], "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"type": "object", "required": ["data"], "properties": {"data": {"$ref": "#/components/schemas/Order"}}}}}}, "400": {"description": "Invalid request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "402": {"description": "Insufficient balance", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Read-only key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "Resource not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "409": {"description": "Conflict or unavailable operation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "413": {"description": "Request too large", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "415": {"description": "Use application/json", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate limit; respect Retry-After", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "503": {"description": "Processing unavailable", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}}, "/orders/{id}/cancel": {"post": {"operationId": "cancelOrder", "description": "Requires order scope. Only allowed before a supplier attempt exists. Idempotent cancellation releases the hold once. Issued/uncertain orders cannot be refunded early.", "security": [{"BearerAuth": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}], "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"type": "object", "required": ["data"], "properties": {"data": {"$ref": "#/components/schemas/Order"}}}}}}, "400": {"description": "Invalid request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "402": {"description": "Insufficient balance", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Read-only key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "Resource not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "409": {"description": "Conflict or unavailable operation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "413": {"description": "Request too large", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "415": {"description": "Use application/json", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate limit; respect Retry-After", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "503": {"description": "Processing unavailable", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}}, "/orders/{id}/resend": {"post": {"operationId": "requestAnotherSms", "description": "Requires order scope. Only supported completed orders before expires_at; otherwise 409. A 202 response means confirmation is pending. Keep polling the same order.", "security": [{"BearerAuth": []}], "parameters": [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}], "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"type": "object", "properties": {"data": {"$ref": "#/components/schemas/Order"}, "confirmed": {"type": "boolean"}}}}}}, "202": {"description": "Accepted", "content": {"application/json": {"schema": {"type": "object", "properties": {"data": {"$ref": "#/components/schemas/Order"}, "confirmed": {"type": "boolean"}}}}}}, "400": {"description": "Invalid request", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "401": {"description": "Invalid key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "402": {"description": "Insufficient balance", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "403": {"description": "Read-only key", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "404": {"description": "Resource not found", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "409": {"description": "Conflict or unavailable operation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "413": {"description": "Request too large", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "415": {"description": "Use application/json", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "429": {"description": "Rate limit; respect Retry-After", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "503": {"description": "Processing unavailable", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}}}}}, "components": {"securitySchemes": {"BearerAuth": {"type": "http", "scheme": "bearer"}}, "schemas": {"Error": {"type": "object", "required": ["error", "request_id"], "properties": {"error": {"type": "object", "required": ["code", "message"], "properties": {"code": {"type": "string"}, "message": {"type": "string"}}}, "request_id": {"type": "string"}}}, "Country": {"type": "object", "properties": {"id": {"type": "string"}, "name": {"type": "string"}}}, "Service": {"type": "object", "properties": {"id": {"type": "string"}, "name": {"type": "string"}}}, "Price": {"type": "object", "properties": {"price_id": {"type": "integer", "minimum": 0}, "price_version": {"type": "integer", "minimum": 0}, "service": {"type": "string"}, "country": {"type": "string"}, "price": {"type": "string", "pattern": "^[0-9]+\\.[0-9]{4}$", "example": "0.7500"}, "price_units": {"type": "integer", "minimum": 0}, "currency": {"type": "string", "enum": ["USD"]}, "available": {"type": "boolean"}}}, "Balance": {"type": "object", "properties": {"currency": {"type": "string", "enum": ["USD"]}, "available": {"type": "string", "pattern": "^[0-9]+\\.[0-9]{4}$", "example": "0.7500"}, "held": {"type": "string", "pattern": "^[0-9]+\\.[0-9]{4}$", "example": "0.7500"}, "available_units": {"type": "integer", "minimum": 0}, "held_units": {"type": "integer", "minimum": 0}, "units_per_usd": {"type": "integer", "enum": [1000000]}}}, "Order": {"type": "object", "properties": {"id": {"type": "string", "format": "uuid"}, "status": {"type": "string", "enum": ["allocating", "allocation_pending", "waiting_sms", "finalizing", "completed", "expired", "failed"]}, "service": {"type": "string"}, "country": {"type": "string"}, "phone": {"type": "string", "nullable": true}, "price": {"type": "string", "pattern": "^[0-9]+\\.[0-9]{4}$", "example": "0.7500"}, "price_units": {"type": "integer", "minimum": 0}, "currency": {"type": "string", "enum": ["USD"]}, "created_at": {"type": "string", "format": "date-time", "nullable": true}, "expires_at": {"type": "string", "format": "date-time", "nullable": true}, "completed_at": {"type": "string", "format": "date-time", "nullable": true}, "reason": {"type": "string", "nullable": true}, "sms": {"type": "array", "items": {"type": "object", "properties": {"code": {"type": "string"}, "text": {"type": "string"}, "received_at": {"type": "string", "format": "date-time", "nullable": true}}}}}}}}}