Skip to content

Webhosting API ​

This page covers the domains on a webhosting account and the PHP version of each domain. All endpoints require Bearer-token authentication. An API key needs access to Webhosting, read/write for changes. Sub-clients can read but not change domains or PHP versions. The panel side is described in Domains.

A suspended account answers every route below except GET /webhosting/{id} with 403 Hosting account is suspended. Contact support.

GET /webhosting/{id} ​

Returns the account. domains lists every domain on it, primary first:

json
{
  "data": {
    "hosting_id": 321,
    "domain": "example.com",
    "domains": [
      { "domain": "example.com", "zone_id": 966, "primary": true },
      { "domain": "example.no", "zone_id": 967, "primary": false }
    ]
  }
}

domain is the primary domain. zone_id is the domain's DNS zone, or 0 if the zone no longer exists.

Choosing the domain: ?domain= ​

Each domain has its own website folder, email and SSL certificate. Routes under /webhosting/{id}/... act on the primary domain unless you add ?domain=<name>:

bash
curl "https://api.gigahost.no/api/v0/webhosting/321/php?domain=example.no" \
  -H "Authorization: Bearer $TOKEN"

A domain that is not on the account returns 404 Domain not found on this hosting account., also on routes that are not per domain.

POST /webhosting/{id}/domains ​

Add a domain to the account. The domain must exist as a DNS zone on your account and must not be on any webhosting account already.

FieldTypeRequiredDescription
zone_idnumberYesThe domain's zone, from GET /dns/zones.
update_dnsnumberNo1 to write the website and email records into the zone. Default 0.
bash
curl -X POST https://api.gigahost.no/api/v0/webhosting/321/domains \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"zone_id": 967, "update_dns": 1}'

Returns 201 with domain, zone_id, dns_updated and records. records lists what the domain needs: A (and AAAA if the server has IPv6) for @, ftp, mail, smtp and www, an MX to mail.<domain>. with priority 10, an SPF and a DMARC TXT, and the DKIM TXT when DKIM is on.

With update_dns set and the zone on Gigahost nameservers, these records replace the existing A/AAAA records on those five names and the MX at the apex. An existing SPF record is replaced, other TXT records are kept, and an existing DMARC record is left alone. Otherwise dns_updated is false: add records at your DNS provider.

Statusmeta.message
400Missing required field: zone_id
404Domain not found or does not belong to your account.
409This domain is already on a webhosting account.
500Failed to add domain: …

PUT /webhosting/{id}/domains/{domain}/primary ​

Make a domain the primary domain. The account is listed under it and public_html points to it. Each domain keeps its own folder and email.

Returns 200 with domain. Errors: 400 This domain is already the primary domain., 500 Failed to change primary domain: …

DELETE /webhosting/{id}/domains/{domain} ​

Remove a domain from the account.

WARNING

The domain's files, mailboxes and subdomains are deleted from the server and cannot be restored. The DNS zone and its records stay as they are.

The primary domain cannot be removed: 400 The primary domain cannot be removed. Make another domain primary first. Other errors: 404 Domain not found on this hosting account., 500 Failed to remove domain: …

GET /webhosting/{id}/php ​

The PHP version of a domain and the versions it can switch to, newest first. Use ?domain= for a domain other than the primary.

json
{
  "data": {
    "php": { "current": "8.3", "versions": ["8.4", "8.3", "8.2"] }
  }
}

versions is empty when the server offers no choice.

PUT /webhosting/{id}/php ​

FieldTypeDescription
versionstringOne of versions, for example 8.3.
bash
curl -X PUT "https://api.gigahost.no/api/v0/webhosting/321/php?domain=example.no" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"version": "8.3"}'

Returns 200 with php. Errors: 400 Missing required field: version, 400 Unsupported PHP version., 500 Failed to change PHP version: …

Gigahost Docs

This site is currently in development.
Enter the password to continue.