Custom Domains

A CustomDomain object represents an additional customer-owned domain that routes to a Files.com site.

List Custom Domains

SDK Method

CustomDomain.list()

Return Object

CustomDomain[]

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Additional Arguments

Example Request

import CustomDomain from 'files.com/lib/models/CustomDomain';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const customDomains = await CustomDomain.list();
  for (const customDomain of customDomains) {
    // Operate on customDomain
  }
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Show Custom Domain

SDK Method

CustomDomain.find()

Return Object

CustomDomain

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
id
int64
Required
Custom Domain ID.

Example Request

import CustomDomain from 'files.com/lib/models/CustomDomain';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const customDomain = await CustomDomain.find(id);
  // Operate on customDomain
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Create Custom Domain

SDK Method

CustomDomain.create()

Return Object

CustomDomain

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDefaultDescription
destination
string
"site_alias"Where this custom domain routes. Can be site_alias, public_hosting, s3_endpoint, or unassigned (not routing traffic). Set to unassigned automatically when a bound public_hosting folder behavior is deleted, and can be set manually via the API for any reason.
Possible values: site_alias, public_hosting, s3_endpoint, unassigned
folder_behavior_id
int64
Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior. Preserved as historical context when destination becomes unassigned.
ssl_certificate_id
int64
Current SSL certificate ID.
domain
string
Required
Customer-owned domain name.

Example Request

import CustomDomain from 'files.com/lib/models/CustomDomain';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const customDomain = await CustomDomain.create({
    domain: "files.example.com",
  });
  // Operate on customDomain
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Update Custom Domain

SDK Method

customDomain.update()

Return Object

CustomDomain

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
destination
string
Where this custom domain routes. Can be site_alias, public_hosting, s3_endpoint, or unassigned (not routing traffic). Set to unassigned automatically when a bound public_hosting folder behavior is deleted, and can be set manually via the API for any reason.
Possible values: site_alias, public_hosting, s3_endpoint, unassigned
folder_behavior_id
int64
Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior. Preserved as historical context when destination becomes unassigned.
ssl_certificate_id
int64
Current SSL certificate ID.
domain
string
Customer-owned domain name.

Example Request

import CustomDomain from 'files.com/lib/models/CustomDomain';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the customDomain object by its id.
  const customDomain = await CustomDomain.find(id);
  await customDomain.update({
    destination: "site_alias",
  });
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Delete Custom Domain

SDK Method

customDomain.delete()

Return Object

No return value.

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Example Request

import CustomDomain from 'files.com/lib/models/CustomDomain';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the customDomain object by its id.
  const customDomain = await CustomDomain.find(id);
  await customDomain.delete();
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

The CustomDomain Object

Some of the methods above return a CustomDomain object. The attributes of this object are listed below.

AttributeDescription
id
int64
Custom Domain ID.
domain
string
Customer-owned domain name.
destination
string
Where this custom domain routes. Can be site_alias, public_hosting, s3_endpoint, or unassigned (not routing traffic). Set to unassigned automatically when a bound public_hosting folder behavior is deleted, and can be set manually via the API for any reason.
Possible values: site_alias, public_hosting, s3_endpoint, unassigned
dns_status
string
Current DNS verification status.
Possible values: disabled, correct, no_records, cname_wrong, a_record, caa_conflict
ssl_certificate_id
int64
Current SSL certificate ID.
brick_managed
boolean
Is this domain's SSL certificate automatically managed and renewed by Files.com?
folder_behavior_id
int64
Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior. Preserved as historical context when destination becomes unassigned.
created_at
date-time
When this Custom Domain was created.
updated_at
date-time
When this Custom Domain was last updated.