Skip to main content
Version: 2.0.0

PDP Sync Error Webhooks

Permit.io PDPs report their state to the API, so when data synchronization doesn't work, the system can automatically retry. If it doesn't work after several retries, Permit's support team will be notified automatically so they can look into the issue. If you want to be notified too, you can define a webhook to make Permit notify you when that happens.

Note that the system will only trigger the notification flow if a PDP reports it's online, but cannot sync. If a PDP is offline, no report will be made.

First, make sure your PDP is of at least version 0.2.24. This feature won't work with older PDPs.

To define a webhook, POST to https://api.permit.io/v2/projects/{project}/envs/{environment}/webhooks as follows:

curl \
-H 'Authorization: Bearer API_SECRET_KEY' \
-H 'Content-Type: application/json' \
-d '{"type": "pdp_sync_error", "url": "https://your.webhook.receiver/path/to/webhook"}'
'https://api.permit.io/v2/projects/{project_id}/envs/{env_id}/webooks'

As with other APIs, the project and environment can be either IDs or keys.

On a sync error, Permit will trigger a POST request to your defined URL, with a payload that looks like this:

{
"org_id": "a40c5d1f-d889-43e9-94ea-b9b33585fc6b",
"project_id": "405d8339-3514-403b-8c43-83ae74cfe0e9",
"env_id": "3f967d0d-4d55-42f3-97c4-6a5455dfe4a6",
"pdp_ids": ["497f6eca-6276-4993-bfeb-53cbbbba6f08"],
}

Example receiver

Here's an example receiver for the webhook:

from uuid import UUID

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class PDPErrorWebhook(BaseModel):
org_id: UUID
project_id: UUID
env_id: UUID
pdp_ids: list[UUID]


@app.post("/webhook")
def post_webhook(webhook_data: PDPErrorWebhook):
print(f"Got webhook with {webhook_data}")

The full reference for the webhooks API is available at https://api.permit.io/v2/redoc#tag/Webhooks.