---
title: 'Link API Create'
url: 'https://dev.paytr.com/en/link-api/link-api-create'
markdown: 'https://dev.paytr.com/en/link-api/link-api-create.md'
lang: en
date: '2026-11-29'
description: 'You can create payment links for your Service / Product or Invoice / Current collections by using the Link Create 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/create ) along wit…'
taxonomy:
  category:
    - docs
---

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

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

# Link API Create

You can create payment links for your Service / Product or Invoice / Current collections by using the Link Create 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/create ) along with the generated token and the fields that must be sent..

**Required parameters for token creation**

| Field name / Type | Description | Mandatory | Limitations & Notes |
|---|---|---|---|
| name (string) | Product or Service Name | Yes | Description of the product or service. (Minimum 4 and maximum 200 characters required) |
| price (string) | Payment Amount | Yes | For example, 3456 should be sent for 34.56 (34.56 \* 100 = 3456) |
| currency (string) | Currency | Yes | TL, EUR, USD, GBP, RUB ((If the value is null, TL is accepted)) |
| max\_installment (string) | Maximum number of installments: Specifies the maximum number of installments to be displayed (example usage: up to 4 installments is allowed for jewellery expenditures) | Yes | It can be sent between 2 and 12. If 1 is sent, individual cards cannot be used for installments |
| link\_type(integer) | Link Type | Yes | For product sale: product For invoice / current collection: collection |
| lang(string) | Language to be used on the pages during the payment process | Yes | tr for Turkish or en for English (If it is sent null, tr will be valid) |
| 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 & Notes |
|---|---|---|---|
| merchant\_id (integer) | Merchant number: Merchant number given to you by PayTR | Yes | - |
| name (string) | Product or Service Name | Yes | Description of the product or service. (Minimum 4 and maximum 200 characters required) |
| price (string) | Payment Amount | Yes | For example, 3456 should be sent for 34.56 (34.56 \* 100 = 3456) |
| currency (string) | Currency | Yes | TL, EUR, USD, GBP, RUB ((If the value is null, TL is accepted)) |
| max\_installment (string) | Maximum number of installments: Specifies the maximum number of installments to be displayed (example usage: up to 4 installments is allowed for jewellery expenditures) | Yes | It can be sent between 2 and 12. If 1 is sent, individual cards cannot be used for installments |
| link\_type(integer) | Link Type | Yes | For product sale: product For invoice / current collection: collection |
| lang(string) | Language to be used on the pages during the payment process | Yes | tr for Turkish or en for English (If it is sent null, tr will be valid) |
| get\_qr | QR code returns in base64 format, it needs to be converted to image format and used. | No | 1 or 0 can be sent. 1 must be sent to receive a QR code response. |
| 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 |
| min\_count (integer) | Minimum quantity limit.(it is required if link type is product) | No | It can be at least 1 |
| email(string) | E-mail address (it is required if link type is collection) | No | It can contain up to 100 characters and Must not contain Turkish characters |
| max\_count(integer) | Stock quantity (It can only be used in product type. It set the stock quantity of Link and if it is not sent, the stock limit is not applied. When the payment is made as much as the stock number, the link is closed | No | It can be at least 1. |
| pft (integer) | Installment Cash Price setting (optional).All installment options up to the highest number sent are set as Installments to Cash Price. ATTENTION: Installment commissions will be deducted from you in all payment | No | It can be sent ​​between 2-12. |
| expiry\_date | Link expiration date | No | Link's expiration date. If not sent, it remains open until deleted. Example format: 2021-05-31 17:00:00 |
| callback\_link | The URL where the result of the link payment will be sent | No | Must start with http: // or https: //, not contain localhost and port. |
| callback\_id | Notification ID to return in notification. This field is required when the callback\_link is sent. | No | It can be alphanumeric and up to 64 characters. |
| debug\_on | Error message (Be sure to send 1 to detect errors during the integration and testing process). | No | 0 or 1 |

**2) RESPONS**

| Description | Field name / Type | Values |
|---|---|---|
| Response | status (string) | success, error or failed |
| Unique link id | id (string) | Example: NB2Zlz3 |
| Link | status (string) | Example: https://www.paytr.com/link/NB2Zlz3 |
| Request description (in case of error) | reason (string) | Example: Required field value is invalid or not sent (Link API - create): price |

