X Enterprises
fastify-xplaid

xplaid.items.remove

Permanently remove a Plaid Item and invalidate its access token, revoking all access to the connected bank account.

xplaid.items.remove

Permanently removes the Plaid Item and invalidates its access token. This action is irreversible — the user must complete the full Plaid Link flow to reconnect.

Signature

fastify.xplaid.items.remove(
  accessToken: string
): Promise<{ requestId: string }>

Params

NameTypeRequiredDescription
accessTokenstringYesThe access token for the Item to remove.

Returns

Promise<{ requestId: string }> — confirmation only; the access token is immediately invalidated.

Throws

  • [xPlaid] accessToken is required and must be a non-empty string
  • Plaid API errors — shape: { message, statusCode, plaidError }.

Examples

Basic

await fastify.xplaid.items.remove(accessToken);
// accessToken is now invalid — delete it from your database

Realistic

fastify.delete("/plaid/disconnect", async (request, reply) => {
  const record = await db.plaidItems.findFirst({ where: { userId: request.user.id } });
  if (!record) return reply.status(404).send({ error: "No linked account" });

  try {
    await fastify.xplaid.items.remove(decrypt(record.accessToken));
  } catch (error) {
    if (error.plaidError) {
      request.log.warn({ code: error.plaidError.error_code }, "Plaid remove failed — still deleting local record");
    } else {
      throw error;
    }
  }

  // Delete even if Plaid reports an error — the token is stale regardless
  await db.plaidItems.delete({ where: { id: record.id } });
  return reply.code(204).send();
});

See also


AI Context

package: "@xenterprises/fastify-xplaid"
method: fastify.xplaid.items.remove(accessToken)
use-when: Permanently revoke a Plaid Item's access token and disconnect the bank account
returns: { requestId }
Copyright © 2026