Add a custom domain

add_custom_domain

Adds a custom domain to a site, alongside any it already has.

POST /v1/add_custom_domainScopeconfig:writeDestructive

A site can have up to 10 custom domains, and each one serves the same site alongside the others. Adding one requires a paid plan and the Manage domains permission, and is refused on a free workspace.

Pass a bare hostname. A value with http:// or https://, a path, or fewer than 4 or more than 253 characters is refused with the same messages as the Custom Domain field, and so is a Modulify address. A domain longer than 230 characters is refused with example.com is too long for the TXT record that proves you own it, so it cannot be added!, because the name of its TXT record would not fit in DNS. A hostname belongs to one site only. A domain this site already has is refused, and so is one another site in this workspace has, with that site's name in the message, so remove it there first. Any domain is refused once the site has 10.

For a root domain the www companion is added too, unless that www hostname is already on this site or on another site in this workspace, and passing www.example.com adds example.com with www.example.com as its companion. When the domain it adds, or the companion added with it, is the domain waiting on verification, that pending verification is cleared.

The answer carries the new domainId and the full domains list. Adding does not make the domain live: read the records to add with get_domain_status, then call it again once they are in place, because that call re-checks DNS and flips the domain to connected.

Every new domain needs proof that you own it before it serves the site. It is added with Verified false, and the records get_domain_status lists for it include a TXT record at _modulify-verification.<domain>. It connects once that record and the others are in place, and a domain still unverified 14 days after it was added, or after get_domain_status last checked it, is removed on its own. A domain the workspace bought on its Domains page, or one a site in this workspace had verified and gave up in the last 30 days, starts verified and needs no TXT record. Adding a domain the site already has, while it still waits on its TXT record, verifies it when the workspace bought it or the record is in place, with example.com was already on this site, and its ownership is now verified., and is refused otherwise. See The ownership record.

When a site in another workspace has the domain, as a domain or as its www companion, nothing is added yet. The answer carries domainId as null and a verification object with domain, verificationTxtName, verificationTxtValue and reason, which is in-use, and the domain becomes the site's pending verification. verificationTxtName is the full DNS name, such as _modulify-verification.example.com, while many DNS hosts expect only _modulify-verification, so the tool tells the client to say which form your host wants and never to let the zone appear twice. Add that TXT record at your DNS host, then call verify_domain, which adds the domain and moves it off the other site. Calling this again for the same domain keeps the same record, and once the other site has let the domain go, it adds the domain with that same record. Adding a domain the workspace bought on its Domains page takes it off a site in another workspace that has it, without a TXT record. See One site per domain.

When the workspace bought the domain on its Domains page and it uses Modulify's nameservers, Modulify adds those records by itself as part of this call and you add nothing, which get_domain_status shows as OwnedDomain with ManagedDns true. On such a domain, the A, AAAA, ANAME and CNAME records already at each hostname it adds are replaced, so whatever they pointed at, such as a site on another host, stops answering there. That is why the tool is marked destructive and tells the client to confirm with you first. While the registration of a domain the workspace bought is not confirmed yet, adding it, or a name under it, is refused with status 409 and example.com is still being registered, so connect it once its registration is confirmed! See Records Modulify manages.

The site keeps serving its free address and its other domains throughout. See Connect a custom domain.

Request

Call it with a POST to https://api.modulify.ai/v1/add_custom_domain, sending the inputs below as a JSON object. The token needs the config:write scope.

This method is marked destructive: it deletes or overwrites data. Check the inputs before you call it, and send an Idempotency-Key header whenever you might retry it.

curl -X POST https://api.modulify.ai/v1/add_custom_domain \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID","domain":"DOMAIN"}'

Over MCP, the same method is the add_custom_domain tool.

Inputs

Input Type Required Description
projectId string Yes The site id.
domain string Yes The bare hostname to attach, for example example.com.

Response

Every call answers with the JSON envelope of success, message, data, code and version. data holds the result described above, and on a method that returns a total, count carries it. The response headers carry the call's X-Request-Id and what is left of your per-minute budget in X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. Errors explains every status code a call can answer with.