Table of Contents

Class TurnstileWidget

Namespace
Cloudflare.NET.Turnstile.Models
Assembly
Cloudflare.NET.dll

Represents a Turnstile widget configuration.

Turnstile widgets provide bot protection without user friction. Each widget is identified by a public sitekey used in frontend integration, and has a secret key for server-side verification.

public record TurnstileWidget : IEquatable<TurnstileWidget>
Inheritance
TurnstileWidget
Implements
Inherited Members

Remarks

The Secret property is only populated when the widget is created or when the secret is rotated. Subsequent GET requests will return null for this field.

Constructors

TurnstileWidget(string, string, WidgetMode, IReadOnlyList<string>, DateTime, DateTime, bool, ClearanceLevel?, bool, bool, string?, string?)

Represents a Turnstile widget configuration.

Turnstile widgets provide bot protection without user friction. Each widget is identified by a public sitekey used in frontend integration, and has a secret key for server-side verification.

public TurnstileWidget(string Sitekey, string Name, WidgetMode Mode, IReadOnlyList<string> Domains, DateTime CreatedOn, DateTime ModifiedOn, bool BotFightMode = false, ClearanceLevel? ClearanceLevel = null, bool EphemeralId = false, bool Offlabel = false, string? Region = null, string? Secret = null)

Parameters

Sitekey string

Widget public key used in frontend integration.

Name string

Widget name for identification.

Mode WidgetMode

Widget mode determining user interaction level.

Domains IReadOnlyList<string>

Allowed domains/hostnames for this widget.

CreatedOn DateTime

When the widget was created.

ModifiedOn DateTime

When the widget was last modified.

BotFightMode bool

Whether bot fight mode is enabled.

ClearanceLevel ClearanceLevel?

Challenge clearance level.

EphemeralId bool

Whether to use ephemeral IDs.

Offlabel bool

Whether off-label use is allowed.

Region string

Geographic region for the widget.

Secret string

Widget secret key. Only returned on create or rotate.

Remarks

The Secret property is only populated when the widget is created or when the secret is rotated. Subsequent GET requests will return null for this field.

Properties

BotFightMode

Whether bot fight mode is enabled.

[JsonPropertyName("bot_fight_mode")]
public bool BotFightMode { get; init; }

Property Value

bool

ClearanceLevel

Challenge clearance level.

[JsonPropertyName("clearance_level")]
public ClearanceLevel? ClearanceLevel { get; init; }

Property Value

ClearanceLevel?

CreatedOn

When the widget was created.

[JsonPropertyName("created_on")]
public DateTime CreatedOn { get; init; }

Property Value

DateTime

Domains

Allowed domains/hostnames for this widget.

[JsonPropertyName("domains")]
public IReadOnlyList<string> Domains { get; init; }

Property Value

IReadOnlyList<string>

EphemeralId

Whether to use ephemeral IDs.

[JsonPropertyName("ephemeral_id")]
public bool EphemeralId { get; init; }

Property Value

bool

Mode

Widget mode determining user interaction level.

[JsonPropertyName("mode")]
public WidgetMode Mode { get; init; }

Property Value

WidgetMode

ModifiedOn

When the widget was last modified.

[JsonPropertyName("modified_on")]
public DateTime ModifiedOn { get; init; }

Property Value

DateTime

Name

Widget name for identification.

[JsonPropertyName("name")]
public string Name { get; init; }

Property Value

string

Offlabel

Whether off-label use is allowed.

[JsonPropertyName("offlabel")]
public bool Offlabel { get; init; }

Property Value

bool

Region

Geographic region for the widget.

[JsonPropertyName("region")]
public string? Region { get; init; }

Property Value

string

Secret

Widget secret key. Only returned on create or rotate.

[JsonPropertyName("secret")]
public string? Secret { get; init; }

Property Value

string

Sitekey

Widget public key used in frontend integration.

[JsonPropertyName("sitekey")]
public string Sitekey { get; init; }

Property Value

string