> ## Documentation Index
> Fetch the complete documentation index at: https://nango.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to set up webhooks with ConnectWise PSA on Nango

> Learn how to receive real-time ConnectWise PSA events in Nango

This guide explains how Nango receives and routes ConnectWise PSA webhooks.

## How it works

1. ConnectWise sends a signed POST request to your Nango webhook URL when a subscribed event occurs.
2. Nango verifies the signature using the signing key referenced in the payload's `Metadata.key_url` (only trusted `*.myconnectwise.net` subdomains are accepted).
3. Nango routes the webhook to the matching connection(s), then either forwards it to your app or runs a sync (`onWebhook`).

## Connection routing

ConnectWise webhook payloads include a `ProductInstanceId` field identifying the tenant the event belongs to. Nango routes each webhook to the connection(s) whose `metadata.productInstanceId` **exactly matches** the payload's `ProductInstanceId`.

<Warning>
  You must set `metadata.productInstanceId` on each connection for webhook routing to work. If it is unset (or does not match the `ProductInstanceId` in the payload), the connection receives no webhooks. The match is case-sensitive.
</Warning>

### Set `metadata.productInstanceId` on a connection

Set `metadata.productInstanceId` to the ConnectWise Product Instance ID for that tenant — the same Product Instance ID used in the connection's credentials (the value ConnectWise sends as `ProductInstanceId` in the webhook payload).

Set it via the API:

```bash theme={null}
curl -X PATCH "https://api.nango.dev/connections/metadata" \
  -H "Authorization: Bearer <NANGO-API-KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "connection_id": "<CONNECTION_ID>",
    "provider_config_key": "connectwise-psa",
    "metadata": { "productInstanceId": "<CONNECTWISE-PRODUCT-INSTANCE-ID>" }
  }'
```

`PATCH` merges the key into existing metadata; use `POST` if you want to replace all metadata.

You can also set it from a [post-connection-creation event function](/docs/getting-started/use-cases/implement-event-handler) with `nango.updateMetadata({ productInstanceId })` once you have the Product Instance ID for the connection.

## Handle the webhook

Once routed to a connection, you have two options:

* **Forward it to your app** — Nango verifies the signature and forwards the event to your webhook URL with connection attribution. See [External webhook forwarding](/docs/guides/platform/webhook-forwarding).
* **Process it in a sync** — run a sync when the webhook arrives using `webhookSubscriptions` and `onWebhook` in a sync script. See [Real-time syncs](/docs/guides/functions/syncs/realtime-syncs).

<Tip>Need help getting started? Get help in the [community](https://nango.dev/slack).</Tip>

***
