---
title: Set default payment method
slug: reference/set-default-payment-method
docTags: 
createdAt: 2024-09-30T17:03:00.667Z
---

{
  "id": "1b3Yy1GvGRcykqPMjLl4D",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://app.amberflo.io/customer-portal/payment-method",
    "servers": [
      {
        "url": "https://app.amberflo.io/customer-portal/payment-method"
      }
    ],
    "name": "Set default payment method",
    "description": "<p>Use this endpoint to set the default payment method of the customer, when registering the customer's payment credentials for future payments.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [
        {
          "kind": "required",
          "name": "sessionToken",
          "type": "string",
          "description": "<p>A required session token used to authenticate API calls made on behalf of a customer. This token is obtained from the <code>Create a session</code> endpoint and must be included with every request to authorize access.</p>"
        }
      ],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "payment-method-post",
          "schema": [
            {
              "name": "provider",
              "kind": "required",
              "type": "string<stripe>",
              "example": "",
              "default": "stripe"
            },
            {
              "name": "paymentMethodId",
              "kind": "required",
              "type": "string",
              "example": ""
            }
          ],
          "modelRef": "#/components/schemas/payment-method-post",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "api_key",
          "name": "x-api-key",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful response",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "payment-method-post",
            "schema": [
              {
                "name": "provider",
                "kind": "required",
                "type": "string<stripe>",
                "example": "",
                "default": "stripe"
              },
              {
                "name": "paymentMethodId",
                "kind": "required",
                "type": "string",
                "example": ""
              }
            ],
            "modelRef": "#/components/schemas/payment-method-post",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "_BpU-jwNj26jcqoJf6NNi",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url 'https://app.amberflo.io/customer-portal/payment-method?sessionToken=string' \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"provider\": \"stripe\",\n     \"paymentMethodId\": \"\"\n     }'"
        },
        {
          "id": "4YLbybtDut0BUtEj-4gh7",
          "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   \"provider\": \"stripe\",\n   \"paymentMethodId\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://app.amberflo.io/customer-portal/payment-method?sessionToken=string\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "fPN9lwjnyPq7buXKeXWl-",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://app.amberflo.io/customer-portal/payment-method?sessionToken=string\")\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   \"provider\": \"stripe\",\n   \"paymentMethodId\": \"\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "_oUkaWjaCQX_3bSTSAJqi",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://app.amberflo.io/customer-portal/payment-method?sessionToken=string\"\n\npayload = json.dumps({\n   \"provider\": \"stripe\",\n   \"paymentMethodId\": \"\"\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": "_BpU-jwNj26jcqoJf6NNi"
    },
    "results": {
      "languages": [
        {
          "id": "M8W6zsfnBHkqE1IWVpcgy",
          "language": "200",
          "code": "// Successful response\n{\n  \"provider\": \"\",\n  \"paymentMethodId\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "M8W6zsfnBHkqE1IWVpcgy"
    }
  },
  "children": [
    {
      "id": "3eMa3tnxGVCBaQFoXvZqR",
      "type": "paragraph",
      "children": [
        {
          "text": "Use this endpoint to set the default payment method of the customer, when registering the customer's payment credentials for future payments.",
          "id": "NFOIx8hzg9LTMVACrjO5f"
        }
      ]
    }
  ]
}