pydo.domains.create()

Description

To create a new domain, send a POST request to /v2/domains. Set the “name” attribute to the domain name you are adding. Optionally, you may set the “ip_address” attribute, and an A record will be automatically created pointing to the apex domain.

Request Sample

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "name": "example.com"
}

resp = client.domains.create(body=req)

Responses

See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.

The response will be a JSON object with a key called domain. The value of this will be an object that contains the standard attributes associated with a domain.

Click to expand an example response.
{
  "domain": {
    "name": "example.com",
    "ttl": 1800,
    "zone_file": null
  }
}

Unauthorized

Click to expand an example response.
{
  "id": "unauthorized",
  "message": "Unable to authenticate you."
}

API Rate limit exceeded

Click to expand an example response.
{
  "id": "too_many_requests",
  "message": "API Rate limit exceeded."
}

Server error.

Click to expand an example response.
{
  "id": "server_error",
  "message": "Unexpected server-side error"
}

Unexpected error

Click to expand an example response.
{
  "id": "example_error",
  "message": "some error message"
}