Skip to main content

Overview

This setup is particularly useful for handling scenarios where direct authenticated requests are not feasible, such as during onboarding flows or when additional server-side processing is required before reaching Turnkey’s backend.

Initialize

Here’s how you can initialize the TurnkeyClient with a proxy server URL:
This initializer configures the TurnkeyClient to route all requests through the specified proxy server. The proxy server is then responsible for forwarding these requests to a backend capable of authenticating them using an API private key. After authentication, the proxy server forwards the requests to Turnkey’s backend and relays the response back to the client. This setup is especially useful for operations like:

Request Header

The middleware adds an X-Turnkey-Request-Url header to each request, which contains the original request URL. This is used to forward the request to Turnkey’s backend. Example implementation of a Node.js proxy server:

Response Matching

It is crucial that the response from the developer’s backend matches exactly with what would be expected from Turnkey’s backend. Any discrepancy in the response format or data can cause the request to fail.

Conclusion

While ProxyMiddleware is not required, it provides a convenient way to send requests on behalf of unauthenticated users looking to perform operations such as email authentication, wallet import/export, and sub-organization creation.