foil

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 24 Imported by: 0

README

Foil Go Library

Preview

The Foil Go library provides convenient access to the Foil API from Go services and applications. It includes a context-aware client for Sessions, visitor fingerprints, Organizations, Organization API key management, sealed token verification, Gate, and Gate delivery/webhook helpers.

The library also provides:

  • a fast configuration path using FOIL_SECRET_KEY
  • iterator-style helpers for cursor-based pagination
  • structured API errors and built-in sealed token verification
  • webhook endpoint management, test sends, and event delivery history
  • public, bearer-token, and secret-key auth modes for Gate flows
  • Gate delivery/webhook helpers

Documentation

See the Foil docs and API reference.

Installation

You don't need this source code unless you want to modify the module. If you just want to use it, run:

go get github.com/abxy-labs/foil-server-go

Requirements

  • Go 1.22+

Usage

Use FOIL_SECRET_KEY or WithSecretKey(...) for core detect APIs. For public or bearer-auth Gate flows, the client can also be created without a secret key:

package main

import (
  "context"
  "log"

  foil "github.com/abxy-labs/foil-server-go"
)

func main() {
  client, err := foil.NewClient(foil.WithSecretKey("sk_live_..."))
  if err != nil {
    log.Fatal(err)
  }

  page, err := client.Sessions.List(context.Background(), foil.SessionListParams{
    Verdict: "bot",
    Limit:   25,
  })
  if err != nil {
    log.Fatal(err)
  }

  session, err := client.Sessions.Get(context.Background(), "sid_0123456789abcdefghjkmnpqrs")
  if err != nil {
    log.Fatal(err)
  }

  log.Println(page.Items[0].ID, session.Decision.AutomationStatus, session.Highlights[0].Summary)
}
Sealed token verification
result := foil.SafeVerifyFoilToken(sealedToken, "sk_live_...")
if !result.OK {
  log.Fatal(result.Error)
}

log.Println(result.Data.Decision.Verdict, result.Data.Decision.RiskScore)
Pagination
err := client.Sessions.Iter(context.Background(), foil.SessionListParams{Search: "signup"}, func(session foil.SessionSummary) error {
  log.Println(session.ID, session.LatestDecision.Verdict)
  return nil
})
if err != nil {
  log.Fatal(err)
}
Visitor fingerprints
fingerprint, err := client.Fingerprints.Get(context.Background(), "vid_0123456789abcdefghjkmnpqrs")
if err != nil {
  log.Fatal(err)
}

log.Println(fingerprint.ID)
Organizations
organization, err := client.Organizations.Get(context.Background(), "org_0123456789abcdefghjkmnpqrs")
if err != nil {
  log.Fatal(err)
}

updated, err := client.Organizations.Update(context.Background(), "org_0123456789abcdefghjkmnpqrs", foil.UpdateOrganizationParams{
  Name: "New Name",
})
if err != nil {
  log.Fatal(err)
}

_, _ = organization, updated
Organization API keys
created, err := client.Organizations.APIKeys.Create(
  context.Background(),
  "org_0123456789abcdefghjkmnpqrs",
  foil.CreateAPIKeyParams{Name: "Production", Type: "secret", Environment: "live"},
)
if err != nil {
  log.Fatal(err)
}

_, err = client.Organizations.APIKeys.Revoke(context.Background(), "org_0123456789abcdefghjkmnpqrs", created.ID)
if err != nil {
  log.Fatal(err)
}
Webhooks
endpoint, err := client.Webhooks.CreateEndpoint(context.Background(), "org_0123456789abcdefghjkmnpqrs", foil.CreateWebhookEndpointParams{
  Name:       "Production alerts",
  URL:        "https://example.com/foil/webhook",
  EventTypes: []string{"session.result.persisted", "gate.session.approved"},
})
if err != nil {
  log.Fatal(err)
}

events, err := client.Webhooks.ListEvents(context.Background(), "org_0123456789abcdefghjkmnpqrs", foil.EventListParams{
  EndpointID: endpoint.ID,
  Type:       "session.result.persisted",
})
if err != nil {
  log.Fatal(err)
}

log.Println(events.Items[0].WebhookDeliveries[0].Status)
Gate APIs
deliveryKeyPair, err := foil.CreateDeliveryKeyPair()
if err != nil {
  log.Fatal(err)
}

registry, err := client.Gate.Registry.List(context.Background())
if err != nil {
  log.Fatal(err)
}

session, err := client.Gate.Sessions.Create(context.Background(), foil.CreateGateSessionParams{
  ServiceID:   "foil",
  AccountName: "my-project",
  Delivery:    deliveryKeyPair.Delivery,
})
if err != nil {
  log.Fatal(err)
}

log.Println(registry[0].ID, session.ConsentURL)
Gate delivery and webhook helpers
deliveryKeyPair, err := foil.CreateDeliveryKeyPair()
if err != nil {
  log.Fatal(err)
}

response, err := foil.CreateGateApprovedWebhookResponse(foil.GateDeliveryHelperInput{
  Delivery: deliveryKeyPair.Delivery,
  Outputs: map[string]string{
    "FOIL_PUBLISHABLE_KEY": "pk_live_...",
    "FOIL_SECRET_KEY":      "sk_live_...",
  },
})
if err != nil {
  log.Fatal(err)
}

payload, err := foil.DecryptGateDeliveryEnvelope(deliveryKeyPair.PrivateKey, response.EncryptedDelivery)
if err != nil {
  log.Fatal(err)
}

log.Println(payload.Outputs["FOIL_SECRET_KEY"])
Error handling
_, err := client.Sessions.List(context.Background(), foil.SessionListParams{Limit: 999})
if apiErr, ok := err.(*foil.APIError); ok {
  log.Println(apiErr.Status, apiErr.Code, apiErr.Message)
}

Support

If you need help integrating Foil, start with usefoil.com/docs.

Documentation

Index

Constants

View Source
const (
	GateDeliveryVersion     = 1
	GateDeliveryAlgorithm   = "x25519-hkdf-sha256/aes-256-gcm"
	GateAgentTokenEnvSuffix = "_GATE_AGENT_TOKEN"
)

Variables

This section is empty.

Functions

func DeriveGateAgentTokenEnvKey

func DeriveGateAgentTokenEnvKey(serviceID string) (string, error)

func ExportDeliveryPrivateKeyPKCS8

func ExportDeliveryPrivateKeyPKCS8(privateKey any) (string, error)

func ImportDeliveryPrivateKeyPKCS8

func ImportDeliveryPrivateKeyPKCS8(value string) (*ecdh.PrivateKey, error)

func IsBlockedGateEnvVarKey

