Table of Contents

Class CreateWebhookRequest

Namespace
Mailtrap.Webhooks.Requests
Assembly
Mailtrap.Abstractions.dll

Request object for creating a webhook.

public sealed record CreateWebhookRequest : IValidatable, IEquatable<CreateWebhookRequest>
Inheritance
CreateWebhookRequest
Implements

Properties

Active

Gets or sets a value indicating whether the webhook is active. Defaults to true.

[JsonPropertyName("active")]
[JsonPropertyOrder(3)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? Active { get; set; }

Property Value

bool?

Active flag or null to use the API default.

DomainId

Gets or sets the domain ID to scope the webhook to.
When omitted, the webhook applies to all domains.
Applicable only for email_sending webhooks.

[JsonPropertyName("domain_id")]
[JsonPropertyOrder(7)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public long? DomainId { get; set; }

Property Value

long?

Domain identifier or null.

EventTypes

Gets the list of event types to subscribe to.
Required for email_sending webhook type.

[JsonPropertyName("event_types")]
[JsonPropertyOrder(6)]
[JsonObjectCreationHandling(JsonObjectCreationHandling.Populate)]
public IList<WebhookEventType> EventTypes { get; }

Property Value

IList<WebhookEventType>

List of event types.

PayloadFormat

Gets or sets the format of the webhook payload.

[JsonPropertyName("payload_format")]
[JsonPropertyOrder(4)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public WebhookPayloadFormat? PayloadFormat { get; set; }

Property Value

WebhookPayloadFormat

Webhook payload format or null to use the API default ("json").

SendingStream

Gets or sets sending stream the webhook subscribes to.
Required for email_sending webhook type.

[JsonPropertyName("sending_stream")]
[JsonPropertyOrder(5)]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public SendingStream? SendingStream { get; set; }

Property Value

SendingStream

Sending stream or null.

Url

Gets or sets the URL that will receive webhook payloads.

[JsonPropertyName("url")]
[JsonPropertyOrder(1)]
[JsonRequired]
public Uri? Url { get; set; }

Property Value

Uri

Target URL.

WebhookType

Gets or sets webhook type.

[JsonPropertyName("webhook_type")]
[JsonPropertyOrder(2)]
[JsonRequired]
public WebhookType WebhookType { get; set; }

Property Value

WebhookType

Webhook type. Allowed values: "email_sending", "audit_log".

Methods

Validate()

Validates the current instance.

public ValidationResult Validate()

Returns

ValidationResult

Object containing validation errors, if any.