---
title: add credit card
slug: api-documentation/add-credit-card
docTags: 
createdAt: 2026-08-27T17:02:13.658Z
---

{
  "id": "F1UgjAwv64hTkTAi9dSi2",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.upstartcommerce.com/v1/customer/{customerId}/creditcards/cards",
    "servers": [
      {
        "url": "https://api.upstartcommerce.com/v1/customer/{customerId}/creditcards/cards"
      }
    ],
    "name": "add credit card",
    "description": "<p>This endpoint allows administrators to set the default credit card, by label, for a given consumer.</p>\n<p>Authorized permissions:</p>\n<ul>\n<li><code>customer.update</code></li>\n</ul>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "customerId",
          "type": "string",
          "description": "Unique identifier for the consumer that the call should be interacting with."
        }
      ],
      "headerParameters": [
        {
          "kind": "required",
          "name": "x-upstart-tenant",
          "type": "string",
          "description": "Tenant identifier associated with the site this call is for."
        },
        {
          "kind": "optional",
          "name": "x-upstart-site",
          "type": "string",
          "description": "Unique identifier for the site."
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "The request body should contain the data from the credit card.",
          "customType": "CreditCard",
          "schema": [
            {
              "name": "cardNumber",
              "kind": "required",
              "type": "string",
              "description": "This should be the last 4 digits of the consumer's payment card.",
              "example": "8111",
              "pattern": "[0-9]{4}"
            },
            {
              "name": "cardType",
              "kind": "required",
              "type": "string",
              "description": "<p>The type of payment card (Visa, Mastercard, Discover, Debit etc.)</p>",
              "example": "Visa"
            },
            {
              "name": "expirationMonth",
              "kind": "required",
              "type": "string",
              "description": "<p>The 2-digit month on which the card expires.</p>",
              "example": "10",
              "pattern": "^[0,1][0-9]$"
            },
            {
              "name": "expirationYear",
              "kind": "required",
              "type": "string",
              "description": "<p>This should be the 4-digit year on which the card expires.</p>",
              "example": "2025",
              "pattern": "^2[0-9]{3}$"
            },
            {
              "name": "label",
              "kind": "required",
              "type": "string",
              "description": "<p>This is a user-friendly label the consumer can use to identify this particular card.</p>",
              "example": "Personal"
            },
            {
              "name": "token",
              "kind": "required",
              "type": "string",
              "description": "A token provided by the payment gateway that can be used transactionally and represents the actual card PAN.",
              "example": "65FZG32BYZ756JH345"
            }
          ],
          "modelRef": "#/components/schemas/CreditCard",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "NoChannelPortalAccess",
          "name": "NoChannelPortalAccess",
          "kind": "optional",
          "type": "http",
          "description": "<p>This authentication is required for clients to interact with any of the management APIs. Similar to 'LoggedIn', it indicates that the user has actually logged into the system, but in this case with a management role.</p>",
          "scheme": "bearer"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "<p>Success-default credit card added.</p>",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "400",
        "description": "The request contained information that the server was unable to process. Appropriate errors are provided in the response body.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "ValidationErrorResponse",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/ValidationErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "The provided credentials were not valid for this endpoint. It may be that they are expired or that the user's roles are insufficient.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "reason",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "403",
        "description": "<p>An update to this resource requires the if-match and if-unmodified-since headers to be sent in order to process the request.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "reason",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "404",
        "description": "The requested resource was not found in the NoChannel system.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "reason",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "mFSm5tlAfnPtlQh7qJ9pm",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.upstartcommerce.com/v1/customer/{customerId}/creditcards/cards \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --header 'x-upstart-tenant: string' \\\n     --data '{\n     \"cardNumber\": \"8111\",\n     \"cardType\": \"Visa\",\n     \"expirationMonth\": \"10\",\n     \"expirationYear\": \"2025\",\n     \"label\": \"Personal\",\n     \"token\": \"65FZG32BYZ756JH345\"\n     }'"
        },
        {
          "id": "YjaoJOWL9jp0LnYGBNemR",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\nmyHeaders.append(\"x-upstart-tenant\", \"string\");\n\nvar raw = JSON.stringify({\n   \"cardNumber\": \"8111\",\n   \"cardType\": \"Visa\",\n   \"expirationMonth\": \"10\",\n   \"expirationYear\": \"2025\",\n   \"label\": \"Personal\",\n   \"token\": \"65FZG32BYZ756JH345\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.upstartcommerce.com/v1/customer/{customerId}/creditcards/cards\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "dREc2BbIMEwdBb8N2OpcM",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.upstartcommerce.com/v1/customer/{customerId}/creditcards/cards\")\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[\"x-upstart-tenant\"] = \"string\"\nrequest.body = JSON.dump({\n   \"cardNumber\": \"8111\",\n   \"cardType\": \"Visa\",\n   \"expirationMonth\": \"10\",\n   \"expirationYear\": \"2025\",\n   \"label\": \"Personal\",\n   \"token\": \"65FZG32BYZ756JH345\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "V6RIFAsRnGynzXa9JuaHU",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.upstartcommerce.com/v1/customer/{customerId}/creditcards/cards\"\n\npayload = json.dumps({\n   \"cardNumber\": \"8111\",\n   \"cardType\": \"Visa\",\n   \"expirationMonth\": \"10\",\n   \"expirationYear\": \"2025\",\n   \"label\": \"Personal\",\n   \"token\": \"65FZG32BYZ756JH345\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json',\n   'x-upstart-tenant': 'string'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "mFSm5tlAfnPtlQh7qJ9pm"
    },
    "results": {
      "languages": [
        {
          "id": "IVGAe9jJ_ZZ1mr9EJH3j3",
          "language": "200",
          "code": "// Success-default credit card added.\n"
        },
        {
          "id": "9aGzk6uMIF5mcAlJZhMMG",
          "language": "400",
          "code": "// The request contained information that the server was unable to process. Appropriate errors are provided in the response body.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": \"\"\n}"
        },
        {
          "id": "r2bwBZyeQ5SzaZhN4YIwR",
          "language": "401",
          "code": "// The provided credentials were not valid for this endpoint. It may be that they are expired or that the user's roles are insufficient.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": \"\",\n  \"reason\": \"\"\n}"
        },
        {
          "id": "l_irkr-wSkYs4M_rci2WP",
          "language": "403",
          "code": "// An update to this resource requires the if-match and if-unmodified-since headers to be sent in order to process the request.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": \"\",\n  \"reason\": \"\"\n}"
        },
        {
          "id": "pRfvFzQkujTcYpWfR35JY",
          "language": "404",
          "code": "// The requested resource was not found in the NoChannel system.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": \"\",\n  \"reason\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "IVGAe9jJ_ZZ1mr9EJH3j3"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}