func IsBlockedGateEnvVarKey(key string) bool

func IsGateManagedEnvVarKey

func IsGateManagedEnvVarKey(key string) bool

func KeyIDForRawX25519PublicKey

func KeyIDForRawX25519PublicKey(rawPublicKey []byte) (string, error)

func VerifyGateWebhookSignature

func VerifyGateWebhookSignature(input VerifyGateWebhookSignatureInput) bool

Types

type APIError

type APIError struct {
	Status      int
	Code        string
	Message     string
	RequestID   string
	FieldErrors []FieldError
	DocsURL     string
	Body        map[string]any
}

func (*APIError) Error

func (e *APIError) Error() string

type APIKey

type APIKey struct {
	Object         string   `json:"object"`
	ID             string   `json:"id"`
	Type           string   `json:"type"`
	Name           string   `json:"name"`
	Environment    string   `json:"environment"`
	AllowedOrigins []string `json:"allowed_origins,omitempty"`
	Scopes         []string `json:"scopes,omitempty"`
	RateLimit      *int     `json:"rate_limit,omitempty"`
	Status         string   `json:"status"`
	KeyPreview     string   `json:"key_preview"`
	DisplayKey     *string  `json:"display_key,omitempty"`
	LastUsedAt     *string  `json:"last_used_at,omitempty"`
	CreatedAt      string   `json:"created_at"`
	RotatedAt      *string  `json:"rotated_at,omitempty"`
	RevokedAt      *string  `json:"revoked_at,omitempty"`
	GraceExpiresAt *string  `json:"grace_expires_at,omitempty"`
}

type APIKeyListParams

type APIKeyListParams struct {
	Limit  int
	Cursor string
}

type APIKeysService

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

func (*APIKeysService) Create

func (s *APIKeysService) Create(ctx context.Context, organizationID string, params CreateAPIKeyParams) (IssuedAPIKey, error)

func (*APIKeysService) List

func (s *APIKeysService) List(ctx context.Context, organizationID string, params APIKeyListParams) (ListResult[APIKey], error)

func (*APIKeysService) Revoke

func (s *APIKeysService) Revoke(ctx context.Context, organizationID string, keyID string) (APIKey, error)

func (*APIKeysService) Rotate

func (s *APIKeysService) Rotate(ctx context.Context, organizationID string, keyID string) (IssuedAPIKey, error)

func (*APIKeysService) Update

func (s *APIKeysService) Update(ctx context.Context, organizationID string, keyID string, params UpdateAPIKeyParams) (APIKey, error)

type AcknowledgeGateSessionDeliveryParams

type AcknowledgeGateSessionDeliveryParams struct {
	PollToken string `json:"-"`
	AckToken  string `json:"ack_token"`
}

type AgentTokenVerification

type AgentTokenVerification struct {
	Valid         bool   `json:"valid"`
	GateAccountID string `json:"gate_account_id,omitempty"`
	Status        string `json:"status,omitempty"`
	CreatedAt     string `json:"created_at,omitempty"`
	ExpiresAt     string `json:"expires_at,omitempty"`
}

type ApiErrorBody

type ApiErrorBody struct {
	Code      string       `json:"code"`
	Message   string       `json:"message"`
	Status    int          `json:"status"`
	Retryable bool         `json:"retryable"`
	RequestID string       `json:"request_id"`
	DocsURL   string       `json:"docs_url,omitempty"`
	Details   ErrorDetails `json:"details,omitempty"`
}

type Attribution

type Attribution struct {
	Bot map[string]any `json:"bot,omitempty"`
	Raw map[string]any `json:"raw,omitempty"`
}

type Client

type Client struct {
	Sessions      *SessionsService
	Fingerprints  *FingerprintsService
	Organizations *OrganizationsService
	Gate          *GateService
	Webhooks      *WebhooksService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...Option) (*Client, error)

type ConfigurationError

type ConfigurationError struct {
	Message string
}

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

type ConsumeGateLoginSessionParams

type ConsumeGateLoginSessionParams struct {
	Code string `json:"code"`
}

type CreateAPIKeyParams

type CreateAPIKeyParams struct {
	Name           string   `json:"name,omitempty"`
	Type           string   `json:"type,omitempty"`
	Environment    string   `json:"environment,omitempty"`
	AllowedOrigins []string `json:"allowed_origins,omitempty"`
	Scopes         []string `json:"scopes,omitempty"`
}

type CreateGateLoginSessionParams

type CreateGateLoginSessionParams struct {
	ServiceID  string `json:"service_id"`
	AgentToken string `json:"-"`
}

type CreateGateServiceParams

type CreateGateServiceParams struct {
	ID                string                    `json:"id"`
	Discoverable      *bool                     `json:"discoverable,omitempty"`
	Name              string                    `json:"name"`
	Description       string                    `json:"description"`
	Website           string                    `json:"website"`
	DashboardLoginURL string                    `json:"dashboard_login_url,omitempty"`
	WebhookEndpointID string                    `json:"webhook_endpoint_id"`
	EnvVars           []GateServiceEnvVar       `json:"env_vars,omitempty"`
	DocsURL           string                    `json:"docs_url,omitempty"`
	SDKs              []GateServiceSDKInstall   `json:"sdks,omitempty"`
	Branding          *GateServiceBrandingInput `json:"branding,omitempty"`
	Consent           *GateServiceConsent       `json:"consent,omitempty"`
}

type CreateGateSessionParams

type CreateGateSessionParams struct {
	ServiceID   string              `json:"service_id"`
	AccountName string              `json:"account_name"`
	Metadata    map[string]any      `json:"metadata,omitempty"`
	Delivery    GateDeliveryRequest `json:"delivery"`
}

type CreateOrganizationParams

type CreateOrganizationParams struct {
	Name string `json:"name"`
	Slug string `json:"slug"`
}

type CreateWebhookEndpointParams

type CreateWebhookEndpointParams struct {
	Name       string   `json:"name"`
	URL        string   `json:"url"`
	EventTypes []string `json:"event_types"`
}

type Decision

type Decision struct {
	EventID              string        `json:"event_id"`
	Verdict              string        `json:"verdict"`
	RiskScore            int           `json:"risk_score"`
	Phase                string        `json:"phase,omitempty"`
	IsProvisional        *bool         `json:"is_provisional,omitempty"`
	Manipulation         *Manipulation `json:"manipulation,omitempty"`
	EvaluationDurationMS *int          `json:"evaluation_duration_ms,omitempty"`
	EvaluatedAt          string        `json:"evaluated_at"`
}

type ErrorDetails

