Server-side calls without request headers?
Hi, I was wondering if there’s a way to create users, send invitations, etc. purely from the server side, without having to pass through the request context or headers to the authClient.api.* functions. For example, is there a way to create an auth client that has a server secret token baked in or some other means of authentication that's baked into the client? 
Right now, if I want to build something like a generic user-invitation service, it feels awkward to either (a) not have the request handy, or (b) thread headers all the way down through multiple layers of my app just so I can call Better Auth in cases where, perhaps user invitations are sent as part of a larger complex workflow.
What I’d really like is a way to make these kinds of trusted, server-initiated calls on behalf of the application itself (not tied to a logged-in user).
Is there a supported way to do this in Better Auth?
4 Replies
Did you found a way?
Plugins | Better Auth
Learn how to use plugins with Better Auth.
Not sure if i 100% get what you mean. Using auth.api.foo calls the function, doesnt make an api request
here's my solution that I found: