# Attach a payment method to a customer

`POST /api/v1/customers/{id}/payment-methods`

Files a gateway payment method against the customer. Display fields are read back from the gateway, not taken from the request body.

Needs the `customers:write` scope, or a full-access key.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | required |  |

## Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | string | optional | A unique value for this operation, chosen by you. A retry with the same key and the same body returns the first response instead of running again. The same key with a different body answers 409 `idempotency_key_reused`; a key whose first request is still running answers 409 `idempotency_in_progress`. |

## Request body

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "gateway_pm_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "example": "pm_1QkAbCdEfGhIjKlM"
    },
    "set_default": {
      "type": "boolean"
    }
  },
  "required": [
    "gateway_pm_id"
  ]
}
```

## Responses

### 201

Payment method saved.

JSON Schema:

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
        },
        "customer_id": {
          "type": "string",
          "format": "uuid",
          "example": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
        },
        "gateway": {
          "type": "string",
          "example": "stripe"
        },
        "gateway_pm_id": {
          "type": "string",
          "example": "pm_1Qk..."
        },
        "brand": {
          "type": [
            "string",
            "null"
          ],
          "example": "visa"
        },
        "last4": {
          "type": [
            "string",
            "null"
          ],
          "example": "4242"
        },
        "exp_month": {
          "type": [
            "integer",
            "null"
          ]
        },
        "exp_year": {
          "type": [
            "integer",
            "null"
          ]
        },
        "is_default": {
          "type": "boolean"
        },
        "created_at": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "customer_id",
        "gateway",
        "gateway_pm_id",
        "brand",
        "last4",
        "exp_month",
        "exp_year",
        "is_default",
        "created_at"
      ]
    },
    "_agent": {
      "type": "object",
      "properties": {
        "summary": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "ok"
          ]
        },
        "next_actions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "summary",
        "status",
        "next_actions",
        "warnings"
      ]
    },
    "api_version": {
      "type": "string",
      "example": "2026-07-01"
    }
  },
  "required": [
    "data",
    "_agent",
    "api_version"
  ]
}
```
