Cancel Invoice
An invoice is a document you provide to your client after they purchase goods or services from you. It serves to both record the sale and request payment. For detailed information about PayTabs invoices, please refer to our articleWhat is PayTabs Invoice?
In this manual, we will guide you on the correct method to change the status of any invoice to "canceled" using the specified endpoint. We strongly recommend that you and your team review theInvoices | Payment Workflowmanual first to grasp the business logic behind this integration type.
The Endpoint and Related Postman Collection
In this tutorial, we will rely on the PayTabs cancel Transaction API Endpoint, mentioned on the PayTabs API endpoints postman collection, which you can access fromhere. The endpoint will need to be accessed with a POST request on the below-mentioned URL
POST | {{domain}}payment/invoice/{{invoice_id}}/cancel |
---|
Please note that not using the proper endpoint URL {domain} will lead to authentication issues within your responses. To find the your proper domain you can read ourWhat is my (Region)/(endpoint URL)?tutorial article.
- KSA
- UAE
- Egypt
- Oman
- Jordan
- Kuwait
- Global
https://secure.paytabs.sapayment/invoice/{{invoice_id}}/cancel
https://secure.paytabs.compayment/invoice/{{invoice_id}}/cancel
https://secure-egypt.paytabs.compayment/invoice/{{invoice_id}}/cancel
https://secure-oman.paytabs.compayment/invoice/{{invoice_id}}/cancel
https://secure-jordan.paytabs.compayment/invoice/{{invoice_id}}/cancel
https://secure-kuwait.paytabs.compayment/invoice/{{invoice_id}}/cancel
https://secure-global.paytabs.compayment/invoice/{{invoice_id}}/cancel
How to Cancel Invoice ?
Once your invoice is initiated, it can be classified as one of three statuses: "paid," "pending," or "canceled." For more information on invoice statuses, please refer to our invoice status manual. This article specifically outlines the proper method for changing the status of a particular invoice using the Invoice Cancel request.
The Minimum Required Parameters
To initiate a query invoice request, there are minimum required parameters that need to be passed with valid information. The specification of these required parameters is clarified below according to the query type:
- Via Put Request
- Via Post Request
In the PUT request type, you can cancel the status by sending a PUT request with only the { invoice_id } as a parameter in the URL. Below is a sample request that demonstrates how to cancel an invoice with the ID "2075865."

In the POST request type, we simply use a POST request with only the "invoice_id" and "profile_id" as payload parameters to cancel the invoice. As shown below
Parameter | Data Type | Required | Purpose |
---|---|---|---|
| INT | ✔ | The merchant Profile ID you can get from your PayTabs dashboard. For more information please check ourHow to get your account information from PT2 Dashboard?tutorial article. To know more about this parameter please click here profile_id. |
| |||
| INT | ✔ | Indicates the invoice reference you want to query. To know more about this parameter please click here invoice . |
|
Sample Request Payloads
- Via Put Request
- Via Post Request
As we mentioned before, you can cancel the status by sending a PUT request with only the { invoice_id } as a parameter in the URL. Below is a sample request that demonstrates how to cancel an invoice with the ID "2075865."

For post request, you need to set as usual the API key and the profile ID in the request as shown below:
{
"profile_id": 79010,
"invoice_id": {{invoice_id}}
}
Sample Response Payloads
{
"message": "Invoice has been cancelled"
}