Domains
Domains allow you to configure custom domains for your projects. You can add multiple domains, configure WWW redirects, and verify DNS settings. On this page, we will dive into the different domain endpoints you can use to manage project domains programmatically.
Domain configuration #
Each project can have multiple domains configured. The domain endpoints allow you to update domain settings and verify DNS configuration.
WWW Redirect options #
- 0 integer
-
No redirect
- 1 integer
-
www to non-www
- 2 integer
-
non-www to www
/api/v1/projects/:id/check-nsCheck NS record #
This endpoint allows you to verify that the DNS records for a project’s domain are correctly configured and pointing to the server’s IP address.
curl https://app.depfloy.com/api/v1/projects/1/check-ns \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json"{
"status": "success",
"domain": "example.com",
"expected_ip": "203.0.113.50",
"resolved_ip": "203.0.113.50",
"message": "DNS records are correctly configured"
}{
"status": "failed",
"domain": "example.com",
"expected_ip": "203.0.113.50",
"resolved_ip": "198.51.100.25",
"message": "DNS records do not point to the correct server"
}/api/v1/projects/:id/domainsAdd domain #
This endpoint allows you to add a domain to a project.
Attributes for adding a domain #
- domain string
-
The domain name to add to the project.
curl -X POST https://app.depfloy.com/api/v1/projects/1/domains \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"domain": "example.com"
}'{
"status": "success",
"message": "Domain added successfully",
"domain": "example.com"
}/api/v1/projects/:id/domainsUpdate domains #
This endpoint allows you to update the domains configured for a project. You can set multiple domains and configure WWW redirect behavior.
Required attributes #
- domains array
-
An array of domain names to configure for the project.
Optional attributes #
- www_redirect integer
-
The WWW redirect setting for the project. 0 = no redirect, 1 = www to non-www, 2 = non-www to www
curl -X PUT https://app.depfloy.com/api/v1/projects/1/domains \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"domains": ["example.com", "www.example.com"],
"www_redirect": 2
}'curl -X PUT https://app.depfloy.com/api/v1/projects/1/domains \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"domains": ["example.com"]
}'{
"status": "success",
"message": "Domains updated successfully",
"data": {
"domains": ["example.com", "www.example.com"],
"www_redirect": 2,
"primary_domain": "www.example.com"
},
"nginx_response": {
"ok": true,
"system_output": [
"[nginx] : nginx: the configuration file /etc/nginx/nginx.conf syntax is ok",
"[nginx] : nginx: configuration file /etc/nginx/nginx.conf test is successful"
]
}
}/api/v1/projects/:id/domains/:domainId/primarySet primary domain #
This endpoint allows you to set a domain as the primary domain for a project by its ID.
curl -X PUT https://app.depfloy.com/api/v1/projects/1/domains/136526/primary \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json"{
"status": "success",
"message": "Primary domain updated successfully.",
"redirect_setting": 0
}/api/v1/projects/:projectId/domains/:domainId/redirectUpdate WWW redirect #
This endpoint allows you to update the WWW redirect setting for a domain by its ID.
curl -X PUT https://app.depfloy.com/api/v1/projects/14532/domains/136526/redirect \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json"{
"status": "success",
"message": "Redirect settings updated successfully",
"domains": [
// updated domains
]
}/api/v1/projects/:projectId/domains/:domainIdRemove domain #
This endpoint allows you to remove a domain from a project by its ID.
curl -X DELETE https://app.depfloy.com/api/v1/projects/14532/domains/136526 \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json"{
"status": "success",
"message": "Domain removed successfully",
}