# Request Voucher

Create a withdraw voucher request to be redeemed by anyone. Money will be deducted from your lightning wallet.

#### Method

```

POST https://api.ninjapay.me/lapi/v1/requestVoucher

```

#### Parameters

```javascript
Body (application/json)
{
  amount: number, // The amount in BTC(not SAT) per voucher
  voucher_count: number; // Number of vouhers required (1min - 100max)
  from?: string; // Optional From title for voucher giveaway
  title?: string; // Title/message of the voucher 
  expiry?: number; // Optional voucher expiry in mins
  receiver_email?: string, // Add this email ID if you want to send the voucher to an email. Note: voucher_count has to be one for email trigger!
  unique_design?: bool, // Add "true" if you want to use your own custom design for voucher.
  unique_design_url?: string, // Custom voucher design url in 640x360px(16:9) in size.
  callback_url?: string, // Add this if you want a success response upon 
}

```

#### Response

<pre class="language-jsx"><code class="lang-jsx">{
  "status": true,
<strong>    "data": {
</strong>        "tid": "19M86602AN139N97", 
        "created_at": 1414912921,
        "expires_at": 1714912921,
        "voucher_count": 2,
        "voucher_redeemed": 1,
        "amount": 0.00001000, // amount/voucher in BTC
        "from": "Swiggy",
        "title": "Congrats IPL Spinwheel winner",
        "receiver_email": null, // Note: voucher_count has to be one for email trigger!
        "email_status": "undefined", // "success", "pending", "undefined" status's
        "unique_design": true,
        "unique_design_url": "https://www.mycompanydesignin600x900pixel.com",
        "callback_url": "https://yourwebhook.com",
        "voucher_static_url": "https://www.ninjapay.me/voucher/198660213997", // This single multi use url can be used to redeem all vouchers.
        "voucher_urls": [
               {
                "voucher_url": "https://www.ninjapay.me/voucher/redeem/7ee15185"
               },
               {
                "voucher_url": "https://www.ninjapay.me/voucher/redeem/39e11981h",
               },
          ]
      },
     "message": "", 
}

</code></pre>

Note: By default for static voucher url's, a ninjapay user(@username) can redeem only once. This will avoid ass-milking.&#x20;

#### Webhook Response

```json

{
  "tid":"1986B6021A3N997",
  "voucher_url": "https://www.ninjapay.me/voucher/redeem/7ee15185",
  "redeemed_by": "ninjatagUsername", // @ninjatag(ninjapay username) or invoice(lnbc..ndjj)
  "redeemed_tid": 128660213994,
}
```

#### Code Example

```jsx

const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'API_KEY' //Admin key required
  },
  body: '{"amount":0.00180204,"voucher_count":1,"title":"Happy Birthday🥳"}'
};

fetch('https://api.ninjapay.me/lapi/v1/requestVoucher', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
  
```
