> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crossmint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Remove Cards

> Remove saved cards, delete agents, and rotate agent cards.

## Introduction

This page covers the independent lifecycle operations for the cards flow. Pick the section that matches what you need to do — each operation is self-contained.

| If you need to…                                              | See                                           |
| ------------------------------------------------------------ | --------------------------------------------- |
| Stop a saved card from being used for any future agent cards | [Remove a saved card](#remove-a-saved-card)   |
| Cut off an agent's ability to create new agent cards         | [Delete an agent](#delete-an-agent)           |
| Immediately invalidate a single active agent card            | [Revoke an agent card](#revoke-an-agent-card) |
| Replace an agent card whose credentials may be compromised   | [Rotate an agent card](#rotate-an-agent-card) |

## Prerequisites

* An authenticated user with a valid JWT.
* The ID of the resource you want to modify (`paymentMethodId` for a card, `agentId` for an agent).

## Remove a Saved Card

Send a `DELETE` request with the `paymentMethodId`. The card can no longer be used to create new agent cards.

```typescript theme={null}
const BASE_URL = "https://staging.crossmint.com/api/unstable";

async function removePaymentMethod(jwt: string, paymentMethodId: string) {
    const response = await fetch(
        `${BASE_URL}/payment-methods/${paymentMethodId}`,
        {
            method: "DELETE",
            headers: {
                "Content-Type": "application/json",
                "X-API-KEY": CROSSMINT_CLIENT_API_KEY,
                Authorization: `Bearer ${jwt}`,
            },
        }
    );

    if (!response.ok) {
        throw new Error(`Failed to remove payment method (${response.status})`);
    }
}
```

<Note>
  Removing a saved card does **not** cancel agent cards already created against it. Active order intents keep working until their internal expiration is reached. To cut off an in-flight order intent immediately, [revoke it](#revoke-an-agent-card) or delete the agent.
</Note>

## Delete an Agent

Send a `DELETE` request with the `agentId`. The agent loses the ability to create new agent cards, and any active order intents tied to it stop working.

```typescript theme={null}
const BASE_URL = "https://staging.crossmint.com/api/unstable";

async function deleteAgent(jwt: string, agentId: string) {
    const response = await fetch(
        `${BASE_URL}/agents/${agentId}`,
        {
            method: "DELETE",
            headers: {
                "Content-Type": "application/json",
                "X-API-KEY": CROSSMINT_CLIENT_API_KEY,
                Authorization: `Bearer ${jwt}`,
            },
        }
    );

    if (!response.ok) {
        throw new Error(`Failed to delete agent (${response.status})`);
    }
}
```

<Warning>
  Deletion is permanent. To restore the agent's ability to spend, register a new agent by following [Register an Agent](/agents/payment-methods/cards/register-agent).
</Warning>

## Revoke an Agent Card

To immediately invalidate a single agent card — for example if its credentials may have been compromised — send a `DELETE` request with the `orderIntentId`. The order intent transitions to the `revoked` phase and its credentials can no longer be used for purchases.

Only order intents currently in the `active` or `requires-verification` phase can be revoked. Already-`expired` or already-`revoked` order intents return an error.

```typescript theme={null}
const BASE_URL = "https://staging.crossmint.com/api/unstable";

async function revokeOrderIntent(jwt: string, orderIntentId: string) {
    const response = await fetch(
        `${BASE_URL}/order-intents/${orderIntentId}`,
        {
            method: "DELETE",
            headers: {
                "Content-Type": "application/json",
                "X-API-KEY": CROSSMINT_CLIENT_API_KEY,
                Authorization: `Bearer ${jwt}`,
            },
        }
    );

    if (!response.ok) {
        throw new Error(`Failed to revoke order intent (${response.status})`);
    }
}
```

A successful revoke returns `204 No Content`. The underlying saved card and agent are untouched — only the targeted order intent is affected. To replace it with a new agent card, see [Rotate an agent card](#rotate-an-agent-card).

For the full schema, see the [Revoke Agent Card API Reference](/api-reference/agentic-commerce/order-intents/revoke-order-intent).

## Rotate an Agent Card

To rotate an agent card — for example if its credentials may have been compromised — revoke the old order intent and create a replacement:

1. [Revoke](#revoke-an-agent-card) the old order intent so its credentials can no longer be used.
2. Create a new order intent against the same saved card with the same (or updated) spending rules. See [Create an Agent Card](/agents/payment-methods/cards/create-agent-card).
3. Have the user authorize the new intent via passkey.
4. Use the new credentials in your checkout flow.

```typescript theme={null}
await revokeOrderIntent(jwt, oldOrderIntentId);

// Create a replacement agent card against the same payment method
const newOrderIntent = await createOrderIntent(jwt, agentId, paymentMethodId, mandates);

// If requires-verification, prompt the user for passkey authorization,
// then fetch credentials for the new card
const newCredentials = await fetchCardCredentials(jwt, newOrderIntent.orderIntentId, merchant);
```

<Note>
  To cut off an agent's access to **all** of its agent cards immediately, [delete the agent](#delete-an-agent) instead. For the full list of order intent phases — including `revoked` and `expired` — see the [Get Order Intent API Reference](/api-reference/agentic-commerce/order-intents/get-order-intent).
</Note>

## Next Steps

<CardGroup cols={2}>
  <Card title="Create an Agent Card" icon="credit-card" href="/agents/payment-methods/cards/create-agent-card">
    Set up a new scoped agent card with updated spending rules.
  </Card>

  <Card title="Register an Agent" icon="robot" href="/agents/payment-methods/cards/register-agent">
    Create a new agent after deleting one.
  </Card>
</CardGroup>
