Skip to main content
DNS zones are authoritative containers for domain name records, with support for DNSSEC and SOA configuration.

Create Zone

Create a new DNS zone.
ctx := context.Background()

zone, err := client.DNS.Zones.New(ctx, dns.ZoneNewParams{
    Name: gcore.F("example.com"),
    Contact: gcore.F("[email protected]"),
    Enabled: gcore.F(true),
    Ttl: gcore.F(int64(3600)),
    Refresh: gcore.F(int64(10800)),
    Retry: gcore.F(int64(3600)),
    Expiry: gcore.F(int64(604800)),
    NxTtl: gcore.F(int64(300)),
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Zone ID: %d\n", zone.ID)

Parameters

name
string
required
Name of the DNS zone (e.g., “example.com”)
contact
string
Email address of the administrator responsible for this zone
enabled
boolean
default:true
If disabled, zone records will not be resolved on DNS servers
primary_server
string
Primary master name server for the zone
refresh
integer
default:10800
Seconds after which secondary name servers should query the master for SOA record to detect zone changes
retry
integer
default:3600
Seconds after which secondary name servers should retry to request the serial number
expiry
integer
default:604800
Seconds after which secondary name servers should stop answering requests for this zone
nx_ttl
integer
default:300
Time To Live for negative caching (NXDOMAIN responses)
serial
integer
Serial number for zone version tracking. If not specified, timestamp will be used
meta
object
Arbitrary metadata in JSON format. Can include:
  • webhook - URL to receive notifications about zone changes
  • webhook_method - HTTP method for webhook (default: POST)

Response Fields

id
integer
required
Unique identifier for the created zone
warnings
array
Array of warning messages, if any

List Zones

Retrieve a list of DNS zones with filtering and pagination.
ctx := context.Background()

response, err := client.DNS.Zones.List(ctx, dns.ZoneListParams{
    Enabled: gcore.F(true),
    Limit: gcore.F(int64(50)),
    Offset: gcore.F(int64(0)),
    OrderBy: gcore.F("name"),
    OrderDirection: gcore.F(dns.ZoneListParamsOrderDirectionAsc),
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Total zones: %d\n", response.TotalAmount)
for _, zone := range response.Zones {
    fmt.Printf("Zone: %s (ID: %d, Enabled: %v)\n", zone.Name, zone.ID, zone.Enabled)
}

Query Parameters

limit
integer
default:100
Maximum number of records to return
offset
integer
default:0
Number of records to skip before beginning to return results
enabled
boolean
Filter by enabled/disabled status
dynamic
boolean
Filter zones with dynamic RRsets
healthcheck
boolean
Filter zones with RRsets that have healthchecks enabled
name
array
Filter by zone names (can pass multiple values)
order_by
string
Field name to sort by
order_direction
string
Sort order: asc or desc

Get Zone

Retrieve detailed information about a specific zone.
ctx := context.Background()

zone, err := client.DNS.Zones.Get(ctx, "example.com")
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Zone: %s\n", zone.Name)
fmt.Printf("Enabled: %v\n", zone.Enabled)
fmt.Printf("DNSSEC: %v\n", zone.DnssecEnabled)
fmt.Printf("Total records: %d\n", zone.RrsetsAmount.Total)

Path Parameters

name
string
required
Zone name (e.g., “example.com”)

Update Zone

Update zone configuration and SOA record.
ctx := context.Background()

zone, err := client.DNS.Zones.Replace(ctx, "example.com", dns.ZoneReplaceParams{
    Name: gcore.F("example.com"),
    Contact: gcore.F("[email protected]"),
    Enabled: gcore.F(true),
    Refresh: gcore.F(int64(7200)),
    Retry: gcore.F(int64(1800)),
    Expiry: gcore.F(int64(1209600)),
    NxTtl: gcore.F(int64(600)),
})
if err != nil {
    log.Fatal(err)
}

Path Parameters

name
string
required
Zone name to update

Delete Zone

Delete a DNS zone and all its records.
ctx := context.Background()

err := client.DNS.Zones.Delete(ctx, "example.com")
if err != nil {
    log.Fatal(err)
}

fmt.Println("Zone deleted successfully")

Path Parameters

name
string
required
Zone name to delete

Enable/Disable Zone

Enable or disable DNS resolution for a zone.
ctx := context.Background()

err := client.DNS.Zones.Enable(ctx, "example.com")
if err != nil {
    log.Fatal(err)
}

Check Delegation Status

Verify if a domain is properly delegated to Gcore name servers. This endpoint is rate-limited.
ctx := context.Background()

status, err := client.DNS.Zones.CheckDelegationStatus(ctx, "example.com")
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Zone exists: %v\n", status.ZoneExists)
fmt.Printf("Gcore authorized: %d\n", status.GcoreAuthorizedCount)
fmt.Printf("Non-Gcore authorized: %d\n", status.NonGcoreAuthorizedCount)
fmt.Printf("Whitelabel delegation: %v\n", status.IsWhitelabelDelegation)

Get Zone Statistics

Retrieve DNS query statistics for a zone. Use all as the zone name to get statistics for all zones.
ctx := context.Background()

stats, err := client.DNS.Zones.GetStatistics(ctx, "example.com", dns.ZoneGetStatisticsParams{
    From: gcore.F(int64(1709068637)),
    To: gcore.F(int64(1709673437)),
    Granularity: gcore.F("1h"),
    RecordType: gcore.F("A"),
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Total requests: %d\n", stats.Total)

Query Parameters

from
integer
Beginning of time period (Unix timestamp, UTC)
to
integer
End of time period (Unix timestamp, UTC)
granularity
string
Time interval granularity (e.g., “5m”, “1h”, “1d”). Valid units: s, m, h
record_type
string
Filter by DNS record type: A, AAAA, NS, CNAME, MX, TXT, SVCB, HTTPS
Statistics are updated in near real-time, typically within 30 minutes.

Import Zone

Import DNS records in BIND9 format.
ctx := context.Background()

bindZoneFile := `
$TTL 3600
@   IN  SOA ns1.example.com. admin.example.com. (
        2024010101 ; serial
        10800      ; refresh
        3600       ; retry
        604800     ; expire
        300 )      ; minimum

    IN  NS  ns1.example.com.
    IN  NS  ns2.example.com.
    IN  A   192.0.2.1
www IN  A   192.0.2.2
`

result, err := client.DNS.Zones.Import(ctx, "example.com", dns.ZoneImportParams{
    Body: bindZoneFile,
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Success: %v\n", result.Success)
fmt.Printf("Imported RRsets: %d\n", result.Imported.Rrsets)
fmt.Printf("Resource records: %d\n", result.Imported.ResourceRecords)

Export Zone

Export zone records in BIND9 format.
ctx := context.Background()

export, err := client.DNS.Zones.Export(ctx, "example.com")
if err != nil {
    log.Fatal(err)
}

fmt.Println(export.RawZone)

DNSSEC Management

Enable DNSSEC

Enable DNSSEC for a DNS zone and retrieve DS records.
ctx := context.Background()

response, err := client.DNS.Zones.Dnssec.Update(ctx, "example.com", dns.ZoneDnssecUpdateParams{
    Enabled: gcore.F(true),
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("DS Record: %s\n", response.Ds)
fmt.Printf("Algorithm: %s\n", response.Algorithm)
fmt.Printf("Key Tag: %d\n", response.KeyTag)

Get DNSSEC Information

Retrieve DNSSEC DS records for a zone.
ctx := context.Background()

dnssec, err := client.DNS.Zones.Dnssec.Get(ctx, "example.com")
if err != nil {
    log.Fatal(err)
}

fmt.Printf("DS Record: %s\n", dnssec.Ds)

Disable DNSSEC

ctx := context.Background()

err := client.DNS.Zones.Dnssec.Update(ctx, "example.com", dns.ZoneDnssecUpdateParams{
    Enabled: gcore.F(false),
})
if err != nil {
    log.Fatal(err)
}

Build docs developers (and LLMs) love