prelude

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

README

Prelude Go API Library

Go Reference

The Prelude Go library provides convenient access to the Prelude REST API from applications written in Go.

It is generated with Stainless.

Installation

import (
	"github.com/prelude-so/go-sdk" // imported as prelude
)

Or to pin the version:

go get -u 'github.com/prelude-so/go-sdk@v0.7.0'

Requirements

This library requires Go 1.18+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/prelude-so/go-sdk"
	"github.com/prelude-so/go-sdk/option"
)

func main() {
	client := prelude.NewClient(
		option.WithAPIToken("My API Token"), // defaults to os.LookupEnv("API_TOKEN")
	)
	verification, err := client.Verification.New(context.TODO(), prelude.VerificationNewParams{
		Target: prelude.F(prelude.VerificationNewParamsTarget{
			Type:  prelude.F(prelude.VerificationNewParamsTargetTypePhoneNumber),
			Value: prelude.F("+30123456789"),
		}),
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", verification.ID)
}

Request fields

All request parameters are wrapped in a generic Field type, which we use to distinguish zero values from null or omitted fields.

This prevents accidentally sending a zero value if you forget a required parameter, and enables explicitly sending null, false, '', or 0 on optional parameters. Any field not specified is not sent.

To construct fields with values, use the helpers String(), Int(), Float(), or most commonly, the generic F[T](). To send a null, use Null[T](), and to send a nonconforming value, use Raw[T](any). For example:

params := FooParams{
	Name: prelude.F("hello"),

	// Explicitly send `"description": null`
	Description: prelude.Null[string](),

	Point: prelude.F(prelude.Point{
		X: prelude.Int(0),
		Y: prelude.Int(1),

		// In cases where the API specifies a given type,
		// but you want to send something else, use `Raw`:
		Z: prelude.Raw[int64](0.01), // sends a float
	}),
}
Response objects

All fields in response structs are value types (not pointers or wrappers).

If a given field is null, not present, or invalid, the corresponding field will simply be its zero value.

All response structs also include a special JSON field, containing more detailed information about each property, which you can use like so:

if res.Name == "" {
	// true if `"name"` is either not present or explicitly null
	res.JSON.Name.IsNull()

	// true if the `"name"` key was not present in the response JSON at all
	res.JSON.Name.IsMissing()

	// When the API returns data that cannot be coerced to the expected type:
	if res.JSON.Name.IsInvalid() {
		raw := res.JSON.Name.Raw()

		legacyName := struct{
			First string `json:"first"`
			Last  string `json:"last"`
		}{}
		json.Unmarshal([]byte(raw), &legacyName)
		name = legacyName.First + " " + legacyName.Last
	}
}

These .JSON structs also include an Extras map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := prelude.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Verification.New(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

Errors

When the API returns a non-success status code, we return an error with type *prelude.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Verification.New(context.TODO(), prelude.VerificationNewParams{
	Target: prelude.F(prelude.VerificationNewParamsTarget{
		Type:  prelude.F(prelude.VerificationNewParamsTargetTypePhoneNumber),
		Value: prelude.F("+30123456789"),
	}),
})
if err != nil {
	var apierr *prelude.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/v2/verification": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Verification.New(
	ctx,
	prelude.VerificationNewParams{
		Target: prelude.F(prelude.VerificationNewParamsTarget{
			Type:  prelude.F(prelude.VerificationNewParamsTargetTypePhoneNumber),
			Value: prelude.F("+30123456789"),
		}),
	},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as param.Field[io.Reader]. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper prelude.FileParam(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := prelude.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Verification.New(
	context.TODO(),
	prelude.VerificationNewParams{
		Target: prelude.F(prelude.VerificationNewParamsTarget{
			Type:  prelude.F(prelude.VerificationNewParamsTargetTypePhoneNumber),
			Value: prelude.F("+30123456789"),
		}),
	},
	option.WithMaxRetries(5),
)
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
verification, err := client.Verification.New(
	context.TODO(),
	prelude.VerificationNewParams{
		Target: prelude.F(prelude.VerificationNewParamsTarget{
			Type:  prelude.F(prelude.VerificationNewParamsTargetTypePhoneNumber),
			Value: prelude.F("+30123456789"),
		}),
	},
	option.WithResponseInto(&response),
)
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", verification)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]interface{}

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   prelude.F("id_xxxx"),
    Data: prelude.F(FooNewParamsData{
        FirstName: prelude.F("John"),
    }),
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := prelude.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(value bool) param.Field[bool]

Bool is a param field helper which helps specify bools.

func DefaultClientOptions added in v0.3.0

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (API_TOKEN, PRELUDE_BASE_URL). This should be used to initialize new clients.

func F

func F[T any](value T) param.Field[T]

F is a param field helper used to initialize a param.Field generic struct. This helps specify null, zero values, and overrides, as well as normal values. You can read more about this in our README.

func FileParam

func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader]

FileParam is a param field helper which helps files with a mime content-type.

func Float

func Float(value float64) param.Field[float64]

Float is a param field helper which helps specify floats.

func Int

func Int(value int64) param.Field[int64]

Int is a param field helper which helps specify integers. This is particularly helpful when specifying integer constants for fields.

func Null

func Null[T any]() param.Field[T]

Null is a param field helper which explicitly sends null to the API.

func Raw

func Raw[T any](value any) param.Field[T]

Raw is a param field helper for specifying values for fields when the type you are looking to send is different from the type that is specified in the SDK. For example, if the type of the field is an integer, but you want to send a float, you could do that by setting the corresponding field with Raw[int](0.5).

func String

func String(value string) param.Field[string]

String is a param field helper which helps specify strings.

Types

type Client

type Client struct {
	Options       []option.RequestOption
	Lookup        *LookupService
	Transactional *TransactionalService
	Verification  *VerificationService
	Watch         *WatchService
}

Client creates a struct with services and top level methods that help with interacting with the Prelude API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r *Client)

NewClient generates a new client with the default option read from the environment (API_TOKEN, PRELUDE_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type Error

type Error = apierror.Error

type LookupLookupParams added in v0.3.0

type LookupLookupParams struct {
	// Optional features. Possible values are:
	//
	//   - `cnam` - Retrieve CNAM (Caller ID Name) along with other information. Contact
	//     us if you need to use this functionality.
	Type param.Field[[]LookupLookupParamsType] `query:"type"`
}

func (LookupLookupParams) URLQuery added in v0.3.0

func (r LookupLookupParams) URLQuery() (v url.Values)

URLQuery serializes LookupLookupParams's query parameters as `url.Values`.

type LookupLookupParamsType added in v0.3.0

type LookupLookupParamsType string
const (
	LookupLookupParamsTypeCnam LookupLookupParamsType = "cnam"
)

func (LookupLookupParamsType) IsKnown added in v0.3.0

func (r LookupLookupParamsType) IsKnown() bool

type LookupLookupResponse added in v0.3.0

type LookupLookupResponse struct {
	// The CNAM (Caller ID Name) associated with the phone number. Contact us if you
	// need to use this functionality. Once enabled, put `cnam` option to `type` query
	// parameter.
	CallerName string `json:"caller_name"`
	// The country code of the phone number.
	CountryCode string `json:"country_code"`
	// A list of flags associated with the phone number.
	//
	//   - `ported` - Indicates the phone number has been transferred from one carrier to
	//     another.
	//   - `temporary` - Indicates the phone number is likely a temporary or virtual
	//     number, often used for verification services or burner phones.
	Flags []LookupLookupResponseFlag `json:"flags"`
	// The type of phone line.
	//
	//   - `calling_cards` - Numbers that are associated with providers of pre-paid
	//     domestic and international calling cards.
	//   - `fixed_line` - Landline phone numbers.
	//   - `isp` - Numbers reserved for Internet Service Providers.
	//   - `local_rate` - Numbers that can be assigned non-geographically.
	//   - `mobile` - Mobile phone numbers.
	//   - `other` - Other types of services.
	//   - `pager` - Number ranges specifically allocated to paging devices.
	//   - `payphone` - Allocated numbers for payphone kiosks in some countries.
	//   - `premium_rate` - Landline numbers where the calling party pays more than
	//     standard.
	//   - `satellite` - Satellite phone numbers.
	//   - `service` - Automated applications.
	//   - `shared_cost` - Specific landline ranges where the cost of making the call is
	//     shared between the calling and called party.
	//   - `short_codes_commercial` - Short codes are memorable, easy-to-use numbers,
	//     like the UK's NHS 111, often sold to businesses. Not available in all
	//     countries.
	//   - `toll_free` - Number where the called party pays for the cost of the call not
	//     the calling party.
	//   - `universal_access` - Number ranges reserved for Universal Access initiatives.
	//   - `unknown` - Unknown phone number type.
	//   - `vpn` - Numbers are used exclusively within a private telecommunications
	//     network, connecting the operator's terminals internally and not accessible via
	//     the public telephone network.
	//   - `voice_mail` - A specific category of Interactive Voice Response (IVR)
	//     services.
	//   - `voip` - Specific ranges for providers of VoIP services to allow incoming
	//     calls from the regular telephony network.
	LineType LookupLookupResponseLineType `json:"line_type"`
	// The current carrier information.
	NetworkInfo LookupLookupResponseNetworkInfo `json:"network_info"`
	// The original carrier information.
	OriginalNetworkInfo LookupLookupResponseOriginalNetworkInfo `json:"original_network_info"`
	// The phone number.
	PhoneNumber string                   `json:"phone_number"`
	JSON        lookupLookupResponseJSON `json:"-"`
}

func (*LookupLookupResponse) UnmarshalJSON added in v0.3.0

func (r *LookupLookupResponse) UnmarshalJSON(data []byte) (err error)

type LookupLookupResponseFlag added in v0.3.0

type LookupLookupResponseFlag string
const (
	LookupLookupResponseFlagPorted    LookupLookupResponseFlag = "ported"
	LookupLookupResponseFlagTemporary LookupLookupResponseFlag = "temporary"
)

func (LookupLookupResponseFlag) IsKnown added in v0.3.0

func (r LookupLookupResponseFlag) IsKnown() bool

type LookupLookupResponseLineType added in v0.3.0

type LookupLookupResponseLineType string

The type of phone line.

  • `calling_cards` - Numbers that are associated with providers of pre-paid domestic and international calling cards.
  • `fixed_line` - Landline phone numbers.
  • `isp` - Numbers reserved for Internet Service Providers.
  • `local_rate` - Numbers that can be assigned non-geographically.
  • `mobile` - Mobile phone numbers.
  • `other` - Other types of services.
  • `pager` - Number ranges specifically allocated to paging devices.
  • `payphone` - Allocated numbers for payphone kiosks in some countries.
  • `premium_rate` - Landline numbers where the calling party pays more than standard.
  • `satellite` - Satellite phone numbers.
  • `service` - Automated applications.
  • `shared_cost` - Specific landline ranges where the cost of making the call is shared between the calling and called party.
  • `short_codes_commercial` - Short codes are memorable, easy-to-use numbers, like the UK's NHS 111, often sold to businesses. Not available in all countries.
  • `toll_free` - Number where the called party pays for the cost of the call not the calling party.
  • `universal_access` - Number ranges reserved for Universal Access initiatives.
  • `unknown` - Unknown phone number type.
  • `vpn` - Numbers are used exclusively within a private telecommunications network, connecting the operator's terminals internally and not accessible via the public telephone network.
  • `voice_mail` - A specific category of Interactive Voice Response (IVR) services.
  • `voip` - Specific ranges for providers of VoIP services to allow incoming calls from the regular telephony network.
const (
	LookupLookupResponseLineTypeCallingCards         LookupLookupResponseLineType = "calling_cards"
	LookupLookupResponseLineTypeFixedLine            LookupLookupResponseLineType = "fixed_line"
	LookupLookupResponseLineTypeIsp                  LookupLookupResponseLineType = "isp"
	LookupLookupResponseLineTypeLocalRate            LookupLookupResponseLineType = "local_rate"
	LookupLookupResponseLineTypeMobile               LookupLookupResponseLineType = "mobile"
	LookupLookupResponseLineTypeOther                LookupLookupResponseLineType = "other"
	LookupLookupResponseLineTypePager                LookupLookupResponseLineType = "pager"
	LookupLookupResponseLineTypePayphone             LookupLookupResponseLineType = "payphone"
	LookupLookupResponseLineTypePremiumRate          LookupLookupResponseLineType = "premium_rate"
	LookupLookupResponseLineTypeSatellite            LookupLookupResponseLineType = "satellite"
	LookupLookupResponseLineTypeService              LookupLookupResponseLineType = "service"
	LookupLookupResponseLineTypeSharedCost           LookupLookupResponseLineType = "shared_cost"
	LookupLookupResponseLineTypeShortCodesCommercial LookupLookupResponseLineType = "short_codes_commercial"
	LookupLookupResponseLineTypeTollFree             LookupLookupResponseLineType = "toll_free"
	LookupLookupResponseLineTypeUniversalAccess      LookupLookupResponseLineType = "universal_access"
	LookupLookupResponseLineTypeUnknown              LookupLookupResponseLineType = "unknown"
	LookupLookupResponseLineTypeVpn                  LookupLookupResponseLineType = "vpn"
	LookupLookupResponseLineTypeVoiceMail            LookupLookupResponseLineType = "voice_mail"
	LookupLookupResponseLineTypeVoip                 LookupLookupResponseLineType = "voip"
)

func (LookupLookupResponseLineType) IsKnown added in v0.3.0

func (r LookupLookupResponseLineType) IsKnown() bool

type LookupLookupResponseNetworkInfo added in v0.3.0

type LookupLookupResponseNetworkInfo struct {
	// The name of the carrier.
	CarrierName string `json:"carrier_name"`
	// Mobile Country Code.
	Mcc string `json:"mcc"`
	// Mobile Network Code.
	Mnc  string                              `json:"mnc"`
	JSON lookupLookupResponseNetworkInfoJSON `json:"-"`
}

The current carrier information.

func (*LookupLookupResponseNetworkInfo) UnmarshalJSON added in v0.3.0

func (r *LookupLookupResponseNetworkInfo) UnmarshalJSON(data []byte) (err error)

type LookupLookupResponseOriginalNetworkInfo added in v0.3.0

type LookupLookupResponseOriginalNetworkInfo struct {
	// The name of the original carrier.
	CarrierName string `json:"carrier_name"`
	// Mobile Country Code.
	Mcc string `json:"mcc"`
	// Mobile Network Code.
	Mnc  string                                      `json:"mnc"`
	JSON lookupLookupResponseOriginalNetworkInfoJSON `json:"-"`
}

The original carrier information.

func (*LookupLookupResponseOriginalNetworkInfo) UnmarshalJSON added in v0.3.0

func (r *LookupLookupResponseOriginalNetworkInfo) UnmarshalJSON(data []byte) (err error)

type LookupService added in v0.3.0

type LookupService struct {
	Options []option.RequestOption
}

LookupService contains methods and other services that help with interacting with the Prelude API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewLookupService method instead.

func NewLookupService added in v0.3.0

func NewLookupService(opts ...option.RequestOption) (r *LookupService)

NewLookupService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*LookupService) Lookup added in v0.3.0

func (r *LookupService) Lookup(ctx context.Context, phoneNumber string, query LookupLookupParams, opts ...option.RequestOption) (res *LookupLookupResponse, err error)

Retrieve detailed information about a phone number including carrier data, line type, and portability status.

type TransactionalSendParams

type TransactionalSendParams struct {
	// The template identifier.
	TemplateID param.Field[string] `json:"template_id,required"`
	// The recipient's phone number.
	To param.Field[string] `json:"to,required"`
	// The callback URL.
	CallbackURL param.Field[string] `json:"callback_url"`
	// A user-defined identifier to correlate this transactional message with. It is
	// returned in the response and any webhook events that refer to this
	// transactionalmessage.
	CorrelationID param.Field[string] `json:"correlation_id"`
	// The message expiration date.
	ExpiresAt param.Field[string] `json:"expires_at"`
	// The Sender ID.
	From param.Field[string] `json:"from"`
	// A BCP-47 formatted locale string with the language the text message will be sent
	// to. If there's no locale set, the language will be determined by the country
	// code of the phone number. If the language specified doesn't exist, the default
	// set on the template will be used.
	Locale param.Field[string] `json:"locale"`
	// The variables to be replaced in the template.
	Variables param.Field[map[string]string] `json:"variables"`
}

func (TransactionalSendParams) MarshalJSON

func (r TransactionalSendParams) MarshalJSON() (data []byte, err error)

type TransactionalSendResponse

type TransactionalSendResponse struct {
	// The message identifier.
	ID string `json:"id,required"`
	// The message creation date.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// The message expiration date.
	ExpiresAt time.Time `json:"expires_at,required" format:"date-time"`
	// The template identifier.
	TemplateID string `json:"template_id,required"`
	// The recipient's phone number.
	To string `json:"to,required"`
	// The variables to be replaced in the template.
	Variables map[string]string `json:"variables,required"`
	// The callback URL.
	CallbackURL string `json:"callback_url"`
	// A user-defined identifier to correlate this transactional message with. It is
	// returned in the response and any webhook events that refer to this transactional
	// message.
	CorrelationID string `json:"correlation_id"`
	// The Sender ID.
	From string                        `json:"from"`
	JSON transactionalSendResponseJSON `json:"-"`
}

func (*TransactionalSendResponse) UnmarshalJSON

func (r *TransactionalSendResponse) UnmarshalJSON(data []byte) (err error)

type TransactionalService

type TransactionalService struct {
	Options []option.RequestOption
}

TransactionalService contains methods and other services that help with interacting with the Prelude API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewTransactionalService method instead.

func NewTransactionalService

func NewTransactionalService(opts ...option.RequestOption) (r *TransactionalService)

NewTransactionalService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*TransactionalService) Send

Send a transactional message to your user.

type VerificationCheckParams

type VerificationCheckParams struct {
	// The OTP code to validate.
	Code param.Field[string] `json:"code,required"`
	// The verification target. Either a phone number or an email address. To use the
	// email verification feature contact us to discuss your use case.
	Target param.Field[VerificationCheckParamsTarget] `json:"target,required"`
}

func (VerificationCheckParams) MarshalJSON

func (r VerificationCheckParams) MarshalJSON() (data []byte, err error)

type VerificationCheckParamsTarget

type VerificationCheckParamsTarget struct {
	// The type of the target. Either "phone_number" or "email_address".
	Type param.Field[VerificationCheckParamsTargetType] `json:"type,required"`
	// An E.164 formatted phone number or an email address.
	Value param.Field[string] `json:"value,required"`
}

The verification target. Either a phone number or an email address. To use the email verification feature contact us to discuss your use case.

func (VerificationCheckParamsTarget) MarshalJSON

func (r VerificationCheckParamsTarget) MarshalJSON() (data []byte, err error)

type VerificationCheckParamsTargetType

type VerificationCheckParamsTargetType string

The type of the target. Either "phone_number" or "email_address".

const (
	VerificationCheckParamsTargetTypePhoneNumber  VerificationCheckParamsTargetType = "phone_number"
	VerificationCheckParamsTargetTypeEmailAddress VerificationCheckParamsTargetType = "email_address"
)

func (VerificationCheckParamsTargetType) IsKnown

type VerificationCheckResponse

type VerificationCheckResponse struct {
	// The status of the check.
	Status VerificationCheckResponseStatus `json:"status,required"`
	// The verification identifier.
	ID string `json:"id"`
	// The metadata for this verification.
	Metadata  VerificationCheckResponseMetadata `json:"metadata"`
	RequestID string                            `json:"request_id"`
	JSON      verificationCheckResponseJSON     `json:"-"`
}

func (*VerificationCheckResponse) UnmarshalJSON

func (r *VerificationCheckResponse) UnmarshalJSON(data []byte) (err error)

type VerificationCheckResponseMetadata

type VerificationCheckResponseMetadata struct {
	// A user-defined identifier to correlate this verification with. It is returned in
	// the response and any webhook events that refer to this verification.
	CorrelationID string                                `json:"correlation_id"`
	JSON          verificationCheckResponseMetadataJSON `json:"-"`
}

The metadata for this verification.

func (*VerificationCheckResponseMetadata) UnmarshalJSON

func (r *VerificationCheckResponseMetadata) UnmarshalJSON(data []byte) (err error)

type VerificationCheckResponseStatus

type VerificationCheckResponseStatus string

The status of the check.

const (
	VerificationCheckResponseStatusSuccess           VerificationCheckResponseStatus = "success"
	VerificationCheckResponseStatusFailure           VerificationCheckResponseStatus = "failure"
	VerificationCheckResponseStatusExpiredOrNotFound VerificationCheckResponseStatus = "expired_or_not_found"
)

func (VerificationCheckResponseStatus) IsKnown

type VerificationNewParams

type VerificationNewParams struct {
	// The verification target. Either a phone number or an email address. To use the
	// email verification feature contact us to discuss your use case.
	Target param.Field[VerificationNewParamsTarget] `json:"target,required"`
	// The identifier of the dispatch that came from the front-end SDK.
	DispatchID param.Field[string] `json:"dispatch_id"`
	// The metadata for this verification. This object will be returned with every
	// response or webhook sent that refers to this verification.
	Metadata param.Field[VerificationNewParamsMetadata] `json:"metadata"`
	// Verification options
	Options param.Field[VerificationNewParamsOptions] `json:"options"`
	// The signals used for anti-fraud. For more details, refer to
	// [Signals](/verify/v2/documentation/prevent-fraud#signals).
	Signals param.Field[VerificationNewParamsSignals] `json:"signals"`
}

func (VerificationNewParams) MarshalJSON

func (r VerificationNewParams) MarshalJSON() (data []byte, err error)

type VerificationNewParamsMetadata

type VerificationNewParamsMetadata struct {
	// A user-defined identifier to correlate this verification with. It is returned in
	// the response and any webhook events that refer to this verification.
	CorrelationID param.Field[string] `json:"correlation_id"`
}

The metadata for this verification. This object will be returned with every response or webhook sent that refers to this verification.

func (VerificationNewParamsMetadata) MarshalJSON

func (r VerificationNewParamsMetadata) MarshalJSON() (data []byte, err error)

type VerificationNewParamsOptions

type VerificationNewParamsOptions struct {
	// This allows you to automatically retrieve and fill the OTP code on mobile apps.
	// Currently only Android devices are supported.
	AppRealm param.Field[VerificationNewParamsOptionsAppRealm] `json:"app_realm"`
	// The URL where webhooks will be sent when verification events occur, including
	// verification creation, attempt creation, and delivery status changes. For more
	// details, refer to [Webhook](/verify/v2/documentation/webhook).
	CallbackURL param.Field[string] `json:"callback_url"`
	// The size of the code generated. It should be between 4 and 8. Defaults to the
	// code size specified from the Dashboard.
	CodeSize param.Field[int64] `json:"code_size"`
	// The custom code to use for OTP verification. To use the custom code feature,
	// contact us to enable it for your account. For more details, refer to
	// [Custom Code](/verify/v2/documentation/custom-codes).
	CustomCode param.Field[string] `json:"custom_code"`
	// A BCP-47 formatted locale string with the language the text message will be sent
	// to. If there's no locale set, the language will be determined by the country
	// code of the phone number. If the language specified doesn't exist, it defaults
	// to US English.
	Locale param.Field[string] `json:"locale"`
	// The method used for verifying this phone number. The 'voice' option provides an
	// accessible alternative for visually impaired users by delivering the
	// verification code through a phone call rather than a text message. It also
	// allows verification of landline numbers that cannot receive SMS messages.
	Method param.Field[VerificationNewParamsOptionsMethod] `json:"method"`
	// The preferred channel to be used in priority for verification.
	PreferredChannel param.Field[VerificationNewParamsOptionsPreferredChannel] `json:"preferred_channel"`
	// The Sender ID to use for this message. The Sender ID needs to be enabled by
	// Prelude.
	SenderID param.Field[string] `json:"sender_id"`
	// The identifier of a verification template. It applies use case-specific
	// settings, such as the message content or certain verification parameters.
	TemplateID param.Field[string] `json:"template_id"`
	// The variables to be replaced in the template.
	Variables param.Field[map[string]string] `json:"variables"`
}

Verification options

func (VerificationNewParamsOptions) MarshalJSON

func (r VerificationNewParamsOptions) MarshalJSON() (data []byte, err error)

type VerificationNewParamsOptionsAppRealm

type VerificationNewParamsOptionsAppRealm struct {
	// The platform the SMS will be sent to. We are currently only supporting
	// "android".
	Platform param.Field[VerificationNewParamsOptionsAppRealmPlatform] `json:"platform,required"`
	// The Android SMS Retriever API hash code that identifies your app.
	Value param.Field[string] `json:"value,required"`
}

This allows you to automatically retrieve and fill the OTP code on mobile apps. Currently only Android devices are supported.

func (VerificationNewParamsOptionsAppRealm) MarshalJSON

func (r VerificationNewParamsOptionsAppRealm) MarshalJSON() (data []byte, err error)

type VerificationNewParamsOptionsAppRealmPlatform

type VerificationNewParamsOptionsAppRealmPlatform string

The platform the SMS will be sent to. We are currently only supporting "android".

const (
	VerificationNewParamsOptionsAppRealmPlatformAndroid VerificationNewParamsOptionsAppRealmPlatform = "android"
)

func (VerificationNewParamsOptionsAppRealmPlatform) IsKnown

type VerificationNewParamsOptionsMethod added in v0.4.0

type VerificationNewParamsOptionsMethod string

The method used for verifying this phone number. The 'voice' option provides an accessible alternative for visually impaired users by delivering the verification code through a phone call rather than a text message. It also allows verification of landline numbers that cannot receive SMS messages.

const (
	VerificationNewParamsOptionsMethodAuto  VerificationNewParamsOptionsMethod = "auto"
	VerificationNewParamsOptionsMethodVoice VerificationNewParamsOptionsMethod = "voice"
)

func (VerificationNewParamsOptionsMethod) IsKnown added in v0.4.0

type VerificationNewParamsOptionsPreferredChannel added in v0.4.0

type VerificationNewParamsOptionsPreferredChannel string

The preferred channel to be used in priority for verification.

const (
	VerificationNewParamsOptionsPreferredChannelSMS      VerificationNewParamsOptionsPreferredChannel = "sms"
	VerificationNewParamsOptionsPreferredChannelRcs      VerificationNewParamsOptionsPreferredChannel = "rcs"
	VerificationNewParamsOptionsPreferredChannelWhatsapp VerificationNewParamsOptionsPreferredChannel = "whatsapp"
	VerificationNewParamsOptionsPreferredChannelViber    VerificationNewParamsOptionsPreferredChannel = "viber"
	VerificationNewParamsOptionsPreferredChannelZalo     VerificationNewParamsOptionsPreferredChannel = "zalo"
	VerificationNewParamsOptionsPreferredChannelTelegram VerificationNewParamsOptionsPreferredChannel = "telegram"
)

func (VerificationNewParamsOptionsPreferredChannel) IsKnown added in v0.4.0

type VerificationNewParamsSignals

type VerificationNewParamsSignals struct {
	// The version of your application.
	AppVersion param.Field[string] `json:"app_version"`
	// The unique identifier for the user's device. For Android, this corresponds to
	// the `ANDROID_ID` and for iOS, this corresponds to the `identifierForVendor`.
	DeviceID param.Field[string] `json:"device_id"`
	// The model of the user's device.
	DeviceModel param.Field[string] `json:"device_model"`
	// The type of the user's device.
	DevicePlatform param.Field[VerificationNewParamsSignalsDevicePlatform] `json:"device_platform"`
	// The IP address of the user's device.
	IP param.Field[string] `json:"ip" format:"ipv4"`
	// This signal should provide a higher level of trust, indicating that the user is
	// genuine. Contact us to discuss your use case. For more details, refer to
	// [Signals](/verify/v2/documentation/prevent-fraud#signals).
	IsTrustedUser param.Field[bool] `json:"is_trusted_user"`
	// The version of the user's device operating system.
	OsVersion param.Field[string] `json:"os_version"`
	// The user agent of the user's device. If the individual fields (os_version,
	// device_platform, device_model) are provided, we will prioritize those values
	// instead of parsing them from the user agent string.
	UserAgent param.Field[string] `json:"user_agent"`
}

The signals used for anti-fraud. For more details, refer to [Signals](/verify/v2/documentation/prevent-fraud#signals).

func (VerificationNewParamsSignals) MarshalJSON

func (r VerificationNewParamsSignals) MarshalJSON() (data []byte, err error)

type VerificationNewParamsSignalsDevicePlatform

type VerificationNewParamsSignalsDevicePlatform string

The type of the user's device.

const (
	VerificationNewParamsSignalsDevicePlatformAndroid VerificationNewParamsSignalsDevicePlatform = "android"
	VerificationNewParamsSignalsDevicePlatformIos     VerificationNewParamsSignalsDevicePlatform = "ios"
	VerificationNewParamsSignalsDevicePlatformIpados  VerificationNewParamsSignalsDevicePlatform = "ipados"
	VerificationNewParamsSignalsDevicePlatformTvos    VerificationNewParamsSignalsDevicePlatform = "tvos"
	VerificationNewParamsSignalsDevicePlatformWeb     VerificationNewParamsSignalsDevicePlatform = "web"
)

func (VerificationNewParamsSignalsDevicePlatform) IsKnown

type VerificationNewParamsTarget

type VerificationNewParamsTarget struct {
	// The type of the target. Either "phone_number" or "email_address".
	Type param.Field[VerificationNewParamsTargetType] `json:"type,required"`
	// An E.164 formatted phone number or an email address.
	Value param.Field[string] `json:"value,required"`
}

The verification target. Either a phone number or an email address. To use the email verification feature contact us to discuss your use case.

func (VerificationNewParamsTarget) MarshalJSON

func (r VerificationNewParamsTarget) MarshalJSON() (data []byte, err error)

type VerificationNewParamsTargetType

type VerificationNewParamsTargetType string

The type of the target. Either "phone_number" or "email_address".

const (
	VerificationNewParamsTargetTypePhoneNumber  VerificationNewParamsTargetType = "phone_number"
	VerificationNewParamsTargetTypeEmailAddress VerificationNewParamsTargetType = "email_address"
)

func (VerificationNewParamsTargetType) IsKnown

type VerificationNewResponse

type VerificationNewResponse struct {
	// The verification identifier.
	ID string `json:"id,required"`
	// The method used for verifying this phone number.
	Method VerificationNewResponseMethod `json:"method,required"`
	// The status of the verification.
	Status VerificationNewResponseStatus `json:"status,required"`
	// The ordered sequence of channels to be used for verification
	Channels []VerificationNewResponseChannel `json:"channels"`
	// The metadata for this verification.
	Metadata VerificationNewResponseMetadata `json:"metadata"`
	// The reason why the verification was blocked. Only present when status is
	// "blocked".
	Reason    VerificationNewResponseReason `json:"reason"`
	RequestID string                        `json:"request_id"`
	// The silent verification specific properties.
	Silent VerificationNewResponseSilent `json:"silent"`
	JSON   verificationNewResponseJSON   `json:"-"`
}

func (*VerificationNewResponse) UnmarshalJSON

func (r *VerificationNewResponse) UnmarshalJSON(data []byte) (err error)

type VerificationNewResponseChannel added in v0.7.0

type VerificationNewResponseChannel string
const (
	VerificationNewResponseChannelRcs      VerificationNewResponseChannel = "rcs"
	VerificationNewResponseChannelSilent   VerificationNewResponseChannel = "silent"
	VerificationNewResponseChannelSMS      VerificationNewResponseChannel = "sms"
	VerificationNewResponseChannelTelegram VerificationNewResponseChannel = "telegram"
	VerificationNewResponseChannelViber    VerificationNewResponseChannel = "viber"
	VerificationNewResponseChannelVoice    VerificationNewResponseChannel = "voice"
	VerificationNewResponseChannelWhatsapp VerificationNewResponseChannel = "whatsapp"
	VerificationNewResponseChannelZalo     VerificationNewResponseChannel = "zalo"
)

func (VerificationNewResponseChannel) IsKnown added in v0.7.0

type VerificationNewResponseMetadata

type VerificationNewResponseMetadata struct {
	// A user-defined identifier to correlate this verification with. It is returned in
	// the response and any webhook events that refer to this verification.
	CorrelationID string                              `json:"correlation_id"`
	JSON          verificationNewResponseMetadataJSON `json:"-"`
}

The metadata for this verification.

func (*VerificationNewResponseMetadata) UnmarshalJSON

func (r *VerificationNewResponseMetadata) UnmarshalJSON(data []byte) (err error)

type VerificationNewResponseMethod

type VerificationNewResponseMethod string

The method used for verifying this phone number.

const (
	VerificationNewResponseMethodEmail   VerificationNewResponseMethod = "email"
	VerificationNewResponseMethodMessage VerificationNewResponseMethod = "message"
	VerificationNewResponseMethodSilent  VerificationNewResponseMethod = "silent"
	VerificationNewResponseMethodVoice   VerificationNewResponseMethod = "voice"
)

func (VerificationNewResponseMethod) IsKnown

func (r VerificationNewResponseMethod) IsKnown() bool

type VerificationNewResponseReason added in v0.5.0

type VerificationNewResponseReason string

The reason why the verification was blocked. Only present when status is "blocked".

const (
	VerificationNewResponseReasonExpiredSignature   VerificationNewResponseReason = "expired_signature"
	VerificationNewResponseReasonInBlockList        VerificationNewResponseReason = "in_block_list"
	VerificationNewResponseReasonInvalidPhoneLine   VerificationNewResponseReason = "invalid_phone_line"
	VerificationNewResponseReasonInvalidPhoneNumber VerificationNewResponseReason = "invalid_phone_number"
	VerificationNewResponseReasonInvalidSignature   VerificationNewResponseReason = "invalid_signature"
	VerificationNewResponseReasonRepeatedAttempts   VerificationNewResponseReason = "repeated_attempts"
	VerificationNewResponseReasonSuspicious         VerificationNewResponseReason = "suspicious"
)

func (VerificationNewResponseReason) IsKnown added in v0.5.0

func (r VerificationNewResponseReason) IsKnown() bool

type VerificationNewResponseSilent added in v0.5.0

type VerificationNewResponseSilent struct {
	// The URL to start the silent verification towards.
	RequestURL string                            `json:"request_url,required"`
	JSON       verificationNewResponseSilentJSON `json:"-"`
}

The silent verification specific properties.

func (*VerificationNewResponseSilent) UnmarshalJSON added in v0.5.0

func (r *VerificationNewResponseSilent) UnmarshalJSON(data []byte) (err error)

type VerificationNewResponseStatus

type VerificationNewResponseStatus string

The status of the verification.

const (
	VerificationNewResponseStatusSuccess VerificationNewResponseStatus = "success"
	VerificationNewResponseStatusRetry   VerificationNewResponseStatus = "retry"
	VerificationNewResponseStatusBlocked VerificationNewResponseStatus = "blocked"
)

func (VerificationNewResponseStatus) IsKnown

func (r VerificationNewResponseStatus) IsKnown() bool

type VerificationService

type VerificationService struct {
	Options []option.RequestOption
}

VerificationService contains methods and other services that help with interacting with the Prelude API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewVerificationService method instead.

func NewVerificationService

func NewVerificationService(opts ...option.RequestOption) (r *VerificationService)

NewVerificationService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*VerificationService) Check

Check the validity of a verification code.

func (*VerificationService) New

Create a new verification for a specific phone number. If another non-expired verification exists (the request is performed within the verification window), this endpoint will perform a retry instead.

type WatchPredictParams

type WatchPredictParams struct {
	// The prediction target. Only supports phone numbers for now.
	Target param.Field[WatchPredictParamsTarget] `json:"target,required"`
	// The identifier of the dispatch that came from the front-end SDK.
	DispatchID param.Field[string] `json:"dispatch_id"`
	// The metadata for this prediction.
	Metadata param.Field[WatchPredictParamsMetadata] `json:"metadata"`
	// The signals used for anti-fraud. For more details, refer to
	// [Signals](/verify/v2/documentation/prevent-fraud#signals).
	Signals param.Field[WatchPredictParamsSignals] `json:"signals"`
}

func (WatchPredictParams) MarshalJSON

func (r WatchPredictParams) MarshalJSON() (data []byte, err error)

type WatchPredictParamsMetadata added in v0.3.0

type WatchPredictParamsMetadata struct {
	// A user-defined identifier to correlate this prediction with. It is returned in
	// the response and any webhook events that refer to this prediction.
	CorrelationID param.Field[string] `json:"correlation_id"`
}

The metadata for this prediction.

func (WatchPredictParamsMetadata) MarshalJSON added in v0.3.0

func (r WatchPredictParamsMetadata) MarshalJSON() (data []byte, err error)

type WatchPredictParamsSignals

type WatchPredictParamsSignals struct {
	// The version of your application.
	AppVersion param.Field[string] `json:"app_version"`
	// The unique identifier for the user's device. For Android, this corresponds to
	// the `ANDROID_ID` and for iOS, this corresponds to the `identifierForVendor`.
	DeviceID param.Field[string] `json:"device_id"`
	// The model of the user's device.
	DeviceModel param.Field[string] `json:"device_model"`
	// The type of the user's device.
	DevicePlatform param.Field[WatchPredictParamsSignalsDevicePlatform] `json:"device_platform"`
	// The IP address of the user's device.
	IP param.Field[string] `json:"ip" format:"ipv4"`
	// This signal should provide a higher level of trust, indicating that the user is
	// genuine. Contact us to discuss your use case. For more details, refer to
	// [Signals](/verify/v2/documentation/prevent-fraud#signals).
	IsTrustedUser param.Field[bool] `json:"is_trusted_user"`
	// The version of the user's device operating system.
	OsVersion param.Field[string] `json:"os_version"`
	// The user agent of the user's device. If the individual fields (os_version,
	// device_platform, device_model) are provided, we will prioritize those values
	// instead of parsing them from the user agent string.
	UserAgent param.Field[string] `json:"user_agent"`
}

The signals used for anti-fraud. For more details, refer to [Signals](/verify/v2/documentation/prevent-fraud#signals).

func (WatchPredictParamsSignals) MarshalJSON

func (r WatchPredictParamsSignals) MarshalJSON() (data []byte, err error)

type WatchPredictParamsSignalsDevicePlatform added in v0.3.0

type WatchPredictParamsSignalsDevicePlatform string

The type of the user's device.

const (
	WatchPredictParamsSignalsDevicePlatformAndroid WatchPredictParamsSignalsDevicePlatform = "android"
	WatchPredictParamsSignalsDevicePlatformIos     WatchPredictParamsSignalsDevicePlatform = "ios"
	WatchPredictParamsSignalsDevicePlatformIpados  WatchPredictParamsSignalsDevicePlatform = "ipados"
	WatchPredictParamsSignalsDevicePlatformTvos    WatchPredictParamsSignalsDevicePlatform = "tvos"
	WatchPredictParamsSignalsDevicePlatformWeb     WatchPredictParamsSignalsDevicePlatform = "web"
)

func (WatchPredictParamsSignalsDevicePlatform) IsKnown added in v0.3.0

type WatchPredictParamsTarget

type WatchPredictParamsTarget struct {
	// The type of the target. Either "phone_number" or "email_address".
	Type param.Field[WatchPredictParamsTargetType] `json:"type,required"`
	// An E.164 formatted phone number or an email address.
	Value param.Field[string] `json:"value,required"`
}

The prediction target. Only supports phone numbers for now.

func (WatchPredictParamsTarget) MarshalJSON

func (r WatchPredictParamsTarget) MarshalJSON() (data []byte, err error)

type WatchPredictParamsTargetType

type WatchPredictParamsTargetType string

The type of the target. Either "phone_number" or "email_address".

const (
	WatchPredictParamsTargetTypePhoneNumber  WatchPredictParamsTargetType = "phone_number"
	WatchPredictParamsTargetTypeEmailAddress WatchPredictParamsTargetType = "email_address"
)

func (WatchPredictParamsTargetType) IsKnown

func (r WatchPredictParamsTargetType) IsKnown() bool

type WatchPredictResponse

type WatchPredictResponse struct {
	// The prediction identifier.
	ID string `json:"id,required"`
	// The prediction outcome.
	Prediction WatchPredictResponsePrediction `json:"prediction,required"`
	// A string that identifies this specific request. Report it back to us to help us
	// diagnose your issues.
	RequestID string                   `json:"request_id,required"`
	JSON      watchPredictResponseJSON `json:"-"`
}

func (*WatchPredictResponse) UnmarshalJSON

func (r *WatchPredictResponse) UnmarshalJSON(data []byte) (err error)

type WatchPredictResponsePrediction

type WatchPredictResponsePrediction string

The prediction outcome.

const (
	WatchPredictResponsePredictionLegitimate WatchPredictResponsePrediction = "legitimate"
	WatchPredictResponsePredictionSuspicious WatchPredictResponsePrediction = "suspicious"
)

func (WatchPredictResponsePrediction) IsKnown

type WatchSendEventsParams added in v0.3.0

type WatchSendEventsParams struct {
	// A list of events to dispatch.
	Events param.Field[[]WatchSendEventsParamsEvent] `json:"events,required"`
}

func (WatchSendEventsParams) MarshalJSON added in v0.3.0

func (r WatchSendEventsParams) MarshalJSON() (data []byte, err error)

type WatchSendEventsParamsEvent added in v0.3.0

type WatchSendEventsParamsEvent struct {
	// A confidence level you want to assign to the event.
	Confidence param.Field[WatchSendEventsParamsEventsConfidence] `json:"confidence,required"`
	// A label to describe what the event refers to.
	Label param.Field[string] `json:"label,required"`
	// The event target. Only supports phone numbers for now.
	Target param.Field[WatchSendEventsParamsEventsTarget] `json:"target,required"`
}

func (WatchSendEventsParamsEvent) MarshalJSON added in v0.3.0

func (r WatchSendEventsParamsEvent) MarshalJSON() (data []byte, err error)

type WatchSendEventsParamsEventsConfidence added in v0.3.0

type WatchSendEventsParamsEventsConfidence string

A confidence level you want to assign to the event.

const (
	WatchSendEventsParamsEventsConfidenceMaximum WatchSendEventsParamsEventsConfidence = "maximum"
	WatchSendEventsParamsEventsConfidenceHigh    WatchSendEventsParamsEventsConfidence = "high"
	WatchSendEventsParamsEventsConfidenceNeutral WatchSendEventsParamsEventsConfidence = "neutral"
	WatchSendEventsParamsEventsConfidenceLow     WatchSendEventsParamsEventsConfidence = "low"
	WatchSendEventsParamsEventsConfidenceMinimum WatchSendEventsParamsEventsConfidence = "minimum"
)

func (WatchSendEventsParamsEventsConfidence) IsKnown added in v0.3.0

type WatchSendEventsParamsEventsTarget added in v0.3.0

type WatchSendEventsParamsEventsTarget struct {
	// The type of the target. Either "phone_number" or "email_address".
	Type param.Field[WatchSendEventsParamsEventsTargetType] `json:"type,required"`
	// An E.164 formatted phone number or an email address.
	Value param.Field[string] `json:"value,required"`
}

The event target. Only supports phone numbers for now.

func (WatchSendEventsParamsEventsTarget) MarshalJSON added in v0.3.0

func (r WatchSendEventsParamsEventsTarget) MarshalJSON() (data []byte, err error)

type WatchSendEventsParamsEventsTargetType added in v0.3.0

type WatchSendEventsParamsEventsTargetType string

The type of the target. Either "phone_number" or "email_address".

const (
	WatchSendEventsParamsEventsTargetTypePhoneNumber  WatchSendEventsParamsEventsTargetType = "phone_number"
	WatchSendEventsParamsEventsTargetTypeEmailAddress WatchSendEventsParamsEventsTargetType = "email_address"
)

func (WatchSendEventsParamsEventsTargetType) IsKnown added in v0.3.0

type WatchSendEventsResponse added in v0.3.0

type WatchSendEventsResponse struct {
	// A string that identifies this specific request. Report it back to us to help us
	// diagnose your issues.
	RequestID string `json:"request_id,required"`
	// The status of the events dispatch.
	Status WatchSendEventsResponseStatus `json:"status,required"`
	JSON   watchSendEventsResponseJSON   `json:"-"`
}

func (*WatchSendEventsResponse) UnmarshalJSON added in v0.3.0

func (r *WatchSendEventsResponse) UnmarshalJSON(data []byte) (err error)

type WatchSendEventsResponseStatus added in v0.3.0

type WatchSendEventsResponseStatus string

The status of the events dispatch.

const (
	WatchSendEventsResponseStatusSuccess WatchSendEventsResponseStatus = "success"
)

func (WatchSendEventsResponseStatus) IsKnown added in v0.3.0

func (r WatchSendEventsResponseStatus) IsKnown() bool

type WatchSendFeedbacksParams added in v0.3.0

type WatchSendFeedbacksParams struct {
	// A list of feedbacks to send.
	Feedbacks param.Field[[]WatchSendFeedbacksParamsFeedback] `json:"feedbacks,required"`
}

func (WatchSendFeedbacksParams) MarshalJSON added in v0.3.0

func (r WatchSendFeedbacksParams) MarshalJSON() (data []byte, err error)

type WatchSendFeedbacksParamsFeedback added in v0.3.0

type WatchSendFeedbacksParamsFeedback struct {
	// The feedback target. Only supports phone numbers for now.
	Target param.Field[WatchSendFeedbacksParamsFeedbacksTarget] `json:"target,required"`
	// The type of feedback.
	Type param.Field[WatchSendFeedbacksParamsFeedbacksType] `json:"type,required"`
	// The identifier of the dispatch that came from the front-end SDK.
	DispatchID param.Field[string] `json:"dispatch_id"`
	// The metadata for this feedback.
	Metadata param.Field[WatchSendFeedbacksParamsFeedbacksMetadata] `json:"metadata"`
	// The signals used for anti-fraud. For more details, refer to
	// [Signals](/verify/v2/documentation/prevent-fraud#signals).
	Signals param.Field[WatchSendFeedbacksParamsFeedbacksSignals] `json:"signals"`
}

func (WatchSendFeedbacksParamsFeedback) MarshalJSON added in v0.3.0

func (r WatchSendFeedbacksParamsFeedback) MarshalJSON() (data []byte, err error)

type WatchSendFeedbacksParamsFeedbacksMetadata added in v0.3.0

type WatchSendFeedbacksParamsFeedbacksMetadata struct {
	// A user-defined identifier to correlate this feedback with. It is returned in the
	// response and any webhook events that refer to this feedback.
	CorrelationID param.Field[string] `json:"correlation_id"`
}

The metadata for this feedback.

func (WatchSendFeedbacksParamsFeedbacksMetadata) MarshalJSON added in v0.3.0

func (r WatchSendFeedbacksParamsFeedbacksMetadata) MarshalJSON() (data []byte, err error)

type WatchSendFeedbacksParamsFeedbacksSignals added in v0.3.0

type WatchSendFeedbacksParamsFeedbacksSignals struct {
	// The version of your application.
	AppVersion param.Field[string] `json:"app_version"`
	// The unique identifier for the user's device. For Android, this corresponds to
	// the `ANDROID_ID` and for iOS, this corresponds to the `identifierForVendor`.
	DeviceID param.Field[string] `json:"device_id"`
	// The model of the user's device.
	DeviceModel param.Field[string] `json:"device_model"`
	// The type of the user's device.
	DevicePlatform param.Field[WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatform] `json:"device_platform"`
	// The IP address of the user's device.
	IP param.Field[string] `json:"ip" format:"ipv4"`
	// This signal should provide a higher level of trust, indicating that the user is
	// genuine. Contact us to discuss your use case. For more details, refer to
	// [Signals](/verify/v2/documentation/prevent-fraud#signals).
	IsTrustedUser param.Field[bool] `json:"is_trusted_user"`
	// The version of the user's device operating system.
	OsVersion param.Field[string] `json:"os_version"`
	// The user agent of the user's device. If the individual fields (os_version,
	// device_platform, device_model) are provided, we will prioritize those values
	// instead of parsing them from the user agent string.
	UserAgent param.Field[string] `json:"user_agent"`
}

The signals used for anti-fraud. For more details, refer to [Signals](/verify/v2/documentation/prevent-fraud#signals).

func (WatchSendFeedbacksParamsFeedbacksSignals) MarshalJSON added in v0.3.0

func (r WatchSendFeedbacksParamsFeedbacksSignals) MarshalJSON() (data []byte, err error)

type WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatform added in v0.3.0

type WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatform string

The type of the user's device.

const (
	WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatformAndroid WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatform = "android"
	WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatformIos     WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatform = "ios"
	WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatformIpados  WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatform = "ipados"
	WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatformTvos    WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatform = "tvos"
	WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatformWeb     WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatform = "web"
)

func (WatchSendFeedbacksParamsFeedbacksSignalsDevicePlatform) IsKnown added in v0.3.0

type WatchSendFeedbacksParamsFeedbacksTarget added in v0.3.0

type WatchSendFeedbacksParamsFeedbacksTarget struct {
	// The type of the target. Either "phone_number" or "email_address".
	Type param.Field[WatchSendFeedbacksParamsFeedbacksTargetType] `json:"type,required"`
	// An E.164 formatted phone number or an email address.
	Value param.Field[string] `json:"value,required"`
}

The feedback target. Only supports phone numbers for now.

func (WatchSendFeedbacksParamsFeedbacksTarget) MarshalJSON added in v0.3.0

func (r WatchSendFeedbacksParamsFeedbacksTarget) MarshalJSON() (data []byte, err error)

type WatchSendFeedbacksParamsFeedbacksTargetType added in v0.3.0

type WatchSendFeedbacksParamsFeedbacksTargetType string

The type of the target. Either "phone_number" or "email_address".

const (
	WatchSendFeedbacksParamsFeedbacksTargetTypePhoneNumber  WatchSendFeedbacksParamsFeedbacksTargetType = "phone_number"
	WatchSendFeedbacksParamsFeedbacksTargetTypeEmailAddress WatchSendFeedbacksParamsFeedbacksTargetType = "email_address"
)

func (WatchSendFeedbacksParamsFeedbacksTargetType) IsKnown added in v0.3.0

type WatchSendFeedbacksParamsFeedbacksType added in v0.3.0

type WatchSendFeedbacksParamsFeedbacksType string

The type of feedback.

const (
	WatchSendFeedbacksParamsFeedbacksTypeVerificationStarted   WatchSendFeedbacksParamsFeedbacksType = "verification.started"
	WatchSendFeedbacksParamsFeedbacksTypeVerificationCompleted WatchSendFeedbacksParamsFeedbacksType = "verification.completed"
)

func (WatchSendFeedbacksParamsFeedbacksType) IsKnown added in v0.3.0

type WatchSendFeedbacksResponse added in v0.3.0

type WatchSendFeedbacksResponse struct {
	// A string that identifies this specific request. Report it back to us to help us
	// diagnose your issues.
	RequestID string `json:"request_id,required"`
	// The status of the feedbacks sending.
	Status WatchSendFeedbacksResponseStatus `json:"status,required"`
	JSON   watchSendFeedbacksResponseJSON   `json:"-"`
}

func (*WatchSendFeedbacksResponse) UnmarshalJSON added in v0.3.0

func (r *WatchSendFeedbacksResponse) UnmarshalJSON(data []byte) (err error)

type WatchSendFeedbacksResponseStatus added in v0.3.0

type WatchSendFeedbacksResponseStatus string

The status of the feedbacks sending.

const (
	WatchSendFeedbacksResponseStatusSuccess WatchSendFeedbacksResponseStatus = "success"
)

func (WatchSendFeedbacksResponseStatus) IsKnown added in v0.3.0

type WatchService

type WatchService struct {
	Options []option.RequestOption
}

WatchService contains methods and other services that help with interacting with the Prelude API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewWatchService method instead.

func NewWatchService

func NewWatchService(opts ...option.RequestOption) (r *WatchService)

NewWatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*WatchService) Predict

func (r *WatchService) Predict(ctx context.Context, body WatchPredictParams, opts ...option.RequestOption) (res *WatchPredictResponse, err error)

Predict the outcome of a verification based on Prelude’s anti-fraud system.

func (*WatchService) SendEvents added in v0.3.0

Send real-time event data from end-user interactions within your application. Events will be analyzed for proactive fraud prevention and risk scoring.

func (*WatchService) SendFeedbacks added in v0.3.0

Send feedback regarding your end-users verification funnel. Events will be analyzed for proactive fraud prevention and risk scoring.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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