Skip to main content
Backend scripts can call external APIs with http.get(), http.post() and http.patch(). They are on for every brand. Requests to private or internal addresses are blocked. To send an API key, save it as a secret and put env.secret.NAME in a header. Never paste keys into the script itself.

http.get(url, headers?)

Make an HTTP GET request.

http.post(url, body, headers?)

Make an HTTP POST request.

http.patch(url, body, headers?)

Same as http.post, with the PATCH method.

Response object

Every http.* call returns an object:
The body is always a string, so binary answers (a raw mp3 or image) do not come through intact. Use an endpoint that returns JSON, for example one with base64 audio inside. To work with JSON APIs, parse the body:

Limits

Security

  • Private and internal addresses are blocked: localhost, 10.x.x.x, 172.16-31.x.x, 192.168.x.x, 169.254.x.x and cloud metadata endpoints, including hostnames that resolve to them.
  • Only http:// and https:// URLs are allowed. Redirects are not followed.
  • Secrets are sent only over https, in headers, to their allowed hosts.

Example: external auth check