---
agentTools:
  projectIndex: https://docs.developer.plastiq.com/llms.txt
---

# Create a Payment Method

# OpenAPI definition

```json
{
  "openapi": "3.0.1",
  "info": {
    "title": "Plastiq Public API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://connect.sandbox.plastiq.com/api",
      "description": "Sandbox server"
    },
    {
      "url": "https://connect.plastiq.com/api",
      "description": "Production server"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/payment-methods": {
      "post": {
        "summary": "Create a Payment Method",
        "tags": [
          "Payment Methods"
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/TraceId"
          },
          {
            "$ref": "#/components/parameters/EndUserAgent"
          },
          {
            "$ref": "#/components/parameters/EndUserIp"
          },
          {
            "$ref": "#/components/parameters/EndUserOS"
          },
          {
            "$ref": "#/components/parameters/EndUserDeviceId"
          },
          {
            "$ref": "#/components/parameters/EndUserDeviceManufacturer"
          },
          {
            "$ref": "#/components/parameters/EndUserDeviceModel"
          }
        ],
        "requestBody": {
          "description": "Payment Method to create",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePaymentMethodRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment Method created successfully",
            "headers": {
              "Trace-Id": {
                "$ref": "#/components/headers/Trace-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentMethod"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "token"
      }
    },
    "headers": {
      "Trace-Id": {
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "The trace ID for the request"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad Request",
        "headers": {
          "Trace-Id": {
            "$ref": "#/components/headers/Trace-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized",
        "headers": {
          "Trace-Id": {
            "$ref": "#/components/headers/Trace-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Forbidden",
        "headers": {
          "Trace-Id": {
            "$ref": "#/components/headers/Trace-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "InternalServerError": {
        "description": "Internal Server Error",
        "headers": {
          "Trace-Id": {
            "$ref": "#/components/headers/Trace-Id"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "GENERIC_ERROR"
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "details": {
                  "type": "string"
                }
              }
            }
          },
          "traceId": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "payerId": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "8f51c396-6e29-49a6-ba5a-1a31d5420158"
          }
        }
      },
      "CreatePaymentMethodRequest": {
        "type": "object",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "CARD",
              "BANK_ACCOUNT"
            ]
          },
          "externalId": {
            "type": "string",
            "description": "Consumer defined ID that will be attached to this resource",
            "pattern": "^[-a-zA-Z0-9_~.]*$"
          },
          "data": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Card"
              },
              {
                "$ref": "#/components/schemas/BankAccount"
              }
            ]
          },
          "payer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/payerId"
              }
            ]
          }
        }
      },
      "BankAccount": {
        "description": "Bank Account Funded",
        "type": "object",
        "required": [
          "accountHolderName",
          "accountNumber",
          "routingNumber",
          "billingAddress"
        ],
        "properties": {
          "accountHolderName": {
            "type": "string",
            "description": "The legal name of the account holder",
            "example": "Jane Payer"
          },
          "accountNumber": {
            "type": "string",
            "description": "The account number of the bank account",
            "example": "41541433888"
          },
          "accountType": {
            "type": "string",
            "description": "The type of the bank account",
            "enum": [
              "CHECKING",
              "SAVINGS"
            ],
            "example": "CHECKING"
          },
          "routingNumber": {
            "type": "string",
            "description": "The routing number of the bank account",
            "example": "211371120"
          },
          "billingAddress": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/Address"
              }
            ]
          }
        }
      },
      "BankAccountResponse": {
        "type": "object",
        "properties": {
          "accountType": {
            "type": "string",
            "description": "The type of the bank account",
            "enum": [
              "CHECKING",
              "SAVINGS"
            ],
            "example": "CHECKING"
          },
          "accountHolderName": {
            "type": "string",
            "description": "The legal name of the account holder",
            "example": "Jane Payer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2020-11-19T01:35:53.096Z"
          },
          "accountLastFour": {
            "type": "string",
            "description": "Last 4 digits of the account number",
            "example": "4242"
          },
          "routingNumber": {
            "type": "string",
            "description": "The routing number of the bank account",
            "example": "211371120"
          },
          "billingAddress": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/Address"
              }
            ]
          }
        }
      },
      "Card": {
        "description": "Debit or Credit Card",
        "type": "object",
        "required": [
          "accountNumber",
          "cvv",
          "expirationMonth",
          "expirationYear",
          "billingAddress",
          "cardHolderName"
        ],
        "properties": {
          "cardHolderName": {
            "type": "string",
            "example": "Jen Doe"
          },
          "accountNumber": {
            "type": "string",
            "description": "Card number.",
            "example": "4242424242424242"
          },
          "cvv": {
            "type": "string",
            "description": "3-4 digits",
            "example": "123"
          },
          "expirationMonth": {
            "type": "string",
            "example": "01"
          },
          "expirationYear": {
            "type": "string",
            "example": "2021"
          },
          "billingAddress": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/Address"
              }
            ]
          }
        }
      },
      "CardResponse": {
        "type": "object",
        "properties": {
          "last4": {
            "type": "string",
            "description": "Last 4 digits of card number",
            "example": "4242"
          },
          "brand": {
            "type": "string",
            "example": "Visa"
          },
          "expirationMonth": {
            "type": "string",
            "example": "01"
          },
          "expirationYear": {
            "type": "string",
            "example": "2021"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2020-11-19T01:35:53.096Z"
          },
          "billingAddress": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/Address"
              }
            ]
          },
          "subType": {
            "type": "string",
            "enum": [
              "CREDIT",
              "DEBIT"
            ],
            "example": "CREDIT"
          }
        }
      },
      "PaymentMethod": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "6f0eb884-3f41-4b57-b86a-80f62dca011e"
          },
          "externalId": {
            "type": "string",
            "description": "Consumer defined ID that will be attached to this resource",
            "pattern": "^[-a-zA-Z0-9_~.]*$"
          },
          "type": {
            "type": "string",
            "enum": [
              "CARD",
              "BANK_ACCOUNT"
            ]
          },
          "data": {
            "type": "object",
            "oneOf": [
              {
                "$ref": "#/components/schemas/CardResponse"
              },
              {
                "$ref": "#/components/schemas/BankAccountResponse"
              }
            ]
          },
          "status": {
            "type": "string",
            "allOf": [
              {
                "$ref": "#/components/schemas/PaymentMethodStatus"
              }
            ],
            "example": "ACTIVE"
          },
          "statusReasons": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/StatusReason"
                }
              ]
            }
          }
        }
      },
      "Address": {
        "type": "object",
        "required": [
          "line1",
          "country",
          "city",
          "state",
          "postalCode"
        ],
        "properties": {
          "line1": {
            "type": "string",
            "description": "Address line 1 (e.g., street, PO Box, or company name).",
            "example": "360 9th St."
          },
          "line2": {
            "type": "string",
            "description": "Address line 2 (e.g., apartment, suite, unit, or building).",
            "example": null
          },
          "city": {
            "type": "string",
            "description": "City, district, suburb, town, or village.",
            "example": "San Francisco"
          },
          "state": {
            "type": "string",
            "description": "State, county, province, or region.",
            "example": "CA"
          },
          "postalCode": {
            "type": "string",
            "description": "ZIP or postal code.",
            "example": "94103"
          },
          "country": {
            "type": "string",
            "description": "Two-letter country code (ISO 3166-1 alpha-2).",
            "example": "US"
          }
        }
      },
      "PaymentMethodStatus": {
        "example": "INACTIVE",
        "type": "string",
        "description": "In some cases Payment Method will remain Inactive until additional information provided",
        "enum": [
          "ACTIVE",
          "INACTIVE"
        ]
      },
      "StatusReason": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "description": "Used to provide more context in reference to the status response",
        "properties": {
          "code": {
            "type": "string",
            "example": "STATUS_REASON_CODE"
          },
          "message": {
            "type": "string",
            "example": "Some message to help resolve status issue."
          }
        }
      }
    },
    "parameters": {
      "TraceId": {
        "in": "header",
        "name": "Trace-Id",
        "schema": {
          "type": "string"
        },
        "description": "A valid UUID (V4) for tracing requests. Will be returned as a header. If not present or invalid, a generated UUID will be returned."
      },
      "EndUserAgent": {
        "name": "End-User-Agent",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "A string representing the User Agent of the end user. Recommended for compliance. Required only when the request is not coming from the end user's browser."
      },
      "EndUserDeviceId": {
        "name": "End-User-Device-Id",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "A unique identifier for the end user's device. Recommended for compliance."
      },
      "EndUserDeviceModel": {
        "name": "End-User-Device-Model",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "The device model used by the end user. Recommended for compliance."
      },
      "EndUserDeviceManufacturer": {
        "name": "End-User-Device-Manufacturer",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "The manufacturer of the device used by the end user. Recommended for compliance."
      },
      "EndUserIp": {
        "name": "End-User-Ip",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "The IP address of the end user. Recommended for compliance."
      },
      "EndUserOS": {
        "name": "End-User-OS",
        "in": "header",
        "schema": {
          "type": "string"
        },
        "description": "The Operating System of the end user. Recommended for compliance."
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 101,
      "1": 248,
      "2": 203,
      "3": 227,
      "4": 144,
      "5": 15,
      "6": 124,
      "7": 0,
      "8": 95,
      "9": 254,
      "10": 160,
      "11": 146
    }
  }
}
```