There are more AWS SDK examples available in the AWS Doc SDK Examples
Use RegisterDomain
with an AWS SDK or CLI
The following code examples show how to use RegisterDomain
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:
- .NET
-
- AWS SDK for .NET
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. /// <summary> /// Initiate a domain registration request. /// </summary> /// <param name="contact">Contact details.</param> /// <param name="domainName">The domain name to register.</param> /// <param name="autoRenew">True if the domain should automatically renew.</param> /// <param name="duration">The duration in years for the domain registration.</param> /// <returns>The operation Id.</returns> public async Task<string?> RegisterDomain(string domainName, bool autoRenew, int duration, ContactDetail contact) { // This example uses the same contact information for admin, registrant, and tech contacts. try { var result = await _amazonRoute53Domains.RegisterDomainAsync( new RegisterDomainRequest() { AdminContact = contact, RegistrantContact = contact, TechContact = contact, DomainName = domainName, AutoRenew = autoRenew, DurationInYears = duration, PrivacyProtectAdminContact = false, PrivacyProtectRegistrantContact = false, PrivacyProtectTechContact = false } ); return result.OperationId; } catch (InvalidInputException) { _logger.LogInformation($"Unable to request registration for domain {domainName}"); return null; } }
-
For API details, see RegisterDomain in AWS SDK for .NET API Reference.
-
- CLI
-
- AWS CLI
-
To register a domain
The following
register-domain
command registers a domain, retrieving all parameter values from a JSON-formatted file.This command runs only in the
us-east-1
Region. If your default region is set tous-east-1
, you can omit theregion
parameter.aws route53domains register-domain \ --region
us-east-1
\ --cli-input-jsonfile://register-domain.json
Contents of
register-domain.json
:{ "DomainName": "example.com", "DurationInYears": 1, "AutoRenew": true, "AdminContact": { "FirstName": "Martha", "LastName": "Rivera", "ContactType": "PERSON", "OrganizationName": "Example", "AddressLine1": "1 Main Street", "City": "Anytown", "State": "WA", "CountryCode": "US", "ZipCode": "98101", "PhoneNumber": "+1.8005551212", "Email": "mrivera@example.com" }, "RegistrantContact": { "FirstName": "Li", "LastName": "Juan", "ContactType": "PERSON", "OrganizationName": "Example", "AddressLine1": "1 Main Street", "City": "Anytown", "State": "WA", "CountryCode": "US", "ZipCode": "98101", "PhoneNumber": "+1.8005551212", "Email": "ljuan@example.com" }, "TechContact": { "FirstName": "Mateo", "LastName": "Jackson", "ContactType": "PERSON", "OrganizationName": "Example", "AddressLine1": "1 Main Street", "City": "Anytown", "State": "WA", "CountryCode": "US", "ZipCode": "98101", "PhoneNumber": "+1.8005551212", "Email": "mjackson@example.com" }, "PrivacyProtectAdminContact": true, "PrivacyProtectRegistrantContact": true, "PrivacyProtectTechContact": true }
Output:
{ "OperationId": "b114c44a-9330-47d1-a6e8-a0b11example" }
To confirm that the operation succeeded, you can run
get-operation-detail
. For more information, see get-operation-detail .For more information, see Registering a New Domain in the Amazon Route 53 Developer Guide.
For information about which top-level domains (TLDs) require values for
ExtraParams
and what the valid values are, see ExtraParam in the Amazon Route 53 API Reference.-
For API details, see RegisterDomain
in AWS CLI Command Reference.
-
- Java
-
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. public static String requestDomainRegistration(Route53DomainsClient route53DomainsClient, String domainSuggestion, String phoneNumber, String email, String firstName, String lastName, String city) { try { ContactDetail contactDetail = ContactDetail.builder() .contactType(ContactType.COMPANY) .state("LA") .countryCode(CountryCode.IN) .email(email) .firstName(firstName) .lastName(lastName) .city(city) .phoneNumber(phoneNumber) .organizationName("My Org") .addressLine1("My Address") .zipCode("123 123") .build(); RegisterDomainRequest domainRequest = RegisterDomainRequest.builder() .adminContact(contactDetail) .registrantContact(contactDetail) .techContact(contactDetail) .domainName(domainSuggestion) .autoRenew(true) .durationInYears(1) .build(); RegisterDomainResponse response = route53DomainsClient.registerDomain(domainRequest); System.out.println("Registration requested. Operation Id: " + response.operationId()); return response.operationId(); } catch (Route53Exception e) { System.err.println(e.getMessage()); System.exit(1); } return ""; }
-
For API details, see RegisterDomain in AWS SDK for Java 2.x API Reference.
-
- Kotlin
-
- SDK for Kotlin
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. suspend fun requestDomainRegistration( domainSuggestion: String?, phoneNumberVal: String?, emailVal: String?, firstNameVal: String?, lastNameVal: String?, cityVal: String?, ): String? { val contactDetail = ContactDetail { contactType = ContactType.Company state = "LA" countryCode = CountryCode.In email = emailVal firstName = firstNameVal lastName = lastNameVal city = cityVal phoneNumber = phoneNumberVal organizationName = "My Org" addressLine1 = "My Address" zipCode = "123 123" } val domainRequest = RegisterDomainRequest { adminContact = contactDetail registrantContact = contactDetail techContact = contactDetail domainName = domainSuggestion autoRenew = true durationInYears = 1 } Route53DomainsClient { region = "us-east-1" }.use { route53DomainsClient -> val response = route53DomainsClient.registerDomain(domainRequest) println("Registration requested. Operation Id: ${response.operationId}") return response.operationId } }
-
For API details, see RegisterDomain
in AWS SDK for Kotlin API reference.
-