type ErrorDetails struct {
	Fields []FieldError `json:"fields,omitempty"`
}

type Event

type Event struct {
	Object            string            `json:"object"`
	ID                string            `json:"id"`
	Type              string            `json:"type"`
	Subject           EventSubject      `json:"subject"`
	Data              map[string]any    `json:"data"`
	WebhookDeliveries []WebhookDelivery `json:"webhook_deliveries"`
	CreatedAt         string            `json:"created_at"`
}

type EventListParams

type EventListParams struct {
	EndpointID string
	Type       string
	Limit      int
}

type EventSubject

type EventSubject struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

type FieldError

type FieldError struct {
	Name     string `json:"name"`
	Issue    string `json:"issue"`
	Expected string `json:"expected,omitempty"`
	Received any    `json:"received,omitempty"`
}

type FingerprintListParams

type FingerprintListParams struct {
	Limit  int
	Cursor string
	Search string
	Sort   string
}

type FingerprintsService

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

func (*FingerprintsService) Get

func (*FingerprintsService) Iter

func (*FingerprintsService) List

type GateAgentTokensService

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

func (*GateAgentTokensService) Revoke

func (*GateAgentTokensService) Verify

type GateApprovedWebhookFoil

type GateApprovedWebhookFoil struct {
	Verdict string   `json:"verdict"`
	Score   *float64 `json:"score"`
}

type GateApprovedWebhookPayload

type GateApprovedWebhookPayload struct {
	ServiceID     string                  `json:"service_id"`
	GateSessionID string                  `json:"gate_session_id"`
	GateAccountID string                  `json:"gate_account_id"`
	AccountName   string                  `json:"account_name"`
	Metadata      map[string]any          `json:"metadata"`
	Foil          GateApprovedWebhookFoil `json:"foil"`
	Delivery      GateDeliveryRequest     `json:"delivery"`
}

func ValidateGateApprovedWebhookPayload

func ValidateGateApprovedWebhookPayload(value GateApprovedWebhookPayload) (*GateApprovedWebhookPayload, error)

type GateDashboardLogin

type GateDashboardLogin struct {
	Object        string `json:"object"`
	GateAccountID string `json:"gate_account_id"`
	AccountName   string `json:"account_name"`
}

type GateDeliveryBundle

type GateDeliveryBundle struct {
	Integrator GateDeliveryEnvelope `json:"integrator"`
	Gate       GateDeliveryEnvelope `json:"gate"`
}

type GateDeliveryEnvelope

type GateDeliveryEnvelope struct {
	Version            int    `json:"version"`
	Algorithm          string `json:"algorithm"`
	KeyID              string `json:"key_id"`
	EphemeralPublicKey string `json:"ephemeral_public_key"`
	Salt               string `json:"salt"`
	IV                 string `json:"iv"`
	Ciphertext         string `json:"ciphertext"`
	Tag                string `json:"tag"`
}

func EncryptGateDeliveryPayload

func EncryptGateDeliveryPayload(delivery GateDeliveryRequest, payload GateDeliveryPayload) (*GateDeliveryEnvelope, error)

func ValidateEncryptedGateDeliveryEnvelope

func ValidateEncryptedGateDeliveryEnvelope(value GateDeliveryEnvelope) (*GateDeliveryEnvelope, error)

type GateDeliveryHelperInput

type GateDeliveryHelperInput struct {
	Delivery GateDeliveryRequest `json:"delivery"`
	Outputs  map[string]string   `json:"outputs"`
}

type GateDeliveryPayload

type GateDeliveryPayload struct {
	Version  int               `json:"version"`
	Outputs  map[string]string `json:"outputs"`
	AckToken string            `json:"ack_token,omitempty"`
}

func DecryptGateDeliveryEnvelope

func DecryptGateDeliveryEnvelope(privateKey any, envelope GateDeliveryEnvelope) (*GateDeliveryPayload, error)

type GateDeliveryRequest

type GateDeliveryRequest struct {
	Version   int    `json:"version"`
	Algorithm string `json:"algorithm"`
	KeyID     string `json:"key_id"`
	PublicKey string `json:"public_key"`
}

func ValidateGateDeliveryRequest

func ValidateGateDeliveryRequest(value GateDeliveryRequest) (*GateDeliveryRequest, error)

type GateEncryptedDeliveryResponse

type GateEncryptedDeliveryResponse struct {
	EncryptedDelivery GateDeliveryEnvelope `json:"encrypted_delivery"`
}

type GateLoginSession

type GateLoginSession struct {
	Object     string `json:"object"`
	ID         string `json:"id"`
	Status     string `json:"status"`
	ConsentURL string `json:"consent_url"`
	ExpiresAt  string `json:"expires_at"`
}

type GateLoginSessionsService

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

func (*GateLoginSessionsService) Consume

func (*GateLoginSessionsService) Create

type GateManagedService

type GateManagedService struct {
	Object            string                  `json:"object"`
	ID                string                  `json:"id"`
	Status            GateServiceStatus       `json:"status"`
	Discoverable      bool                    `json:"discoverable"`
	Name              string                  `json:"name"`
	Description       string                  `json:"description"`
	Website           string                  `json:"website"`
	DashboardLoginURL string                  `json:"dashboard_login_url,omitempty"`
	WebhookEndpointID *string                 `json:"webhook_endpoint_id"`
	EnvVars           []GateServiceEnvVar     `json:"env_vars"`
	DocsURL           string                  `json:"docs_url"`
	SDKs              []GateServiceSDKInstall `json:"sdks"`
	Branding          GateServiceBranding     `json:"branding"`
	Consent           GateServiceConsent      `json:"consent"`
	CreatedAt         string                  `json:"created_at"`
	UpdatedAt         string                  `json:"updated_at"`
}

type GateManagedServicesService

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

func (*GateManagedServicesService) Create

func (*GateManagedServicesService) Disable

func (*GateManagedServicesService) Get

func (*GateManagedServicesService) List

func (*GateManagedServicesService) Update

type GateRegistryEntry

type GateRegistryEntry struct {
	ID                string                  `json:"id"`
	Status            GateServiceStatus       `json:"status"`
	Discoverable      bool                    `json:"discoverable"`
	Name              string                  `json:"name"`
	Description       string                  `json:"description"`
	Website           string                  `json:"website"`
	DashboardLoginURL string                  `json:"dashboard_login_url,omitempty"`
	EnvVars           []GateServiceEnvVar     `json:"env_vars"`
	DocsURL           string                  `json:"docs_url"`
	SDKs              []GateServiceSDKInstall `json:"sdks"`
	Branding          GateServiceBranding     `json:"branding"`
	Consent           GateServiceConsent      `json:"consent"`
}

type GateRegistryService

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

func (*GateRegistryService) Get

func (*GateRegistryService) List

type GateService

type GateService struct {
	Registry      *GateRegistryService
	Services      *GateManagedServicesService
	Sessions      *GateSessionsService
	LoginSessions *GateLoginSessionsService
	AgentTokens   *GateAgentTokensService
	// contains filtered or unexported fields
}

type GateServiceBranding

type GateServiceBranding struct {
	LogoURL        string `json:"logo_url,omitempty"`
	PrimaryColor   string `json:"primary_color,omitempty"`
	SecondaryColor string `json:"secondary_color,omitempty"`
	ASCIIArt       string `json:"ascii_art,omitempty"`
	Verified       bool   `json:"verified"`
}

type GateServiceBrandingInput

type GateServiceBrandingInput struct {
	LogoURL        string `json:"logo_url,omitempty"`
	PrimaryColor   string `json:"primary_color,omitempty"`
	SecondaryColor string `json:"secondary_color,omitempty"`
	ASCIIArt       string `json:"ascii_art,omitempty"`
}

type GateServiceConsent

type GateServiceConsent struct {
	TermsURL   string `json:"terms_url,omitempty"`
	PrivacyURL string `json:"privacy_url,omitempty"`
}

type GateServiceEnvVar

type GateServiceEnvVar struct {
	Name   string `json:"name"`
	Key    string `json:"key"`
	Secret bool   `json:"secret"`
}

type GateServiceSDKInstall

type GateServiceSDKInstall struct {
	Label   string `json:"label"`
	Install string `json:"install"`
	URL     string `json:"url"`
}

type GateServiceStatus

type GateServiceStatus string
const (
	GateServiceStatusActive   GateServiceStatus = "active"
	GateServiceStatusDisabled GateServiceStatus = "disabled"
)

type GateSessionCreate

type GateSessionCreate struct {
	Object     string `json:"object"`
	ID         string `json:"id"`
	Status     string `json:"status"`
	PollToken  string `json:"poll_token"`
	ConsentURL string `json:"consent_url"`
	ExpiresAt  string `json:"expires_at"`
}

type GateSessionDeliveryAcknowledgement

type GateSessionDeliveryAcknowledgement struct {
	Object        string `json:"object"`
	GateSessionID string `json:"gate_session_id"`
	Status        string `json:"status"`
}

type GateSessionPollData

type GateSessionPollData struct {
	Object         string              `json:"object"`
	ID             string              `json:"id"`
	Status         string              `json:"status"`
	ExpiresAt      string              `json:"expires_at,omitempty"`
	GateAccountID  string              `json:"gate_account_id,omitempty"`
	AccountName    string              `json:"account_name,omitempty"`
	DeliveryBundle *GateDeliveryBundle `json:"delivery_bundle,omitempty"`
	DocsURL        string              `json:"docs_url,omitempty"`
}

type GateSessionsService

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

func (*GateSessionsService) Acknowledge

func (*GateSessionsService) Create

func (*GateSessionsService) Poll

func (s *GateSessionsService) Poll(ctx context.Context, gateSessionID string, pollToken string) (GateSessionPollData, error)

type GeneratedDeliveryKeyPair

type GeneratedDeliveryKeyPair struct {
	Delivery   GateDeliveryRequest
	PrivateKey *ecdh.PrivateKey
}

func CreateDeliveryKeyPair

func CreateDeliveryKeyPair() (*GeneratedDeliveryKeyPair, error)

type IssuedAPIKey

type IssuedAPIKey struct {
	APIKey
	RevealedKey string `json:"revealed_key"`
}

type ListResult

type ListResult[T any] struct {
	Items      []T
	Limit      int
	HasMore    bool
	NextCursor string
}

type Manipulation

type Manipulation struct {
	Score   *int    `json:"score,omitempty"`
	Verdict *string `json:"verdict,omitempty"`
}

type Option

type Option func(*clientConfig)

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

func WithSecretKey

func WithSecretKey(secretKey string) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithUserAgent

func WithUserAgent(userAgent string) Option

type Organization

type Organization struct {
	Object    string  `json:"object"`
	ID        string  `json:"id"`
	Name      string  `json:"name"`
	Slug      string  `json:"slug"`
	Status    string  `json:"status"`
	CreatedAt string  `json:"created_at"`
	UpdatedAt *string `json:"updated_at,omitempty"`
}

type OrganizationsService

type OrganizationsService struct {
	APIKeys *APIKeysService
	// contains filtered or unexported fields
}

func (*OrganizationsService) Create

func (*OrganizationsService) Get

func (s *OrganizationsService) Get(ctx context.Context, organizationID string) (Organization, error)

func (*OrganizationsService) Update

func (s *OrganizationsService) Update(ctx context.Context, organizationID string, params UpdateOrganizationParams) (Organization, error)

type RequestContext

type RequestContext struct {
	UserAgent      string  `json:"user_agent"`
	URL            string  `json:"url"`
	ScreenSize     *string `json:"screen_size,omitempty"`
	IsTouchCapable *bool   `json:"is_touch_capable,omitempty"`
	IPAddress      string  `json:"ip_address"`
}

type RevokeGateAgentTokenParams

type RevokeGateAgentTokenParams struct {
	AgentToken string `json:"agent_token"`
}

type ScoreBreakdown

type ScoreBreakdown struct {
	Categories map[string]int `json:"categories"`
}

type SessionAnalysisCoverage

type SessionAnalysisCoverage struct {
	Browser         bool `json:"browser"`
	Device          bool `json:"device"`
	Network         bool `json:"network"`
	Runtime         bool `json:"runtime"`
	Behavioral      bool `json:"behavioral"`
	VisitorIdentity bool `json:"visitor_identity"`
}

type SessionAttribution

type SessionAttribution struct {
	Labels    []SessionAttributionLabel    `json:"labels"`
	Behaviors []SessionAttributionBehavior `json:"behaviors"`
}

type SessionAttributionBehavior

type SessionAttributionBehavior struct {
	Channel    string `json:"channel"`
	Value      string `json:"value"`
	Label      string `json:"label"`
	Confidence int    `json:"confidence"`
}

type SessionAttributionLabel

type SessionAttributionLabel struct {
	Kind       string `json:"kind"`
	Value      string `json:"value"`
	Label      string `json:"label"`
	Confidence int    `json:"confidence"`
}

type SessionBrowser

type SessionBrowser struct {
	Name         *string `json:"name,omitempty"`
	Version      *string `json:"version,omitempty"`
	MajorVersion *string `json:"major_version,omitempty"`
	Engine       string  `json:"engine"`
}

