Create Purchase Intent

Create a Purchase Intent to generate temporary credentials (virtual card, network token, etc) for a specific payment method, enabling secure transactions on behalf of the user.

Request

POST /projects/:projectId/purchase-intents
curl -X POST \
  https://api.basistheory.ai/projects/:projectId/purchase-intents \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "entityId": "user-12345",
    "credentialType": "virtual-card",
    "paymentMethodId": "26859380-7829-4ee1-8a0a-38927881e7ef",
    "mandates": [
      {
        "type": "maxAmount",
        "value": "100",
        "details": {
          "currency": "840"
        }
      },
      {
        "type": "merchantMcc",
        "value": "140"
      }
    ]
  }'

URL Parameters

ParameterRequiredTypeDefaultDescription
projectIdtruestringnullThe project ID (must match JWT issuer).

Request Parameters

ParameterRequiredTypeDefaultDescription
entityIdtruestringnullUnique user identifier (must match JWT sub claim).
credentialTypetruestringnullThe type of credential to create (“virtual-card”, “network-token”, “pan”).
paymentMethodIdtruestringnullThe payment method ID to create credentials from.
mandatestrueMandate Object[]nullArray of spending limits and restrictions for the credential.

Mandate Object

PropertyRequiredTypeDescription
typetruestringThe mandate type.
valuetruestringThe mandate value.
detailsconditionalobjectDetails about the mandate. Vary by mandate.

Response

{
  "id": "0b1ac700-c1a7-46b0-a166-809e5aac4dc3",
  "entityId": "user-12345",
  "credentialType": "virtual-card",
  "status": "active",
  "createdAt": "2025-01-15T14:00:00Z",
  "expiresAt": "2025-01-16T14:00:00Z",
  "card": {
    "number": "2222030198005808",
    "expirationMonth": "07",
    "expirationYear": "2028",
    "cvc": "211"
  }
}

Response Properties

PropertyTypeDescription
idstringUnique purchase intent identifier.
entityIdstringUser ID that owns this purchase intent.
credentialTypestringType of credential created (“virtual-card”, “network-token”, “pan”).
statusstringPurchase intent status (typically “active”).
createdAtstringISO 8601 timestamp when the purchase intent was created.
expiresAtstringISO 8601 timestamp when the credentials expire (typically 24 hours).
cardCard ObjectVirtual card details (when credentialType is “virtual-card”).
tokenToken ObjectNetwork token details (when credentialType is “network-token”).
panPAN ObjectPAN details (when credentialType is “pan”).

Virtual Card Object

PropertyTypeDescription
numberstringTemporary virtual card number for one-time use.
expirationMonthstringVirtual card expiration month in MM format.
expirationYearstringVirtual card expiration year in YYYY format.
cvcstringVirtual card security code.

Token Object

PropertyTypeDescription
numberstringNetwork-tokenized card number.
expirationMonthstringToken expiration month in MM format.
expirationYearstringToken expiration year in YYYY format.
cryptogramstringToken cryptogram for transaction authentication.

PAN Object

PropertyTypeDescription
numberstringThe original card number (PAN).
expirationMonthstringCard expiration month in MM format.
expirationYearstringCard expiration year in YYYY format.
cvcstringCard security code.

Security Note: The PAN credential type exposes the original card number and should only be used in highly secure, PCI-compliant environments.

Error Handling

{
  "error": {
    "status": 400,
    "type": "invalidRequest",
    "title": "The request is invalid",
    "message": "Request is invalid, check details object for details.",
    "details": {
      "fields": {
        "credentialType": "Must be one of: virtual-card, network-token, pan."
      }
    }
  }
}

Credential Types

Available Credential Types

TypeDescriptionStatus Scenarios
virtual-cardGenerates a virtual card number for one-time useactive
network-tokenGenerates a network tokenized credentialactive, verify
panUses the original card PANactive

Status Meanings

StatusDescription
activeCredential is ready for immediate use
verifyAdditional verification required before use
unavailableCredential type not available for this payment method

Mandate Types

Available Mandate Types

TypeDescriptionRequired Details
maxAmountMaximum transaction amountcurrency (ISO 4217 code)
merchantMccMerchant category code restrictionNone
expirationDateCredential expiration datedate (ISO 8601)
usageLimitMaximum number of usescount (integer)

Example Mandates

{
  "mandates": [
    {
      "type": "maxAmount",
      "value": "500.00",
      "details": {
        "currency": "840"
      }
    },
    {
      "type": "merchantMcc",
      "value": "5411"
    },
    {
      "type": "expirationDate", 
      "value": "2024-12-31T23:59:59Z"
    },
    {
      "type": "usageLimit",
      "value": "1",
      "details": {
        "count": 1
      }
    }
  ]
}