fastify-xplaid
link.getToken
Get metadata for an existing Plaid Link token — useful for debugging Link configurations and verifying token parameters.
link.getToken
Retrieves raw metadata for an existing Link token. Use this to inspect token configuration, verify expiration, or confirm which products and country codes were set before sending the token to the frontend.
Signature
fastify.xplaid.link.getToken(
linkToken: string
): Promise<{
link_token: string;
created_at: string;
expiration: string;
metadata: {
initial_products: string[];
country_codes: string[];
language: string;
webhook?: string;
redirect_uri?: string;
};
}>
Params
| Name | Type | Required | Description |
|---|---|---|---|
linkToken | string | Yes | An existing Link token created by link.createToken. |
Returns
The raw Plaid LinkTokenGetResponse object.
| Field | Type | Description |
|---|---|---|
link_token | string | The link token itself. |
created_at | string | ISO 8601 creation timestamp. |
expiration | string | ISO 8601 expiration timestamp (typically 4 hours from creation). |
metadata.initial_products | string[] | Products enabled for this Link session. |
metadata.country_codes | string[] | Country codes configured for institution filtering. |
metadata.language | string | Display language for the Link UI. |
metadata.webhook | string | undefined | Webhook URL, if configured. |
metadata.redirect_uri | string | undefined | OAuth redirect URI, if configured. |
Throws
[xPlaid] linkToken is required and must be a non-empty string— whenlinkTokenis missing or empty.- Plaid API errors wrapped via
wrapPlaidError— shape:{ message, statusCode, plaidError }.
Examples
Basic — inspect a Link token
const { linkToken } = await fastify.xplaid.link.createToken({ userId: "u1" });
const info = await fastify.xplaid.link.getToken(linkToken);
fastify.log.info({ expiration: info.expiration }, "Link token expires");
Verify products before sending to client
fastify.get("/plaid/link-token-info", async (request, reply) => {
const { linkToken } = request.query;
const info = await fastify.xplaid.link.getToken(linkToken);
return {
expiration: info.expiration,
products: info.metadata.initial_products,
countryCodes: info.metadata.country_codes,
isExpired: new Date(info.expiration) < new Date(),
};
});
Debug in a test
const { linkToken } = await fastify.xplaid.link.createToken({
userId: "test_user",
products: ["auth", "transactions"],
});
const info = await fastify.xplaid.link.getToken(linkToken);
assert.deepEqual(info.metadata.initial_products, ["auth", "transactions"]);
assert.ok(new Date(info.expiration) > new Date());
See also
- link.createToken — Create the Link token to inspect.
- link.exchangePublicToken — Exchange the public token after the user completes Link.
- fastify-xplaid overview — Plugin setup and options.
AI Context
package: "@xenterprises/fastify-xplaid"
method: fastify.xplaid.link.getToken(linkToken)
use-when: Inspect metadata for an existing Link token — expiration, products, country codes, webhook URL
params: linkToken (string)
returns: { link_token, created_at, expiration, metadata: { initial_products, country_codes, language, webhook?, redirect_uri? } }
