Hi @databrickspooja
Yes, the 401 is expected: the Databricks Apps proxy only accepts OAuth access tokens, not PATs, so it rejects the request before your code runs. A static header can't hold an OAuth token either, because M2M tokens expire after about an hour. The supported pattern is a small relay in front of the app that holds the service principal's OAuth secret, gets and caches a token, and forwards the webhook.
Why the PAT fails
- PATs work for the workspace REST API, but app URLs go through the Apps auth proxy, which only accepts OAuth tokens (user U2M or service principal M2M).
The app docs only describe OAuth bearer tokens (M2M for external systems): https://docs.databricks.com/aws/en/dev-tools/databricks-apps/connect-local. The notebook example there even exchanges a PAT for an OAuth token first, and the MCP-on-Apps docs say outright that PATs aren't supported. So your 401 matches the documented behaviour, even if there's no single sentence saying "PATs rejected."
- There's no anonymous or public mode for an app, so the SaaS sender can't call it directly with only a static header.
You can have a relay setup something like below:
1. Deploy a tiny HTTPS function (AWS Lambda + function URL, Azure Function, Cloud Run or a Cloudflare Worker) as the public webhook target.
2. Have the SaaS send its static header (a long random shared secret) and check it in the relay. Also verify the sender's HMAC signature if it offers one.
3. In the relay, get an M2M token from https://<workspace-host>/oidc/v1/token with grant_type=client_credentials&scope=all-apis, using the service principal's client ID and secret (stored in the cloud's secret manager). Cache the token until shortly before expires_in.
4. Forward the body to the app with Authorization: Bearer <token>. You've already confirmed this path reaches your code.
token = requests.post(f"{HOST}/oidc/v1/token",
auth=(CLIENT_ID, CLIENT_SECRET),
data={"grant_type": "client_credentials", "scope": "all-apis"}).json()["access_token"]
requests.post(APP_URL + "/webhook", data=body,
headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"})
If the app only stores the events, consider skipping the app: let the relay write the payloads to a cloud storage path or queue and pick them up with Auto Loader or a Lakeflow pipeline. That way you don't need a long-running endpoint at all.
If the solution helps, please accept it as solution so that it is helpful for other community members ๐