/** Public response and parameter shapes for the VirtualSMS REST v1 API. */ export interface VirtualSMSOptions { /** Override the API base URL. Default: https://virtualsms.io/api/v1 */ baseUrl?: string; /** Request timeout in seconds. Default: 30. */ timeout?: number; } export interface Service { code: string; name: string; icon?: string; } export interface Country { iso: string; name: string; flag?: string; } export interface Price { price_usd: number; currency: string; available: boolean; } export interface CatalogCountry { iso: string; name: string; price_usd: number; count: number; } export interface Balance { balance_usd: number; } export interface Profile { id: string; email: string; telegram_linked: boolean; telegram_username?: string; balance_usd: number; total_spent_usd: number; total_credits_usd: number; total_orders: number; active_api_keys: number; created_at: string; } export interface Transaction { id: string; amount: number; type: string; description?: string; order_id?: string; balance_before: number; balance_after: number; created_at: string; } export interface TransactionsPage { count: number; limit: number; offset: number; transactions: Transaction[]; } export interface SmsMessage { content: string; sender?: string; received_at?: string; } export interface Order { order_id: string; phone_number: string; service?: string; country?: string; price?: number; created_at?: string; expires_at?: string; status: string; sms_code?: string; sms_text?: string; messages?: SmsMessage[]; sms_received?: boolean; cancel_available_at?: string; swap_available_at?: string; } export interface CancelResult { success: boolean; refunded: boolean; } export interface RetryOrderResult { success: boolean; order_id: string; message: string; } export interface GetSmsResult { status: string; phone_number: string; messages?: SmsMessage[]; code?: string; sms_code?: string; sms_text?: string; } export interface WaitForSmsSuccess { success: true; order_id: string; phone_number: string; status: 'sms_received'; messages: SmsMessage[]; code?: string; sms_code?: string; sms_text?: string; delivery_method: 'websocket' | 'polling' | 'instant'; elapsed_seconds: number; poll_attempts?: number; } export interface WaitForSmsTimeout { success: false; error: 'timeout'; order_id: string; phone_number: string; message?: string; } export type WaitForSmsResult = WaitForSmsSuccess | WaitForSmsTimeout; export interface OrderHistoryResult { count: number; total_matched: number; filters: { status?: string; service?: string; country?: string; since_days?: number; }; orders: Array<{ order_id: string; phone_number: string; service?: string; country?: string; price?: number; status: string; created_at?: string; sms_code?: string; }>; } export interface CancelAllOrdersResult { cancelled: number; failed: number; total_active: number; cancelled_orders: Array<{ order_id: string; refunded: boolean }>; failures: Array<{ order_id: string; error: string }>; message?: string; } export interface SearchServiceMatch { code: string; name: string; match_score: number; } export interface SearchServicesResult { query: string; matches: SearchServiceMatch[]; message?: string; tip?: string; } export interface FindCheapestOption { country: string; country_name: string; price_usd: number; stock: true; } export interface FindCheapestResult { service: string; cheapest_options: FindCheapestOption[]; total_available_countries: number; message?: string; } export interface GetStatsResult { window_days: number; balance_usd: number; total_orders: number; successful_orders: number; success_rate: number | null; total_spend_usd: number; status_breakdown: Record; top_services: Array<{ key: string; count: number }>; top_countries: Array<{ key: string; count: number }>; note?: string; } // ─── Rentals ──────────────────────────────────────────────────────────────── export type RentalTier = 'full_access' | 'platform'; export interface RentalPricingTier { rental_type: string; duration_hours: number; duration_label: string; base_price: number; country_code: string; service_id: string; } export interface RentalDurationPrice { duration_hours: number; duration_label: string; price: number; } export interface RentalAvailabilityCountry { country_code: string; country_name: string; flag?: string; available_count: number; pricing: Record; service_count?: number; popular_services?: string[]; min_price_per_day?: number; } export interface RentalAvailabilityResult { countries: RentalAvailabilityCountry[]; total_available: number; full_access_countries?: unknown[]; provider?: string; } export interface RentalCatalogService { service_id: string; service_name: string; physical_count: number; our_price?: number; base_price?: number; popular: boolean; icon_url?: string; } export interface RentalPriceResult { price: number; duration_hours: number; } export interface Rental { id: string; phone_number: string; rental_type: string; service_id?: string; duration_hours: number; started_at: string; expires_at: string; price: number; auto_renew: boolean; status: string; sms_received: number; sms_forwarded: number; last_sms_at?: string; provider: string; } export interface CreateRentalParams { tier: RentalTier; country: string; duration_hours: number; /** Required for tier="platform"; optional for tier="full_access". */ service?: string; /** full_access only. Default false. */ auto_renew?: boolean; } export interface CreateRentalResult { success: boolean; rental_id: string; phone_number: string; rental_type?: string; service?: string; duration?: string; price?: number; started_at?: string; expires_at: string; auto_renew?: boolean; status?: string; retail_cost?: number; currency?: string; } export interface RentalActionResult { success: boolean; rental_id: string; status?: string; refund?: number; new_expires_at?: string; price?: number; hours_used?: string; message?: string; } // ─── Proxies ──────────────────────────────────────────────────────────────── export type ProxyPoolType = 'residential' | 'residential_premium' | 'mobile' | 'datacenter'; export interface ProxyCatalogCountry { code: string; name: string; available: boolean; ip_count: number; } export interface ProxyCatalogPoolType { id: string; label: string; price_per_gb: number; countries: ProxyCatalogCountry[]; } export interface ProxyListItem { proxy_id: string; pool_type: string; country_code: string; country_name?: string; gb_total: number; gb_used: number; gb_remaining: number; proxy_host: string; proxy_port: number; proxy_login: string; proxy_password: string; updated_at?: string; created_at?: string; } export interface BuyProxyParams { pool_type: ProxyPoolType; gb: number; country_code?: string; idempotency_key?: string; } export interface ProxyPurchaseResult { proxy_id: string; pool_type: string; gb_added: number; gb_remaining: number; country_code: string; proxy_login: string; proxy_password: string; proxy_host: string; proxy_port: number; proxy_port_socks?: number; price: number; balance?: number; } export interface ProxyRotateResult { rotated: boolean; port: number; message: string; } export interface ProxyUsage { gb_used: number; gb_remaining: number; requests: number; updated_at?: string; } export interface ProxyUsageHistoryPoint { date: string; gb: number; requests: number; } export interface ProxyUsageHistoryResult { series: ProxyUsageHistoryPoint[]; totals: { gb: number; requests: number }; } export interface ProxyTargetingParams { country_code: string; cities?: string[]; asns?: number[]; } export interface ProxyTargetingResult { ok: boolean; country_code: string; premium_2x: boolean; } export interface ProxyTestParams { country: string; session?: 'rotating' | 'sticky'; protocol?: 'http' | 'socks5'; } export interface ProxyTestResult { ok: boolean; exit_ip?: string; country_code?: string; country_name?: string; city?: string; region?: string; isp?: string; asn?: string; latency_ms?: number; error?: string; } export interface ProxyLocationItem { code: string; name: string; count: number; } export type ProxyLocationKind = 'cities' | 'states' | 'asns' | 'zipcodes'; export type ProxyLocationPoolType = 'residential' | 'mobile' | 'datacenter'; export interface GenerateProxyEndpointParams { proxy_id: string; country_code: string; target_by?: 'country' | 'state' | 'city' | 'zip' | 'asn'; location_code?: string; session?: 'rotating' | 'sticky'; sticky_ttl_minutes?: number; count?: number; protocol?: 'HTTP' | 'SOCKS5'; format?: 'host:port:user:pass' | 'user:pass@host:port' | 'curl'; } export interface ProxyEndpointResult { proxy_id: string; pool_type: string; host: string; port: number; protocol: 'HTTP' | 'SOCKS5'; session: 'rotating' | 'sticky'; sticky_ttl_minutes?: number; country_code: string; target_by: 'country' | 'state' | 'city' | 'zip' | 'asn'; location_code?: string; premium_2x: boolean; endpoints: string[]; } // ─── Session ──────────────────────────────────────────────────────────────── export interface StartManualRegistrationSessionParams { service_name?: string; country?: string; device_mode?: 'desktop' | 'mobile'; with_proxy?: boolean; target_url?: string; order_id?: string; mode?: 'attach' | 'fresh'; } export interface BrowserSessionResult { id: string; status: string; service_name?: string; country_code?: string; device_mode?: string; with_proxy?: boolean; viewer_url?: string; target_url?: string; order_id?: string; phone_number?: string; timeline?: Array<{ at: string; event: string; detail?: string }>; } // ─── Number check ─────────────────────────────────────────────────────────── export interface NumberCheckResult { valid: boolean; e164: string; national?: string; country_code: string; country_name: string; country_prefix?: string; location?: string; carrier?: string; line_type: string; spam_risk: string; cached: boolean; message?: string; } // ─── Webhooks ─────────────────────────────────────────────────────────────── export type WebhookEventType = | 'order.created' | 'order.sms_received' | 'order.cancelled' | 'order.expired' | 'rental.created' | 'rental.sms_received' | 'rental.expired' | 'rental.cancelled' | 'proxy.purchased' | 'balance.low' | string; export interface WebhookEndpoint { id: string; url: string; description?: string; events: WebhookEventType[]; active: boolean; paused: boolean; threshold?: number; failure_count_consecutive: number; last_delivered_at?: string; last_error_at?: string; last_error_code?: number; created_at: string; updated_at: string; } export interface CreateWebhookParams { url: string; description?: string; events: WebhookEventType[]; /** Required when events includes "balance.low". 0 < n <= 99999.99, 2dp. */ threshold?: number; } export interface UpdateWebhookParams { url?: string; description?: string; events?: WebhookEventType[]; threshold?: number; active?: boolean; paused?: boolean; } export interface WebhookDelivery { id: string; event_id: string; event_type: string; attempt: number; status: string; response_status?: number; response_body?: string; scheduled_for?: string; delivered_at?: string; error_message?: string; created_at: string; payload?: unknown; } export interface ListWebhookDeliveriesParams { limit?: number; offset?: number; } export interface ListWebhookDeliveriesResult { success: boolean; deliveries: WebhookDelivery[]; count: number; limit: number; offset: number; } export interface TestWebhookResult { success: boolean; message: string; delivery_id: string; event_id: string; event_type: string; }