---
updatedAt: 2026-05-07T18:17:26.000Z
agentTools:
  projectIndex: https://docs.joinforage.app/llms.txt
---

# Submit a test PIN during sandbox development

> ⚠️ Use For Sandbox Only
>
> Only use this endpoint during sandbox testing. It cannot be used in production.

A `POST` request to `/payments/{payment_ref}/collect_pin_backend/` programmatically associates a test PIN with an existing `Payment` object.

Use this endpoint to automate sandbox testing when you're building an integration that [defers payment capture to the server](doc:capture-ebt-payments-server-side).


# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "x-readme": {
    "explorer-enabled": false,
    "proxy-enabled": false
  },
  "info": {
    "title": "Forage Payments API",
    "description": "The Forage Payments API is a REST API for processing Electronic Benefits Transfer (EBT) payments (SNAP and EBT Cash) in your e-commerce or in-store application.\n\nProcessing any EBT payment, or checking an EBT card's balance, requires the cardholder's PIN. Federal regulations require all PIN entry to happen through a PCI-compliant, USDA-approved interface. Forage provides that interface, so EBT PIN collection always happens through a Forage-hosted surface (Forage Checkout or a Forage SDK), never directly in your own form. Some endpoints (for example, capture and balance) are only reachable through that surface because they require PIN data in the request.\n\nEBT rarely covers an entire order: items like delivery fees and non-eligible products can't be paid with SNAP or EBT Cash. You decide how to handle the remaining balance (split tender) and any credit or debit processing alongside the EBT portion.\n\nForage offers four integration options. Pick the one that fits your platform and engineering resources:\n\n1. **Fully Hosted Checkout.** Forage processes EBT and credit/debit through a Forage-hosted Checkout UI. Lowest engineering effort, and Forage absorbs most error handling. See the [Fully Hosted Checkout guide](https://docs.joinforage.app/docs/fully-hosted).\n2. **Custom Checkout.** Forage processes EBT; you handle split tender, taxes, and credit/debit in your own checkout flow. Best when you want minimal changes to your existing UX. See the [Custom Checkout guide](https://docs.joinforage.app/docs/custom).\n3. **Online SDKs.** Client-side SDKs for [web](https://docs.joinforage.app/docs/forage-js), [iOS](https://docs.joinforage.app/docs/ios), and [Android](https://docs.joinforage.app/docs/android) that collect EBT PINs in your app while keeping you out of PCI scope.\n4. **POS Terminal SDK.** Accept in-person EBT payments on an Android POS device. See the [POS Terminal guide](https://docs.joinforage.app/docs/forage-terminal-android).\n\nAs a general principle, any data created by your requests, or by your customers on a Forage-hosted surface, is retrievable through GET requests to the appropriate resource.\n\nHave more questions? Use our [contact form](https://www.joinforage.com/get-in-touch) to reach our sales and engineering support teams.\n",
    "contact": {
      "name": "API Support",
      "email": "engineering@joinforage.com"
    },
    "version": "2025-08-04"
  },
  "externalDocs": {
    "description": "Forage documentation",
    "url": "https://docs.joinforage.app/"
  },
  "servers": [
    {
      "url": "https://{environment}.joinforage.app",
      "variables": {
        "environment": {
          "default": "api.sandbox",
          "enum": [
            "api",
            "api.sandbox"
          ]
        }
      }
    }
  ],
  "security": [],
  "paths": {
    "/api/payments/{payment_ref}/collect_pin_backend/": {
      "parameters": [
        {
          "name": "payment_ref",
          "in": "path",
          "description": "A unique reference hash for the Forage `Payment` object, returned when the [`Payment` was created](https://docs.joinforage.app/reference/create-a-payment).",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AuthenticationBearerTokenHeader"
        },
        {
          "$ref": "#/components/parameters/MerchantAccountHeader"
        },
        {
          "$ref": "#/components/parameters/IdempotencyKeyHeader"
        }
      ],
      "post": {
        "tags": [
          "Sandbox Testing"
        ],
        "summary": "Submit a test PIN during sandbox development",
        "x-readme": {
          "code-samples": [
            {
              "language": "curl",
              "code": "curl --request POST \\\n    --url https://api.sandbox.joinforage.app/api/payments/cc3175bfea/collect_pin_backend/ \\\n    --header 'Authorization: Bearer <api_key>' \\\n    --header 'Merchant-Account: <merchant-id>' \\\n    --header 'Idempotency-Key: <idempotency-key>' \\\n    --header 'accept: application/json' \\\n    --header 'content-type: application/json' \\\n    --data '{\"pin\":\"1234\"}'\n"
            }
          ]
        },
        "description": "> ⚠️ Use For Sandbox Only\n>\n> Only use this endpoint during sandbox testing. It cannot be used in production.\n\nA `POST` request to `/payments/{payment_ref}/collect_pin_backend/` programmatically associates a test PIN with an existing `Payment` object.\n\nUse this endpoint to automate sandbox testing when you're building an integration that [defers payment capture to the server](https://docs.joinforage.app/docs/capture-ebt-payments-server-side).\n",
        "operationId": "Submit PIN during sandbox testing",
        "security": [
          {
            "OAuth2": [
              "internal",
              "pinpad_only"
            ]
          }
        ],
        "requestBody": {
          "$ref": "#/components/requestBodies/CollectPinBackend"
        },
        "responses": {
          "200": {
            "description": "__OK__ - Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "items": {}
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseObject"
                },
                "examples": {
                  "cannot_parse_request_body": {
                    "summary": "Cannot Parse Request Body",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "cannot_parse_request_body",
                          "message": "Payment ref {payment_ref} requires a pin which is missing from capture request body",
                          "source": {
                            "resource": "Payments",
                            "ref": "{payment_ref}"
                          }
                        }
                      ]
                    }
                  },
                  "invalid_input_data": {
                    "summary": "Invalid input data",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "invalid_input_data",
                          "message": "Query parameter unrecognized.",
                          "source": {
                            "resource": "Payments",
                            "ref": "{payment_ref}"
                          }
                        }
                      ]
                    }
                  },
                  "invalid_merchant_account": {
                    "summary": "Invalid Merchant Account",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "invalid_merchant_account",
                          "message": "Merchant account FNS number not valid.",
                          "source": {
                            "resource": "Merchants"
                          }
                        }
                      ]
                    }
                  },
                  "missing_idempotency_key": {
                    "summary": "Missing Idempotency Key",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "missing_idempotency_key",
                          "message": "You must include a value for the IDEMPOTENCY-KEY header in your requests to this endpoint.",
                          "source": {
                            "resource": "Idempotency_Key"
                          }
                        }
                      ]
                    }
                  },
                  "missing_merchant_account": {
                    "summary": "Missing Merchant Account",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "missing_merchant_account",
                          "message": "No merchant account was provided.",
                          "source": {
                            "resource": "Merchants"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseObject"
                },
                "examples": {
                  "invalid_token": {
                    "summary": "Invalid Token",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "invalid_token",
                          "message": "Invalid Token",
                          "source": {
                            "resource": "OAuth_Access_Tokens"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "__Forbidden__",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "detail": {
                      "type": "string",
                      "description": "A string that describes the nature of the error."
                    }
                  }
                },
                "example": {
                  "detail": "You do not have permission to perform this action."
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseObject"
                },
                "examples": {
                  "resource_not_found": {
                    "summary": "Payment Not Found",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "resource_not_found",
                          "message": "Payment with ref {payment_ref} does not exist.",
                          "source": {
                            "resource": "Payments",
                            "ref": "{payment_ref}"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseObject"
                },
                "examples": {
                  "cannot_change_request": {
                    "summary": "Cannot change request",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "cannot_change_request",
                          "message": "Two requests were submitted with the same idempotency key, but slightly different request bodies. Please use a new idempotency key if you intended to change the request body",
                          "source": {
                            "resource": "Idempotency_Key"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseObject"
                },
                "examples": {
                  "too_many_requests": {
                    "summary": "Too Many Requests",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "too_many_requests",
                          "message": "Request was throttled, please try again later.",
                          "source": {
                            "resource": "Payments"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseObject"
                },
                "examples": {
                  "unknown_server_error": {
                    "summary": "Unknown Server Error",
                    "value": {
                      "path": "/api/payments/{payment_ref}/collect_pin_backend/",
                      "errors": [
                        {
                          "code": "unknown_server_error",
                          "message": "Unknown exception from EBT network",
                          "source": {
                            "resource": "Payments"
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorsArray": {
        "type": "array",
        "description": "An array with information about the error.",
        "items": {
          "type": "object",
          "properties": {
            "code": {
              "type": "string",
              "description": "A short string that represents the error."
            },
            "message": {
              "type": "string",
              "description": "A developer-facing message with more details about the error, not to be displayed to customers."
            },
            "source": {
              "type": "object",
              "properties": {
                "resource": {
                  "type": "string",
                  "description": "The type of the Forage resource involved in the error."
                },
                "ref": {
                  "type": "string",
                  "description": "If applicable, the ten character reference hash of the Forage resource that caused the error. An empty string if no specific individual resource was involved."
                }
              }
            },
            "details": {
              "type": "object",
              "description": "Additional details about the error, if applicable."
            }
          }
        },
        "example": []
      },
      "ErrorResponseObject": {
        "type": "object",
        "description": "An object that includes details about the error.",
        "properties": {
          "path": {
            "type": "string",
            "description": "The requested endpoint."
          },
          "errors": {
            "$ref": "#/components/schemas/ErrorsArray"
          }
        }
      },
      "CollectPinBackendRequest": {
        "type": "object",
        "properties": {
          "pin": {
            "type": "string",
            "description": "A test four-digit PIN number, represented as a string.",
            "example": "1234"
          }
        },
        "required": [
          "pin"
        ]
      }
    },
    "requestBodies": {
      "CollectPinBackend": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/CollectPinBackendRequest"
            }
          }
        }
      }
    },
    "parameters": {
      "AuthenticationBearerTokenHeader": {
        "name": "Authorization",
        "in": "header",
        "description": "An OAuth 2.0 [authentication token](https://docs.joinforage.app/docs/authentication#authentication-tokens) that validates the request. Send a `POST` to the [`/o/token/`](https://docs.joinforage.app/reference/create-authentication-token) endpoint to generate an authentication token. Pass the token in this header after the word `Bearer` and a whitespace, for example `Bearer <api_key>`.",
        "schema": {
          "type": "string"
        },
        "required": true
      },
      "MerchantAccountHeader": {
        "name": "Merchant-Account",
        "in": "header",
        "description": "A unique merchant ID that Forage provides during onboarding, as in `123ab45c67`. The Merchant ID can be found in the Forage [sandbox](https://dashboard.sandbox.joinforage.app/login/) or [production](https://dashboard.joinforage.app/login/) dashboard.",
        "schema": {
          "type": "string"
        },
        "required": true
      },
      "IdempotencyKeyHeader": {
        "name": "Idempotency-Key",
        "in": "header",
        "description": "An alphanumeric key that clients can use to identify repeated requests that are dropped in transit. Generate a distinct key for every unique request and only re-use keys for retries.",
        "schema": {
          "type": "string"
        },
        "required": true
      }
    },
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "description": "Pass the access token in the 'Authorization' header with the format \"Bearer ${token}\", i.e. the word \"Bearer\" and your access token from the /o/token/ API, separated by whitespace.\n",
        "flows": {
          "password": {
            "tokenUrl": "/o/token/",
            "scopes": {
              "hosted_checkout": "Scope for tokens used by merchant applications which allow Forage to manage split tender processing (i.e. EBT + Credit/Debit).\n",
              "pinpad_only": "Scope for tokens used by merchant applications which manage their own split tender (i.e. Forage Checkout is used only for EBT processing).\n"
            }
          },
          "clientCredentials": {
            "tokenUrl": "/o/token/",
            "scopes": {
              "internal": "Scope for tokens used by Forage internal applications.\n",
              "pin-protected": "Scope for tokens which can access secure storage.\n",
              "disbursement": "Scope for tokens which can disburse money to merchants.\n"
            }
          }
        }
      }
    }
  }
}
```

# Sibling pages

* [Capture a Payment during sandbox testing](https://docs.joinforage.app/reference/capture-a-payment-during-sandbox-testing.md)