- [PHP](#eb7f5564c40)
- [PYTHON](#eb7f5564c41)
- [.NET](#eb7f5564c42)
- [NODEJS](#eb7f5564c43)

```php
<?php

    ########################## ÖDEME LİNKİ OLUŞTURMAK İÇİN ÖRNEK KODLAR ########################
    #                                                                                          #
    ################################ DÜZENLEMESİ ZORUNLU ALANLAR ###############################
    #
    ## API Entegrasyon Bilgileri - Mağaza paneline giriş yaparak BİLGİ sayfasından alabilirsiniz.
    $merchant_id    = 'AAAAAA';
    $merchant_key   = 'XXXXXXXXXXXXXXXX';
    $merchant_salt  = 'XXXXXXXXXXXXXXXX';
    #

    ## Gerekli Bilgiler
    #
    $name            = "Örnek Ürün / Hizmet Adı";
    # Ürün / Hizmetin açıklaması. En az 4 en fazla 200 karakter.
    #
    $price           = 1445;
    # 14.45 TL için 14.45 * 100 = 1445 (100 ile çarpılmış ve integer olarak gönderilmelidir.)
    #
    $currency        = "TL";
    # TL - USD - EUR - GBP gönderilebilir.
    #
    $max_installment = "12";
    # 2 - 12 arası gönderilebilir. 1 gönderilirse bireysel kartlar taksit yapılamaz.
    #
    $link_type       = "product";
    # collection (fatura/cari tahsilat) veya product (ürün/hizmet satışı) gönderilebilir.
    # collection ise email (ödeme yapan tarafın eposta adresi olmalı).
    # product ise min_count (satın alma adet alt limiti) gereklidir.
    #
    $lang            = "tr";
    # tr veya en gönderilebilir.
    $get_qr          = 1;
    # Opsiyoneldir 1 veya 0 gönderilebilir. 1 gönderildiğinde yanıt içerisinde
    # QR kod oluşturabilmeniz için PNG formatında Base64 kodu döner.

    $required        = $name.$price.$currency.$max_installment.$link_type.$lang;

    //Esneklink için gerekli token yöntemi
    // $required        = $name.$price.$currency.$max_installment.$link_type.$lang.$flex_max_price;

    if($link_type == "product"){
        $min_count     = "1";
        # Alt adet limiti.
        $required     .= $min_count;
    }elseif($link_type == "collection"){
        $email         = time()."@example.com";
        # Ödeme yapan kullanıcının eposta adresi.
        $required     .= $email;
    }

    ## Opsiyonel bilgiler, gönderilmesi zorunlu değildir.
    #
    $expiry_date        = "2020-03-23 17:00:00";
    # Link'in son kullanma tarihi. Gönderilmezse, sürekli açık kalır.
    # Örnek format: 2021-05-31 17:00:00
    #
    $max_count          = "1";
    # Yalnızca product modunda kullanılabilir.
    # Link'in stok adedini belirler. Gönderilmezse, stok limiti uygulanmaz.
    # Stok adedi kadar ödeme yapıldığında link pasif olur.
    #
    //$pft             = "0"; // OPSİYONEL
    # 2 - 12 arası gönderilebilir. Gönderilen en yüksek sayıya kadar olan tüm taksit seçenekleri
    # Peşin Fiyatına Taksit olarak ayarlanır.
    # DİKKAT: Peşin Fiyatına Taksit olarak belirlediğiniz taksit sayıları için yapılan tüm
    # ödeme işlemlerinde, taksit komisyonları sizden kesilecektir.
    #
    $callback_link      = "";
    # Link ile yapılan ödemenin sonucunun gönderileceği URL. En fazla 400 kararkter.
    # http:// ya da https:// ile başlamalı, localhost olmamalı ve port içermemelidir.
    # callback_id gönderildiğinde bu alan zorunlu olmaktadır.
    #
    $callback_id        = "";
    # Bildirimde dönülecek bildirim ID'si. Alfanumerik ve en fazla 64 karakter olabilir.
    # callback_link gönderildiğinde bu alan zorunlu olmaktadır.

    $debug_on           = 1;
    # Entegrasyon hatalarını alabilmek için 1 olarak bırakın.
    #
    ############################################################################################

    ################ Bu kısımda herhangi bir değişiklik yapmanıza gerek yoktur. ################
    #
    $paytr_token=base64_encode(hash_hmac('sha256', $required.$merchant_salt, $merchant_key, true));
    $post_vals=array(
        '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,
        'get_qr'            => $get_qr,
        'paytr_token'       => $paytr_token,
        'user_name'         => $user_name,
        'flex_max_price'    => $flex_max_price
    );
    #
    ############################################################################################

    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/api/link/create");
    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 CREATE 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+
# Link API Create Servisi icin kullanılacak örnek kod yapısı.

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

# API Entegrasyon Bilgilier - Mağaza paneline giriş yaparak BİLGİ sayfasından alabilirsiniz.
merchant_id = 'AAAAAA'
merchant_key = b'XXXXXXXXXXXXXXXX'
merchant_salt = 'XXXXXXXXXXXXXXXX'

## Gerekli Bilgiler
name = 'Örnek Ürün / Hizmet Adı'
# Ürün / Hizmetin açıklaması. En az 4 en fazla 200 karakter.
price           = '1445'
# 14.45 TL için 14.45 * 100 = 1445 (100 ile çarpılmış ve integer olarak gönderilmelidir.)
currency        = 'TL'
# TL - USD - EUR - GBP gönderilebilir.
max_installment = '12'
# 2 - 12 arası gönderilebilir. 1 gönderilirse bireysel kartlar taksit yapılamaz.
link_type       = 'product'
# collection (fatura/cari tahsilat) veya product (ürün/hizmet satışı) gönderilebilir.
# collection ise email (ödeme yapan tarafın eposta adresi olmalı).
# product ise min_count (satın alma adet alt limiti) gereklidir.
lang            = 'tr'
# tr veya en gönderilebilir.
get_qr          = 1
# Opsiyoneldir 1 veya 0 gönderilebilir. 1 gönderildiğinde yanıt içerisinde
# QR kod oluşturabilmeniz için PNG formatında Base64 kodu döner.
email           =''
min_count       =''

required        = name + price + currency + max_installment + link_type + lang
#Esneklink için gerekli token yöntemi
# required        = name + price + currency + max_installment + link_type + lang + flex_max_price;

if link_type == 'product':
    min_count = '1'
    # Alt adet limiti.
    required+=min_count
elif link_type == 'collection':
    email= random.randint(1, 9999999).__str__() + '@example.com'
    # Ödeme yapan kullanıcının eposta adresi.
    required+=email

## Opsiyonel bilgiler, gönderilmesi zorunlu değildir.
expiry_date= '2021-03-23 17:00:00'
# Link'in son kullanma tarihi. Gönderilmezse, sürekli açık kalır.
# Örnek format: 2021-05-31 17:00:00
max_count='1'
# Yalnızca product modunda kullanılabilir.
# Link'in stok adedini belirler. Gönderilmezse, stok limiti uygulanmaz.
# Stok adedi kadar ödeme yapıldığında link pasif olur.
#
#pft='0'; // OPSİYONEL
# 2 - 12 arası gönderilebilir. Gönderilen en yüksek sayıya kadar olan tüm taksit seçenekleri
# Peşin Fiyatına Taksit olarak ayarlanır.
# DİKKAT: Peşin Fiyatına Taksit olarak belirlediğiniz taksit sayıları için yapılan tüm
# ödeme işlemlerinde, taksit komisyonları sizden kesilecektir.
#
callback_link =''
# Link ile yapılan ödemenin sonucunun gönderileceği URL. En fazla 400 kararkter.
# http:// ya da https:// ile başlamalı, localhost olmamalı ve port içermemelidir.
# callback_id gönderildiğinde bu alan zorunlu olmaktadır.
callback_id=''
# Bildirimde dönülecek bildirim ID'si. Alfanumerik ve en fazla 64 karakter olabilir.
# callback_link gönderildiğinde bu alan zorunlu olmaktadır.
debug_on=1
# Entegrasyon hatalarını alabilmek için 1 olarak bırakın.

# Bu kısımda herhangi bir değişiklik yapmanıza gerek yoktur.
hash_str = required + merchant_salt
paytr_token = base64.b64encode(hmac.new(merchant_key, hash_str.encode(), hashlib.sha256).digest())

params = {
    '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,
    'get_qr': get_qr,
    'paytr_token': paytr_token
}

result = requests.post('https://www.paytr.com/odeme/api/link/create', 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 CreateController : Controller
    {
        public ActionResult List()
        {
            // ####################### DÜZENLEMESİ ZORUNLU ALANLAR #######################
            //
            // API Entegrasyon Bilgileri - Mağaza paneline giriş yaparak BİLGİ sayfasından alabilirsiniz.
            string merchant_id = "AAAAAA";
            string merchant_key = "XXXXXXXXXXXXXXXX";
            string merchant_salt = "XXXXXXXXXXXXXXXX";
            //

            //    ## Gerekli Bilgiler
            string name = "Örnek Ürün / Hizmet Adı";
            // Ürün / Hizmetin açıklaması. En az 4 en fazla 200 karakter.

            int price = 1445;
            // 14.45 TL için 14.45 * 100 = 1445 (100 ile çarpılmış ve integer olarak gönderilmelidir.)

            string max_installment = "12";
            // 2 - 12 arası gönderilebilir. 1 gönderilirse bireysel kartlar taksit yapılamaz.

            string currency = "TL";
            //TL - USD - EUR - GBP gönderilebilir.

            string link_type = "product";
            //collection (fatura/cari tahsilat) veya product (ürün/hizmet satışı) gönderilebilir.
            //collection ise email (ödeme yapan tarafın eposta adresi olmalı).
            //product ise min_count (satın alma adet alt limiti) gereklidir.

            string lang = "tr";
            //tr veya en gönderilebilir.

            get_qr          = '';
            // Opsiyoneldir 1 veya 0 gönderilebilir. 1 gönderildiğinde yanıt içerisinde
            // QR kod oluşturabilmeniz için PNG formatında Base64 kodu döner.
            ////////////////////////////////////////////////////////////////////////////////////////
            // Opsiyonel bilgiler, gönderilmesi zorunlu değildir.
            string expiry_date = "2020-11-23 17:00:00";
            // Link'in son kullanma tarihi. Gönderilmezse, sürekli açık kalır.
            // Örnek format: 2021-05-31 17:00:00

            string callback_id = "";
            // Bildirimde dönülecek bildirim ID'si. Alfanumerik ve en fazla 64 karakter olabilir.
            //callback_link gönderildiğinde bu alan zorunlu olmaktadır.

            string callback_link = "";
            //Link ile yapılan ödemenin sonucunun gönderileceği URL. En fazla 400 kararkter.
            //http:// ya da https:// ile başlamalı, localhost olmamalı ve port içermemelidir.
            //callback_id gönderildiğinde bu alan zorunlu olmaktadır.

            string max_count = "";
            //Yalnızca product modunda kullanılabilir.
            //Link'in stok adedini belirler. Gönderilmezse, stok limiti uygulanmaz.
            //Stok adedi kadar ödeme yapıldığında link pasif olur.

            string pft = "";
            //2 - 12 arası gönderilebilir. Gönderilen en yüksek sayıya kadar olan tüm taksit seçenekleri
            //Peşin Fiyatına Taksit olarak ayarlanır.
            //DİKKAT: Peşin Fiyatına Taksit olarak belirlediğiniz taksit sayıları için yapılan tüm
            //ödeme işlemlerinde, taksit komisyonları sizden kesilecektir.

            string debug_on = "1";
            //Entegrasyon hatalarını alabilmek için 1 olarak bırakın.
            ////////////////////////////////////////////////////////////////////////////////////////////
            ///
            string min_count = "";
            string email = "";
            string Birlestir = "";

            NameValueCollection data = new NameValueCollection();
            data["merchant_id"] = merchant_id;
            data["name"] = name;
            data["price"] = price.ToString();

            // Token oluşturma fonksiyonu, değiştirilmeden kullanılmalıdır.
            //Esneklink için gerekli token yöntemi
             //required        = name,price,currency,max_installment,link_type,lang,flex_max_price;
            if (link_type == "product")
            {
               min_count = "1";
            Birlestir = string.Concat(name,price.ToString(),currency,max_installment,link_type,lang,min_count,merchant_salt);
            }
            else if (link_type == "collection")
            {
               email = "test@mail.com";
            Birlestir = string.Concat(name,price.ToString(),currency,max_installment,link_type,lang,email,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);

            // Gönderilecek veriler oluşturuluyor
            data["currency"] = currency;
            data["max_installment"] = max_installment;
            data["link_type"] = link_type;
            data["lang"] = lang;
            data["get_qr"] = get_qr;
            data["min_count"] = min_count;
            data["email"] = email;
            data["expiry_date"] = expiry_date;
            data["callback_link"] = callback_link;
            data["callback_id"] = callback_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/create", "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);
                   /* Başarılı yanıt içerik örneği

                     [status]  => success
                     [id]      => XXXXXX
                     [link]    => https://www.paytr.com/link/XXXXXX
                     */
                }
            }
            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ı';  // Ürün / Hizmetin açıklaması. En az 4 en fazla 200 karakter.
    var price = '1445'; // 14.45 TL için 14.45 * 100 = 1445 (100 ile çarpılmış ve integer olarak gönderilmelidir.)
    var currency = 'TL';  //TL - USD - EUR - GBP gönderilebilir.
    var max_installment = '12'; // 2 - 12 arası gönderilebilir. 1 gönderilirse bireysel kartlar taksit yapılamaz.

    //collection (fatura/cari tahsilat) veya product (ürün/hizmet satışı) gönderilebilir.
    //collection ise email (ödeme yapan tarafın eposta adresi olmalı).
    //product ise min_count (satın alma adet alt limiti) gereklidir.

    var link_type = 'product';
    var lang = 'tr'; //tr veya en gönderilebilir.
    var get_qr = ''; 
    // Opsiyoneldir 1 veya 0 gönderilebilir. 1 gönderildiğinde yanıt içerisinde
    // QR kod oluşturabilmeniz için PNG formatında Base64 kodu döner
    var required = name + price + currency + max_installment + link_type + lang;
    //Esneklink için gerekli token yöntemi
    //var required        = name + price + currency + max_installment + link_type + lang + flex_max_price;
    var email = '';
    var min_count = '';
    if (link_type == 'product') {
        min_count = '1';
        // Alt adet limiti.
        required += min_count;
    } else {
        (link_type == 'collection')
        email = 'test@example.com';
        // Ödeme yapan kullanıcının eposta adresi.
        required += email;
    }

    var max_count = '1';

    // Opsiyonel bilgiler, gönderilmesi zorunlu değildir.

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

    // Link'in son kullanma tarihi. Gönderilmezse, sürekli açık kalır.
    // Örnek format: 2021-05-31 17:00:00

    //$pft             = '0'; // OPSİYONEL
    // 2 - 12 arası gönderilebilir. Gönderilen en yüksek sayıya kadar olan tüm taksit seçenekleri
    // Peşin Fiyatına Taksit olarak ayarlanır.
    // DİKKAT:Peşin Fiyatına Taksit olarak belirlediğiniz taksit sayıları için yapılan tüm ödeme işlemlerinde, taksit komisyonları sizden kesilecektir.
    //

    //Link ile yapılan ödemenin sonucunun gönderileceği URL. En fazla 400 kararkter.
    //http:// ya da https:// ile başlamalı, localhost olmamalı ve port içermemelidir.
    //callback_id gönderildiğinde bu alan zorunlu olmaktadır.

    var callback_link = '';

    // Bildirimde dönülecek bildirim ID'si. Alfanumerik ve en fazla 64 karakter olabilir.
    //callback_link gönderildiğinde bu alan zorunlu olmaktadır.
    var callback_id = '';

    var debug_on = '1'; //Entegrasyon hatalarını alabilmek için 1 olarak bırakın.

    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,
            'get_qr': get_qr,
            '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 Create service sample codes.[ **Click to download**](https://dev.paytr.com/en/link-api/link-api-create/PayTR%20Link%20API%20-%20Create%20.zip)

 [ ](https://dev.paytr.com/en/link-api) [](https://dev.paytr.com/en/link-api/link-api-delete)

---

## Navigation

- Parent: [Link API](https://dev.paytr.com/en/link-api.md)
- Next: [Link API Delete](https://dev.paytr.com/en/link-api/link-api-delete.md)