type SessionClientTelemetry

type SessionClientTelemetry struct {
	Navigator SessionRawDeviceNavigator `json:"navigator"`
	Storage   SessionRawDeviceStorage   `json:"storage"`
	Canvas    SessionRawDeviceCanvas    `json:"canvas"`
	Graphics  SessionRawDeviceGraphics  `json:"graphics"`
	Audio     SessionRawDeviceAudio     `json:"audio"`
	Fonts     SessionRawDeviceFonts     `json:"fonts"`
	Media     SessionRawDeviceMedia     `json:"media"`
}

type SessionConnectionFingerprint

type SessionConnectionFingerprint struct {
	JA4                SessionConnectionFingerprintJA4   `json:"ja4"`
	HTTP2              SessionConnectionFingerprintHTTP2 `json:"http2"`
	UserAgentAlignment *string                           `json:"user_agent_alignment,omitempty"`
}

type SessionConnectionFingerprintHTTP2

type SessionConnectionFingerprintHTTP2 struct {
	AkamaiFingerprint *string `json:"akamai_fingerprint,omitempty"`
	Profile           *string `json:"profile,omitempty"`
}

type SessionConnectionFingerprintJA4

type SessionConnectionFingerprintJA4 struct {
	Hash          *string `json:"hash,omitempty"`
	Profile       *string `json:"profile,omitempty"`
	Family        *string `json:"family,omitempty"`
	Product       *string `json:"product,omitempty"`
	Confidence    *string `json:"confidence,omitempty"`
	Deterministic *bool   `json:"deterministic,omitempty"`
}

type SessionDecision

type SessionDecision struct {
	EventID          string  `json:"event_id"`
	AutomationStatus string  `json:"automation_status"`
	RiskScore        int     `json:"risk_score"`
	EvaluationPhase  *string `json:"evaluation_phase,omitempty"`
	DecisionStatus   string  `json:"decision_status"`
	EvaluatedAt      string  `json:"evaluated_at"`
}

type SessionDetail

type SessionDetail struct {
	Object                 string                           `json:"object"`
	ID                     string                           `json:"id"`
	CreatedAt              *string                          `json:"created_at,omitempty"`
	Decision               SessionDecision                  `json:"decision"`
	Highlights             []SessionHighlight               `json:"highlights"`
	Attribution            *SessionAttribution              `json:"attribution,omitempty"`
	WebBotAuth             *SessionWebBotAuth               `json:"web_bot_auth,omitempty"`
	Network                SessionNetwork                   `json:"network"`
	RuntimeIntegrity       SessionRuntimeIntegrity          `json:"runtime_integrity"`
	NativeRuntimeIntegrity map[string]any                   `json:"native_runtime_integrity,omitempty"`
	NativeApp              map[string]any                   `json:"native_app,omitempty"`
	NativeCarrier          map[string]any                   `json:"native_carrier,omitempty"`
	NativeMotionPrint      map[string]any                   `json:"native_motion_print,omitempty"`
	DeviceIdentity         map[string]any                   `json:"device_identity,omitempty"`
	InstallID              *string                          `json:"install_id,omitempty"`
	VisitorFingerprint     *SessionDetailVisitorFingerprint `json:"visitor_fingerprint,omitempty"`
	ConnectionFingerprint  SessionConnectionFingerprint     `json:"connection_fingerprint"`
	PreviousDecisions      []SessionDecision                `json:"previous_decisions"`
	Request                SessionDetailRequest             `json:"request"`
	Browser                SessionBrowser                   `json:"browser"`
	Device                 SessionDevice                    `json:"device"`
	AnalysisCoverage       SessionAnalysisCoverage          `json:"analysis_coverage"`
	SignalsFired           []SessionSignalFired             `json:"signals_fired"`
	ClientTelemetry        SessionClientTelemetry           `json:"client_telemetry"`
}

type SessionDetailRequest

type SessionDetailRequest struct {
	URL       string  `json:"url"`
	Referrer  *string `json:"referrer,omitempty"`
	UserAgent string  `json:"user_agent"`
}

type SessionDetailVisitorFingerprint

type SessionDetailVisitorFingerprint struct {
	Object       string                                   `json:"object"`
	ID           string                                   `json:"id"`
	Confidence   *int                                     `json:"confidence,omitempty"`
	IdentifiedAt *string                                  `json:"identified_at,omitempty"`
	Lifecycle    SessionDetailVisitorFingerprintLifecycle `json:"lifecycle"`
}

type SessionDetailVisitorFingerprintLifecycle

type SessionDetailVisitorFingerprintLifecycle struct {
	FirstSeenAt *string `json:"first_seen_at,omitempty"`
	LastSeenAt  *string `json:"last_seen_at,omitempty"`
	SeenCount   *int    `json:"seen_count,omitempty"`
}

type SessionDevice

type SessionDevice struct {
	FormFactor      string                       `json:"form_factor"`
	OperatingSystem SessionDeviceOperatingSystem `json:"operating_system"`
	Architecture    *string                      `json:"architecture,omitempty"`
	Screen          SessionDeviceScreen          `json:"screen"`
	Locale          SessionDeviceLocale          `json:"locale"`
	Capabilities    SessionDeviceCapabilities    `json:"capabilities"`
}

type SessionDeviceAvailabilityCapability

type SessionDeviceAvailabilityCapability struct {
	Available *bool `json:"available,omitempty"`
}

type SessionDeviceCapabilities

type SessionDeviceCapabilities struct {
	Touch                 SessionDeviceTouchCapabilities                 `json:"touch"`
	Storage               SessionDeviceStorageCapabilities               `json:"storage"`
	WebGPU                SessionDeviceAvailabilityCapability            `json:"webgpu"`
	PlatformAuthenticator SessionDevicePlatformAuthenticatorCapabilities `json:"platform_authenticator"`
	MediaDevices          SessionDeviceAvailabilityCapability            `json:"media_devices"`
	SpeechSynthesis       SessionDeviceAvailabilityCapability            `json:"speech_synthesis"`
}

type SessionDeviceLocale

type SessionDeviceLocale struct {
	Timezone        *string  `json:"timezone,omitempty"`
	PrimaryLanguage *string  `json:"primary_language,omitempty"`
	Languages       []string `json:"languages"`
}

type SessionDeviceOperatingSystem

type SessionDeviceOperatingSystem struct {
	Name    *string `json:"name,omitempty"`
	Version *string `json:"version,omitempty"`
}

type SessionDevicePlatformAuthenticatorCapabilities

