Documentation
¶
Overview ¶
Package numberotp is the official Go client for the NumberOTP API — virtual numbers for SMS / OTP verification.
client := numberotp.NewClient() // reads NOTP_API_KEY
n, err := client.Activations.Create(ctx, numberotp.CreateActivationParams{Service: "wa", Country: "16"})
act, err := client.WaitForCode(ctx, n.Data.ID, 20*time.Minute)
fmt.Println(act.Code())
Index ¶
- Constants
- Variables
- func Bool(v bool) *bool
- func Float(v float64) *float64
- func Int(v int) *int
- func String(v string) *string
- func VerifyWebhook(rawBody []byte, signatureHeader, secret string) bool
- type AccountService
- func (s *AccountService) AppConfig(ctx context.Context, opts ...RequestOption) (*AppConfigResult, error)
- func (s *AccountService) Delete(ctx context.Context, params DeleteMeParams, opts ...RequestOption) (*JSONObject, error)
- func (s *AccountService) Get(ctx context.Context, opts ...RequestOption) (*MeResult, error)
- func (s *AccountService) Transactions(ctx context.Context, opts ...RequestOption) (*ListResult, error)
- type Activation
- type ActivationClosedError
- type ActivationResult
- type ActivationsService
- func (s *ActivationsService) Cancel(ctx context.Context, id string, opts ...RequestOption) (*ActivationResult, error)
- func (s *ActivationsService) Create(ctx context.Context, params CreateActivationParams, opts ...RequestOption) (*CreateActivationResult, error)
- func (s *ActivationsService) Finish(ctx context.Context, id string, opts ...RequestOption) (*ActivationResult, error)
- func (s *ActivationsService) Get(ctx context.Context, id string, opts ...RequestOption) (*ActivationResult, error)
- func (s *ActivationsService) List(ctx context.Context, params *ListActivationsParams, opts ...RequestOption) (*ListResult, error)
- func (s *ActivationsService) Resend(ctx context.Context, id string, opts ...RequestOption) (*ActivationResult, error)
- func (s *ActivationsService) WaitOnce(ctx context.Context, id string, opts ...RequestOption) (*WaitResult, error)
- type ApiKeysService
- func (s *ApiKeysService) Create(ctx context.Context, params CreateApiKeyParams, opts ...RequestOption) (*JSONObject, error)
- func (s *ApiKeysService) Delete(ctx context.Context, params DeleteApiKeyParams, opts ...RequestOption) (*JSONObject, error)
- func (s *ApiKeysService) List(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
- type AppConfig
- type AppConfigResult
- type AuthService
- func (s *AuthService) DecideDeviceSignIn(ctx context.Context, params DecideDeviceSignInParams, opts ...RequestOption) (*JSONObject, error)
- func (s *AuthService) GetDeviceSignIn(ctx context.Context, params *GetDeviceSignInParams, opts ...RequestOption) (*JSONObject, error)
- func (s *AuthService) Revoke(ctx context.Context, params RevokeTokenParams, opts ...RequestOption) (*JSONObject, error)
- func (s *AuthService) SendEmailCode(ctx context.Context, params SendEmailCodeParams, opts ...RequestOption) (*JSONObject, error)
- func (s *AuthService) StartDeviceSignIn(ctx context.Context, params StartDeviceSignInParams, opts ...RequestOption) (*DeviceCode, error)
- func (s *AuthService) Token(ctx context.Context, params OauthTokenParams, opts ...RequestOption) (*TokenResponse, error)
- type Client
- func (c *Client) CreateAndWait(ctx context.Context, params CreateActivationParams, timeout time.Duration, ...) (*Activation, error)
- func (c *Client) DeviceLogin(ctx context.Context, o DeviceLoginOptions) (*TokenResponse, error)
- func (c *Client) RefreshToken() string
- func (c *Client) SetTokens(tok TokenResponse)
- func (c *Client) SignInWithEmailCode(ctx context.Context, email, code, platform, deviceName string) (*TokenResponse, error)
- func (c *Client) SignOut(ctx context.Context) error
- func (c *Client) StreamEvents(ctx context.Context, since string) iter.Seq2[Event, error]
- func (c *Client) WaitForCode(ctx context.Context, id string, timeout time.Duration) (*Activation, error)
- type ClientSession
- type ConvertResellerEarningsParams
- type CountriesService
- type Country
- type CountryList
- type CreateActivationParams
- type CreateActivationResult
- type CreateApiKeyParams
- type CreateAppleTopupParams
- type CreateCardTopupParams
- type CreateCryptoTopupParams
- type CreateGoogleTopupParams
- type CreateReminderParams
- type CreateRentalParams
- type CreateRentalResult
- type CreateResellerCardTopupParams
- type CreateResellerCryptoTopupParams
- type CreateResellerUserParams
- type DecideDeviceSignInParams
- type DeleteApiKeyParams
- type DeleteMeParams
- type DeviceCode
- type DeviceLoginOptions
- type DevicesService
- func (s *DevicesService) List(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
- func (s *DevicesService) Register(ctx context.Context, params RegisterPushDeviceParams, opts ...RequestOption) (*JSONObject, error)
- func (s *DevicesService) Unregister(ctx context.Context, params UnregisterPushDeviceParams, opts ...RequestOption) (*JSONObject, error)
- func (s *DevicesService) Update(ctx context.Context, params UpdatePushDeviceParams, opts ...RequestOption) (*JSONObject, error)
- type Error
- type Event
- type EventPoll
- type EventsService
- type ExtendOptionsResult
- type ExtendRentalParams
- type GetDeviceSignInParams
- type GetPricesParams
- type GetRentPricesParams
- type IapTopupResult
- type JSONObject
- type ListActivationsParams
- type ListCountriesParams
- type ListResult
- type ListServicesParams
- type Loyalty
- type Me
- type MeResult
- type OauthTokenParams
- type Option
- func WithAPIKey(key string) Option
- func WithBaseURL(u string) Option
- func WithHTTPClient(h *http.Client) Option
- func WithHeader(key, value string) Option
- func WithMaxRetries(n int) Option
- func WithOnTokens(fn func(TokenResponse)) Option
- func WithTimeout(d time.Duration) Option
- func WithTokens(accessToken, refreshToken string) Option
- type PoolOffer
- type PriceEntry
- type PriceList
- type PricesService
- type RegisterPushDeviceParams
- type RemindersService
- func (s *RemindersService) Create(ctx context.Context, params CreateReminderParams, opts ...RequestOption) (*JSONObject, error)
- func (s *RemindersService) Delete(ctx context.Context, id string, opts ...RequestOption) (*JSONObject, error)
- func (s *RemindersService) List(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
- type RentPriceList
- type Rental
- type RentalResult
- type RentalsService
- func (s *RentalsService) Cancel(ctx context.Context, id string, opts ...RequestOption) (*JSONObject, error)
- func (s *RentalsService) Create(ctx context.Context, params CreateRentalParams, opts ...RequestOption) (*CreateRentalResult, error)
- func (s *RentalsService) Extend(ctx context.Context, id string, params ExtendRentalParams, ...) (*JSONObject, error)
- func (s *RentalsService) ExtendOptions(ctx context.Context, id string, opts ...RequestOption) (*ExtendOptionsResult, error)
- func (s *RentalsService) Get(ctx context.Context, id string, opts ...RequestOption) (*RentalResult, error)
- func (s *RentalsService) List(ctx context.Context, opts ...RequestOption) (*ListResult, error)
- type RequestOption
- type ResellerPublicService
- func (s *ResellerPublicService) Brand(ctx context.Context, resellerPublicId string, opts ...RequestOption) (*JSONObject, error)
- func (s *ResellerPublicService) CardTopup(ctx context.Context, resellerPublicId string, ...) (*JSONObject, error)
- func (s *ResellerPublicService) CryptoTopup(ctx context.Context, resellerPublicId string, ...) (*JSONObject, error)
- func (s *ResellerPublicService) Signup(ctx context.Context, resellerPublicId string, params ResellerSignupParams, ...) (*JSONObject, error)
- type ResellerService
- func (s *ResellerService) CardTopup(ctx context.Context, params CreateResellerCardTopupParams, ...) (*JSONObject, error)
- func (s *ResellerService) ConvertEarnings(ctx context.Context, params ConvertResellerEarningsParams, ...) (*JSONObject, error)
- func (s *ResellerService) CreateUser(ctx context.Context, params CreateResellerUserParams, opts ...RequestOption) (*JSONObject, error)
- func (s *ResellerService) CryptoTopup(ctx context.Context, params CreateResellerCryptoTopupParams, ...) (*JSONObject, error)
- func (s *ResellerService) DeleteUser(ctx context.Context, subUserId string, opts ...RequestOption) (*JSONObject, error)
- func (s *ResellerService) GetMarkup(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
- func (s *ResellerService) GetProfile(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
- func (s *ResellerService) GetUser(ctx context.Context, subUserId string, opts ...RequestOption) (*JSONObject, error)
- func (s *ResellerService) ListUsers(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
- func (s *ResellerService) UpdateMarkup(ctx context.Context, params UpdateResellerMarkupParams, opts ...RequestOption) (*JSONObject, error)
- func (s *ResellerService) UpdateProfile(ctx context.Context, params UpdateResellerProfileParams, opts ...RequestOption) (*JSONObject, error)
- func (s *ResellerService) UpdateUser(ctx context.Context, subUserId string, params UpdateResellerUserParams, ...) (*JSONObject, error)
- func (s *ResellerService) WithdrawEarnings(ctx context.Context, params WithdrawResellerEarningsParams, ...) (*JSONObject, error)
- type ResellerSignupParams
- type ResellerSubUserCardTopupParams
- type ResellerSubUserCryptoTopupParams
- type RevokeSessionsParams
- type RevokeTokenParams
- type SMS
- type SearchServicesParams
- type SendEmailCodeParams
- type ServiceList
- type ServiceMatch
- type ServiceSearchResult
- type ServicesService
- type SessionList
- type SessionsService
- type SetWebhookParams
- type StartDeviceSignInParams
- type StreamEventsParams
- type TokenResponse
- type Topup
- type TopupResult
- type TopupStarted
- type TopupsService
- func (s *TopupsService) Apple(ctx context.Context, params CreateAppleTopupParams, opts ...RequestOption) (*IapTopupResult, error)
- func (s *TopupsService) Card(ctx context.Context, params CreateCardTopupParams, opts ...RequestOption) (*TopupStarted, error)
- func (s *TopupsService) Crypto(ctx context.Context, params CreateCryptoTopupParams, opts ...RequestOption) (*TopupStarted, error)
- func (s *TopupsService) Get(ctx context.Context, id string, opts ...RequestOption) (*TopupResult, error)
- func (s *TopupsService) Google(ctx context.Context, params CreateGoogleTopupParams, opts ...RequestOption) (*IapTopupResult, error)
- type UnregisterPushDeviceParams
- type UpdatePushDeviceParams
- type UpdateResellerMarkupParams
- type UpdateResellerProfileParams
- type UpdateResellerUserParams
- type WaitResult
- type WebhookPayload
- type WebhookService
- type WithdrawResellerEarningsParams
Constants ¶
const DefaultBaseURL = "https://api.numberotp.com/v1"
DefaultBaseURL is the production API.
const Version = "0.1.0"
Version of this SDK.
Variables ¶
var ErrWaitTimeout = errors.New("numberotp: timed out waiting for the code; the number is still open")
ErrWaitTimeout: WaitForCode's own timeout passed first. The number may still receive a code — wait again, or cancel it for a refund.
Functions ¶
func VerifyWebhook ¶
VerifyWebhook checks a webhook's x-numberotp-signature header ("sha256=<hex>") against the raw request body and your webhook secret. Verify before parsing JSON.
body, _ := io.ReadAll(r.Body)
if !numberotp.VerifyWebhook(body, r.Header.Get("X-NumberOTP-Signature"), secret) { … 401 … }
Types ¶
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
AccountService: Your account, balance and transactions.
func (*AccountService) AppConfig ¶
func (s *AccountService) AppConfig(ctx context.Context, opts ...RequestOption) (*AppConfigResult, error)
AppConfig — App Configuration — No auth. What the mobile app needs at start: minimum supported version per platform, maintenance notice, the in-app credit packs, where store rules allow a web top-up link, and support links.
func (*AccountService) Delete ¶
func (s *AccountService) Delete(ctx context.Context, params DeleteMeParams, opts ...RequestOption) (*JSONObject, error)
Delete — Delete My Account — Permanently deletes the account: email, name, sign-ins, API keys, connected devices and webhook are removed, numbers waiting for an SMS are released, and any remaining balance is forfeited. Requires a signed-in person and `{ "confirm": "DELETE" }`. Resellers with customers must contact support first (409 `RESELLER_HAS_SUB_USERS`).
func (*AccountService) Get ¶
func (s *AccountService) Get(ctx context.Context, opts ...RequestOption) (*MeResult, error)
Get — Get My Account — Profile, balance, money on hold for numbers still waiting, loyalty tier and (for a reseller's customer) their branding — everything a home screen needs.
func (*AccountService) Transactions ¶
func (s *AccountService) Transactions(ctx context.Context, opts ...RequestOption) (*ListResult, error)
Transactions — List Transactions — Completed top-ups, purchases, refunds and adjustments, newest first.
type Activation ¶
type Activation struct {
ID string `json:"id"`
PhoneNumber string `json:"phone_number"`
Service string `json:"service"`
ServiceName string `json:"service_name"`
Country string `json:"country"`
// Status: waiting, received, finished, canceled or expired.
Status string `json:"status"`
// OTP is the code, once one arrived.
OTP *string `json:"otp"`
FullSMS *string `json:"full_sms"`
SMS []SMS `json:"sms"`
Cost float64 `json:"cost"`
Pool string `json:"pool"`
ExpiresAt string `json:"expires_at"`
CreatedAt string `json:"created_at"`
}
Activation is a one-time number.
func (*Activation) Code ¶
func (a *Activation) Code() string
Code returns the OTP, or "" if none yet.
type ActivationClosedError ¶
type ActivationClosedError struct{ ActivationStatus string }
ActivationClosedError: WaitForCode found the number expired or canceled before an SMS arrived. It has been refunded.
func (*ActivationClosedError) Error ¶
func (e *ActivationClosedError) Error() string
type ActivationResult ¶
type ActivationResult struct {
Success bool `json:"success"`
Data Activation `json:"data"`
}
type ActivationsService ¶
type ActivationsService struct {
// contains filtered or unexported fields
}
ActivationsService: One-time numbers: buy, wait for the code, finish, cancel.
func (*ActivationsService) Cancel ¶
func (s *ActivationsService) Cancel(ctx context.Context, id string, opts ...RequestOption) (*ActivationResult, error)
Cancel — Cancel and Refund — Releases a number that hasn't received an SMS yet and refunds it in full (same as `DELETE /activations/{id}`). Safe to retry — it refunds once.
func (*ActivationsService) Create ¶
func (s *ActivationsService) Create(ctx context.Context, params CreateActivationParams, opts ...RequestOption) (*CreateActivationResult, error)
Create — Purchase a Number — Deducts balance from your account and provisions a temporary phone number for the requested service. Once an OTP SMS arrives (within 20 minutes), it is delivered via: 1. **Webhook** — instantly POSTed to your configured global webhook URL, or the per-request `webhook_url` override. 2. **Polling** — call `GET /activations/{id}` at your preferred interval. 3. **Long-poll** — call `GET /activations/{id}/wait` to block until the OTP arrives or the window expires. If no OTP is received within 20 minutes, the charged amount is automatically refunded to your wallet.
func (*ActivationsService) Finish ¶
func (s *ActivationsService) Finish(ctx context.Context, id string, opts ...RequestOption) (*ActivationResult, error)
Finish — Mark Code as Used — Closes a number that received its code (same as `PATCH /activations/{id}`). Not required — numbers close on their own when the window ends.
func (*ActivationsService) Get ¶
func (s *ActivationsService) Get(ctx context.Context, id string, opts ...RequestOption) (*ActivationResult, error)
Get — Poll Activation Status — Returns the current status of an activation. Safe to call repeatedly at any interval. If the OTP has already been received, it is returned immediately from the database without an upstream call. If the activation is still `waiting`, a live upstream check is made and the result is cached in the database.
func (*ActivationsService) List ¶
func (s *ActivationsService) List(ctx context.Context, params *ListActivationsParams, opts ...RequestOption) (*ListResult, error)
List — List My Numbers — Your one-time numbers, newest first. Open ones are synced with their pool first, so the list is current.
func (*ActivationsService) Resend ¶
func (s *ActivationsService) Resend(ctx context.Context, id string, opts ...RequestOption) (*ActivationResult, error)
Resend — Request Another SMS — Asks for another SMS on a number that has already received one and is still open (for when the site asks you to request a new code). Free. The new SMS arrives as an `activation.sms_received` event and is appended to `sms`. Supported on Pool 1 numbers; others answer 409 `RESEND_NOT_SUPPORTED`.
func (*ActivationsService) WaitOnce ¶
func (s *ActivationsService) WaitOnce(ctx context.Context, id string, opts ...RequestOption) (*WaitResult, error)
WaitOnce — Wait for OTP (Long-Poll) — Blocks the HTTP connection until an OTP is received or the activation expires (up to 20 minutes). Useful for simple integrations that want a single blocking call rather than a polling loop. For production workloads with multiple concurrent activations, the **Webhook** approach is strongly preferred.
type ApiKeysService ¶
type ApiKeysService struct {
// contains filtered or unexported fields
}
ApiKeysService: Developer API keys (needs a signed-in person, not an API key).
func (*ApiKeysService) Create ¶
func (s *ApiKeysService) Create(ctx context.Context, params CreateApiKeyParams, opts ...RequestOption) (*JSONObject, error)
Create — Create an API Key — The raw key is returned once — store it.
func (*ApiKeysService) Delete ¶
func (s *ApiKeysService) Delete(ctx context.Context, params DeleteApiKeyParams, opts ...RequestOption) (*JSONObject, error)
Delete — Delete an API Key
func (*ApiKeysService) List ¶
func (s *ApiKeysService) List(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
List — List API Keys — Requires a signed-in person (website, app or CLI) — an API key can't manage keys.
type AppConfig ¶
type AppConfig struct {
MinVersion map[string]string `json:"min_version"`
LatestVersion map[string]*string `json:"latest_version"`
StoreURLs map[string]*string `json:"store_urls"`
Maintenance *struct {
Message string `json:"message"`
} `json:"maintenance"`
IAP struct {
IOS bool `json:"ios"`
Android bool `json:"android"`
Products []struct {
ID string `json:"id"`
Credit float64 `json:"credit"`
PriceUSD float64 `json:"price_usd"`
} `json:"products"`
} `json:"iap"`
WebTopup struct {
URL string `json:"url"`
IOSStorefronts []string `json:"ios_storefronts"`
AndroidRegions []string `json:"android_regions"`
} `json:"web_topup"`
Links map[string]string `json:"links"`
}
AppConfig is what the mobile app needs at start (GET /app/config).
type AppConfigResult ¶
AppConfigResult wraps AppConfig.
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService: Sign-in and tokens.
func (*AuthService) DecideDeviceSignIn ¶
func (s *AuthService) DecideDeviceSignIn(ctx context.Context, params DecideDeviceSignInParams, opts ...RequestOption) (*JSONObject, error)
DecideDeviceSignIn — Approve or Deny a Device
func (*AuthService) GetDeviceSignIn ¶
func (s *AuthService) GetDeviceSignIn(ctx context.Context, params *GetDeviceSignInParams, opts ...RequestOption) (*JSONObject, error)
GetDeviceSignIn — Look Up a Device Code — For the approval screen (numberotp.com/device, or the mobile app). Signed-in people only.
func (*AuthService) Revoke ¶
func (s *AuthService) Revoke(ctx context.Context, params RevokeTokenParams, opts ...RequestOption) (*JSONObject, error)
Revoke — Sign Out (Revoke a Refresh Token)
func (*AuthService) SendEmailCode ¶
func (s *AuthService) SendEmailCode(ctx context.Context, params SendEmailCodeParams, opts ...RequestOption) (*JSONObject, error)
SendEmailCode — Email a Sign-In Code — Sends a 6-digit code (valid 10 minutes) to exchange with the `email_code` grant. Same answer whether or not the account exists.
func (*AuthService) StartDeviceSignIn ¶
func (s *AuthService) StartDeviceSignIn(ctx context.Context, params StartDeviceSignInParams, opts ...RequestOption) (*DeviceCode, error)
StartDeviceSignIn — Start Device Sign-In — RFC 8628 device flow for the CLI, extension and MCP servers. Show `user_code`, open `verification_uri_complete` in a browser, then poll `/oauth/token` every `interval` seconds with `grant_type=urn:ietf:params:oauth:grant-type:device_code`.
func (*AuthService) Token ¶
func (s *AuthService) Token(ctx context.Context, params OauthTokenParams, opts ...RequestOption) (*TokenResponse, error)
Token — Get Tokens — How apps, the browser extension, the CLI and MCP servers sign in. Returns a 15-minute access token and a 60-day refresh token that rotates on every use (re-using an old one signs that device out). Errors follow RFC 6749 (`{ error, error_description }`).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the NumberOTP API. Its fields are the API resources.
func (*Client) CreateAndWait ¶
func (c *Client) CreateAndWait(ctx context.Context, params CreateActivationParams, timeout time.Duration, onNumber func(*CreateActivationResult)) (*Activation, error)
CreateAndWait buys a number, calls onNumber with it (may be nil), then waits for its code.
func (*Client) DeviceLogin ¶
func (c *Client) DeviceLogin(ctx context.Context, o DeviceLoginOptions) (*TokenResponse, error)
DeviceLogin signs in with the device flow (RFC 8628): show a code, the person approves it on numberotp.com/device. The client is signed in afterwards.
func (*Client) RefreshToken ¶
RefreshToken returns the current refresh token (to persist securely).
func (*Client) SetTokens ¶
func (c *Client) SetTokens(tok TokenResponse)
SetTokens switches the client to a signed-in user's tokens.
func (*Client) SignInWithEmailCode ¶
func (c *Client) SignInWithEmailCode(ctx context.Context, email, code, platform, deviceName string) (*TokenResponse, error)
SignInWithEmailCode exchanges the 6-digit code from Auth.SendEmailCode — creates the account if it's new.
func (*Client) StreamEvents ¶
StreamEvents yields live account events until ctx is done. It reconnects by itself and resumes after the last event, so none are skipped. Pass since="" to start from now.
for ev, err := range client.StreamEvents(ctx, "") {
if err != nil { return err }
if ev.Type == "activation.code_received" { … }
}
func (*Client) WaitForCode ¶
func (c *Client) WaitForCode(ctx context.Context, id string, timeout time.Duration) (*Activation, error)
WaitForCode waits until the number's code arrives and returns the whole activation. It returns *ActivationClosedError if the number expired or was canceled first (it's refunded), or ErrWaitTimeout when timeout passes.
type ClientSession ¶
type ConvertResellerEarningsParams ¶
type ConvertResellerEarningsParams struct {
Amount float64 `json:"amount"`
}
ConvertResellerEarningsParams is the body of POST /reseller/payout/convert.
type CountriesService ¶
type CountriesService struct {
// contains filtered or unexported fields
}
CountriesService: Countries numbers are available in.
func (*CountriesService) List ¶
func (s *CountriesService) List(ctx context.Context, params *ListCountriesParams, opts ...RequestOption) (*CountryList, error)
List — List Countries — Returns all countries available for number provisioning. Use the `id` field from each item as the `country` parameter when creating activations. Optionally filter by service code to see only countries that have numbers available for that specific service.
type CountryList ¶
type CreateActivationParams ¶
type CreateActivationParams struct {
Service string `json:"service"` // Short service code from `GET /public/services`. **Do not** pass the display name.
Country string `json:"country"` // Numeric country ID from `GET /public/countries`. **Do not** pass the country name or ISO code.
WebhookURL *string `json:"webhook_url,omitempty"` // Optional. Override your global webhook URL for this specific activation only.
Pool *string `json:"pool,omitempty"` // Optional (default "auto"). "auto" buys from the pool with the best measured delivery rate for this service and country (weighed against price and stock, and your own recent results unless you turned personalization off in Dashboard → Settings), switching to the next pool automatically if one cannot supply a number. A specific pool is only ever that pool.
MaxPrice *float64 `json:"max_price,omitempty"` // Optional. Highest price (USD) you accept for this number. Pools above it are skipped; if none remains the request fails instead of charging more.
}
CreateActivationParams is the body of POST /activations.
type CreateActivationResult ¶
type CreateApiKeyParams ¶
type CreateApiKeyParams struct {
Name string `json:"name"`
Scopes []string `json:"scopes,omitempty"` // Defaults to all three.
}
CreateApiKeyParams is the body of POST /user/apikeys.
type CreateAppleTopupParams ¶
type CreateAppleTopupParams struct {
SignedTransaction string `json:"signed_transaction"`
}
CreateAppleTopupParams is the body of POST /topups/apple.
type CreateCardTopupParams ¶
type CreateCardTopupParams struct {
Amount float64 `json:"amount"`
}
CreateCardTopupParams is the body of POST /payments/card.
type CreateCryptoTopupParams ¶
type CreateCryptoTopupParams struct {
Amount float64 `json:"amount"`
}
CreateCryptoTopupParams is the body of POST /payments/crypto.
type CreateGoogleTopupParams ¶
type CreateGoogleTopupParams struct {
ProductID string `json:"product_id"`
PurchaseToken string `json:"purchase_token"`
}
CreateGoogleTopupParams is the body of POST /topups/google.
type CreateReminderParams ¶
type CreateReminderParams struct {
Service string `json:"service"`
Country string `json:"country"`
ServiceName *string `json:"serviceName,omitempty"`
CountryName *string `json:"countryName,omitempty"`
}
CreateReminderParams is the body of POST /user/reminders.
type CreateRentalParams ¶
type CreateRentalParams struct {
Service string `json:"service"` // Service code (e.g. wa, tg, go)
Country string `json:"country"` // Country ID from /public/countries
Duration int `json:"duration"` // Duration in hours: 2, 4, 12, or multiples of 24 up to 720 (30 days)
}
CreateRentalParams is the body of POST /rentals.
type CreateRentalResult ¶
type CreateResellerCardTopupParams ¶
type CreateResellerCardTopupParams struct {
Amount float64 `json:"amount"`
}
CreateResellerCardTopupParams is the body of POST /reseller/payments/card.
type CreateResellerCryptoTopupParams ¶
type CreateResellerCryptoTopupParams struct {
Amount float64 `json:"amount"`
}
CreateResellerCryptoTopupParams is the body of POST /reseller/payments/crypto.
type CreateResellerUserParams ¶
type CreateResellerUserParams struct {
Email string `json:"email"`
Password string `json:"password"`
Name *string `json:"name,omitempty"`
InitialBalance *float64 `json:"initialBalance,omitempty"` // Deducted from reseller buying credits.
AllowSelfFund *bool `json:"allowSelfFund,omitempty"`
}
CreateResellerUserParams is the body of POST /reseller/users.
type DecideDeviceSignInParams ¶
type DecideDeviceSignInParams struct {
UserCode string `json:"user_code"`
Action string `json:"action"`
}
DecideDeviceSignInParams is the body of POST /oauth/device.
type DeleteApiKeyParams ¶
type DeleteApiKeyParams struct {
ID string `json:"id"`
}
DeleteApiKeyParams is the body of DELETE /user/apikeys.
type DeleteMeParams ¶
type DeleteMeParams struct {
Confirm string `json:"confirm"`
}
DeleteMeParams is the body of DELETE /me.
type DeviceCode ¶
type DeviceLoginOptions ¶
type DeviceLoginOptions struct {
// Client is "cli" (default), "extension", "mcp" or "other".
Client string
DeviceName string
// OnCode shows the person the code and the link to approve it.
OnCode func(DeviceCode)
}
DeviceLoginOptions configures DeviceLogin.
type DevicesService ¶
type DevicesService struct {
// contains filtered or unexported fields
}
DevicesService: Push notification registration (apps and extensions).
func (*DevicesService) List ¶
func (s *DevicesService) List(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
List — List Push Devices — This account's push-registered devices, plus the VAPID public key a browser extension subscribes with.
func (*DevicesService) Register ¶
func (s *DevicesService) Register(ctx context.Context, params RegisterPushDeviceParams, opts ...RequestOption) (*JSONObject, error)
Register — Register for Push Notifications — Called by the mobile app (Expo push token) or browser extension (Push API subscription). Not available to API keys.
func (*DevicesService) Unregister ¶
func (s *DevicesService) Unregister(ctx context.Context, params UnregisterPushDeviceParams, opts ...RequestOption) (*JSONObject, error)
Unregister — Stop Push Notifications to a Device
func (*DevicesService) Update ¶
func (s *DevicesService) Update(ctx context.Context, params UpdatePushDeviceParams, opts ...RequestOption) (*JSONObject, error)
Update — Show or Hide Codes in Notifications
type Error ¶
type Error struct {
// Status is the HTTP status, or 0 when the request never got an answer.
Status int
Code string
Message string
// Body is the decoded error body, when there was one.
Body map[string]any
}
Error is returned for every failed API call. Branch on Code (stable, e.g. "INSUFFICIENT_BALANCE", "NO_NUMBERS_AVAILABLE", "invalid_grant"), not on Message, which is written for people and may change.
var apiErr *numberotp.Error
if errors.As(err, &apiErr) && apiErr.Code == "INSUFFICIENT_BALANCE" { … }
func (*Error) IsConflict ¶
func (*Error) IsInsufficientBalance ¶
Convenience checks.
func (*Error) IsNotFound ¶
func (*Error) IsRateLimited ¶
func (*Error) IsUnauthorized ¶
type Event ¶
type Event struct {
ID string `json:"id"`
Type string `json:"type"`
CreatedAt string `json:"created_at"`
Initiator string `json:"initiator,omitempty"`
Refunded *bool `json:"refunded,omitempty"`
// Data is the activation (activation.* / rental.*), {transaction_id, amount, method} (topup.completed) or {reminder_id, service, service_name, country, country_name} (reminder.back_in_stock).
Data json.RawMessage `json:"data"`
// StreamID is the position in your event stream — resume after it.
StreamID string `json:"stream_id,omitempty"`
}
Event is a live account event (see Client.StreamEvents).
func (Event) Activation ¶
func (e Event) Activation() (*Activation, error)
Activation decodes Data for activation.* and rental.* events.
type EventsService ¶
type EventsService struct {
// contains filtered or unexported fields
}
EventsService: Live account events.
func (*EventsService) Poll ¶
func (s *EventsService) Poll(ctx context.Context, params *StreamEventsParams, opts ...RequestOption) (*EventPoll, error)
Poll — Live Events (Server-Sent Events) — A `text/event-stream` of your account's events — `activation.code_received`, `activation.sms_received`, `activation.expired` (refunded), `activation.canceled`, `activation.finished`, `rental.sms_received`, `rental.expired`, `topup.completed`, `reminder.back_in_stock`. Each connection lasts ~55 s; reconnect with `Last-Event-ID` (EventSource does this for you) and nothing is missed — the last 200 events are kept for 7 days. `?once=1` returns pending events as JSON instead, for clients that would rather poll.
type ExtendOptionsResult ¶
type ExtendRentalParams ¶
type ExtendRentalParams struct {
Hours int `json:"hours"` // Additional hours: 2, 4, 12, or multiples of 24
}
ExtendRentalParams is the body of POST /rentals/{id}.
type GetDeviceSignInParams ¶
type GetDeviceSignInParams struct {
UserCode string `url:"user_code"`
}
GetDeviceSignInParams is the query of GET /oauth/device.
type GetPricesParams ¶
GetPricesParams is the query of GET /public/prices.
type GetRentPricesParams ¶
type GetRentPricesParams struct {
Service string `url:"service"`
}
GetRentPricesParams is the query of GET /public/rent-prices.
type IapTopupResult ¶
type IapTopupResult struct {
Success bool `json:"success"`
Data struct {
Status string `json:"status"` // credited | already_credited
Amount float64 `json:"amount"`
Balance float64 `json:"balance"`
TransactionID string `json:"transaction_id"`
} `json:"data"`
}
IapTopupResult is returned by Topups.Apple and Topups.Google.
type JSONObject ¶
JSONObject is the decoded body of endpoints without a dedicated model.
type ListActivationsParams ¶
ListActivationsParams is the query of GET /user/activations.
type ListCountriesParams ¶
type ListCountriesParams struct {
Service *string `url:"service"`
}
ListCountriesParams is the query of GET /public/countries.
type ListResult ¶
type ListResult struct {
Success bool `json:"success"`
Data []JSONObject `json:"data"`
}
type ListServicesParams ¶
type ListServicesParams struct {
Country *string `url:"country"`
}
ListServicesParams is the query of GET /public/services.
type Loyalty ¶
type Loyalty struct {
Level int `json:"level"`
Label string `json:"label"`
Discount float64 `json:"discount"`
WeeklyActivations int `json:"weekly_activations"`
WeeklyTopup float64 `json:"weekly_topup"`
ProgressPct float64 `json:"progress_pct"`
NextTier *struct {
Level int `json:"level"`
Label string `json:"label"`
Discount float64 `json:"discount"`
} `json:"next_tier"`
}
type Me ¶
type Me struct {
ID string `json:"id"`
Email string `json:"email"`
Name *string `json:"name"`
EmailVerified bool `json:"email_verified"`
CreatedAt string `json:"created_at"`
Balance float64 `json:"balance"`
// OnHold is charged for numbers still waiting for an SMS — refunded if none arrives.
OnHold float64 `json:"on_hold"`
Currency string `json:"currency"`
OpenNumbers int `json:"open_numbers"`
Loyalty *Loyalty `json:"loyalty"`
Restrictions struct {
PurchasesOnHold bool `json:"purchases_on_hold"`
} `json:"restrictions"`
Auth struct {
Via string `json:"via"`
Scopes []string `json:"scopes"`
} `json:"auth"`
}
type OauthTokenParams ¶
type OauthTokenParams struct {
GrantType string `json:"grant_type"`
// Extra holds any additional fields to send.
Extra map[string]string `json:"-"`
}
OauthTokenParams is the body of POST /oauth/token.
type Option ¶
type Option func(*config)
Option configures a Client.
func WithAPIKey ¶
WithAPIKey authenticates with a developer API key (notp_…). Defaults to $NOTP_API_KEY.
func WithBaseURL ¶
WithBaseURL overrides https://api.numberotp.com/v1 (reseller white-label domains work too).
func WithHTTPClient ¶
WithHTTPClient uses your own *http.Client (proxies, tests).
func WithHeader ¶
WithHeader adds a header to every request.
func WithMaxRetries ¶
WithMaxRetries sets retries for network errors, 429 and 5xx where safe (default 2).
func WithOnTokens ¶
func WithOnTokens(fn func(TokenResponse)) Option
WithOnTokens is called whenever new tokens are issued — persist them (securely) here.
func WithTimeout ¶
WithTimeout sets the per-request timeout (default 30s).
func WithTokens ¶
WithTokens authenticates as a signed-in user. With a refresh token the client renews the access token by itself.
type PriceEntry ¶
type PriceEntry struct {
Cost float64 `json:"cost"`
Count int `json:"count"`
// Quality is the measured delivery rate (0–1) of the pool "auto" picks.
Quality float64 `json:"quality"`
Pool string `json:"pool"`
Pools map[string]PoolOffer `json:"pools,omitempty"`
Personalized bool `json:"personalized,omitempty"`
}
type PriceList ¶
type PriceList struct {
Success bool `json:"success"`
// Data[countryID][serviceCode]
Data map[string]map[string]PriceEntry `json:"data"`
}
type PricesService ¶
type PricesService struct {
// contains filtered or unexported fields
}
PricesService: Live prices, stock and success rates.
func (*PricesService) Get ¶
func (s *PricesService) Get(ctx context.Context, params *GetPricesParams, opts ...RequestOption) (*PriceList, error)
Get — Get Prices — Returns real-time pricing for all service/country combinations. Results are cached for up to 5 minutes. Use the `service` short code and numeric `country` ID to look up the price for a specific combination.
func (*PricesService) Rentals ¶
func (s *PricesService) Rentals(ctx context.Context, params *GetRentPricesParams, opts ...RequestOption) (*RentPriceList, error)
Rentals — Get Rental Prices — Rental prices for one service, by country and duration in hours: `data[countryId][hours]` is `{cost, count}`.
type RegisterPushDeviceParams ¶
type RegisterPushDeviceParams struct {
Kind *string `json:"kind,omitempty"`
Token *string `json:"token,omitempty"`
Platform *string `json:"platform,omitempty"`
Locale *string `json:"locale,omitempty"` // Language for notification text: en, es, pt, fr, de, hi, ru or ar (a tag like pt-BR works too). Default en.
ShowCode *bool `json:"show_code,omitempty"` // Show the code itself in the notification
Subscription map[string]any `json:"subscription,omitempty"`
}
RegisterPushDeviceParams is the body of POST /devices.
type RemindersService ¶
type RemindersService struct {
// contains filtered or unexported fields
}
RemindersService: Back-in-stock reminders.
func (*RemindersService) Create ¶
func (s *RemindersService) Create(ctx context.Context, params CreateReminderParams, opts ...RequestOption) (*JSONObject, error)
Create — Create a Back-in-Stock Reminder — Emails you when a sold-out service/country comes back. Limits depend on your loyalty tier.
func (*RemindersService) Delete ¶
func (s *RemindersService) Delete(ctx context.Context, id string, opts ...RequestOption) (*JSONObject, error)
Delete — Cancel a Reminder
func (*RemindersService) List ¶
func (s *RemindersService) List(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
List — List Back-in-Stock Reminders
type RentPriceList ¶
type Rental ¶
type Rental struct {
ID string `json:"id"`
PhoneNumber string `json:"phoneNumber"`
Service string `json:"service"`
ServiceName string `json:"serviceName"`
Country string `json:"country"`
Status string `json:"status"`
ExpiresAt string `json:"expiresAt"`
RentDurationHours int `json:"rentDurationHours"`
SMSHistory []struct {
Code string `json:"code"`
Text string `json:"text"`
ReceivedAt string `json:"receivedAt"`
} `json:"smsHistory"`
}
type RentalResult ¶
type RentalsService ¶
type RentalsService struct {
// contains filtered or unexported fields
}
RentalsService: Rented numbers that receive SMS for hours or days.
func (*RentalsService) Cancel ¶
func (s *RentalsService) Cancel(ctx context.Context, id string, opts ...RequestOption) (*JSONObject, error)
Cancel — Cancel a Rental — Releases a rented number before it expires. **No refund.**
func (*RentalsService) Create ¶
func (s *RentalsService) Create(ctx context.Context, params CreateRentalParams, opts ...RequestOption) (*CreateRentalResult, error)
Create — Rent a Number — Purchase a number for a fixed duration (2h, 4h, 12h, 24h, 48h, 72h, 96h, 120h, 144h, 168h, 336h, 504h, 720h). The number receives unlimited SMS during the rental window. Extend at any time via PATCH /rentals/{id}.
func (*RentalsService) Extend ¶
func (s *RentalsService) Extend(ctx context.Context, id string, params ExtendRentalParams, opts ...RequestOption) (*JSONObject, error)
Extend — Extend a Rental — Add hours to an active rental. Same duration constraints as POST /rentals. **⚠ No refunds** once extended.
func (*RentalsService) ExtendOptions ¶
func (s *RentalsService) ExtendOptions(ctx context.Context, id string, opts ...RequestOption) (*ExtendOptionsResult, error)
ExtendOptions — Get Extension Prices — Prices to extend this rental, by hours — e.g. `{"24": 0.54, "48": 1.08}`.
func (*RentalsService) Get ¶
func (s *RentalsService) Get(ctx context.Context, id string, opts ...RequestOption) (*RentalResult, error)
Get — Get Rental Status & SMS History
func (*RentalsService) List ¶
func (s *RentalsService) List(ctx context.Context, opts ...RequestOption) (*ListResult, error)
List — List My Rentals
type RequestOption ¶
type RequestOption func(*requestConfig)
RequestOption tunes one call.
func WithIdempotencyKey ¶
func WithIdempotencyKey(k string) RequestOption
WithIdempotencyKey uses your own key for a buy / rent / top-up call (one is generated otherwise).
func WithRequestHeader ¶
func WithRequestHeader(key, value string) RequestOption
WithRequestHeader adds a header to one call.
func WithRequestRetries ¶
func WithRequestRetries(n int) RequestOption
WithRequestRetries overrides the retry count for one call.
func WithRequestTimeout ¶
func WithRequestTimeout(d time.Duration) RequestOption
WithRequestTimeout overrides the timeout for one call.
type ResellerPublicService ¶
type ResellerPublicService struct {
// contains filtered or unexported fields
}
ResellerPublicService: A reseller's white-label sign-up and top-up.
func (*ResellerPublicService) Brand ¶
func (s *ResellerPublicService) Brand(ctx context.Context, resellerPublicId string, opts ...RequestOption) (*JSONObject, error)
Brand — Get Reseller Brand Info — Returns white-label brand data (name, logo URL, color) for the signup page. No authentication required.
func (*ResellerPublicService) CardTopup ¶
func (s *ResellerPublicService) CardTopup(ctx context.Context, resellerPublicId string, params ResellerSubUserCardTopupParams, opts ...RequestOption) (*JSONObject, error)
CardTopup — Sub-User Card Top-Up — Creates a card checkout link (Stripe Checkout) for a sub-user to fund their own balance. Authenticate as the sub-user (Bearer notp_... API key or session cookie) — NOT as the reseller. Minimum = reseller's configured minSubUserTopup. Self-funding must be enabled by the reseller. Cards must be enabled on the platform.
func (*ResellerPublicService) CryptoTopup ¶
func (s *ResellerPublicService) CryptoTopup(ctx context.Context, resellerPublicId string, params ResellerSubUserCryptoTopupParams, opts ...RequestOption) (*JSONObject, error)
CryptoTopup — Sub-User Crypto Top-Up — Creates a Cryptomus invoice for a sub-user to fund their own balance. Authenticate as the sub-user (Bearer notp_... API key or session cookie) — NOT as the reseller. Minimum = reseller's configured minSubUserTopup. Self-funding must be enabled by the reseller.
func (*ResellerPublicService) Signup ¶
func (s *ResellerPublicService) Signup(ctx context.Context, resellerPublicId string, params ResellerSignupParams, opts ...RequestOption) (*JSONObject, error)
Signup — Register as Sub-User — Creates a new account linked to this reseller. Requires a Cloudflare Turnstile token. Sends an email OTP for verification. Sub-users use `POST /api/auth/verify-email` next.
type ResellerService ¶
type ResellerService struct {
// contains filtered or unexported fields
}
ResellerService: Reseller management (reseller accounts only).
func (*ResellerService) CardTopup ¶
func (s *ResellerService) CardTopup(ctx context.Context, params CreateResellerCardTopupParams, opts ...RequestOption) (*JSONObject, error)
CardTopup — Top Up Buying Credits via Card — Create a card checkout link (Stripe Checkout) to add buying credits. Minimum $20. Returns a checkout URL to redirect to.
func (*ResellerService) ConvertEarnings ¶
func (s *ResellerService) ConvertEarnings(ctx context.Context, params ConvertResellerEarningsParams, opts ...RequestOption) (*JSONObject, error)
ConvertEarnings — Convert Earned Balance → Buying Credits — Instantly move funds from earned balance (sub-user revenue) to buying credits wallet. Zero fee. Guarded atomically against race conditions.
func (*ResellerService) CreateUser ¶
func (s *ResellerService) CreateUser(ctx context.Context, params CreateResellerUserParams, opts ...RequestOption) (*JSONObject, error)
CreateUser — Create Sub-User — Manually create a sub-user. Optionally deduct initialBalance from your buying credits and allocate it to the new account.
func (*ResellerService) CryptoTopup ¶
func (s *ResellerService) CryptoTopup(ctx context.Context, params CreateResellerCryptoTopupParams, opts ...RequestOption) (*JSONObject, error)
CryptoTopup — Top Up Buying Credits via Crypto — Create a Cryptomus invoice to add buying credits. Minimum $20. Returns a checkout URL to redirect to.
func (*ResellerService) DeleteUser ¶
func (s *ResellerService) DeleteUser(ctx context.Context, subUserId string, opts ...RequestOption) (*JSONObject, error)
DeleteUser — Delete Sub-User — Permanently deletes the sub-user. Remaining balance is forfeited.
func (*ResellerService) GetMarkup ¶
func (s *ResellerService) GetMarkup(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
GetMarkup — Get Markup Configuration — Returns the global price multiplier, per-service overrides, per-country overrides, and autoAdjustLoyalty flag.
func (*ResellerService) GetProfile ¶
func (s *ResellerService) GetProfile(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
GetProfile — Get Reseller Profile — Returns account info including buying balance, earned balance, reseller public ID, brand settings (name, logo, color), webhook URL, sub-user defaults, and markup version.
func (*ResellerService) GetUser ¶
func (s *ResellerService) GetUser(ctx context.Context, subUserId string, opts ...RequestOption) (*JSONObject, error)
GetUser — Get Sub-User Details — Returns full profile for one sub-user.
func (*ResellerService) ListUsers ¶
func (s *ResellerService) ListUsers(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
ListUsers — List Sub-Users — Returns all sub-users linked to this reseller account.
func (*ResellerService) UpdateMarkup ¶
func (s *ResellerService) UpdateMarkup(ctx context.Context, params UpdateResellerMarkupParams, opts ...RequestOption) (*JSONObject, error)
UpdateMarkup — Update Markup — Set global multiplier and optional per-service/country overrides. Sub-user price = platform_price × countryOverride × serviceOverride × global. Busts the markup cache immediately on save.
func (*ResellerService) UpdateProfile ¶
func (s *ResellerService) UpdateProfile(ctx context.Context, params UpdateResellerProfileParams, opts ...RequestOption) (*JSONObject, error)
UpdateProfile — Update Brand, Webhook & Sub-User Settings — Update brand fields, webhook URL/secret, and sub-user defaults. All fields optional — only provided keys are updated.
func (*ResellerService) UpdateUser ¶
func (s *ResellerService) UpdateUser(ctx context.Context, subUserId string, params UpdateResellerUserParams, opts ...RequestOption) (*JSONObject, error)
UpdateUser — Update Sub-User — Adjust balance delta, toggle suspension, or change allowSelfFund. balanceDelta is atomic — positive adds funds from reseller buying credits, negative deducts from sub-user.
func (*ResellerService) WithdrawEarnings ¶
func (s *ResellerService) WithdrawEarnings(ctx context.Context, params WithdrawResellerEarningsParams, opts ...RequestOption) (*JSONObject, error)
WithdrawEarnings — Withdraw Earned Balance as Crypto — Submit a crypto withdrawal request. Minimum $10. Processed within 24 hours.
type ResellerSignupParams ¶
type ResellerSignupParams struct {
Email string `json:"email"`
Password string `json:"password"`
Name *string `json:"name,omitempty"`
TurnstileToken string `json:"turnstileToken"`
}
ResellerSignupParams is the body of POST /reseller-public/{resellerPublicId}/signup.
type ResellerSubUserCardTopupParams ¶
type ResellerSubUserCardTopupParams struct {
Amount float64 `json:"amount"`
}
ResellerSubUserCardTopupParams is the body of POST /reseller-public/{resellerPublicId}/topup/card.
type ResellerSubUserCryptoTopupParams ¶
type ResellerSubUserCryptoTopupParams struct {
Amount float64 `json:"amount"`
}
ResellerSubUserCryptoTopupParams is the body of POST /reseller-public/{resellerPublicId}/topup/crypto.
type RevokeSessionsParams ¶
type RevokeSessionsParams struct {
ID *string `json:"id,omitempty"`
All *bool `json:"all,omitempty"`
}
RevokeSessionsParams is the body of DELETE /user/sessions.
type RevokeTokenParams ¶
type RevokeTokenParams struct {
Token string `json:"token"`
}
RevokeTokenParams is the body of POST /oauth/revoke.
type SMS ¶
type SMS struct {
Code string `json:"code"`
Text string `json:"text"`
ReceivedAt string `json:"received_at"`
}
SMS is one message received on a number.
type SearchServicesParams ¶
SearchServicesParams is the query of GET /services/search.
type SendEmailCodeParams ¶
type SendEmailCodeParams struct {
Email string `json:"email"`
}
SendEmailCodeParams is the body of POST /oauth/email-code.
type ServiceList ¶
type ServiceMatch ¶
type ServiceSearchResult ¶
type ServiceSearchResult struct {
Success bool `json:"success"`
Query struct {
Input string `json:"input"`
MatchedAs string `json:"matched_as"`
} `json:"query"`
Data []ServiceMatch `json:"data"`
// Fallback is offered when nothing matched: the catch-all "any other service".
Fallback *ServiceMatch `json:"fallback,omitempty"`
}
type ServicesService ¶
type ServicesService struct {
// contains filtered or unexported fields
}
ServicesService: Find services (the sites and apps you can receive codes for).
func (*ServicesService) List ¶
func (s *ServicesService) List(ctx context.Context, params *ListServicesParams, opts ...RequestOption) (*ServiceList, error)
List — List Services — Returns all services available for activation. Use the `code` field from each item as the `service` parameter when creating activations. Optionally filter by country numeric ID to see only services available in that country.
func (*ServicesService) Search ¶
func (s *ServicesService) Search(ctx context.Context, params *SearchServicesParams, opts ...RequestOption) (*ServiceSearchResult, error)
Search — Find a Service by Name or Domain — Turns what you have — a name, a code, a URL or a domain like `accounts.google.com` — into service codes, best match first. When nothing matches, `fallback` offers the catch-all "any other service" code.
type SessionList ¶
type SessionList struct {
Success bool `json:"success"`
Data []ClientSession `json:"data"`
}
type SessionsService ¶
type SessionsService struct {
// contains filtered or unexported fields
}
SessionsService: Signed-in apps, extensions, CLIs and agents.
func (*SessionsService) List ¶
func (s *SessionsService) List(ctx context.Context, opts ...RequestOption) (*SessionList, error)
List — List Connected Devices — Apps, extensions, CLIs and MCP servers signed in to this account.
func (*SessionsService) Revoke ¶
func (s *SessionsService) Revoke(ctx context.Context, params RevokeSessionsParams, opts ...RequestOption) (*JSONObject, error)
Revoke — Sign Out a Device (or All)
type SetWebhookParams ¶
type SetWebhookParams struct {
WebhookURL *string `json:"webhookUrl,omitempty"` // Public HTTPS URL
}
SetWebhookParams is the body of POST /user/webhook.
type StartDeviceSignInParams ¶
type StartDeviceSignInParams struct {
Client *string `json:"client,omitempty"`
DeviceName *string `json:"device_name,omitempty"`
}
StartDeviceSignInParams is the body of POST /oauth/device/code.
type StreamEventsParams ¶
type StreamEventsParams struct {
Since *string `url:"since"`
}
StreamEventsParams is the query of GET /events.
type TokenResponse ¶
type TopupResult ¶
type TopupStarted ¶
type TopupsService ¶
type TopupsService struct {
// contains filtered or unexported fields
}
TopupsService: Add balance by card or crypto.
func (*TopupsService) Apple ¶
func (s *TopupsService) Apple(ctx context.Context, params CreateAppleTopupParams, opts ...RequestOption) (*IapTopupResult, error)
Apple — Credit an App Store Purchase — For the iOS app. Send the StoreKit 2 `Transaction.jwsRepresentation` of a credit pack bought with `appAccountToken` set to `iap_account_token` from `GET /me`. It is verified against Apple's root certificate and credited once per transaction — safe to retry; finish the StoreKit transaction only after a 200. Test (sandbox) purchases are accepted only for allowlisted accounts. Errors: `INVALID_PURCHASE`, `UNKNOWN_PRODUCT`, `PURCHASE_REVOKED`, `ACCOUNT_MISMATCH`, `SANDBOX_NOT_ALLOWED`.
func (*TopupsService) Card ¶
func (s *TopupsService) Card(ctx context.Context, params CreateCardTopupParams, opts ...RequestOption) (*TopupStarted, error)
Card — Top Up by Card — Returns a Stripe Checkout URL to open in a browser. When it's paid you get a `topup.completed` event.
func (*TopupsService) Crypto ¶
func (s *TopupsService) Crypto(ctx context.Context, params CreateCryptoTopupParams, opts ...RequestOption) (*TopupStarted, error)
Crypto — Top Up with Crypto — Returns a crypto invoice URL. Top-ups of $50 or more get a 10% bonus.
func (*TopupsService) Get ¶
func (s *TopupsService) Get(ctx context.Context, id string, opts ...RequestOption) (*TopupResult, error)
Get — Get Top-Up Status
func (*TopupsService) Google ¶
func (s *TopupsService) Google(ctx context.Context, params CreateGoogleTopupParams, opts ...RequestOption) (*IapTopupResult, error)
Google — Credit a Google Play Purchase — For the Android app. Send the product id and purchase token of a credit pack bought with `obfuscatedAccountId` set to `iap_account_token` from `GET /me`. Checked with Google Play, credited once per order and consumed — safe to retry. Errors as for Apple, plus `PURCHASE_PENDING` and `IAP_UNAVAILABLE`.
type UnregisterPushDeviceParams ¶
type UnregisterPushDeviceParams struct {
Token *string `json:"token,omitempty"`
ID *string `json:"id,omitempty"`
}
UnregisterPushDeviceParams is the body of DELETE /devices.
type UpdatePushDeviceParams ¶
UpdatePushDeviceParams is the body of PATCH /devices.
type UpdateResellerMarkupParams ¶
type UpdateResellerMarkupParams struct {
Global *float64 `json:"global,omitempty"` // Multiplier applied to all prices. 1.0 = no markup.
Overrides map[string]any `json:"overrides,omitempty"` // Per-service multipliers (keyed by service code).
CountryOverrides map[string]any `json:"countryOverrides,omitempty"` // Per-country multipliers (keyed by numeric country ID string).
AutoAdjustLoyalty *bool `json:"autoAdjustLoyalty,omitempty"` // If true, loyalty discounts are passed through to sub-users.
}
UpdateResellerMarkupParams is the body of PATCH /reseller/markup.
type UpdateResellerProfileParams ¶
type UpdateResellerProfileParams struct {
BrandName *string `json:"brandName,omitempty"`
LogoURL *string `json:"logoUrl,omitempty"`
Color *string `json:"color,omitempty"`
WebhookURL *string `json:"webhookUrl,omitempty"`
WebhookSecret *string `json:"webhookSecret,omitempty"`
AllowSelfFundDefault *bool `json:"allowSelfFundDefault,omitempty"`
MinSubUserTopup *float64 `json:"minSubUserTopup,omitempty"`
}
UpdateResellerProfileParams is the body of PATCH /reseller/profile.
type UpdateResellerUserParams ¶
type UpdateResellerUserParams struct {
BalanceDelta *float64 `json:"balanceDelta,omitempty"`
Suspended *bool `json:"suspended,omitempty"`
AllowSelfFund *bool `json:"allowSelfFund,omitempty"`
}
UpdateResellerUserParams is the body of PATCH /reseller/users/{subUserId}.
type WaitResult ¶
type WebhookPayload ¶
type WebhookPayload struct {
Event string `json:"event"`
EventID string `json:"event_id"`
ID string `json:"id"`
PhoneNumber string `json:"phone_number"`
Service string `json:"service"`
Country string `json:"country"`
OTP *string `json:"otp"`
FullSMS *string `json:"full_sms"`
Status string `json:"status"`
}
WebhookPayload is the body NumberOTP POSTs when an SMS arrives.
type WebhookService ¶
type WebhookService struct {
// contains filtered or unexported fields
}
WebhookService: Your webhook URL and signing secret.
func (*WebhookService) Get ¶
func (s *WebhookService) Get(ctx context.Context, opts ...RequestOption) (*JSONObject, error)
Get — Get Webhook Settings
func (*WebhookService) Set ¶
func (s *WebhookService) Set(ctx context.Context, params SetWebhookParams, opts ...RequestOption) (*JSONObject, error)
Set — Set Webhook URL
type WithdrawResellerEarningsParams ¶
type WithdrawResellerEarningsParams struct {
Amount float64 `json:"amount"`
Currency string `json:"currency"` // Crypto ticker: USDT, BTC, ETH, SOL, etc.
CryptoAddress string `json:"cryptoAddress"`
}
WithdrawResellerEarningsParams is the body of POST /reseller/payout/withdraw.