Table of Contents

Class DnsRecord

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

Represents a complete DNS record from the Cloudflare API.

This model includes all properties returned by the API, including optional fields like comments, tags, meta information, and record-specific settings.

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

Examples

var record = await dns.GetDnsRecordAsync(zoneId, recordId);
Console.WriteLine($"{record.Name} ({record.Type}): {record.Content}");
Console.WriteLine($"  TTL: {(record.Ttl == 1 ? "Auto" : record.Ttl.ToString())}");
Console.WriteLine($"  Proxied: {record.Proxied} (Proxiable: {record.Proxiable})");
if (record.Comment != null) Console.WriteLine($"  Comment: {record.Comment}");

Constructors

DnsRecord(string, string, DnsRecordType, string, bool, bool, int, DateTime, DateTime, string?, IReadOnlyList<string>?, int?, DnsRecordMeta?, DnsRecordSettings?)

Represents a complete DNS record from the Cloudflare API.

This model includes all properties returned by the API, including optional fields like comments, tags, meta information, and record-specific settings.

public DnsRecord(string Id, string Name, DnsRecordType Type, string Content, bool Proxied, bool Proxiable, int Ttl, DateTime CreatedOn, DateTime ModifiedOn, string? Comment = null, IReadOnlyList<string>? Tags = null, int? Priority = null, DnsRecordMeta? Meta = null, DnsRecordSettings? Settings = null)

Parameters

Id string

The unique identifier of the DNS record.

Name string

The record name (hostname).

Type DnsRecordType

The DNS record type.

Content string

The record content (value varies by type: IP address, hostname, text, etc.).

Proxied bool

Whether the record is proxied through Cloudflare.

Proxiable bool

Whether the record can be proxied (depends on type and configuration).

Ttl int

Time to live in seconds. A value of 1 means "automatic" (Cloudflare chooses optimal TTL).

CreatedOn DateTime

When the record was created.

ModifiedOn DateTime

When the record was last modified.

Comment string

Optional comment describing the record.

Tags IReadOnlyList<string>

Optional tags in "name:value" format for organizing records.

Priority int?

Record priority (required for MX records, optional for SRV records).

Meta DnsRecordMeta

Additional metadata about the record, such as whether it was auto-added.

Settings DnsRecordSettings

Optional settings for the record (e.g., IPv4/IPv6-only resolution).

Examples

var record = await dns.GetDnsRecordAsync(zoneId, recordId);
Console.WriteLine($"{record.Name} ({record.Type}): {record.Content}");
Console.WriteLine($"  TTL: {(record.Ttl == 1 ? "Auto" : record.Ttl.ToString())}");
Console.WriteLine($"  Proxied: {record.Proxied} (Proxiable: {record.Proxiable})");
if (record.Comment != null) Console.WriteLine($"  Comment: {record.Comment}");
See Also

Properties

Comment

Optional comment describing the record.

[JsonPropertyName("comment")]
public string? Comment { get; init; }

Property Value

string

Content

The record content (value varies by type: IP address, hostname, text, etc.).

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

Property Value

string

CreatedOn

When the record was created.

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

Property Value

DateTime

Id

The unique identifier of the DNS record.

[JsonPropertyName("id")]
public string Id { get; init; }

Property Value

string

Meta

Additional metadata about the record, such as whether it was auto-added.

[JsonPropertyName("meta")]
public DnsRecordMeta? Meta { get; init; }

Property Value

DnsRecordMeta

ModifiedOn

When the record was last modified.

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

Property Value

DateTime

Name

The record name (hostname).

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

Property Value

string

Priority

Record priority (required for MX records, optional for SRV records).

[JsonPropertyName("priority")]
public int? Priority { get; init; }

Property Value

int?

Proxiable

Whether the record can be proxied (depends on type and configuration).

[JsonPropertyName("proxiable")]
public bool Proxiable { get; init; }

Property Value

bool

Proxied

Whether the record is proxied through Cloudflare.

[JsonPropertyName("proxied")]
public bool Proxied { get; init; }

Property Value

bool

Settings

Optional settings for the record (e.g., IPv4/IPv6-only resolution).

[JsonPropertyName("settings")]
public DnsRecordSettings? Settings { get; init; }

Property Value

DnsRecordSettings

Tags

Optional tags in "name:value" format for organizing records.

[JsonPropertyName("tags")]
public IReadOnlyList<string>? Tags { get; init; }

Property Value

IReadOnlyList<string>

Ttl

Time to live in seconds. A value of 1 means "automatic" (Cloudflare chooses optimal TTL).

[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

See Also