type SessionDevicePlatformAuthenticatorCapabilities struct {
	Available            *bool `json:"available,omitempty"`
	ConditionalMediation *bool `json:"conditional_mediation,omitempty"`
}

type SessionDeviceScreen

type SessionDeviceScreen struct {
	Size            *string  `json:"size,omitempty"`
	ColorDepth      *int     `json:"color_depth,omitempty"`
	PixelRatio      *float64 `json:"pixel_ratio,omitempty"`
	OrientationType *string  `json:"orientation_type,omitempty"`
}

type SessionDeviceStorageCapabilities

type SessionDeviceStorageCapabilities struct {
	Cookies       *bool `json:"cookies,omitempty"`
	LocalStorage  *bool `json:"local_storage,omitempty"`
	IndexedDB     *bool `json:"indexed_db,omitempty"`
	ServiceWorker *bool `json:"service_worker,omitempty"`
	WindowName    *bool `json:"window_name,omitempty"`
}

type SessionDeviceTouchCapabilities

type SessionDeviceTouchCapabilities struct {
	Available      *bool `json:"available,omitempty"`
	MaxTouchPoints *int  `json:"max_touch_points,omitempty"`
}

type SessionHighlight

type SessionHighlight struct {
	Key        string                     `json:"key"`
	Effect     string                     `json:"effect"`
	Importance string                     `json:"importance"`
	Summary    string                     `json:"summary"`
	Evidence   []SessionHighlightEvidence `json:"evidence,omitempty"`
}

type SessionHighlightEvidence

type SessionHighlightEvidence struct {
	Signal string `json:"signal"`
	Name   string `json:"name"`
}

type SessionListParams

type SessionListParams struct {
	Limit   int
	Cursor  string
	Verdict string
	Search  string
}

type SessionNetwork

type SessionNetwork struct {
	IPAddress   *string                  `json:"ip_address,omitempty"`
	IPVersion   *string                  `json:"ip_version,omitempty"`
	Status      string                   `json:"status"`
	Summary     *string                  `json:"summary,omitempty"`
	Location    *SessionNetworkLocation  `json:"location,omitempty"`
	Routing     SessionNetworkRouting    `json:"routing"`
	Anonymity   SessionNetworkAnonymity  `json:"anonymity"`
	Reputation  SessionNetworkReputation `json:"reputation"`
	Evidence    SessionNetworkEvidence   `json:"evidence"`
	EvaluatedAt *string                  `json:"evaluated_at,omitempty"`
}

type SessionNetworkAnonymity

type SessionNetworkAnonymity struct {
	VPN              bool    `json:"vpn"`
	Proxy            bool    `json:"proxy"`
	Tor              bool    `json:"tor"`
	Relay            bool    `json:"relay"`
	Hosting          bool    `json:"hosting"`
	ResidentialProxy bool    `json:"residential_proxy"`
	CallbackProxy    bool    `json:"callback_proxy"`
	Provider         *string `json:"provider,omitempty"`
}

type SessionNetworkEvidence

type SessionNetworkEvidence struct {
	RiskSignals  []string `json:"risk_signals"`
	OperatorTags []string `json:"operator_tags"`
	ClientTypes  []string `json:"client_types"`
	ClientCount  *int     `json:"client_count,omitempty"`
}

type SessionNetworkLocation

type SessionNetworkLocation struct {
	City             *string  `json:"city,omitempty"`
	Region           *string  `json:"region,omitempty"`
	Country          *string  `json:"country,omitempty"`
	CountryCode      *string  `json:"country_code,omitempty"`
	Latitude         *float64 `json:"latitude,omitempty"`
	Longitude        *float64 `json:"longitude,omitempty"`
	Timezone         *string  `json:"timezone,omitempty"`
	PostalCode       *string  `json:"postal_code,omitempty"`
	AccuracyRadiusKm *float64 `json:"accuracy_radius_km,omitempty"`
}

type SessionNetworkReputation

type SessionNetworkReputation struct {
	Listed            bool     `json:"listed"`
	Categories        []string `json:"categories"`
	SuspiciousNetwork bool     `json:"suspicious_network"`
}

type SessionNetworkRouting

type SessionNetworkRouting struct {
	ASN          *string `json:"asn,omitempty"`
	Organization *string `json:"organization,omitempty"`
}

type SessionRawDeviceAudio

type SessionRawDeviceAudio struct {
	Hash             any      `json:"hash"`
	SampleRate       *float64 `json:"sample_rate,omitempty"`
	ChannelCount     *int     `json:"channel_count,omitempty"`
	VoiceCount       *int     `json:"voice_count,omitempty"`
	LocalVoiceCount  *int     `json:"local_voice_count,omitempty"`
	DefaultVoiceLang *string  `json:"default_voice_lang,omitempty"`
	NoiseDetected    *bool    `json:"noise_detected,omitempty"`
}

type SessionRawDeviceCanvas

type SessionRawDeviceCanvas struct {
	Hash                any   `json:"hash"`
	GeometryHash        any   `json:"geometry_hash"`
	TextHash            any   `json:"text_hash"`
	Winding             *bool `json:"winding,omitempty"`
	NoiseDetected       *bool `json:"noise_detected,omitempty"`
	OffscreenConsistent *bool `json:"offscreen_consistent,omitempty"`
}

type SessionRawDeviceFonts

type SessionRawDeviceFonts struct {
	DetectedCount   *int `json:"detected_count,omitempty"`
	TestedCount     *int `json:"tested_count,omitempty"`
	EnumerationHash any  `json:"enumeration_hash"`
	MetricsHash     any  `json:"metrics_hash"`
	PreferencesHash any  `json:"preferences_hash"`
	EmojiHash       any  `json:"emoji_hash"`
}

type SessionRawDeviceGraphics

type SessionRawDeviceGraphics struct {
	WebGL  SessionRawDeviceGraphicsWebGL  `json:"webgl"`
	WebGPU SessionRawDeviceGraphicsWebGPU `json:"webgpu"`
}

type SessionRawDeviceGraphicsWebGL

type SessionRawDeviceGraphicsWebGL struct {
	Vendor                  *string `json:"vendor,omitempty"`
	Renderer                *string `json:"renderer,omitempty"`
	Version                 *string `json:"version,omitempty"`
	ShadingLanguageVersion  *string `json:"shading_language_version,omitempty"`
	ParametersHash          any     `json:"parameters_hash"`
	ExtensionsHash          any     `json:"extensions_hash"`
	ExtensionParametersHash any     `json:"extension_parameters_hash"`
	ShaderPrecisionHash     any     `json:"shader_precision_hash"`
}

type SessionRawDeviceGraphicsWebGPU

