API ReferenceIntegrationsKnowledge Base

2. Fetch and Manage Tokens

Once you capture a payment, Razorpay Checkout returns a razorpay_payment_id that can be used to fetch the token_id. This is a manual process and can be done using either APIs or Webhooks. This token_id is used to create and charge subsequent payments. Learn about about Tokens.

Note:
You can also search for the Token on your Dashboard. Learn how to search for a Token on the Dashboard.

2.1. Fetch Token by Payment ID🔗

Use the below endpoint to fetch token id using Payment id.

/payments/:id

Note:
You can also retrieve the token_id from the payment.authorized webhook.

Path Parameter🔗

id mandatory
string The unique identifier of the payment to be retrieved. For example, pay_1Aa00000000002.

2.2. Fetch Tokens by Customer ID🔗

Use the below endpoint to fetch all tokens linked to a customer.

A customer can have multiple tokens tied to them. These tokens can be used to create subsequent payments for multiple products or services.

/customers/:id/tokens

Path Parameter🔗

id mandatory
string The unique identifier of the customer for whom tokens are to be retrieved. For example, cust_1Aa00000000002.

Response Parameters🔗

entity

string The entity being created. Here, it is a collection.

count

integer The number of tokens to be fetched.

items

Details related to token such as token id and bank information.

id

string The unique identifier linked to an item. In this example, it is token_id.

entity

string The entity being created. Here, it is a token.

token

string The token is being fetched.

bank

string Card issuing bank details.

wallet

string Provides wallet information.

method

string The payment method used to make the transaction.

card

Details related to card used to make the transaction.

entity
string The entity being created. Here, it is card.
name
string Name of the cardholder.
last4
integer Last 4 digits of the card.
network
string Name of the payment processor. Here it is Visa.
type
string Card type (debit or credit). In this example, it is credit.
issuer
string Name of the card-issuing bank.
international
string Card usage restriction. Possible values:
  • true: Supports international transactions.
  • false: International transactions are not supported.
emi
string Card EMI status. Possible values.
  • true: The card is on EMI.
  • false: The card is not on EMI.
sub_type

string Type of the customer.

expiry_month

integer Month on which the card expires.

expiry_year

integer Year on which the card expires.

flows

The transaction flow details.

otp
string Whether the OTP function is enabled or not. Possible values:
  • true: The OTP function is enabled.
  • false: The OTP function is not enabled.
recurring
string Whether the recurring for this payment method is enabled or not. Possible Values:
  • true: Recurring is enabled.
  • false: Recurring is not enabled.
vpa

string The VPA details. There are no VPA details in this example.

recurring

string This represents whether recurring is enabled for this token or not. Possible values:

  • true: Recurring is enabled.
  • false: Recurring is not enabled.
auth_type

string The authorization type details.

mrn

string The unique identifier issued by the payment gateway during customer registration. This can be Gateway Reference Number or Gateway Token.

used_at

integer The card usage timestamp.

created_at

integer The card creation timestamp.

expired_at

integer The card expiry date timestamp.

dcc_enabled

string Indicates whether the option to change currency is enabled or not. Possible values.

  • true: The option to change currency is enabled
  • false: The option to change currency is not enabled.

2.3. Delete Tokens🔗

Use the below endpoint to delete a token. You get a 200 OK response if the token is deleted successfully.

/customers/:customer_id/tokens/:token_id

Path Parameter🔗

customer_id mandatory
string The unique identifier of the customer with whom the token is linked. For example, cust_1Aa00000000002.
token_id mandatory
string The unique identifier of the token that is to be deleted. For example, token_1Aa00000000001.
×