numberotp

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 23 Imported by: 0

README

numberotp (Go)

The official Go client for the NumberOTP API. It uses only the standard library and needs Go 1.24+.

go get github.com/DishantSinghDev2/numberotp-go

Get an API key at numberotp.com/dashboard/developer and set it as NOTP_API_KEY. Guides: numberotp.com/docs/sdks.

client := numberotp.NewClient() // reads NOTP_API_KEY

act, err := client.CreateAndWait(ctx,
	numberotp.CreateActivationParams{Service: "wa", Country: "16"},
	20*time.Minute,
	func(n *numberotp.CreateActivationResult) { fmt.Println("Use:", n.Data.PhoneNumber) })
if err != nil {
	var closed *numberotp.ActivationClosedError
	if errors.As(err, &closed) { /* expired — refunded */ }
}
fmt.Println("Code:", act.Code())
client.Services.Search(ctx, &numberotp.SearchServicesParams{Q: "discord.com"})
client.Prices.Get(ctx, &numberotp.GetPricesParams{Service: numberotp.String("wa")})
client.Activations.Cancel(ctx, id) // full refund if no SMS yet
for ev, err := range client.StreamEvents(ctx, "") { … }   // live events
numberotp.VerifyWebhook(body, r.Header.Get("X-NumberOTP-Signature"), secret)
client.DeviceLogin(ctx, numberotp.DeviceLoginOptions{OnCode: func(d numberotp.DeviceCode) { … }})

Errors are *numberotp.Error values with Status and a stable Code. Purchases send an Idempotency-Key, and retries are only made where they're safe.

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

View Source
const DefaultBaseURL = "https://api.numberotp.com/v1"

DefaultBaseURL is the production API.

View Source
const Version = "0.1.0"

Version of this SDK.

Variables

View Source
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 Bool

func Bool(v bool) *bool

func Float

func Float(v float64) *float64

func Int

func Int(v int) *int

func String

func String(v string) *string

Pointer helpers for optional fields.

func VerifyWebhook

func VerifyWebhook(rawBody []byte, signatureHeader, secret string) bool

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

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

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

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

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

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

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

type AppConfigResult struct {
	Success bool      `json:"success"`
	Data    AppConfig `json:"data"`
}

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 NewClient

func NewClient(opts ...Option) *Client

NewClient builds a client. With no options it uses $NOTP_API_KEY.

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

func (c *Client) RefreshToken() string

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) SignOut

func (c *Client) SignOut(ctx context.Context) error

SignOut revokes the refresh token server-side and forgets the tokens.

func (*Client) StreamEvents

func (c *Client) StreamEvents(ctx context.Context, since string) iter.Seq2[Event, error]

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 ClientSession struct {
	ID         string   `json:"id"`
	Platform   string   `json:"platform"`
	DeviceName string   `json:"device_name"`
	Scopes     []string `json:"scopes"`
	LastSeenAt string   `json:"last_seen_at"`
	CreatedAt  string   `json:"created_at"`
	Current    bool     `json:"current"`
}

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

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 Country

type Country struct {
	ID      int    `json:"id"`
	Name    string `json:"eng"`
	Visible int    `json:"visible"`
	Rent    int    `json:"rent"`
}

type CountryList

type CountryList struct {
	Success bool `json:"success"`
	// Data is keyed by country id.
	Data map[string]Country `json:"data"`
}

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 CreateActivationResult struct {
	Success bool `json:"success"`
	Data    struct {
		ID          string `json:"id"`
		PhoneNumber string `json:"phoneNumber"`
		ExpiresAt   string `json:"expiresAt"`
		Pool        string `json:"pool"`
	} `json:"data"`
	// Balance left after the purchase.
	Balance float64 `json:"balance"`
}

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 CreateRentalResult struct {
	Success bool `json:"success"`
	Data    struct {
		ID            string `json:"id"`
		PhoneNumber   string `json:"phoneNumber"`
		ExpiresAt     string `json:"expiresAt"`
		DurationHours int    `json:"durationHours"`
	} `json:"data"`
	Balance float64 `json:"balance"`
}

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 DeviceCode struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri"`
	VerificationURIComplete string `json:"verification_uri_complete"`
	ExpiresIn               int    `json:"expires_in"`
	Interval                int    `json:"interval"`
}

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

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

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) Error