type SessionRawDeviceGraphicsWebGPU struct {
	Available           *bool   `json:"available,omitempty"`
	AdapterVendor       *string `json:"adapter_vendor,omitempty"`
	AdapterArchitecture *string `json:"adapter_architecture,omitempty"`
	FallbackAdapter     *bool   `json:"fallback_adapter,omitempty"`
	FeaturesHash        any     `json:"features_hash"`
	LimitsHash          any     `json:"limits_hash"`
}

type SessionRawDeviceMedia

type SessionRawDeviceMedia struct {
	DeviceCount     *int           `json:"device_count,omitempty"`
	CountsByKind    map[string]int `json:"counts_by_kind"`
	BlankLabelCount *int           `json:"blank_label_count,omitempty"`
	TopologyHash    any            `json:"topology_hash"`
}

type SessionRawDeviceNavigator

type SessionRawDeviceNavigator struct {
	Platform            *string  `json:"platform,omitempty"`
	Vendor              *string  `json:"vendor,omitempty"`
	HardwareConcurrency *int     `json:"hardware_concurrency,omitempty"`
	DeviceMemory        *float64 `json:"device_memory,omitempty"`
	MaxTouchPoints      *int     `json:"max_touch_points,omitempty"`
	PDFViewerEnabled    *bool    `json:"pdf_viewer_enabled,omitempty"`
	CookieEnabled       *bool    `json:"cookie_enabled,omitempty"`
	ProductSub          *string  `json:"product_sub,omitempty"`
	PrimaryLanguage     *string  `json:"primary_language,omitempty"`
	Languages           []string `json:"languages"`
	MimeTypesCount      *int     `json:"mime_types_count,omitempty"`
	Plugins             []string `json:"plugins"`
}

type SessionRawDeviceStorage

type SessionRawDeviceStorage struct {
	Cookies        *bool `json:"cookies,omitempty"`
	LocalStorage   *bool `json:"local_storage,omitempty"`
	SessionStorage *bool `json:"session_storage,omitempty"`
	IndexedDB      *bool `json:"indexed_db,omitempty"`
	ServiceWorker  *bool `json:"service_worker,omitempty"`
	WindowName     *bool `json:"window_name,omitempty"`
}

type SessionRuntimeIntegrity

type SessionRuntimeIntegrity struct {
	Tampering           string `json:"tampering"`
	DeveloperTools      string `json:"developer_tools"`
	Emulation           string `json:"emulation"`
	Virtualization      string `json:"virtualization"`
	PrivacyHardening    string `json:"privacy_hardening"`
	IdentitySpoofing    string `json:"identity_spoofing"`
	Replay              string `json:"replay"`
	OutdatedEnvironment string `json:"outdated_environment"`
}

type SessionSignalFired

type SessionSignalFired struct {
	Signal      string `json:"signal"`
	Role        string `json:"role"`
	Category    string `json:"category"`
	Strength    string `json:"strength"`
	SignalScore int    `json:"signal_score"`
}

type SessionSummary

type SessionSummary struct {
	Object             string                  `json:"object"`
	ID                 string                  `json:"id"`
	CreatedAt          *string                 `json:"created_at,omitempty"`
	LatestDecision     Decision                `json:"latest_decision"`
	VisitorFingerprint *VisitorFingerprintLink `json:"visitor_fingerprint,omitempty"`
}

type SessionWebBotAuth

type SessionWebBotAuth struct {
	Status *string `json:"status,omitempty"`
	Domain *string `json:"domain,omitempty"`
}

type SessionsService

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

func (*SessionsService) Get

func (s *SessionsService) Get(ctx context.Context, sessionID string) (SessionDetail, error)

func (*SessionsService) Iter

func (s *SessionsService) Iter(ctx context.Context, params SessionListParams, yield func(SessionSummary) error) error

func (*SessionsService) List

type TokenVerificationError

type TokenVerificationError struct {
	Message string
	Err     error
}

func (*TokenVerificationError) Error

func (e *TokenVerificationError) Error() string

func (*TokenVerificationError) Unwrap

func (e *TokenVerificationError) Unwrap() error

type UpdateAPIKeyParams

type UpdateAPIKeyParams struct {
	Name           string   `json:"name,omitempty"`
	AllowedOrigins []string `json:"allowed_origins,omitempty"`
	Scopes         []string `json:"scopes,omitempty"`
}

type UpdateGateServiceParams

type UpdateGateServiceParams struct {
	Discoverable      *bool                     `json:"discoverable,omitempty"`
	Name              string                    `json:"name,omitempty"`
	Description       string                    `json:"description,omitempty"`
	Website           string                    `json:"website,omitempty"`
	DashboardLoginURL string                    `json:"dashboard_login_url,omitempty"`
	WebhookEndpointID string                    `json:"webhook_endpoint_id,omitempty"`
	EnvVars           []GateServiceEnvVar       `json:"env_vars,omitempty"`
	DocsURL           string                    `json:"docs_url,omitempty"`
	SDKs              []GateServiceSDKInstall   `json:"sdks,omitempty"`
	Branding          *GateServiceBrandingInput `json:"branding,omitempty"`
	Consent           *GateServiceConsent       `json:"consent,omitempty"`
}

type UpdateOrganizationParams

type UpdateOrganizationParams struct {
	Name   string `json:"name,omitempty"`
	Status string `json:"status,omitempty"`
}

type UpdateWebhookEndpointParams

type UpdateWebhookEndpointParams struct {
	Name       string   `json:"name,omitempty"`
	URL        string   `json:"url,omitempty"`
	Status     string   `json:"status,omitempty"`
	EventTypes []string `json:"event_types,omitempty"`
}

type VerificationResult

type VerificationResult struct {
	OK    bool
	Data  *VerifiedFoilToken
	Error error
}

func SafeVerifyFoilToken

func SafeVerifyFoilToken(sealedToken string, secretKey string) VerificationResult

type VerifiedFoilSignal

type VerifiedFoilSignal struct {
	ID         string         `json:"id"`
	Category   string         `json:"category"`
	Confidence string         `json:"confidence"`
	Score      int            `json:"score"`
	Raw        map[string]any `json:"raw,omitempty"`
}

type VerifiedFoilToken

type VerifiedFoilToken struct {
	Object             string                  `json:"object"`
	SessionID          string                  `json:"session_id"`
	Decision           Decision                `json:"decision"`
	Request            RequestContext          `json:"request"`
	VisitorFingerprint *VisitorFingerprintLink `json:"visitor_fingerprint,omitempty"`
	Signals            []VerifiedFoilSignal    `json:"signals"`
	ScoreBreakdown     ScoreBreakdown          `json:"score_breakdown"`
	Attribution        Attribution             `json:"attribution"`
	Embed              map[string]any          `json:"embed,omitempty"`
	Raw                map[string]any          `json:"raw,omitempty"`
}

