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

  • Name
    0
    Type
    integer
    Description

    No redirect

  • Name
    1
    Type
    integer
    Description

    www to non-www

  • Name
    2
    Type
    integer
    Description

    non-www to www


GET/api/v1/projects/:id/check-ns

Check 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.

Request

GET
/api/v1/projects/1/check-ns
curl https://app.depfloy.com/api/v1/projects/1/check-ns \
  -H "Authorization: Bearer {API_KEY}" \
  -H "Accept: application/json"

Response

{
  "status": "success",
  "domain": "example.com",
  "expected_ip": "203.0.113.50",
  "resolved_ip": "203.0.113.50",
  "message": "DNS records are correctly configured"
}

POST/api/v1/projects/:id/domains

Add domain

This endpoint allows you to add a domain to a project.

Attributes for adding a domain

  • Name
    domain
    Type
    string
    required
    *
    Description

    The domain name to add to the project.

Request

POST
/api/v1/projects/1/domains
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"
  }'

Response

{
  "status": "success",
  "message": "Domain added successfully",
  "domain": "example.com"
}

PUT/api/v1/projects/:id/domains

Update 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

  • Name
    domains
    Type
    array
    required
    *
    Description

    An array of domain names to configure for the project.

Optional attributes

  • Name
    www_redirect
    Type
    integer
    Description

    The WWW redirect setting for the project. 0 = no redirect, 1 = www to non-www, 2 = non-www to www

Request

PUT
/api/v1/projects/1/domains
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
  }'

Response

{
  "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"
    ]
  }
}

PUT/api/v1/projects/:id/domains/:domainId/primary

Set primary domain

This endpoint allows you to set a domain as the primary domain for a project by its ID.

Request

PUT
/api/v1/projects/:id/domains/:domainId/primary
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"

Response

{
  "status": "success",
  "message": "Primary domain updated successfully.",
  "redirect_setting": 0
}

PUT/api/v1/projects/:projectId/domains/:domainId/redirect

Update WWW redirect

This endpoint allows you to update the WWW redirect setting for a domain by its ID.

Request

PUT
/api/v1/projects/:projectId/domains/:domainId/redirect
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"

Response

{
  "status": "success",
  "message": "Redirect settings updated successfully",
  "domains": [
    // updated domains
  ]
}

DELETE/api/v1/projects/:projectId/domains/:domainId

Remove domain

This endpoint allows you to remove a domain from a project by its ID.

Request

DELETE
/api/v1/projects/:projectId/domains/:domainId
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"

Response

{
  "status": "success",
  "message": "Domain removed successfully",
}

Was this page helpful?