Skip to main content

WebhooksApi

Register and manage webhooks for real-time notifications when documents change.

wh_api = client.webhooks

Base path: /api/v6/webhooks

Common Event Types

WebhooksApi.EVENTS = [
"onshape.model.lifecycle.changed",
"onshape.model.translation.complete",
"onshape.document.lifecycle.statechange",
"onshape.workflow.transition",
"onshape.comment.create",
"onshape.revision.created",
]

Methods

list

List all webhooks owned by the current user.

webhooks.list() -> list[Webhook]
hooks = client.webhooks.list()
for h in hooks:
print(f"{h.id}: {h.url} — events={h.events}")

create

Register a new webhook.

webhooks.create(
url: str,
events: list[str],
filter: str | None = None,
options: dict | None = None
) -> Webhook
ParameterTypeDescription
urlstrYour callback endpoint URL
eventslist[str]Event types to subscribe to
filterstrOptional JSON filter (e.g., '{"documentId": "abc123"}')
optionsdictOptional config (e.g., {"collapseEvents": True})
webhook = client.webhooks.create(
url="https://my-server.com/onshape-webhook",
events=["onshape.model.lifecycle.changed"],
filter='{"documentId": "804d1a7a071db077dbad4e42"}',
)
print(f"Created webhook: {webhook.id}")

Example response object:

{
"id": "wh-abc123",
"url": "https://my-server.com/onshape-webhook",
"events": ["onshape.model.lifecycle.changed"],
"options": {},
"raw": { ... }
}

get

Get details of a specific webhook.

webhooks.get(webhook_id: str) -> Webhook

update

Update an existing webhook.

webhooks.update(
webhook_id: str,
url: str | None = None,
events: list[str] | None = None,
filter: str | None = None,
options: dict | None = None
) -> Webhook
client.webhooks.update(
"wh-abc123",
events=["onshape.model.lifecycle.changed", "onshape.comment.create"],
)

delete

Delete a webhook.

webhooks.delete(webhook_id: str) -> None
client.webhooks.delete("wh-abc123")