> 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 subscription

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

Creates a new webhook subscription for a specific external business event, configuring the notification endpoint and event details.

Reference: https://docs.navipartner.com/apis/api-reference/system-services/webhooks/create-subscription

## 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 WebhookSubscriptionRequest.

- `notificationUrl` (string, required) — The full URL endpoint that will receive webhook notifications when the specified event occurs.
- `eventName` (string, required) — Represents the specific name of the external business event that triggers the webhook notification.
- `appId` (UUID, optional) — Unique identifier (UUID) of the application associated with the webhook subscription. Use only for webhooks included in custom applications (custom webhooks).
- `eventVersion` (string, optional) — Specifies the version of the webhook event. If no version is provided, it defaults to the standard version '1.0'.
- `clientState` (string, optional) — The `clientState` property must be provided in the `POST` requests bodies. `clientState` is included in the body of a webhook notification and can be used as an opaque token; a shared secret, enabling the subscriber to verify notifications. The value can be any string up to 50 characters, we recommend using a unique value for each subscription (ideally as a UUID or a base64 encoded string etc.).

## Response

### 200

- `@odata.etag` (string, required) — An internal property (a version control mechanism used by OData to manage concurrency and track changes in resource entities).
- `id` (UUID, required) — Unique identifier (UUID) for a webhook subscription. Required for retrieving or deleting an existing webhook subscription through the API.
- `companyId` (UUID, required)
- `timestamp` (long, required)
- `appId` (UUID, required) — Unique identifier (UUID) of the application associated with the webhook subscription. Use only for webhooks included in custom applications (custom webhooks).
- `eventName` (string, required) — Represents the specific name of the external business event that triggers the webhook notification.
- `companyName` (string, required) — Name of the company within the Business Central environment for which the webhook subscription is configured.
- `userId` (UUID, required) — Unique identifier (UUID) representing the user who created or modified the webhook subscription.
- `notificationUrl` (string, required) — The full URL endpoint that will receive webhook notifications when the specified event occurs.
- `lastModifiedDateTime` (datetime, required)
- `clientState` (string, required) — The `clientState` property must be provided in the `POST` requests bodies. `clientState` is included in the body of a webhook notification and can be used as an opaque token; a shared secret, enabling the subscriber to verify notifications. The value can be any string up to 50 characters, we recommend using a unique value for each subscription (ideally as a UUID or a base64 encoded string etc.).
- `subscriptionType` (enum, required) — Defines the type of subscription supported by the webhook system. Currently, only the "Webhook" type is valid.
  - Allowed values: `Dataverse`, `Webhook`
- `eventVersion` (string, required) — Specifies the version of the webhook event. If no version is provided, it defaults to the standard version '1.0'.
- `subscriptionState` (string, required)
- `systemCreatedAt` (datetime, required)
- `systemCreatedBy` (UUID, required) — Unique identifier (UUID) representing the user who created or modified the webhook subscription.
- `systemModifiedAt` (datetime, required)
- `systemModifiedBy` (UUID, required) — Unique identifier (UUID) representing the user who created or modified the webhook subscription.

## Examples

**Request**

```json
{
  "notificationUrl": "https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7",
  "eventName": "pos_sale_completed",
  "clientState": "HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD"
}
```

**Response**

```json
{
  "@odata.etag": "W/\"JzIwOzEwNzkxMzk5ODM2MTM3MjIwMTQ2MTswMDsn\"",
  "id": "9a381cbf-ad95-4c20-a35d-e94125a91f9e",
  "companyId": "a2518dbc-2baf-ef11-b8eb-6045bde99e24",
  "timestamp": 183372,
  "appId": "992c2309-cca4-43cb-9e41-911f482ec088",
  "eventName": "pos_sale_completed",
  "companyName": "CRONUS%20International%20Ltd.",
  "userId": "6ea36ab6-941a-405b-a184-94ddebff707e",
  "notificationUrl": "https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7",
  "lastModifiedDateTime": "2024-12-02T20:45:29Z",
  "clientState": "HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD",
  "subscriptionType": "Webhook",
  "eventVersion": "1.0",
  "subscriptionState": "Active",
  "systemCreatedAt": "2024-12-02T20:45:29.053Z",
  "systemCreatedBy": "6ea36ab6-941a-405b-a184-94ddebff707e",
  "systemModifiedAt": "2024-12-02T20:45:29.053Z",
  "systemModifiedBy": "6ea36ab6-941a-405b-a184-94ddebff707e"
}
```

**SDK Code**

```python
import requests

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

payload = {
    "notificationUrl": "https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7",
    "eventName": "pos_sale_completed",
    "clientState": "HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD"
}
headers = {
    "x-np-api-key": "<NaviPartner API Key>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./webhook';
const options = {
  method: 'POST',
  headers: {'x-np-api-key': '<NaviPartner API Key>', 'Content-Type': 'application/json'},
  body: '{"notificationUrl":"https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7","eventName":"pos_sale_completed","clientState":"HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD"}'
};

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

```go
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"notificationUrl\": \"https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7\",\n  \"eventName\": \"pos_sale_completed\",\n  \"clientState\": \"HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD\"\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
require 'uri'
require 'net/http'

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

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  \"notificationUrl\": \"https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7\",\n  \"eventName\": \"pos_sale_completed\",\n  \"clientState\": \"HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD\"\n}"

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

```java
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./webhook")
  .header("x-np-api-key", "<NaviPartner API Key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"notificationUrl\": \"https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7\",\n  \"eventName\": \"pos_sale_completed\",\n  \"clientState\": \"HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD\"\n}")
  .asString();
```

```php
<?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./webhook', [
  'body' => '{
  "notificationUrl": "https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7",
  "eventName": "pos_sale_completed",
  "clientState": "HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-np-api-key' => '<NaviPartner API Key>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.npretail.app/01234567-89ab-cdef-0123-456789abcdef/production/CRONUS%2520International%2520Ltd./webhook");
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  \"notificationUrl\": \"https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7\",\n  \"eventName\": \"pos_sale_completed\",\n  \"clientState\": \"HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-np-api-key": "<NaviPartner API Key>",
  "Content-Type": "application/json"
]
let parameters = [
  "notificationUrl": "https://webhook.site/7bb075d4-62ff-4bd9-8832-502c9ed94ab7",
  "eventName": "pos_sale_completed",
  "clientState": "HVA0Y6B84KBNISG45W6CA4TNE38CHSBASD"
] 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./webhook")! 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()
```