func VerifyFoilToken

func VerifyFoilToken(sealedToken string, secretKey string) (*VerifiedFoilToken, error)

type VerifyGateAgentTokenParams

type VerifyGateAgentTokenParams struct {
	AgentToken string `json:"agent_token"`
}

type VerifyGateWebhookSignatureInput

type VerifyGateWebhookSignatureInput struct {
	Secret        string
	Timestamp     string
	RawBody       string
	Signature     string
	MaxAgeSeconds int64
	NowSeconds    int64
}

type VisitorFingerprintActivity

type VisitorFingerprintActivity struct {
	Sessions []VisitorFingerprintSessionSummary `json:"sessions"`
}

type VisitorFingerprintAnchors

type VisitorFingerprintAnchors struct {
	WebGLHash      *string `json:"webgl_hash,omitempty"`
	ParametersHash *string `json:"parameters_hash,omitempty"`
	AudioHash      *string `json:"audio_hash,omitempty"`
}

type VisitorFingerprintComponents

type VisitorFingerprintComponents struct {
	Vector []int `json:"vector"`
}

type VisitorFingerprintDetail

type VisitorFingerprintDetail struct {
	VisitorFingerprintSummary
	Components VisitorFingerprintComponents `json:"components"`
	Activity   VisitorFingerprintActivity   `json:"activity"`
}

type VisitorFingerprintLatestRequest

type VisitorFingerprintLatestRequest struct {
	UserAgent string `json:"user_agent"`
	IPAddress string `json:"ip_address"`
}

type VisitorFingerprintLifecycle

type VisitorFingerprintLifecycle struct {
	FirstSeenAt string `json:"first_seen_at"`
	LastSeenAt  string `json:"last_seen_at"`
	SeenCount   int    `json:"seen_count"`
	ExpiresAt   string `json:"expires_at"`
}
type VisitorFingerprintLink struct {
	Object       string  `json:"object"`
	ID           string  `json:"id"`
	Confidence   *int    `json:"confidence,omitempty"`
	IdentifiedAt *string `json:"identified_at,omitempty"`
}

type VisitorFingerprintSessionSummary

type VisitorFingerprintSessionSummary struct {
	SessionID      string         `json:"session_id"`
	Decision       Decision       `json:"decision"`
	Request        RequestContext `json:"request"`
	ScoreBreakdown ScoreBreakdown `json:"score_breakdown"`
}

type VisitorFingerprintStorage

type VisitorFingerprintStorage struct {
	Cookies       bool `json:"cookies"`
	LocalStorage  bool `json:"local_storage"`
	IndexedDB     bool `json:"indexed_db"`
	ServiceWorker bool `json:"service_worker"`
	WindowName    bool `json:"window_name"`
}

type VisitorFingerprintSummary

type VisitorFingerprintSummary struct {
	Object        string                          `json:"object"`
	ID            string                          `json:"id"`
	Lifecycle     VisitorFingerprintLifecycle     `json:"lifecycle"`
	LatestRequest VisitorFingerprintLatestRequest `json:"latest_request"`
	Storage       VisitorFingerprintStorage       `json:"storage"`
	Anchors       VisitorFingerprintAnchors       `json:"anchors"`
}

type WebhookDelivery

type WebhookDelivery struct {
	Object         string  `json:"object"`
	ID             string  `json:"id"`
	EventID        string  `json:"event_id"`
	EndpointID     string  `json:"endpoint_id"`
	EventType      string  `json:"event_type"`
	Status         string  `json:"status"`
	Attempts       int     `json:"attempts"`
	ResponseStatus *int    `json:"response_status"`
	ResponseBody   *string `json:"response_body"`
	Error          *string `json:"error"`
	CreatedAt      string  `json:"created_at"`
	UpdatedAt      string  `json:"updated_at"`
}

type WebhookEndpoint

type WebhookEndpoint struct {
	Object        string   `json:"object"`
	ID            string   `json:"id"`
	Name          string   `json:"name"`
	URL           string   `json:"url"`
	Status        string   `json:"status"`
	EventTypes    []string `json:"event_types"`
	SigningSecret string   `json:"signing_secret,omitempty"`
	CreatedAt     string   `json:"created_at"`
	UpdatedAt     string   `json:"updated_at"`
}

type WebhookEventEnvelope

type WebhookEventEnvelope struct {
	ID      string          `json:"id"`
	Object  string          `json:"object"`
	Type    string          `json:"type"`
	Created string          `json:"created"`
	Data    json.RawMessage `json:"data"`
}

func ParseWebhookEvent

func ParseWebhookEvent(rawBody []byte) (*WebhookEventEnvelope, any, error)

type WebhookTest

type WebhookTest struct {
	Object         string           `json:"object"`
	EventID        string           `json:"event_id"`
	DeliveryIDs    []string         `json:"delivery_ids"`
	LatestDelivery *WebhookDelivery `json:"latest_delivery"`
}

type WebhooksService

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

func (*WebhooksService) CreateEndpoint

func (s *WebhooksService) CreateEndpoint(ctx context.Context, organizationID string, params CreateWebhookEndpointParams) (WebhookEndpoint, error)

func (*WebhooksService) DisableEndpoint

func (s *WebhooksService) DisableEndpoint(ctx context.Context, organizationID string, endpointID string) (WebhookEndpoint, error)

func (*WebhooksService) ListEndpoints

func (s *WebhooksService) ListEndpoints(ctx context.Context, organizationID string) (ListResult[WebhookEndpoint], error)

func (*WebhooksService) ListEvents

func (s *WebhooksService) ListEvents(ctx context.Context, organizationID string, params EventListParams) (ListResult[Event], error)

func (*WebhooksService) RetrieveEvent

func (s *WebhooksService) RetrieveEvent(ctx context.Context, organizationID string, eventID string) (Event, error)

func (*WebhooksService) RotateSecret

func (s *WebhooksService) RotateSecret(ctx context.Context, organizationID string, endpointID string) (WebhookEndpoint, error)

func (*WebhooksService) SendTest

func (s *WebhooksService) SendTest(ctx context.Context, organizationID string, endpointID string) (WebhookTest, error)

func (*WebhooksService) UpdateEndpoint

func (s *WebhooksService) UpdateEndpoint(ctx context.Context, organizationID string, endpointID string, params UpdateWebhookEndpointParams) (WebhookEndpoint, error)

Jump to

Keyboard shortcuts

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