Table of Contents

Class CreateDnsRecordRequest

Namespace
Cloudflare.NET.Dns.Models
Assembly
Cloudflare.NET.dll

Request to create a new DNS record.

Supports all record types and optional features like comments and tags. For MX and SRV records, the Priority field is required.

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

Examples

// Create an A record
var aRecord = new CreateDnsRecordRequest(DnsRecordType.A, "www.example.com", "192.0.2.1");

// Create an MX record with priority
var mxRecord = new CreateDnsRecordRequest(DnsRecordType.MX, "example.com", "mail.example.com", Priority: 10);

// Create a record with a comment and tags
var taggedRecord = new CreateDnsRecordRequest(
  DnsRecordType.A, "api.example.com", "192.0.2.2",
  Comment: "API server",
  Tags: ["env:production", "service:api"]
);

Constructors

CreateDnsRecordRequest(DnsRecordType, string, string, int, bool?, string?, IReadOnlyList<string>?, int?, DnsRecordSettings?)

Request to create a new DNS record.

Supports all record types and optional features like comments and tags. For MX and SRV records, the Priority field is required.

public CreateDnsRecordRequest(DnsRecordType Type, string Name, string Content, int Ttl = 1, bool? Proxied = null, string? Comment = null, IReadOnlyList<string>? Tags = null, int? Priority = null, DnsRecordSettings? Settings = null)

Parameters

Type DnsRecordType

The DNS record type.

Name string

The record name (hostname). Can be "@" for the root domain.

Content string

The record content. Format varies by record type.

Ttl int

Time to live in seconds. Default: 1 (automatic).

Proxied bool?

Whether to proxy the record through Cloudflare. Only applies to A, AAAA, and CNAME records.

Comment string

Optional comment describing the record (max 100 characters).

Tags IReadOnlyList<string>

Optional tags in "name:value" format.

Priority int?

Record priority. Required for MX records, optional for SRV records.

Settings DnsRecordSettings

Optional settings for the record.

Examples

// Create an A record
var aRecord = new CreateDnsRecordRequest(DnsRecordType.A, "www.example.com", "192.0.2.1");

// Create an MX record with priority
var mxRecord = new CreateDnsRecordRequest(DnsRecordType.MX, "example.com", "mail.example.com", Priority: 10);

// Create a record with a comment and tags
var taggedRecord = new CreateDnsRecordRequest(
  DnsRecordType.A, "api.example.com", "192.0.2.2",
  Comment: "API server",
  Tags: ["env:production", "service:api"]
);

Properties

Comment

Optional comment describing the record (max 100 characters).

[JsonPropertyName("comment")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Comment { get; init; }

Property Value

string

Content

The record content. Format varies by record type.

[JsonPropertyName("content")]
public string Content { get; init; }

Property Value

string

Name

The record name (hostname). Can be "@" for the root domain.

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

Property Value

string

Priority

Record priority. Required for MX records, optional for SRV records.

[JsonPropertyName("priority")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Priority { get; init; }

Property Value

int?

Proxied

Whether to proxy the record through Cloudflare. Only applies to A, AAAA, and CNAME records.

[JsonPropertyName("proxied")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? Proxied { get; init; }

Property Value

bool?

Settings

Optional settings for the record.

[JsonPropertyName("settings")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DnsRecordSettings? Settings { get; init; }

Property Value

DnsRecordSettings

Tags

Optional tags in "name:value" format.

[JsonPropertyName("tags")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IReadOnlyList<string>? Tags { get; init; }

Property Value

IReadOnlyList<string>

Ttl

Time to live in seconds. Default: 1 (automatic).

[JsonPropertyName("ttl")]
public int Ttl { get; init; }

Property Value

int

Type

The DNS record type.

[JsonPropertyName("type")]
public DnsRecordType Type { get; init; }

Property Value

DnsRecordType