# Cloudflare

> Check names, register domains, set DNS records, and put a built site online on your own Cloudflare. Registering, DNS changes and deploys wait for your Approve.

Cloudflare Registrar is a domain registrar, and Cloudflare runs the DNS for the domains registered there. Once you connect it, your assistants can check whether a name is free, list the domains you own, register a new one, and point a domain at your site with DNS records. Registering a domain and every DNS change stop at your Approve.

On StellarFirm web, the same connection also lets the Coder put a finished site online on your own Cloudflare account. See [Putting a site online](#putting-a-site-online).

## Which assistants use it

| Assistant | What it does with Cloudflare |
| --- | --- |
| [Product owner](/docs/personas/product-owner) | Checks names and registers a domain |
| [Coder](/docs/personas/coder) | Points a domain at your site, and registers one when your company has no Product owner. On StellarFirm web, it also puts a built site online on your Cloudflare |

When your company has a Product owner, it is the one that registers domains. Changing DNS records is always the Coder's job.

## What assistants can do

| Ability | How it runs |
| --- | --- |
| Check whether a name is free | Reads on its own |
| List the domains in your Cloudflare account | Reads on its own |
| Register a domain | Always waits for your Approve |
| Set DNS records, such as pointing the domain at your site | Always waits for your Approve |
| Change the nameservers | Not possible: Cloudflare keeps every domain it registers on its own nameservers |

## Setup

1. In Cloudflare, open My Profile, then API Tokens, and create a token for your account. Give it Registrar write, Zone read, and DNS edit.
2. Copy the token. Also copy your account id from the account's overview page. The account id is not a secret.
3. Check that your Cloudflare account has a billing profile with a payment method, a default registrant contact, and the Domain Registration Agreement accepted in the dashboard. Cloudflare charges the payment method for a registration.
4. Open [Integrations](https://stellarfirm.ai/app/integrations) in StellarFirm and pick Cloudflare.
5. Paste the token and the account id, turn on live Cloudflare, and press Connect.
6. Save your company's registrant contact in [Settings, Auto-approve](https://stellarfirm.ai/app/settings/auto-approve). It is who the domain is registered to.

## Permissions

- Listing your domains and checking names happen on their own.
- Registering a domain always waits for your Approve. The request shows what Cloudflare charges now and for each renewal year, and names the registrant contact that will be used. A name check only says whether a name is free.
- Setting DNS records always waits for your Approve, and the request lists exactly what will change.
- No Auto-approve choice in Settings skips these. See [approvals](/docs/ceo/approvals).

## Good to know

- Cloudflare registers only some endings through its Registrar API, and it does not register premium names this way. If Cloudflare turns a name down, the assistant tells you why. Register those names with another registrar, such as [Porkbun](/docs/integrations/porkbun) or [Name.com](/docs/integrations/namecom).
- Cloudflare does not let a domain it registers use other nameservers, so the assistants change DNS records and never the nameservers. To use other nameservers, register the domain with another registrar.
- A DNS change replaces the records that have the same type and name, and leaves every other record alone. Address and alias records are set to DNS only, so they answer with exactly what you approved.
- Just before it registers, the assistant asks Cloudflare again. If the name was taken, or Cloudflare now asks for more than you approved, nothing is registered and the assistant tells you why.
- To use other registrant details for one domain, reply with them before you approve. The assistant posts a new request with those details.
- To cut access, delete the token in Cloudflare.

## Putting a site online

On StellarFirm web the Coder can put a folder of built files online on your own Cloudflare account. The site runs on your account and under your Cloudflare plan, at an address ending in `workers.dev`. Nothing is built on Cloudflare: you and the Coder work on the site together on the Coder's computer, and the Coder puts the finished files online once you approve.

| Ability | How it runs |
| --- | --- |
| List the Workers in your account and their latest versions | Reads on its own |
| Put a folder of built files online | Always waits for your Approve |

### Setup

1. Make the token for the domains steps above, or a new one. For putting a site online it needs **Workers Scripts: Edit** on your account.
2. Your account needs a workers.dev address. If you never chose one, open **Workers & Pages** in Cloudflare and pick one. It is your account's name on workers.dev, so the choice is yours.
3. Open [Integrations](https://stellarfirm.ai/app/integrations) in StellarFirm, pick Cloudflare, paste the token and the account id, turn on live Cloudflare, and press Connect.
4. StellarFirm checks the token with Cloudflare when you press Connect. A token Cloudflare does not accept, or an account id that does not go with it, is not saved.

Only the CEO can connect or remove Cloudflare.

### How putting a site online goes

1. The site is built first on the Coder's computer, for example with `npm run build`, so that its folder, such as `dist`, has an `index.html` at its root and no `package.json`.
2. The Coder asks to put that folder online under a name. The request names the folder, the name, and the address, and says that everything in the folder except hidden files becomes public. You approve it.
3. StellarFirm reads the folder from the Coder's computer, uploads it to your Cloudflare, and switches on the address `https://<name>.<your workers.dev name>.workers.dev`. The Coder gives you the address.

### Good to know

- A folder that still needs a build, or has no `index.html` at its root, is turned back with a message to build first. Nothing is uploaded.
- Everything in the folder except hidden files (names that start with a dot) and `node_modules` is uploaded and becomes public, so never put a key or a password in the site's files. A folder holds at most 2,000 files, 10 MB each and 50 MB in all.
- A site with a `404.html` shows it for an address that does not exist. Any other site answers as a single page app, with its `index.html`.
- Putting a site online again under the same name updates it. A Worker of yours that has code of its own is never replaced: the Coder is told to pick another name.
- StellarFirm never deletes anything on your Cloudflare account. To take a site down, delete it in Cloudflare under **Workers & Pages**.
- Remove on the Cloudflare page in Integrations forgets the token and the account id. To cut access for good, also delete the token in Cloudflare.

## Prompts to try

```prompt title="List our Cloudflare domains"
Coder, list the domains in our Cloudflare account and when each one expires. Read only.
```

```prompt title="Point a domain at the site"
Coder, point [name].com at our site: set the A record for @ to [address] and a CNAME for www. Show me the records before I approve.
```

```prompt title="Register a domain"
Product owner, register [name].com with Cloudflare for one year. Show me what it charges and the registrant contact before I approve.
```

```prompt title="Put the built site online"
Coder, build the site, then put the dist folder online on our Cloudflare as [name]. Wait for my Approve and give me the address when it is live.
```

```prompt title="See what is online"
Coder, list the Workers in our Cloudflare account and when each one last changed. Read only.
```

---

Source: https://stellarfirm.ai/docs/integrations/cloudflare
