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

# Detach a Payment Method

> Remove um método de pagamento salvo do customer.

Desanexa um `payment_method` do customer informado. A credencial salva não é
apagada; ela deixa de ser o método padrão do customer.

<ParamField path="id" type="string" required>
  ID do payment method (`pm_*`).
</ParamField>

<ParamField body="customer" type="string">
  Customer usado como contexto. Obrigatório quando o método estiver associado a mais de um customer acessível.
</ParamField>

<RequestExample>
  ```bash cURL theme={}
  curl -X POST "https://api.chargefy.io/v1/payment-methods/pm_123/detach" \
    -H "Authorization: Bearer {{API_KEY}}"
  ```
</RequestExample>

## Resposta

`200 OK` com o objeto `payment_method` — mesmo shape de [GET /v1/payment-methods/:id](/api-reference/payment-methods/get) — com `customer: null` indicando que o método não está mais anexado ao customer informado.

<ResponseExample>
  ```json 200 theme={}
  {
    "id": "pm_123",
    "object": "payment_method",
    "billing_details": {
      "address": null,
      "email": "cliente@email.com",
      "name": "Ana Silva",
      "phone": null
    },
    "card": {
      "brand": "visa",
      "exp_month": 12,
      "exp_year": 2030,
      "last4": "4242"
    },
    "created_at": "2026-05-16T18:30:00Z",
    "customer": null,
    "livemode": true,
    "metadata": {},
    "type": "credit_card",
    "updated_at": "2026-05-16T18:50:00Z"
  }
  ```

  ```json 400 theme={}
  {
    "error": {
      "code": "invalid_request",
      "message": "customer is required when payment method is attached to multiple customers.",
      "param": "customer",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={}
  {
    "error": {
      "code": "authentication_failed",
      "message": "Invalid API key provided.",
      "type": "authentication_error"
    }
  }
  ```

  ```json 404 theme={}
  {
    "error": {
      "code": "resource_missing",
      "message": "Payment method not found.",
      "type": "invalid_request_error"
    }
  }
  ```
</ResponseExample>
