Server SDKs
Fetch Token
Retrieve the creative token for a registered user
The FetchToken API retrieves the creative token for a user who was previously registered.
Usage
import {
Client, UserData, FetchToken
} from "@geeklab.app/audiencelab_nodejs_sdk";
const client = new Client({
apiKey: "YOUR_API_KEY",
baseUrl: "https://analytics.geeklab.app",
});
const userData = new UserData()
.setUserId("user_12345")
.setUserIp("203.0.113.42");
const response = await new FetchToken(client, userData).send();
userData.setUserCreativeTokenInfo(response);After a successful fetch, call userData.setUserCreativeTokenInfo(response). The SDK stores creative token data, retention dates, cumulative values, and merges returned whitelisted properties with caller-set whitelisted properties.
When to Use
Use FetchToken when:
- The user was previously registered and you need to retrieve their token
- The cached token was lost or expired
- You want to verify the current token assignment
For first-time user registration (which also returns a token), use Register User instead.
RegisterUser both registers the user and returns token info. FetchToken only retrieves token info for an already-registered user.