5.9 KiB
5.9 KiB
| name | description |
|---|---|
| connect-domain | Point a domain registered or hosted at Interweb Mozambique to a Interweb Mozambique VPS, a hosting plan or an outside service, by checking the nameservers and creating the right DNS records through the Interweb Mozambique API, then checking that it works. Use when the user says "connect my domain", "point my domain to my server", "my site does not open on my domain" or wants www and the root domain to work. |
Connect a domain
A guided task that combines the manage-domains, manage-dns, manage-vps and manage-hosting skills.
Setup
- API address:
https://api.interweb.co.mz/v1. It is fixed for Interweb Mozambique: never ask the user for another address. - API key: always read it from the
INTERWEB_API_KEYenvironment variable. Check it without printing it:test -n "$INTERWEB_API_KEY" && echo set || echo missing - If it is missing, ask the user to create a key in the API Center (https://www.meu.interweb.co.mz/api-center.php) with
domains:read,dns:readanddns:write(plusvps:readorhosting:readto find the target), then to runexport INTERWEB_API_KEY="sandbox_..."and restart Claude Code (or the editor). sandbox_keys read the real account but only simulate writes and never charge.prod_keys change the account and can charge.GET /v1/tokengives the mode indata.modeand the permissions indata.permissions. Suggest asandbox_key for a first try.- Never print, log or commit the key, and never put it in code that runs in a browser or a mobile app. In code, read it from the environment.
Every request looks like this:
curl -sS "https://api.interweb.co.mz/v1/PATH" -H "Authorization: Bearer $INTERWEB_API_KEY" -H "Accept: application/json"
Rules
- Before anything that charges, deletes data or cannot be undone, tell the user exactly what will happen (with the price, when the API gives one) and wait for a clear yes.
- Send an
Idempotency-Keyheader on purchases, sends and other POST requests that accept it, and reuse the same value if you retry the same request:IDEM=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid). - Lists come in pages:
?page=1&per_page=100, andmeta.total_pagessays how many there are. - Long operations answer
202with anaction_id. Follow them withGET /v1/actions/{action_id}every 10 to 20 seconds untilstatusisdoneorfailed. - Answer the user in the language they write in, and show amounts with the currency the API returns.
Steps
- Find the domain.
GET /v1/domains/{domain}. If it is not in the account, the user changes the DNS where the domain is managed: give them the records from step 3 and stop. - Check the DNS is ours.
GET /v1/domains/{domain}/dnsand look atmeta.dns_enabled. If it isfalse, the domain uses other nameservers: either the user changes the records there, or, with their clear consent, set our nameservers with themanage-domainsskill (this moves the whole zone, including email). - Find the target.
- VPS:
GET /v1/serversand takeip(and an IPv6 address if the user has one). - Hosting plan:
GET /v1/services/{id}gives the domain of the plan. For an extra domain on the same plan, add it withPOST /v1/services/{id}/addon-domainsfirst. - Outside service: ask the user for the IP or the host name the service gave them.
- VPS:
- Plan the records and show them before changing anything:
- Root:
@A<ip>(andAAAAfor IPv6). - www:
wwwCNAMEmybusiness.co.mzorwwwA<ip>. - Existing records with the same name and type that point elsewhere will be replaced: list them and ask.
- Never touch
MX, SPFTXTor the records of the mail host unless the user asked for email changes.
- Root:
- Apply. Validate each record with
POST /v1/domains/{domain}/dns/validate, then create or update it. Keep the backupidshown inGET /v1/domains/{domain}/dns/backupsin case the user wants to undo. - Check.
dig +short mybusiness.co.mz Aanddig +short www.mybusiness.co.mz(ornslookup). It can take up to the old TTL to spread. - HTTPS. On a hosting plan, run
POST /v1/services/{id}/ssl/autosslonce the domain points there. On a VPS, the web server gets the certificate (for example Caddy does it on its own, seedeploy-to-vps).
When something fails
409cname_conflict: a CNAME cannot live next to other records with the same name. Remove or change the other record first, with the user's consent.409account_email_domain: the account login email is on this domain, so mail records are changed in Meu Interweb (https://www.meu.interweb.co.mz).- The site still does not open after DNS is right: check that the server answers on ports 80 and 443 and that the site is set up for that domain.
Errors
Errors look like {"error": {"code", "message", "correlation_id", "details"}}. Act on code, never on the text of message.
| HTTP | code | What to do |
|---|---|---|
| 401 | unauthorized |
The key is missing, wrong or revoked. Ask the user to check INTERWEB_API_KEY. |
| 402 | insufficient_credit |
Not enough account credit, and nothing was charged. Give the user details.add_funds_url. |
| 403 | insufficient_scope |
The key lacks a permission. Name it and ask for a key that has it. |
| 403 | spending_limit_exceeded |
The purchase goes over the key spending limit. Nothing was charged. |
| 404 | not_found |
Wrong id, or it is not in this account. |
| 409 | conflict and others |
Read details.reason and explain it in plain words. |
| 422 | validation_failed |
Fix the field named in details and try again. |
| 429 | rate_limited |
Wait for the Retry-After seconds, then try once more. |
| 5xx | internal_error, upstream_error |
Try again later. If the user contacts support, give them the correlation_id. |
More
- DNS: https://docs.interweb.co.mz/dns/
- Domains: https://docs.interweb.co.mz/domains/
- Servers: https://docs.interweb.co.mz/servers/
- Full reference: https://api.interweb.co.mz/v1/openapi.json