API Key IP Allowlist
Choose which IP addresses can use each API key.
An IP allowlist limits where an API key can be used. Each key has its own list. An empty list allows requests from any IP address.
You can add up to 100 IPv4 or IPv6 addresses or CIDR networks. Use the public outbound IP of the server that calls MachGen. If it uses a proxy or NAT, use that service's public outbound IP. Example addresses below are placeholders; replace them with your own.
Set allowed IPs on the website
- Open Profile -> API Keys.
- In the key's IP allowlist column, click + to add an address or network.
- Edit the inputs or use the trash icon to remove entries, then click Save.
Changes apply to subsequent requests immediately. Requests from other IPs receive
403 Forbidden. To allow any IP again, remove every entry and save.
Update the list with curl
PUT /api/v0/api-keys/{key_id}/ip-allowlist replaces the entire list. To add an
IP, include both the existing entries you want to keep and the new entry.
You can only update active keys that belong to your account.
Copy the key ID from the API Keys page, or find it with
GET /api/v0/api-keys. The list response includes each key's ip_allowlist.
export MACHGEN_API_KEY='YOUR_API_KEY'
export KEY_ID='KEY_ID_TO_UPDATE'
curl --request PUT \
"https://api.machgen.ai/api/v0/api-keys/${KEY_ID}/ip-allowlist" \
--header "Authorization: Bearer ${MACHGEN_API_KEY}" \
--header "Content-Type: application/json" \
--data '{
"ip_allowlist": [
"203.0.113.10",
"198.51.100.0/24",
"2001:db8::/32"
]
}'The response contains the key's details and saved ip_allowlist. Duplicate entries
are removed and networks are returned in their canonical form.
To remove all IP restrictions:
curl --request PUT \
"https://api.machgen.ai/api/v0/api-keys/${KEY_ID}/ip-allowlist" \
--header "Authorization: Bearer ${MACHGEN_API_KEY}" \
--header "Content-Type: application/json" \
--data '{"ip_allowlist": []}'If you use the key being updated to authenticate, your current IP must be allowed by its existing list. Requests to generate or check tasks still use the same API key; you do not send the allowlist with each request.
Fix a blocked request
If your IP changes or you save the wrong address, sign in to the website and correct the list on the API Keys page. A key's IP restrictions do not prevent you from editing it through your signed-in browser.
| Status | What to check |
|---|---|
401 Unauthorized | The API key is missing, invalid, or revoked. |
403 Forbidden with Source IP is not allowed for this API key | The calling server's public outbound IP is outside the authenticating key's list. |
404 Not Found with Active API key not found | The key being edited does not exist, is revoked, or belongs to another account. |
422 Unprocessable Entity | An entry is not a valid IP address or network, or the list exceeds 100 entries. The saved list is unchanged. |