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

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Attach PaymentMethod

> Attach a Stripe PaymentMethod to a customer.

Use `stripe.attachPaymentMethod` to attach an existing method to a customer. For future use, Stripe recommends first optimizing it with a SetupIntent or PaymentIntent.

```ts automations/stripe-attach-payment-method.automation.ts theme={null}
import { automation, onDashboardRun } from "automate.ax"
import { stripe } from "automate.ax/stripe"

export default automation("Attach PaymentMethod", () => {
  onDashboardRun({ title: "Attach PaymentMethod" })
  stripe.attachPaymentMethod({ customer: "cus_123", paymentMethodId: "pm_123" })
})
```

## Inputs

`customer` and `paymentMethodId` are required. `idempotencyKey` is optional.

## Output

Returns the attached PaymentMethod.
