HomeGuidesReference↗ Forage Dashboard
Log In
Reference

Create a PaymentMethod

A POST request to /payment_methods/ creates a new representation of a customer's payment instrument in Forage's database.

Tokenization vs. Network Validation

Tokenization (this endpoint): Forage validates card format, BIN support, and merchant configuration. The EBT network is NOT contacted during tokenization. Card validity can only be confirmed after attempting a balance check or payment with the processor.

Network validation: Occurs later during balance checks or payments when the EBT network validates the card, PIN, and account status.

StageWho validatesWhen it happensExample errors
TokenizationForagePOST /payment_methodsinvalid PAN, unsupported BIN/state, throttling
ProcessingEBT networkbalance check or paymentcard closed, insufficient funds, wrong PIN

BIN Blocking Scope

Forage blocks known BINs from restricted states (Guam, Virgin Islands) where online EBT is not supported. However, Forage does not block unregistered BINs. An unregistered BIN may pass tokenization but will fail during processing when the EBT network rejects the card.

On success, the API responds with a Forage PaymentMethod object. You need to retrieve and store the ref value for future requests. For example:

  • To get the outcome of a balance inquiry, you need to pass the ref as the path param in a request to Retrieve a PaymentMethod.
  • To Create a Payment, you need to pass the ref as the payment_method request body param.

When to use the Merchant-Account Header

The Merchant-Account Header requirements vary by payment method type:

  • For EBT payment methods: The Merchant-Account header is optional
  • For HSA/FSA payment methods: The Merchant-Account header is required
  • For credit/debit payment methods: The Merchant-Account header is required

The Merchant-Account header is required for all payment methods except EBT due to technical requirements for routing and payout processing.

EBT PaymentMethods are tenant-scoped. An EBT PaymentMethod created under one merchant account can be used by other merchant accounts within the same tenant. The Merchant-Account header does not restrict EBT PaymentMethod usability across merchant accounts within the same tenant.

When Merchant-Account is passed, the created PaymentMethod is associated with that specific merchant account for routing and reporting purposes. For EBT payment methods, the PaymentMethod remains usable across all merchant accounts within the same tenant.

SDK Behavior

Forage JS automatically includes the Merchant-Account header from initialization when creating PaymentMethods. There is currently no option to omit this header during PaymentMethod creation.

Use customer_id When Creating PaymentMethods

Pass customer_id in the request to Create a PaymentMethod. customer_id helps Forage's servers more quickly identify and associate the correct customer with the PaymentMethod. While customer_id is not technically a required parameter, if you omit it then the request to create the PaymentMethod could take longer to process. It is strongly recommended to pass customer_id.

Additionally, passing customer_id enables Forage to throttle card additions per customer, helping prevent abuse and fraud.

Each customer should only have one unique customer_id. For example, if you create both a PaymentMethod and a Payment for the same customer, then the customer_id should be the same in both requests to ensure continuity of stored payment methods.

State Validation

To check which states and BINs Forage supports, use the Retrieve state card details endpoint. This is useful for customers concerned with state waivers or validating card eligibility before tokenization.

See these guides for more information:

Body Params

A PaymentMethod to add to or update on the system.

string
enum
required

The card type. One of:

  • credit
  • debit
  • prepaid
  • ebt

⚠️ The type value can only be credit, debit, or prepaid in a Fully Hosted or HSA/FSA integration.

Allowed:
boolean
required

Whether the PaymentMethod can be reused. If false, then the PaymentMethod can only be used for a single transaction.

string
length ≤ 64

⚠️ If you’re integrating Forage with a POS Terminal, then do not use this param. It is only supported for online transactions.

A unique identifier for the end customer making the payment.

Forage automatically adds the customer_id to the Session's corresponding Order and OrderPayments.

This field helps Forage's servers more quickly identify the customer associated with the request. While customer_id is not technically required, if you omit it then requests could take longer to process. It is strongly recommended to pass customer_id.

If you're providing your internal customer ID, then we recommend that you hash the value before sending it on the payload.

Each customer should only have one unique customer_id. For example, if you create both a PaymentMethod and a Forage Session (Fully Hosted or Custom) or Payment (SDK) for the same customer, then the customer_id should be the same in both requests to ensure continuity of stored payment methods.

card
Headers
string
required

An OAuth 2.0 bearer token that validates the request. You can use either a short-lived session token if the request is coming from the front-end, or an authentication token for server-side requests. Pass the token in this header after the word Bearer and a whitespace, for example Bearer <api_key>.

string
required

A unique merchant ID that Forage provides during onboarding, as in 123ab45c67. The Merchant ID can be found in the Forage sandbox or production dashboard.

Pass a Merchant-Account header to create a PaymentMethod associated with a specific merchant account for routing and reporting purposes. This header does not restrict PaymentMethods to a single merchant account. PaymentMethods are tenant-scoped and can be used across all merchant accounts within the same tenant.

string

The Forage version, represented as a string with the format of a YYYY-MM-DD date.

If not specified in the request header, then the version defaults to the value set in the Forage dashboard.

Responses

Language
Credentials
OAuth2
URL
Request
Response
Choose an example:
application/json