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
| Name | Type | Required | Description |
|---|---|---|---|
accessToken | string | Yes | The 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
- items.get — Check Item status before removing.
- link.createToken — Re-initiate the Link flow after removal.
- sandbox.resetItem — Reset an Item's login state in sandbox testing.
- fastify-xplaid overview — Plugin setup and options.
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 }