func (e *Error) Error() string

func (*Error) IsConflict

func (e *Error) IsConflict() bool

func (*Error) IsInsufficientBalance

func (e *Error) IsInsufficientBalance() bool

Convenience checks.

func (*Error) IsNotFound

func (e *Error) IsNotFound() bool

func (*Error) IsRateLimited

func (e *Error) IsRateLimited() bool

func (*Error) IsUnauthorized

func (e *Error) IsUnauthorized() bool

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 EventPoll

type EventPoll struct {
	Success bool    `json:"success"`
	Data    []Event `json:"data"`
	Cursor  string  `json:"cursor"`
}

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 ExtendOptionsResult struct {
	Success bool `json:"success"`
	// Data maps extra hours to price (USD).
	Data map[string]float64 `json:"data"`
}

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

type GetPricesParams struct {
	Service *string `url:"service"`
	Country *string `url:"country"`
}

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

type JSONObject map[string]any

JSONObject is the decoded body of endpoints without a dedicated model.

type ListActivationsParams

type ListActivationsParams struct {
	Status *string `url:"status"`
	Limit  *int    `url:"limit"`
}

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 MeResult

type MeResult struct {
	Success bool `json:"success"`
	Data    Me   `json:"data"`
}

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

func WithAPIKey(key string) Option

WithAPIKey authenticates with a developer API key (notp_…). Defaults to $NOTP_API_KEY.

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL overrides https://api.numberotp.com/v1 (reseller white-label domains work too).

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient uses your own *http.Client (proxies, tests).

func WithHeader

func WithHeader(key, value string) Option

WithHeader adds a header to every request.

func WithMaxRetries

func WithMaxRetries(n int) Option

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

func WithTimeout(d time.Duration) Option

WithTimeout sets the per-request timeout (default 30s).

func WithTokens

func WithTokens(accessToken, refreshToken string) Option

WithTokens authenticates as a signed-in user. With a refresh token the client renews the access token by itself.

type PoolOffer

type PoolOffer struct {
	Cost    float64  `json:"cost"`
	Count   int      `json:"count"`
	Quality *float64 `json:"quality,omitempty"`
}

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

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 RentPriceList struct {
	Success bool `json:"success"`
	// Data[countryID][hours]
	Data map[string]map[string]struct {
		Cost  float64 `json:"cost"`
		Count int     `json:"count"`
	} `json:"data"`
}

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 RentalResult struct {
	Success bool   `json:"success"`
	Data    Rental `json:"data"`
}

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

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

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

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

type SearchServicesParams struct {
	Q     string `url:"q"`
	Limit *int   `url:"limit"`
}

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 ServiceList struct {
	Success bool `json:"success"`
	Data    struct {
		Services []struct {
			Code string `json:"code"`
			Name string `json:"name"`
		} `json:"services"`
	} `json:"data"`
}

type ServiceMatch

type ServiceMatch struct {
	Code  string `json:"code"`
	Name  string `json:"name"`
	Score int    `json:"score"`
}

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

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

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

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 TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	SessionID    string `json:"session_id"`
	NewUser      *bool  `json:"new_user,omitempty"`
}

type Topup

type Topup struct {
	ID        string  `json:"id"`
	Amount    float64 `json:"amount"`
	Method    string  `json:"method"`
	Status    string  `json:"status"`
	CreatedAt string  `json:"created_at"`
}

type TopupResult

type TopupResult struct {
	Success bool  `json:"success"`
	Data    Topup `json:"data"`
}

type TopupStarted

type TopupStarted struct {
	Success bool `json:"success"`
	// URL opens the checkout in a browser.
	URL           string `json:"url"`
	TransactionID string `json:"transaction_id"`
	InvoiceID     string `json:"invoiceId,omitempty"`
}

type TopupsService

type TopupsService struct {
	// contains filtered or unexported fields
}

TopupsService: Add balance by card or crypto.

func (*TopupsService) Apple

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

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

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

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

type UpdatePushDeviceParams struct {
	Token    string `json:"token"`
	ShowCode bool   `json:"show_code"`
}

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 WaitResult struct {
	Success bool `json:"success"`
	Data    struct {
		OTP     string `json:"otp"`
		FullSMS string `json:"full_sms"`
		Status  string `json:"status"`
	} `json:"data"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL