Cancel a Snap page session via API
In principle, a Snap page will have an expiry time (default 24 hour), which can also be customized following this guide Expire a Snap Session.
In a scenario where you want to cancel a Snap page before the expiry time, you can use this endpoint.
Sample Request
curl --request POST \
--url https://app.midtrans.com/snap/v1/transactions/{token}/cancel \
--header 'Authorization: {merchant_server_key}' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json'
Sample Response
{
"canceled_at": "2025-06-03T13:09:39.776Z"
}
{
"error_messages": [
"token already canceled"
]
}
{
"error_messages": [
"Transaction is on progress"
]
}
{
"error_messages": [
"token not found"
]
}
If the user remains on the Snap page after the session has been canceled and attempts to continue the transaction, they will see an error indicating that they are not able to proceed with the transaction.
