Proxy Request

Makes a proxy request using created payment credentials with template substitution for secure credential handling.

Request

curl -X POST \
  https://api.basistheory.ai/tenants/your-tenant-id/proxy \
  -H 'BT-Authorization: Bearer your-api-key' \
  -H 'BT-Target-URL: https://api.merchant.com/payments' \
  -H 'Content-Type: application/json' \
  -d '{
    "amount": 1000,
    "currency": "usd",
    "payment_method": {
      "type": "card",
      "card": {
        "number": "{{ paymentMethod: 815029c2-29ec-4fc2-8cd4-99feb3ee582c | type: '\''virtualCard'\'' | json: '\''$.card.number'\'' }}",
        "exp_month": "{{ paymentMethod: 815029c2-29ec-4fc2-8cd4-99feb3ee582c | type: '\''virtualCard'\'' | json: '\''$.card.expirationMonth'\'' }}",
        "exp_year": "{{ paymentMethod: 815029c2-29ec-4fc2-8cd4-99feb3ee582c | type: '\''virtualCard'\'' | json: '\''$.card.expirationYear'\'' }}",
        "cvc": "{{ paymentMethod: 815029c2-29ec-4fc2-8cd4-99feb3ee582c | type: '\''virtualCard'\'' | json: '\''$.card.cvc'\'' }}"
      }
    }
  }'

URL Parameters

ParameterRequiredTypeDefaultDescription
tenantIdtruestringnullThe tenant ID.

Required Headers

Authentication will use a slightly different header in the case of the Proxy to avoid colliding with the target url’s headers.

HeaderRequiredDescription
BT-AuthorizationtrueBearer token for API authentication
BT-Target-URLtrueThe target API endpoint URL to proxy the request to

Template Syntax

The proxy supports template substitution to securely inject payment credentials into API requests.

Basic Template Format

{{ paymentMethod: <paymentMethodId> | type: '<credentialType>' | json: '<jsonPath>' }}

Template Components

ComponentDescriptionExample
paymentMethodThe payment method ID815029c2-29ec-4fc2-8cd4-99feb3ee582c
typeThe credential type to usevirtualCard, networkToken, pan
jsonJSONPath to extract specific field$.card.number, $.token.cryptogram

Supported Credential Types

TypeDescriptionAvailable Fields
virtualCardVirtual card credential$.number, $.expirationMonth, $.expirationYear, $.cvc
networkTokenNetwork token credential$.number, $.expirationMonth, $.expirationYear, $.cryptogram
panOriginal card PAN$..number, $.expirationMonth, $.expirationYear, $.cvc

JSONPath Examples

// Virtual Card Fields
"{{ paymentMethod: <id> | type: 'virtualCard' | json: '$.number' }}"
"{{ paymentMethod: <id> | type: 'virtualCard' | json: '$.expirationMonth' }}"
"{{ paymentMethod: <id> | type: 'virtualCard' | json: '$.expirationYear' }}"
"{{ paymentMethod: <id> | type: 'virtualCard' | json: '$.cvc' }}"

Response

The proxy returns the response from the target API endpoint unchanged. Status codes and response bodies are passed through directly from the target API.

Error Handling

{
  "error": {
    "status": 400,
    "type": "invalidTemplate",
    "title": "Invalid template syntax",
    "message": "Template syntax is malformed in request body.",
    "details": {
      "field": "credit_card.number",
      "template": "{{ paymentMethod: invalid-id | type: 'virtualCard' }}"
    }
  }
}