Using the Grid API directly requires advanced configurations. Grid SDK is
the recommended way to authenticate accounts. It handles authentication, key
management, automatic failover, and transaction signing. Learn more about the
Grid SDK in the Grid SDK guide.
This endpoint requires an active bearer token from a previous authentication.
For initial authentication, use Initiate
Authentication followed
by Verify OTP.
How Session Refresh Works
Grid automatically handles different token expiration states:1
Case 1: Re-authentication
If the user token is still valid but the session needs refreshing, the
endpoint re-authenticates using the existing token to obtain new encrypted
credentials.
2
Case 2: Token Refresh
If the user token has expired, the endpoint uses the refresh token to
obtain a new user token, then re-authenticates to get new encrypted
credentials.
When to Use This Endpoint
Use this endpoint when:- Session credentials expire: Your authentication session has expired and you need new credentials
- Token rotation: Implementing proactive token rotation for enhanced security
- Long-running applications: Maintaining continuous access without requiring user re-authentication
Automatic Handling The endpoint automatically determines which case of
refresh to use based on the token expiration state. You don’t need to specify
which approach to use.
Required Configuration
You must provide:- kms_payload: Contains the current session information including tokens
- encryption_public_key: Your HPKE public key for encrypting new credentials
Complete Implementation Guide
For comprehensive implementation details including:- HPKE keypair generation with P-256 curve and DER formatting
- Encryption public key creation
- Authorization key decryption using ECDH + HKDF + ChaCha20-Poly1305
- Session management and token handling
- Error handling and retry strategies
Response Data
Upon successful refresh, you receive:- New session credentials: Encrypted with your public key
- Updated tokens: Fresh user token, access token, and refresh token
- Provider information: Current KMS provider details
Supported Providers
Currently supported KMS providers:- Privy: Full support for two-tier session refresh
- Turnkey: Coming soon
Error Handling
Common error scenarios:- 400 Bad Request: Invalid encryption public key or malformed payload
- 401 Unauthorized: Refresh token expired or invalid, user must re-authenticate
- 500 Internal Server Error: Service error, retry with exponential backoff
Authorizations
Your Grid API key from the Grid Dashboard