Skip to content

Using the SDK and REST API

To execute actions on delegated wallets directly from your server, you can use Privy's NodeJS Server SDK or by making requests to Privy's REST API directly. Follow the instructions below to configure your desired integration.

Using the SDK

If your server is a NodeJS environment, you can integrate the @privy-io/server-auth library to use delegated actions.

To use @privy-io/server-auth, first install the library:

sh
npm install @privy-io/server-auth@latest

Then, import the PrivyClient class and create an instance of it. As parameters to the PrivyClient's constructor, pass your Privy app ID and app secret as strings.

tsx
import { PrivyClient } from '@privy-io/server-auth';

...

const privy = new PrivyClient('insert-your-app-id', 'insert-your-app-secret', {
  walletApi: {
    authorizationPrivateKey: 'wallet-auth:insert-your-authorization-key-from-the-dashboard'
  }
});

If you have also enabled an authorization key for your wallets in the Dashboard, pass the key to the constructor as illustrated above.

Using the REST API

You can also use Privy's REST API directly to take actions with delegated wallets. When requesting the REST API directly, you must set certain headers on your requests.

Authorization

Include a basic auth Authorization header with your Privy app ID as the username and your app secret as the password. The header is the base64-encoding of <privy-app-id>:<privy-app-secret>.

This header is required on all requests.

privy-app-id

Include a privy-app-id header with your Privy app ID.

This header is required on all requests.

privy-authorization-signature

If your app has registered authorization keys, when creating, modifying, or using wallets, you must sign your requests with your authorization key.

Follow the authorization signatures guide to correctly sign your requests to these endpoints with your authorization key. Include the computed authorization signature as a privy-authorization-signature header on requests.

If your app does not have a authorization key enabled, authorization signatures are not required.

Follow the guide below to set up your environment to execute actions with wallets from your server.