---
title: Payment Method Update
slug: payment-method-update
description: Learn how to use the Payment Method Update endpoint to notify Recover of any changes to customer payment methods, enhancing payment recovery performance.
docTags: 
createdAt: 2024-11-20T22:35:55.860Z
---

{
  "id": "n0klWo77n5spcN-xoZe3p",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.butterpayments.com/recover/payment_method_updates",
    "servers": [
      {
        "url": "https://api.butterpayments.com/recover/payment_method_updates"
      }
    ],
    "name": "Payment Method Update",
    "description": "<p>This endpoint is used by the merchant to notify Recover of an update to a payment method for a customer. Whenever a payment method has been updated, added, or removed for any reason, that event should be forwarded to this endpoint so that it can be used as a signal to increase Recover's performance.</p>\n<p>Add field values in the boxes below to create an example payload on the right side of the screen.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "payment_method_update",
          "schema": [
            {
              "name": "customer_id",
              "kind": "required",
              "type": "string",
              "description": "The internal identifier from your subscription management platform used to designate the customer. Either customer_id or psp_customer_id must be populated.",
              "example": "11223344"
            },
            {
              "name": "psp_customer_id",
              "kind": "optional",
              "type": "string",
              "description": "The identifier used by the Payment Processor to designate the customer. Either customer_id or psp_customer_id must be populated.",
              "example": "cus_12345"
            },
            {
              "name": "payment_method_id",
              "kind": "required",
              "type": "string",
              "description": "The id from the PSP representing the payment method.",
              "example": "pm_12345"
            },
            {
              "name": "reason",
              "kind": "optional",
              "type": "string<user_added | user_removed | user_updated | network_updated>",
              "description": "What action lead to this event?",
              "example": "user_updated"
            }
          ],
          "modelRef": "#/components/schemas/payment_method_update",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "api_key_auth",
          "name": "x-api-key",
          "kind": "optional",
          "type": "apiKey",
          "description": "API key to authorize requests.",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Request Successful",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "inline_response_200",
            "schema": [
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "example": "Request submitted for processing",
                "default": "Request submitted for processing"
              },
              {
                "name": "request_id",
                "kind": "optional",
                "type": "string",
                "example": "2c941653-b229-4528-b576-70fcfd388543:49645839701979566120793328447151049151317978254208401410:000000000000",
                "default": "2c941653-b229-4528-b576-70fcfd388543:49645839701979566120793328447151049151317978254208401410:000000000000"
              }
            ],
            "modelRef": "#/components/schemas/inline_response_200",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Request Failed Validation",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "inline_response_400",
            "schema": [
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "example": "Invalid request body",
                "default": "Invalid request body"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "array",
                "example": "[{\"('subscription', 'start_date')\":\"Field required\"}]",
                "default": [
                  {
                    "('subscription', 'start_date')": "Field required"
                  }
                ],
                "itemType": "object",
                "customType": "object[]",
                "itemExample": "",
                "itemDefault": ""
              }
            ],
            "modelRef": "#/components/schemas/inline_response_400",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "403",
        "description": "Invalid API Key",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "inline_response_403",
            "schema": [
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "example": "Forbidden",
                "default": "Forbidden"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "string",
                "example": "Invalid API Key",
                "default": "Invalid API Key"
              }
            ],
            "modelRef": "#/components/schemas/inline_response_403",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "404",
        "description": "Method/Path Not Found",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "inline_response_404",
            "schema": [
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "example": "Method/Path combination not found.",
                "default": "Method/Path combination not found."
              }
            ],
            "modelRef": "#/components/schemas/inline_response_404",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "415",
        "description": "Unsupported Media Type",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "inline_response_415",
            "schema": [
              {
                "name": "message",
                "kind": "optional",
                "type": "string",
                "example": "Unsupported Media Type",
                "default": "Unsupported Media Type"
              },
              {
                "name": "errors",
                "kind": "optional",
                "type": "string",
                "example": "Content-Type must be application/json",
                "default": "Content-Type must be application/json"
              }
            ],
            "modelRef": "#/components/schemas/inline_response_415",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "500",
        "description": "Server Error",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "aYSyv6XymrtvL4W24p8XS",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.butterpayments.com/recover/payment_method_updates \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"customer_id\": \"11223344\",\n     \"payment_method_id\": \"pm_12345\"\n     }'"
        },
        {
          "id": "uI54JtQcc-0gqVBGUvFeF",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"customer_id\": \"11223344\",\n   \"payment_method_id\": \"pm_12345\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.butterpayments.com/recover/payment_method_updates\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "jCdJAXpyDLAW2RKNrBTvj",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.butterpayments.com/recover/payment_method_updates\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"customer_id\": \"11223344\",\n   \"payment_method_id\": \"pm_12345\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "CgLQbs9NA1U2paxUbY0xa",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.butterpayments.com/recover/payment_method_updates\"\n\npayload = json.dumps({\n   \"customer_id\": \"11223344\",\n   \"payment_method_id\": \"pm_12345\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "aYSyv6XymrtvL4W24p8XS"
    },
    "results": {
      "languages": [
        {
          "id": "Zx2_eAmLvg6-63ut542xU",
          "language": "200",
          "code": "// Request Successful\n{\n  \"message\": \"Request submitted for processing\",\n  \"request_id\": \"2c941653-b229-4528-b576-70fcfd388543:49645839701979566120793328447151049151317978254208401410:000000000000\"\n}"
        },
        {
          "id": "ZDR52LA8lj3SapqqGHguw",
          "language": "400",
          "code": "// Request Failed Validation\n{\n  \"message\": \"Invalid request body\",\n  \"errors\": [\n    {}\n  ]\n}"
        },
        {
          "id": "uoJr5NxE6P60rMQYSscuu",
          "language": "403",
          "code": "// Invalid API Key\n{\n  \"message\": \"Forbidden\",\n  \"errors\": \"Invalid API Key\"\n}"
        },
        {
          "id": "0rQe2Hb5ERSI0jJVa_HIA",
          "language": "404",
          "code": "// Method/Path Not Found\n{\n  \"message\": \"Method/Path combination not found.\"\n}"
        },
        {
          "id": "OCYp03qgKfuXiSXpSFoR0",
          "language": "415",
          "code": "// Unsupported Media Type\n{\n  \"message\": \"Unsupported Media Type\",\n  \"errors\": \"Content-Type must be application/json\"\n}"
        },
        {
          "id": "ymJxTuTW4Cjx2n8qc3-PI",
          "language": "500",
          "code": "// Server Error\n"
        }
      ],
      "selectedLanguageId": "Zx2_eAmLvg6-63ut542xU"
    }
  },
  "children": [
    {
      "id": "HZj5hbNEEl63ribPxsri1",
      "type": "paragraph",
      "children": [
        {
          "text": "This endpoint is used by the merchant to notify Recover of an update to a payment method for a customer. Whenever a payment method has been updated, added, or removed for any reason, that event should be forwarded to this endpoint so that it can be used as a signal to increase Recover's performance."
        }
      ]
    },
    {
      "id": "yGkqr1PPLayKHdv5kpLe8",
      "type": "paragraph",
      "children": [
        {
          "text": "Add field values in the boxes below to create an example payload on the right side of the screen."
        }
      ]
    }
  ]
}