Create Purchase Intent

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

Request

POST /projects/:projectId/purchase-intent
curl -X POST \
  https://api.basistheory.ai/projects/:projectId/purchase-intent \
  -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.00",
        "details": {
          "currency": "840",
          "period": "transaction"
        }
      },
      {
        "type": "expirationTime",
        "value": "2024-12-31T23:59:59Z",
        "details": {
          "timezone": "UTC",
          "autoRenew": false
        }
      },
      {
        "type": "consumer",
        "value": "user-12345",
        "details": {
          "email": "user@example.com",
          "name": "Dexter Morgan",
          "address": { 
              "line1": "123 Main St",
              "line2": "Apt 4B",
              "line3": "",
              "city": "New York",
              "postalCode": "10001",
              "stateCode": "NY",
              "countryCode": "US"
            }
          }
        }
      }
    ]
  }'

URL Parameters

ParameterRequiredTypeDefaultDescription
projectIdtruestringnullThe project ID (must match JWT issuer).

Request Parameters

ParameterRequiredTypeDefaultDescription
entityIdtruestringnullUnique user identifier (must match JWT sub claim).
credentialTypetruestringnullCurrently only supports “virtual-card”.
paymentMethodIdtruestringnullThe payment method ID (UUID) to create credentials from.
mandatesfalseMandate Object[][]Array of spending limits and restrictions for the credential.

Mandate Object

PropertyRequiredTypeDescription
typetruestringThe mandate type (see supported types below).
valuetruestringThe mandate value (format varies by type).
detailsconditionalobjectAdditional details for the mandate (varies by type).
metadatafalseobjectOptional metadata for the 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",
  "paymentMethodId": "26859380-7829-4ee1-8a0a-38927881e7ef",
  "projectId": "550e8400-e29b-41d4-a716-446655440000",
  "mandates": [
    {
      "type": "maxAmount",
      "value": "100.00",
      "details": {
        "currency": "840",
        "period": "transaction"
      }
    }
  ]
}

Response Properties

PropertyTypeDescription
idstringUnique purchase intent identifier (UUID).
entityIdstringUser ID that owns this purchase intent.
credentialTypestringType of credential created (currently only “virtual-card”).
statusstringPurchase intent status (“active”, “verify”, “pending”).
createdAtstringISO 8601 timestamp when the purchase intent was created.
expiresAtstringISO 8601 timestamp when the credentials expire (typically 24 hours).
paymentMethodIdstringThe payment method ID used for this purchase intent.
projectIdstringThe project ID this purchase intent belongs to.
mandatesMandate ArrayThe mandates applied to this purchase intent.
cardCard ObjectVirtual card details (only included for verified Visa/Mastercard intents).

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.

Error Handling

{
  "error": {
    "status": 400,
    "type": "validation_error",
    "title": "Validation failed",
    "message": "The request contained invalid data.",
    "details": {
      "fields": {
        "credentialType": "Credential type must be: virtual-card (other types not currently supported)",
        "paymentMethodId": "Payment method ID must be a valid UUID.",
        "mandates.0.value": "maxAmount value must be a valid decimal amount (e.g., \"100.00\")",
      }
    }
  }
}

Credential Types

Available Credential Types

TypeDescriptionStatus Scenarios
virtual-cardGenerates a virtual card number for one-time useactive, verify, pending

Note: Only virtual-card is currently supported. Additional credential types may be added in the future.

Status Meanings

StatusDescription
activeCredential is ready for immediate use
verifyAdditional verification required before use (Visa/Mastercard 3DS)
pendingCredential creation is in progress

Mandate Types

All mandate types are optional. If no mandates are provided, the purchase intent will be created with default restrictions.

Available Mandate Types

TypeRequiredValue FormatDetails SchemaDescriptionNotes
maxAmountDecimal string (e.g. “100.00”){ currency: string (ISO 4217 numeric), period?: 'transaction'|'daily'|'monthly'|'yearly' }Maximum transaction amount limitOnly one per purchase intent
expirationTimeISO 8601 datetime string{ timezone?: string, autoRenew?: boolean }Credential expiration date/timeOnly one per purchase intent
merchantMerchant name string{ category: string, categoryCode: string (4-digit) }Specific merchant restrictionOnly one per purchase intent
descriptionDescription stringOptional objectPurchase description/memoOnly one per purchase intent
promptPrompt message stringOptional objectUser prompt messageOnly one per purchase intent
consumerConsumer ID string (UUID auto-generated if empty){ email: string (valid email), address: { line1, line2, line3, city, postalCode, stateCode, countryCode } }Consumer identificationOnly one per purchase intent

Business Rules

  • Only one mandate of each type allowed per purchase intent
  • Currency in maxAmount must be ISO 4217 numeric code (e.g., “840” for USD)
  • Merchant category codes must be exactly 4 digits

Example Mandates

{
  "mandates": [
    {
      "type": "maxAmount",
      "value": "500.00",
      "details": {
        "currency": "840",
        "period": "transaction"
      }
    },
    {
      "type": "expirationTime", 
      "value": "2024-12-31T23:59:59Z",
      "details": {
        "timezone": "UTC",
        "autoRenew": false
      }
    },
    {
      "type": "merchant",
      "value": "Target",
      "details": {
        "category": "Department Store",
        "categoryCode": "5311"
      }
    },
    {
      "type": "description",
      "value": "Monthly subscription payment"
    },
    {
      "type": "prompt",
      "value": "Authorize payment for Premium subscription?"
    },
    {
      "type": "consumer",
      "value": "user-12345",
      "details": {
        "email": "user@example.com"
      }
    }
  ]
}