X Enterprises
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

NameTypeRequiredDescription
linkTokenstringYesAn existing Link token created by link.createToken.

Returns

The raw Plaid LinkTokenGetResponse object.

FieldTypeDescription
link_tokenstringThe link token itself.
created_atstringISO 8601 creation timestamp.
expirationstringISO 8601 expiration timestamp (typically 4 hours from creation).
metadata.initial_productsstring[]Products enabled for this Link session.
metadata.country_codesstring[]Country codes configured for institution filtering.
metadata.languagestringDisplay language for the Link UI.
metadata.webhookstring | undefinedWebhook URL, if configured.
metadata.redirect_uristring | undefinedOAuth redirect URI, if configured.

Throws

  • [xPlaid] linkToken is required and must be a non-empty string — when linkToken is missing or empty.
  • Plaid API errors wrapped via wrapPlaidError — shape: { message, statusCode, plaidError }.

Examples

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

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? } }
Copyright © 2026