Invoke Supabase Edge Functions.
Provides a single entry point, invoke, that issues an HTTP request
to the project's /functions/v1/<name> endpoint and returns either
{:status :body :headers} or an anomaly map.
(require '[supabase.core.client :as client]
'[supabase.functions :as fns])
(def c (client/make-client "https://abc.supabase.co" "anon-key"))
(fns/invoke c "hello" {:body {:name "world"}})
;; => {:status 200, :body {:message "Hello, world!"}, :headers {...}}
The body type drives content-type:
map → application/jsonString → text/plainbyte[] → application/octet-streamFile/InputStream → caller sets content-typeA content-type already present in :headers always wins.
:response-as controls how the body is returned:
:auto — pick a decoder from the response content-type (default):json — always JSON-decode the body:text — always return a UTF-8 string:byte-array — raw byte[]:stream — java.io.InputStream (caller closes)Network failures become {:supabase/code :functions-fetch-error}.
Edge runtime relay errors (502/504) become :functions-relay-error.
404 becomes :functions-not-found. All other non-2xx responses
become :functions-http-error. The HTTP body (if any) is preserved
under :http/body.
Invoke Supabase Edge Functions.
Provides a single entry point, [[invoke]], that issues an HTTP request
to the project's `/functions/v1/<name>` endpoint and returns either
`{:status :body :headers}` or an anomaly map.
## Example
(require '[supabase.core.client :as client]
'[supabase.functions :as fns])
(def c (client/make-client "https://abc.supabase.co" "anon-key"))
(fns/invoke c "hello" {:body {:name "world"}})
;; => {:status 200, :body {:message "Hello, world!"}, :headers {...}}
## Body encoding
The body type drives `content-type`:
- `map` → `application/json`
- printable `String` → `text/plain`
- `byte[]` → `application/octet-stream`
- `File`/`InputStream` → caller sets `content-type`
A `content-type` already present in `:headers` always wins.
## Response decoding
`:response-as` controls how the body is returned:
- `:auto` — pick a decoder from the response `content-type` (default)
- `:json` — always JSON-decode the body
- `:text` — always return a UTF-8 string
- `:byte-array` — raw `byte[]`
- `:stream` — `java.io.InputStream` (caller closes)
## Errors
Network failures become `{:supabase/code :functions-fetch-error}`.
Edge runtime relay errors (502/504) become `:functions-relay-error`.
404 becomes `:functions-not-found`. All other non-2xx responses
become `:functions-http-error`. The HTTP body (if any) is preserved
under `:http/body`.(invoke client function-name)(invoke client function-name opts)Invokes the Edge Function named function-name and returns
{:status :body :headers} on success, an anomaly on failure.
:body — request body. Maps are JSON-encoded; printable
strings sent as text/plain; byte arrays as
application/octet-stream. File/InputStream
pass through (caller sets content-type).:headers — extra HTTP headers.:method — :get, :post (default), :put, :patch, :delete.:region — region keyword. :any is a no-op.:response-as — :auto (default), :json, :text, :byte-array,
:stream.:timeout — milliseconds (default 15000).:access-token — override the client's access token for this call.(invoke client "hello" {:body {:name "world"}})
(invoke client "csv" {:response-as :stream})
(invoke client "resize" {:method :get :region :us-east-1})
Invokes the Edge Function named `function-name` and returns
`{:status :body :headers}` on success, an anomaly on failure.
## Options (all optional)
- `:body` — request body. Maps are JSON-encoded; printable
strings sent as `text/plain`; byte arrays as
`application/octet-stream`. File/InputStream
pass through (caller sets `content-type`).
- `:headers` — extra HTTP headers.
- `:method` — `:get`, `:post` (default), `:put`, `:patch`, `:delete`.
- `:region` — region keyword. `:any` is a no-op.
- `:response-as` — `:auto` (default), `:json`, `:text`, `:byte-array`,
`:stream`.
- `:timeout` — milliseconds (default 15000).
- `:access-token` — override the client's access token for this call.
## Examples
(invoke client "hello" {:body {:name "world"}})
(invoke client "csv" {:response-as :stream})
(invoke client "resize" {:method :get :region :us-east-1})(update-auth client access-token)Returns a copy of client with access-token swapped in. Thin
wrapper over supabase.core.client/update-access-token.
Returns a copy of `client` with `access-token` swapped in. Thin wrapper over `supabase.core.client/update-access-token`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |