> This page is for API Reference.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.navipartner.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.navipartner.com/_mcp/server.

# Create Voucher

POST https://api.npretail.app/{tenant}/{environment}/{company}/voucher
Content-Type: application/json

Use this endpoint to create a new voucher. If Reference No is blank, a new Reference No will be generated.

Reference: https://docs.navipartner.com/apis/api-reference/vouchers/voucher/create-voucher

## Authentication

- `x-np-api-key` header (required) — API Key authentication via header

## Request

### Path parameters

- `tenant` (string, required) — Your Entra Tenant ID. [More details.](/paths#1-tenant)
- `environment` (string, required) — Your Business Central Environment. [More details.](/paths#2-environment)
- `company` (string, required) — Your Business Central Company. [More details.](/paths#3-company)

### Body (application/json)

This endpoint expects a CreateVoucher.

- `documentNo` (string, required) — DocumentNo for which voucher is issued.
- `voucherType` (string, required) — The type of the voucher
- `referenceNo` (string, optional) — A unique reference number for the voucher
- `name` (string, optional) — The name of the customer who purchased the voucher
- `name2` (string, optional) — Other name of the buying customer
- `address` (string, optional) — The address of the buying customer
- `address2` (string, optional) — The address of the buying customer
- `postCode` (string, optional) — The postal code of the buying customer
- `city` (string, optional) — The city of the buying customer
- `county` (string, optional) — The county of the buying customer
- `countryCode` (string, optional) — The country where the buying customer resides.
- `email` (string, optional) — the email address of the buying customer
- `phoneNo` (string, optional) — The phone number of the buying customer.
- `voucherMessage` (string, optional) — indicates message on voucher
- `description` (string, optional) — A description of the voucher, usually includes Voucher Type and Voucher Number
- `startingDate` (datetime, optional) — The datetime as from which the voucher is valid

## Response

### 200

- `documentNo` (string, required) — DocumentNo for which voucher is issued.
- `voucherType` (string, required) — The type of the voucher
- `referenceNo` (string, optional) — A unique reference number for the voucher
- `name` (string, optional) — The name of the customer who purchased the voucher
- `name2` (string, optional) — Other name of the buying customer
- `address` (string, optional) — The address of the buying customer
- `address2` (string, optional) — The address of the buying customer
- `postCode` (string, optional) — The postal code of the buying customer
- `city` (string, optional) — The city of the buying customer
- `county` (string, optional) — The county of the buying customer
- `countryCode` (string, optional) — The country where the buying customer resides.
- `email` (string, optional) — the email address of the buying customer
- `phoneNo` (string, optional) — The phone number of the buying customer.
- `voucherMessage` (string, optional) — indicates message on voucher
- `description` (string, optional) — A description of the voucher, usually includes Voucher Type and Voucher Number
- `startingDate` (datetime, optional) — The datetime as from which the voucher is valid

## Examples

**Request**

```json
{
  "documentNo": "DocNo1",
  "voucherType": "CREDITVOUCHER",
  "referenceNo": "2802000002460",
  "name": "Spotsmeyer's Furnishings",
  "name2": "Spotsmeyer's Furnishings",
  "address": "Main Building, 1st Floor",
  "address2": "1234 Main Street",
  "postCode": "0011",
  "city": "New York",
  "county": "Manhattan",
  "countryCode": "US",
  "email": "john.doe@acme.com",
  "phoneNo": "+1234567890",
  "voucherMessage": "This is a voucher message",
  "description": "Credit Voucher 000002",
  "startingDate": "2024-09-17T00:00:00"
}
```

**Response**

```json
{
  "documentNo": "DocNo1",
  "voucherType": "CREDITVOUCHER",
  "referenceNo": "2802000002460",
  "name": "Spotsmeyer's Furnishings",
  "name2": "Spotsmeyer's Furnishings",
  "address": "Main Building, 1st Floor",
  "address2": "1234 Main Street",
  "postCode": "0011",
  "city": "New York",
  "county": "Manhattan",
  "countryCode": "US",
  "email": "john.doe@acme.com",
  "phoneNo": "+1234567890",
  "voucherMessage": "This is a voucher message",
  "description": "Credit Voucher 000002",
  "startingDate": "2024-09-17T00:00:00"
}
```

**SDK Code**

```python Example Create Voucher
import requests

url = "https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./voucher"

payload = {
    "documentNo": "DocNo1",
    "voucherType": "CREDITVOUCHER",
    "referenceNo": "2802000002460",
    "name": "Spotsmeyer's Furnishings",
    "name2": "Spotsmeyer's Furnishings",
    "address": "Main Building, 1st Floor",
    "address2": "1234 Main Street",
    "postCode": "0011",
    "city": "New York",
    "county": "Manhattan",
    "countryCode": "US",
    "email": "john.doe@acme.com",
    "phoneNo": "+1234567890",
    "voucherMessage": "This is a voucher message",
    "description": "Credit Voucher 000002",
    "startingDate": "2024-09-17T00:00:00"
}
headers = {
    "x-np-api-key": "<NaviPartner API Key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Example Create Voucher
const url = 'https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./voucher';
const options = {
  method: 'POST',
  headers: {'x-np-api-key': '<NaviPartner API Key>', 'Content-Type': 'application/json'},
  body: '{"documentNo":"DocNo1","voucherType":"CREDITVOUCHER","referenceNo":"2802000002460","name":"Spotsmeyer\'s Furnishings","name2":"Spotsmeyer\'s Furnishings","address":"Main Building, 1st Floor","address2":"1234 Main Street","postCode":"0011","city":"New York","county":"Manhattan","countryCode":"US","email":"john.doe@acme.com","phoneNo":"+1234567890","voucherMessage":"This is a voucher message","description":"Credit Voucher 000002","startingDate":"2024-09-17T00:00:00"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Example Create Voucher
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./voucher"

	payload := strings.NewReader("{\n  \"documentNo\": \"DocNo1\",\n  \"voucherType\": \"CREDITVOUCHER\",\n  \"referenceNo\": \"2802000002460\",\n  \"name\": \"Spotsmeyer's Furnishings\",\n  \"name2\": \"Spotsmeyer's Furnishings\",\n  \"address\": \"Main Building, 1st Floor\",\n  \"address2\": \"1234 Main Street\",\n  \"postCode\": \"0011\",\n  \"city\": \"New York\",\n  \"county\": \"Manhattan\",\n  \"countryCode\": \"US\",\n  \"email\": \"john.doe@acme.com\",\n  \"phoneNo\": \"+1234567890\",\n  \"voucherMessage\": \"This is a voucher message\",\n  \"description\": \"Credit Voucher 000002\",\n  \"startingDate\": \"2024-09-17T00:00:00\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-np-api-key", "<NaviPartner API Key>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Example Create Voucher
require 'uri'
require 'net/http'

url = URI("https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./voucher")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-np-api-key"] = '<NaviPartner API Key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"documentNo\": \"DocNo1\",\n  \"voucherType\": \"CREDITVOUCHER\",\n  \"referenceNo\": \"2802000002460\",\n  \"name\": \"Spotsmeyer's Furnishings\",\n  \"name2\": \"Spotsmeyer's Furnishings\",\n  \"address\": \"Main Building, 1st Floor\",\n  \"address2\": \"1234 Main Street\",\n  \"postCode\": \"0011\",\n  \"city\": \"New York\",\n  \"county\": \"Manhattan\",\n  \"countryCode\": \"US\",\n  \"email\": \"john.doe@acme.com\",\n  \"phoneNo\": \"+1234567890\",\n  \"voucherMessage\": \"This is a voucher message\",\n  \"description\": \"Credit Voucher 000002\",\n  \"startingDate\": \"2024-09-17T00:00:00\"\n}"

response = http.request(request)
puts response.read_body
```

```java Example Create Voucher
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./voucher")
  .header("x-np-api-key", "<NaviPartner API Key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"documentNo\": \"DocNo1\",\n  \"voucherType\": \"CREDITVOUCHER\",\n  \"referenceNo\": \"2802000002460\",\n  \"name\": \"Spotsmeyer's Furnishings\",\n  \"name2\": \"Spotsmeyer's Furnishings\",\n  \"address\": \"Main Building, 1st Floor\",\n  \"address2\": \"1234 Main Street\",\n  \"postCode\": \"0011\",\n  \"city\": \"New York\",\n  \"county\": \"Manhattan\",\n  \"countryCode\": \"US\",\n  \"email\": \"john.doe@acme.com\",\n  \"phoneNo\": \"+1234567890\",\n  \"voucherMessage\": \"This is a voucher message\",\n  \"description\": \"Credit Voucher 000002\",\n  \"startingDate\": \"2024-09-17T00:00:00\"\n}")
  .asString();
```

```php Example Create Voucher
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./voucher', [
  'body' => '{
  "documentNo": "DocNo1",
  "voucherType": "CREDITVOUCHER",
  "referenceNo": "2802000002460",
  "name": "Spotsmeyer\'s Furnishings",
  "name2": "Spotsmeyer\'s Furnishings",
  "address": "Main Building, 1st Floor",
  "address2": "1234 Main Street",
  "postCode": "0011",
  "city": "New York",
  "county": "Manhattan",
  "countryCode": "US",
  "email": "john.doe@acme.com",
  "phoneNo": "+1234567890",
  "voucherMessage": "This is a voucher message",
  "description": "Credit Voucher 000002",
  "startingDate": "2024-09-17T00:00:00"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-np-api-key' => '<NaviPartner API Key>',
  ],
]);

echo $response->getBody();
```

```csharp Example Create Voucher
using RestSharp;

var client = new RestClient("https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./voucher");
var request = new RestRequest(Method.POST);
request.AddHeader("x-np-api-key", "<NaviPartner API Key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"documentNo\": \"DocNo1\",\n  \"voucherType\": \"CREDITVOUCHER\",\n  \"referenceNo\": \"2802000002460\",\n  \"name\": \"Spotsmeyer's Furnishings\",\n  \"name2\": \"Spotsmeyer's Furnishings\",\n  \"address\": \"Main Building, 1st Floor\",\n  \"address2\": \"1234 Main Street\",\n  \"postCode\": \"0011\",\n  \"city\": \"New York\",\n  \"county\": \"Manhattan\",\n  \"countryCode\": \"US\",\n  \"email\": \"john.doe@acme.com\",\n  \"phoneNo\": \"+1234567890\",\n  \"voucherMessage\": \"This is a voucher message\",\n  \"description\": \"Credit Voucher 000002\",\n  \"startingDate\": \"2024-09-17T00:00:00\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example Create Voucher
import Foundation

let headers = [
  "x-np-api-key": "<NaviPartner API Key>",
  "Content-Type": "application/json"
]
let parameters = [
  "documentNo": "DocNo1",
  "voucherType": "CREDITVOUCHER",
  "referenceNo": "2802000002460",
  "name": "Spotsmeyer's Furnishings",
  "name2": "Spotsmeyer's Furnishings",
  "address": "Main Building, 1st Floor",
  "address2": "1234 Main Street",
  "postCode": "0011",
  "city": "New York",
  "county": "Manhattan",
  "countryCode": "US",
  "email": "john.doe@acme.com",
  "phoneNo": "+1234567890",
  "voucherMessage": "This is a voucher message",
  "description": "Credit Voucher 000002",
  "startingDate": "2024-09-17T00:00:00"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./voucher")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```