Guardrails
Domain authority checker API guardrails for prompt-built tools
You will not read every line the assistant wrote, so put the safety where you can see it: the balance, the call count and one list of rules you paste into every prompt.

What actually caps your risk
The prepaid balance is your ceiling
Credit is prepaid, there is no subscription and no overage bill. When it runs out you get HTTP 402 and the calls stop. The worst case is the money you chose to top up, not a surprise invoice.
- $100 free credit equals 1,000,000 credits
- A 2-credit call costs $0.0002
- Free actions never touch the balance
Severity table: what to fix first
| Issue | Severity | Threshold to act | Remedy |
|---|---|---|---|
| Key visible in page source | Critical | Any | Move paid calls to a server or n8n, rotate the key |
| Retry with no cap | High | More than 2 tries | Cap retries, then alert |
| Loop over rows with one call each | High | More than 20 calls per click | Use bulk_dr or compare |
| No daily call counter | Medium | Above 500 calls a day | Add a counter and a stop |
| Pagination left on | Medium | More than 5 pages | Set per and page by hand |
| No date on results | Low | Any | Show the month of the data |
Where the key should live
Free actions need no key, so a purely browser-based DR box has nothing to hide. That is the safest tool you can build.
CORS is open on the API, which is convenient for testing and also means any web page can call it. A key written into a page is a key given to every visitor, who can copy it from the source in seconds.
For paid actions use a server function, an n8n credential or Apps Script properties. All three keep the key out of the page, and all three take one sentence to ask an assistant for.

Inputs you did not write need checking too
Most guardrail talk is about spend. The other half is what the tool sends to the API, and that often comes from a list someone else typed or pasted.
A domain column is the usual source. It may hold a path, a stray space or a line of text that is not a domain at all.
Clean every domain before the call
Strip the protocol, any path and the surrounding spaces, then drop empty rows. Ask the assistant to put this in its own function, so the cleaning lives in one visible place.
A clean list also keeps the row count honest, which makes the rows-in and rows-out check much easier to read.
Accept only domain-shaped text
A simple pattern check can reject anything with a space, a quote mark or a slash before the request is made. Picture a pasted cell that holds a sentence instead of a domain. The check stops it at the door and turns it into a row that says rejected.
Rejected rows are cheap. Sending them is not.
Keep user text out of the action and the path
Never build a request in a way that lets an input change the action or the path. The action name comes from the code, and only the domain value comes from the sheet.
That separation stops a stray cell from turning a checker into a different tool. It is one sentence to ask for, and it is easy to check by reading the request line.
A quick test is to paste a line of plain text into the sheet and confirm that it never produces a request.
Log the input next to the cost
Write the cleaned domain on the same log line as the _credits value. When a bill jumps, you can see which input caused it instead of guessing from the total.
Without that pairing, a cost spike looks like a mystery, and mysteries get fixed by rewriting code rather than by reading the log.
Keep those log lines for at least a month, so a pattern has time to show.
The stop prompt
Paste this at the end of any request that touches a paid action.
Rules for this code:
1. The API key is read from an environment variable, never written in code or in the page.
2. Never retry automatically more than 2 times.
3. Count calls in a variable and stop at 500 per day.
4. Use bulk_dr or compare when more than one domain is needed.
5. If the response has ok: false, show the error and stop.
6. Log the _credits field after every call.A thought experiment with real prices
Say a loop goes wrong and fires refdomains at 2 credits each, with no stop. At $0.0002 a call, the free $100 credit would take 500,000 calls to drain.
That sounds like a lot until you realise a tight loop can do thousands of calls a minute. The example is hypothetical, but it is why the daily counter matters more than any dashboard.
Every authenticated response includes _credits, with the cost and the balance left. Ask the assistant to print it. Watching that one field is the cheapest alarm you can build.

Limits that live in code, not in the prompt
A domain authority checker API built by prompting gets its rules from the prompt on day one. Prompts only shape the first draft. After that, the rules hold only if the code enforces them.
Four limits cover most of the risk, and each one is short enough to read in a minute.
A stop prompt is a request, not a fence
The rules in the stop prompt shape the first draft. Later, the assistant may edit the code again and drop a rule without saying so. Ask for the limits as named constants at the top of the file, so every later edit has to pass them.
Constants also make a review fast. You search for one word and see every place the limit is used.
Count calls where the code can see them
A counter held in a plain variable resets when the page reloads, so a daily limit needs a place that survives. Keep it in the sheet, in n8n or in the script properties. The place matters less than the rule that the tool reads the count before every paid call.
If the count is not visible on screen, add it. A small number in the corner beats a limit nobody can see.
A limit typed into a shared sheet cell is easy to read and just as easy to overwrite, so protect that cell if others can edit the file.
Write the count and the limit on the same line, so a glance tells you how close the tool is to stopping.
Keep the action list short
A tool that needs one action should not carry the whole list. Remove the unused calls from the code instead of leaving them behind a switch. Fewer actions mean fewer paths for a loop to take.
A short list also makes the review easier, because the diff shows what changed and nothing else.
Stop when the balance runs out
A 402 response should end the run, not start a new one. Ask the tool to show the balance it last saw and to refuse further paid calls until someone reads that balance again.
Free actions can keep running, so the page still works for visitors while the paid part waits.
Write the stop message into the prompt too, with the exact words the user should see. A stop that explains itself is easier to trust, and it points the next person to the balance page.
A short message that names the balance and the date is more useful than a generic error, because it tells the next person what to do.
Ten-second review before you share the tool
- Search the code for sk_ and make sure no key appears
- Check that retries have a number next to them
- Confirm paid actions are not called on page load
- Run three domains and read the _credits balance after each
- Write the month of the data on the output
Sharing the tool with someone else
The moment a second person uses your tool, the key question changes. Whose balance pays?
The simplest answer is to give each person their own account and key, because sign-in is a Google account. Then a runaway loop in someone else's copy never touches yours, and you can tell them to read the stop prompt above before they paste anything into their own assistant.
Tell them the balance is theirs to top up, and that the stop prompt is part of the handover. A person who knows where the limit sits is far less likely to lift it by accident.
A safe rollout for a shared tool
- 1
Run three domains on your own key
Use the same three domains as in the troubleshooting page and read _credits after each call. Nothing goes to a second person until those three rows look right.
- 2
Check the balance before and after
Note the balance, run the tool once on a short list and note it again. The gap should match the number of calls times the price in the cost table.
- 3
Hand over a copy with the limits set
Set the daily limit in the copy you share before anyone else touches it, so the next user inherits the rule instead of having to remember it.
- 4
Read the first week of logs together
Look for repeats. Any log line that appears more often than your list is long deserves a question before the tool goes wider.
- 5
Write the limits into the copy
Name each limit, its number and the place in the file where it sits. Someone who opens the copy in a month should not need the chat history to know what the tool may spend.
What this does not cover
We do not publish a per-second request limit here, so pace your own tool anyway. A short pause between chunks is a cheap habit.
For help reading a failing response, use the troubleshooting table. For per-run prices, see the cost table, and for a worked first build see the n8n post-mortem.