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
TypeDnsRecordTypeThe DNS record type.
NamestringThe record name (hostname). Can be "@" for the root domain.
ContentstringThe record content. Format varies by record type.
TtlintTime to live in seconds. Default: 1 (automatic).
Proxiedbool?Whether to proxy the record through Cloudflare. Only applies to A, AAAA, and CNAME records.
CommentstringOptional comment describing the record (max 100 characters).
TagsIReadOnlyList<string>Optional tags in "name:value" format.
Priorityint?Record priority. Required for MX records, optional for SRV records.
SettingsDnsRecordSettingsOptional 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
Content
The record content. Format varies by record type.
[JsonPropertyName("content")]
public string Content { get; init; }
Property Value
Name
The record name (hostname). Can be "@" for the root domain.
[JsonPropertyName("name")]
public string Name { get; init; }
Property Value
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
Tags
Optional tags in "name:value" format.
[JsonPropertyName("tags")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IReadOnlyList<string>? Tags { get; init; }
Property Value
Ttl
Time to live in seconds. Default: 1 (automatic).
[JsonPropertyName("ttl")]
public int Ttl { get; init; }
Property Value
Type
The DNS record type.
[JsonPropertyName("type")]
public DnsRecordType Type { get; init; }