---
title: 'Link API Delete'
url: 'https://dev.paytr.com/en/link-api/link-api-delete'
markdown: 'https://dev.paytr.com/en/link-api/link-api-delete.md'
lang: en
date: '2026-11-29'
description: 'You can delete the payment links you have created before by using the Link Delete Service. 1- The token data is generated with the information below that must be sent. 2- A request is made to the create service https://www.paytr.com/odeme/api/link/delete along with the generated token and the fie…'
taxonomy:
  category:
    - docs
---

- [Türkçe](https://dev.paytr.com/link-api/link-api-delete)
- [English](https://dev.paytr.com/en/link-api/link-api-delete)

 [](#)  [ Getting Started with PayTR ](https://dev.paytr.com/en)     [ Link API ](https://dev.paytr.com/en/link-api)      Link API Delete    

# Link API Delete

You can delete the payment links you have created before by using the Link Delete Service.

1- The token data is generated with the information below that must be sent. 
2- A request is made to the create service https://www.paytr.com/odeme/api/link/delete along with the generated token and the fields that must be sent.

**Required parameters for token creation**

| Field name / Type | Description | Mandatory | Limitations |
|---|---|---|---|
| id (integer) | Link API Returned value from Create method | Yes | - |
| merchant\_id(integer) | A value specific to your store, which you can access through the PayTR Merchant Panel > Information page. | Yes | - |
| merchant\_salt | A value specific to your store, which you can access through the PayTR Merchant Panel > Information page. | Yes | - |
| merchant\_key | A value specific to your store, which you can access through the PayTR Merchant Panel > Information page. | Yes | - |

\* **Values to be sent in POST REQUEST content**

| Field name / Type | Description | Mandatory | Limitations |
|---|---|---|---|
| merchant\_id (integer) | Merchant number: Merchant number given to you by PayTR | Yes | - |
| id (integer) | ID: It is the value returned in the create method. | Yes | - |
| debug\_on(int) | Error message (Send as 1 for integration and test errors) | No | 0(closed) or 1(open |
| paytr\_token(string) | paytr\_token: This value is the one you need to create to make sure the request is coming from you and that the values it contains have not changed | Yes | Please check the sample codes for calculation |

**2) RESPONS**

| Description | Field name / Type | Values |
|---|---|---|
| Response | status (string) | success, error or failed |
| Request description (in case of error) | reason (string) | Example: Invalid id or link has already been deleted |

- [PHP](#968d034fd00)
- [PYTHON](#968d034fd01)
- [.NET](#968d034fd02)
- [NODEJS](#968d034fd03)

```php
<?php

    $merchant_id    = 'AAAAAA';
    $merchant_key   = 'XXXXXXXXXXXXXXXX';
    $merchant_salt  = 'XXXXXXXXXXXXXXXX';

    $id             = "YYYXXX";    
    $debug_on       = 1;           

    $paytr_token=base64_encode(hash_hmac('sha256', $id.$merchant_id.$merchant_salt, $merchant_key, true));
    $post_vals=array(
        'merchant_id'       => $merchant_id,
        'id'                => $id,
        'debug_on'          => $debug_on,
        'paytr_token'       => $paytr_token
    );

    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/link/delete");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1) ;
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    $result = @curl_exec($ch);

    if(curl_errno($ch))
        die("PAYTR LINK DELETE API request timeout. err:".curl_error($ch));

    curl_close($ch);

    $result=json_decode($result,1);

    if($result['status']=='error')
        die($result['err_msg']);
    elseif($result['status']=='failed')
        print_r($result);
    else
        print_r($result);
```

```python
# Python 3.6+

import base64
import hmac
import hashlib
import requests
import json
import random

merchant_id = 'AAAAAA'
merchant_key = b'AAAAAA'
merchant_salt = 'XXXXXXXXXXXXXXXX'

id = 'YYYXXX'

debug_on=1

hash_str = id + merchant_id + merchant_salt
paytr_token = base64.b64encode(hmac.new(merchant_key, hash_str.encode(), hashlib.sha256).digest())

params = {
    'merchant_id': merchant_id,
    'id': id,
    'debug_on': debug_on,
    'paytr_token': paytr_token
}

result = requests.post('https://www.paytr.com/odeme/api/link/delete', params)
res = json.loads(result.text)

if res['status'] == 'error':
    print('Error: ' + res['err_msg'])
elif res['status'] == 'failed':
    print(result.text)
else:
    print(result.text)

```

```c
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Collections.Specialized;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Routing;
namespace WebApplication1.Controllers
{
    public class DeleteController : Controller
    {
        public ActionResult Delete()
        {

            string merchant_id = "AAAAAA";
            string merchant_key = "XXXXXXXXXXXXXXXX";
            string merchant_salt = "XXXXXXXXXXXXXXXX";

            string id = "YYYXXX"; 
            string debug_on = "1";

            string Birlestir = string.Concat(id,merchant_id, merchant_salt);
            HMACSHA256 hmac = new HMACSHA256(Encoding.UTF8.GetBytes(merchant_key));
            byte[] b = hmac.ComputeHash(Encoding.UTF8.GetBytes(Birlestir));
            string paytr_token = Convert.ToBase64String(b);

            NameValueCollection data = new NameValueCollection();
            data["merchant_id"] = merchant_id;
            data["id"] = id;
            data["debug_on"] = debug_on;
            data["paytr_token"] = paytr_token;

            using (WebClient client = new WebClient())
            {
                client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                byte[] result = client.UploadValues("https://www.paytr.com/odeme/api/link/delete", "POST", data);
                string ResultAuthTicket = Encoding.UTF8.GetString(result);
                dynamic json = JValue.Parse(ResultAuthTicket);
                if (json.status == "error")
                {
                    Response.Write("PAYTR LINK CREATE API request timeout. Error:" + json.err_msg + "");
                }
                else
                {
                    Response.Write(json);

                }
            }
            return View();
        }
    }
}
```

```js
var crypto = require('crypto');
var express = require('express');
var app = express();
var request = require('request');

app.use(express.json());
app.use(express.urlencoded({ extended: true }));

var merchant_id = 'AAAAAA';
var merchant_key = 'XXXXXXXXXXXXXXXX';
var merchant_salt = 'XXXXXXXXXXXXXXXX';

app.get("/create", function (req, res) {

    var name = 'Örnek Ürün / Hizmet Adı';  
    var price = '1445'; 
    var currency = 'TL';  
    var max_installment = '12'; 

    var link_type = 'product';
    var lang = 'tr'; 
    var required = name + price + currency + max_installment + link_type + lang;
    var email = '';
    var min_count = '';
    if (link_type == 'product') {
        min_count = '1';

        required += min_count;
    } else {
        (link_type == 'collection')
        email = 'test@example.com';

        required += email;
    }

    var max_count = '1';

    var expiry_date = '2021-06-23 17:00:00';

    var callback_link = '';

    var callback_id = '';

    var debug_on = '1'; 

    var paytr_token = crypto.createHmac('sha256', merchant_key).update(required + merchant_salt).digest('base64');

    var options = {
        'method': 'POST',
        'url': 'https://www.paytr.com/odeme/api/link/create',
        'headers': {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        form: {
            'merchant_id': merchant_id,
            'name': name,
            'price': price,
            'currency': currency,
            'max_installment': max_installment,
            'link_type': link_type,
            'lang': lang,
            'min_count': min_count,
            'email': email,
            'expiry_date': expiry_date,
            'max_count': max_count,
            'callback_link': callback_link,
            'callback_id': callback_id,
            'debug_on': debug_on,
            'paytr_token': paytr_token,
        }
    };

    request(options, function (error, response, body) {
        if (error) throw new Error(error);
        var res_data = JSON.parse(body);

        if (res_data.status == 'success') {
            res.send(body);
        } else {

            res.end(body);
        }

    });

});

app.get("/delete", function (req, res) {

    var id = 'XXXX'; 
    var debug_on = '1'; 

    var paytr_token = crypto.createHmac('sha256', merchant_key).update(id + merchant_id + merchant_salt).digest('base64');

    var options = {
        'method': 'POST',
        'url': 'https://www.paytr.com/odeme/api/link/delete',
        'headers': {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        form: {
            'merchant_id': merchant_id,
            'id': id,
            'debug_on': debug_on,
            'paytr_token': paytr_token,
        }
    };

    request(options, function (error, response, body) {
        if (error) throw new Error(error);
        var res_data = JSON.parse(body);

        if (res_data.status == 'success') {
            res.send(response.body);

        } else {
            console.log(response.body);
            res.end(response.body);
        }

    });

});

app.get("/sendsms", function (req, res) {

    var id = 'XXXX';  
    var cell_phone = '05555555555'; 
    var debug_on = '1'; 

    var paytr_token = crypto.createHmac('sha256', merchant_key).update(id + merchant_id + cell_phone + merchant_salt).digest('base64');

    var options = {
        'method': 'POST',
        'url': 'https://www.paytr.com/odeme/api/link/send-sms',
        'headers': {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        form: {
            'merchant_id': merchant_id,
            'id': id,
            'cell_phone': cell_phone,
            'debug_on': debug_on,
            'paytr_token': paytr_token,
        }
    };

    request(options, function (error, response, body) {
        if (error) throw new Error(error);
        var res_data = JSON.parse(body);

        if (res_data.status == 'success') {
            res.send(response.body);

        } else {
            console.log(response.body);
            res.end(response.body);
        }

    });

});

app.get("/sendmail", function (req, res) {

    var id = 'XXXX'; 
    var email = ''; 
    var debug_on = '1'; 

    var paytr_token = crypto.createHmac('sha256', merchant_key).update(id + merchant_id + email + merchant_salt).digest('base64');

    var options = {
        'method': 'POST',
        'url': 'https://www.paytr.com/odeme/api/link/send-email',
        'headers': {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        form: {
            'merchant_id': merchant_id,
            'id': id,
            'email': email,
            'debug_on': debug_on,
            'paytr_token': paytr_token,
        }
    };

    request(options, function (error, response, body) {
        if (error) throw new Error(error);
        var res_data = JSON.parse(body);

        if (res_data.status == 'success') {
            res.send(response.body);

        } else {
            console.log(response.body);
            res.end(response.body);
        }

    });

});

app.post("/callback", function (req, res) {
    var callback = req.body;

    token = callback.id + callback.merchant_oid + merchant_salt + callback.status + callback.total_amount;
    var paytr_token = crypto.createHmac('sha256', merchant_key).update(token).digest('base64');

    if (paytr_token != callback.hash) {
        throw new Error("PAYTR notification failed: bad hash");
    }

    if (callback.status == 'success') {

    } else {

    }

    res.send('OK');

});

var port = 3200;
app.listen(port, function () {
    console.log("Server is running. Port:" + port);
});

```

For Link API Delete service sample codes [ **Click to download.**](https://dev.paytr.com/en/link-api/link-api-delete/PayTR%20Link%20API%20-%20Delete.zip)

 [ ](https://dev.paytr.com/en/link-api/link-api-create) [](https://dev.paytr.com/en/link-api/linkle-api-sms-and-email)

---

## Navigation

- Parent: [Link API](https://dev.paytr.com/en/link-api.md)
- Previous: [Link API Create](https://dev.paytr.com/en/link-api/link-api-create.md)
- Next: [Link API Callback](https://dev.paytr.com/en/link-api/linkle-api-callback.md)
