# Webhooks ## List webhooks `webhooks.list(WebhookListParams**kwargs) -> WebhookListResponse` **get** `/v2/webhooks/{teamId}` Lists the team's webhooks. Signing secrets are never included. ### Parameters - `team_id: Optional[str]` ### Returns - `class WebhookListResponse: …` - `data: List[Webhook]` - `id: str` - `created_at: datetime` - `enabled: bool` Disabled webhooks are skipped at delivery time. - `name: str` - `team_id: str` - `url: str` Endpoint events are delivered to. - `verified: bool` True once the endpoint has completed the verification handshake. - `description: Optional[str]` - `updated_at: Optional[datetime]` - `verification_token: Optional[str]` Stable token replayed to the endpoint (as the `micro_hook_token` query param) during the verification handshake. The endpoint may check it to confirm the request originated from Micro. - `verified_at: Optional[datetime]` ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) webhooks = client.webhooks.list() print(webhooks.data) ``` #### Response ```json { "data": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "enabled": true, "name": "name", "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "url": "https://example.com", "verified": true, "description": "description", "updated_at": "2019-12-27T18:11:19.117Z", "verification_token": "verification_token", "verified_at": "2019-12-27T18:11:19.117Z" } ] } ``` ## Create a webhook `webhooks.create(WebhookCreateParams**kwargs) -> WebhookWithSecret` **post** `/v2/webhooks/{teamId}` Registers a webhook and enqueues an asynchronous verification handshake (run by the dispatcher). The response includes the signing `secret`, shown only this once; `verified` is false until the handshake passes. ### Parameters - `team_id: Optional[str]` - `name: str` - `url: str` HTTP(S) endpoint. Rejected if it resolves to a private/internal address. - `description: Optional[str]` - `enabled: Optional[bool]` ### Returns - `class WebhookWithSecret: …` Returned ONLY on creation. Includes the signing secret (shown once) and the pending verification status. - `secret: str` HMAC signing secret (prefix `whsec_`). Store it now — it is never returned again. The dispatcher signs each delivered payload with it so your endpoint can verify authenticity. - `verification: Optional[WebhookWithSecretVerification]` Status of the verification handshake enqueued by this request. The handshake runs asynchronously in the dispatcher; poll the webhook (its `verified` flag flips to true on success) to observe the outcome. - `status: Literal["pending"]` Always `pending` at the moment of the response — the dispatcher has been asked to run the handshake but has not reported back yet. - `"pending"` ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) webhook_with_secret = client.webhooks.create( name="x", url="https://example.com", ) print(webhook_with_secret) ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "enabled": true, "name": "name", "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "url": "https://example.com", "verified": true, "description": "description", "updated_at": "2019-12-27T18:11:19.117Z", "verification_token": "verification_token", "verified_at": "2019-12-27T18:11:19.117Z", "secret": "secret", "verification": { "status": "pending" } } ``` ## Get a webhook `webhooks.get(strwebhook_id, WebhookGetParams**kwargs) -> Webhook` **get** `/v2/webhooks/{teamId}/{webhookId}` Get a webhook ### Parameters - `team_id: Optional[str]` - `webhook_id: str` ### Returns - `class Webhook: …` A registered webhook endpoint. - `id: str` - `created_at: datetime` - `enabled: bool` Disabled webhooks are skipped at delivery time. - `name: str` - `team_id: str` - `url: str` Endpoint events are delivered to. - `verified: bool` True once the endpoint has completed the verification handshake. - `description: Optional[str]` - `updated_at: Optional[datetime]` - `verification_token: Optional[str]` Stable token replayed to the endpoint (as the `micro_hook_token` query param) during the verification handshake. The endpoint may check it to confirm the request originated from Micro. - `verified_at: Optional[datetime]` ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) webhook = client.webhooks.get( webhook_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) print(webhook.id) ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "enabled": true, "name": "name", "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "url": "https://example.com", "verified": true, "description": "description", "updated_at": "2019-12-27T18:11:19.117Z", "verification_token": "verification_token", "verified_at": "2019-12-27T18:11:19.117Z" } ``` ## Update a webhook `webhooks.update(strwebhook_id, WebhookUpdateParams**kwargs) -> WebhookUpdateResponse` **patch** `/v2/webhooks/{teamId}/{webhookId}` Updates mutable fields. Changing `url` resets verification and re-runs the handshake. ### Parameters - `team_id: Optional[str]` - `webhook_id: str` - `description: Optional[str]` - `enabled: Optional[bool]` - `name: Optional[str]` - `url: Optional[str]` ### Returns - `class WebhookUpdateResponse: …` A webhook plus the status of a verification handshake enqueued by this request. - `verification: Optional[WebhookUpdateResponseVerification]` Status of the verification handshake enqueued by this request. The handshake runs asynchronously in the dispatcher; poll the webhook (its `verified` flag flips to true on success) to observe the outcome. - `status: Literal["pending"]` Always `pending` at the moment of the response — the dispatcher has been asked to run the handshake but has not reported back yet. - `"pending"` ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) webhook = client.webhooks.update( webhook_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) print(webhook) ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "enabled": true, "name": "name", "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "url": "https://example.com", "verified": true, "description": "description", "updated_at": "2019-12-27T18:11:19.117Z", "verification_token": "verification_token", "verified_at": "2019-12-27T18:11:19.117Z", "verification": { "status": "pending" } } ``` ## Delete a webhook `webhooks.delete(strwebhook_id, WebhookDeleteParams**kwargs)` **delete** `/v2/webhooks/{teamId}/{webhookId}` Delete a webhook ### Parameters - `team_id: Optional[str]` - `webhook_id: str` ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) client.webhooks.delete( webhook_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) ``` ## Re-run verification `webhooks.verify(strwebhook_id, WebhookVerifyParams**kwargs) -> WebhookVerifyResponse` **post** `/v2/webhooks/{teamId}/{webhookId}/verify` Re-runs the GET challenge/echo handshake against the webhook's url and updates its verified state. ### Parameters - `team_id: Optional[str]` - `webhook_id: str` ### Returns - `class WebhookVerifyResponse: …` A webhook plus the status of a verification handshake enqueued by this request. - `verification: Optional[WebhookVerifyResponseVerification]` Status of the verification handshake enqueued by this request. The handshake runs asynchronously in the dispatcher; poll the webhook (its `verified` flag flips to true on success) to observe the outcome. - `status: Literal["pending"]` Always `pending` at the moment of the response — the dispatcher has been asked to run the handshake but has not reported back yet. - `"pending"` ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) response = client.webhooks.verify( webhook_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) print(response) ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "created_at": "2019-12-27T18:11:19.117Z", "enabled": true, "name": "name", "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "url": "https://example.com", "verified": true, "description": "description", "updated_at": "2019-12-27T18:11:19.117Z", "verification_token": "verification_token", "verified_at": "2019-12-27T18:11:19.117Z", "verification": { "status": "pending" } } ``` ## Send a test event `webhooks.ping(strwebhook_id, WebhookPingParams**kwargs) -> WebhookPingResponse` **post** `/v2/webhooks/{teamId}/{webhookId}/ping` Fire-and-forget test delivery through the async dispatcher. The webhook must be enabled and verified. ### Parameters - `team_id: Optional[str]` - `webhook_id: str` - `data: Optional[Dict[str, object]]` Arbitrary JSON payload body. - `event: Optional[str]` Event name to send. ### Returns - `class WebhookPingResponse: …` - `dispatched: bool` - `event: str` - `webhook_id: str` ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) response = client.webhooks.ping( webhook_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) print(response.webhook_id) ``` #### Response ```json { "dispatched": true, "event": "event", "webhook_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" } ``` ## List team deliveries `webhooks.list_deliveries(WebhookListDeliveriesParams**kwargs) -> WebhookListDeliveriesResponse` **get** `/v2/webhooks/{teamId}/deliveries` Account-wide delivery feed across all of the team's webhooks, newest first. ### Parameters - `team_id: Optional[str]` - `cursor: Optional[str]` Opaque cursor from a previous response's `next_cursor`. - `limit: Optional[int]` Page size (1–100, default 25). - `status: Optional[Literal["success", "failed"]]` Filter by outcome. - `"success"` - `"failed"` - `type: Optional[Literal["delivery", "verification", "all"]]` Filter by run type. Defaults to `delivery` (event deliveries). Pass `all` to include verification handshakes. - `"delivery"` - `"verification"` - `"all"` ### Returns - `class WebhookListDeliveriesResponse: …` - `data: List[WebhookDelivery]` - `created_at: datetime` - `delivery_id: str` - `status: Literal["success", "failed"]` - `"success"` - `"failed"` - `type: Literal["delivery", "verification"]` - `"delivery"` - `"verification"` - `webhook_id: str` - `attempts: Optional[int]` Number of attempts made so far (including async retries). - `event: Optional[str]` Event name (e.g. `webhook.test`); `verification` for handshake runs. - `status_code: Optional[int]` HTTP status of the latest attempt; null on a transport error. - `team_id: Optional[str]` - `updated_at: Optional[datetime]` - `url: Optional[str]` - `next_cursor: Optional[str]` Pass as `cursor` to fetch the next page; null when there are no more. ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) response = client.webhooks.list_deliveries() print(response.data) ``` #### Response ```json { "data": [ { "created_at": "2019-12-27T18:11:19.117Z", "delivery_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "status": "success", "type": "delivery", "webhook_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "attempts": 0, "event": "event", "status_code": 0, "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "updated_at": "2019-12-27T18:11:19.117Z", "url": "url" } ], "next_cursor": "next_cursor" } ``` ## Domain Types ### Webhook - `class Webhook: …` A registered webhook endpoint. - `id: str` - `created_at: datetime` - `enabled: bool` Disabled webhooks are skipped at delivery time. - `name: str` - `team_id: str` - `url: str` Endpoint events are delivered to. - `verified: bool` True once the endpoint has completed the verification handshake. - `description: Optional[str]` - `updated_at: Optional[datetime]` - `verification_token: Optional[str]` Stable token replayed to the endpoint (as the `micro_hook_token` query param) during the verification handshake. The endpoint may check it to confirm the request originated from Micro. - `verified_at: Optional[datetime]` ### Webhook Create - `class WebhookCreate: …` On create, the dispatcher asynchronously runs a verification handshake: it sends a GET to `url` with `micro_hook_mode=subscribe`, a one-time `micro_hook_challenge`, and the webhook's `micro_hook_token`. The endpoint must respond 200 and echo the challenge value verbatim in the body; on success the webhook's `verified` flag flips to true. A failed handshake does not fail creation — re-run it later via the verify endpoint. - `name: str` - `url: str` HTTP(S) endpoint. Rejected if it resolves to a private/internal address. - `description: Optional[str]` - `enabled: Optional[bool]` ### Webhook Delivery - `class WebhookDelivery: …` A webhook delivery — one logical event delivery to an endpoint, grouping its attempts. Status and status_code reflect the latest attempt. - `created_at: datetime` - `delivery_id: str` - `status: Literal["success", "failed"]` - `"success"` - `"failed"` - `type: Literal["delivery", "verification"]` - `"delivery"` - `"verification"` - `webhook_id: str` - `attempts: Optional[int]` Number of attempts made so far (including async retries). - `event: Optional[str]` Event name (e.g. `webhook.test`); `verification` for handshake runs. - `status_code: Optional[int]` HTTP status of the latest attempt; null on a transport error. - `team_id: Optional[str]` - `updated_at: Optional[datetime]` - `url: Optional[str]` ### Webhook Delivery Detail - `class WebhookDeliveryDetail: …` A delivery plus its full attempt timeline. - `attempt_history: Optional[List[WebhookDeliveryDetailAttemptHistory]]` - `attempt: int` 1-based attempt number. - `created_at: datetime` - `status: Literal["success", "failed"]` - `"success"` - `"failed"` - `error: Optional[str]` Failure reason, when status is failed. - `request_body: Optional[str]` Body sent to the endpoint (delivery only); may be truncated. - `response_body: Optional[str]` Body returned by the endpoint; may be truncated. - `status_code: Optional[int]` ### Webhook Update - `class WebhookUpdate: …` Partial update. Changing `url` resets verification and re-runs the handshake. - `description: Optional[str]` - `enabled: Optional[bool]` - `name: Optional[str]` - `url: Optional[str]` ### Webhook With Secret - `class WebhookWithSecret: …` Returned ONLY on creation. Includes the signing secret (shown once) and the pending verification status. - `secret: str` HMAC signing secret (prefix `whsec_`). Store it now — it is never returned again. The dispatcher signs each delivered payload with it so your endpoint can verify authenticity. - `verification: Optional[WebhookWithSecretVerification]` Status of the verification handshake enqueued by this request. The handshake runs asynchronously in the dispatcher; poll the webhook (its `verified` flag flips to true on success) to observe the outcome. - `status: Literal["pending"]` Always `pending` at the moment of the response — the dispatcher has been asked to run the handshake but has not reported back yet. - `"pending"` ### Webhook List Response - `class WebhookListResponse: …` - `data: List[Webhook]` - `id: str` - `created_at: datetime` - `enabled: bool` Disabled webhooks are skipped at delivery time. - `name: str` - `team_id: str` - `url: str` Endpoint events are delivered to. - `verified: bool` True once the endpoint has completed the verification handshake. - `description: Optional[str]` - `updated_at: Optional[datetime]` - `verification_token: Optional[str]` Stable token replayed to the endpoint (as the `micro_hook_token` query param) during the verification handshake. The endpoint may check it to confirm the request originated from Micro. - `verified_at: Optional[datetime]` ### Webhook Update Response - `class WebhookUpdateResponse: …` A webhook plus the status of a verification handshake enqueued by this request. - `verification: Optional[WebhookUpdateResponseVerification]` Status of the verification handshake enqueued by this request. The handshake runs asynchronously in the dispatcher; poll the webhook (its `verified` flag flips to true on success) to observe the outcome. - `status: Literal["pending"]` Always `pending` at the moment of the response — the dispatcher has been asked to run the handshake but has not reported back yet. - `"pending"` ### Webhook Verify Response - `class WebhookVerifyResponse: …` A webhook plus the status of a verification handshake enqueued by this request. - `verification: Optional[WebhookVerifyResponseVerification]` Status of the verification handshake enqueued by this request. The handshake runs asynchronously in the dispatcher; poll the webhook (its `verified` flag flips to true on success) to observe the outcome. - `status: Literal["pending"]` Always `pending` at the moment of the response — the dispatcher has been asked to run the handshake but has not reported back yet. - `"pending"` ### Webhook Ping Response - `class WebhookPingResponse: …` - `dispatched: bool` - `event: str` - `webhook_id: str` ### Webhook List Deliveries Response - `class WebhookListDeliveriesResponse: …` - `data: List[WebhookDelivery]` - `created_at: datetime` - `delivery_id: str` - `status: Literal["success", "failed"]` - `"success"` - `"failed"` - `type: Literal["delivery", "verification"]` - `"delivery"` - `"verification"` - `webhook_id: str` - `attempts: Optional[int]` Number of attempts made so far (including async retries). - `event: Optional[str]` Event name (e.g. `webhook.test`); `verification` for handshake runs. - `status_code: Optional[int]` HTTP status of the latest attempt; null on a transport error. - `team_id: Optional[str]` - `updated_at: Optional[datetime]` - `url: Optional[str]` - `next_cursor: Optional[str]` Pass as `cursor` to fetch the next page; null when there are no more. # Deliveries ## List webhook deliveries `webhooks.deliveries.list(strwebhook_id, DeliveryListParams**kwargs) -> DeliveryListResponse` **get** `/v2/webhooks/{teamId}/{webhookId}/deliveries` An endpoint's deliveries, newest first, with optional status / type / time-range filters and cursor pagination. ### Parameters - `team_id: Optional[str]` - `webhook_id: str` - `after: Optional[Union[str, datetime]]` Only deliveries at or after this ISO-8601 timestamp. - `before: Optional[Union[str, datetime]]` Only deliveries at or before this ISO-8601 timestamp. - `cursor: Optional[str]` Opaque cursor from a previous response's `next_cursor`. - `limit: Optional[int]` Page size (1–100, default 25). - `status: Optional[Literal["success", "failed"]]` Filter by outcome. - `"success"` - `"failed"` - `type: Optional[Literal["delivery", "verification", "all"]]` Filter by run type. Defaults to `delivery` (event deliveries). Pass `all` to include verification handshakes. - `"delivery"` - `"verification"` - `"all"` ### Returns - `class DeliveryListResponse: …` - `data: List[WebhookDelivery]` - `created_at: datetime` - `delivery_id: str` - `status: Literal["success", "failed"]` - `"success"` - `"failed"` - `type: Literal["delivery", "verification"]` - `"delivery"` - `"verification"` - `webhook_id: str` - `attempts: Optional[int]` Number of attempts made so far (including async retries). - `event: Optional[str]` Event name (e.g. `webhook.test`); `verification` for handshake runs. - `status_code: Optional[int]` HTTP status of the latest attempt; null on a transport error. - `team_id: Optional[str]` - `updated_at: Optional[datetime]` - `url: Optional[str]` - `next_cursor: Optional[str]` Pass as `cursor` to fetch the next page; null when there are no more. ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) deliveries = client.webhooks.deliveries.list( webhook_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) print(deliveries.data) ``` #### Response ```json { "data": [ { "created_at": "2019-12-27T18:11:19.117Z", "delivery_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "status": "success", "type": "delivery", "webhook_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "attempts": 0, "event": "event", "status_code": 0, "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "updated_at": "2019-12-27T18:11:19.117Z", "url": "url" } ], "next_cursor": "next_cursor" } ``` ## Get a delivery `webhooks.deliveries.get(strdelivery_id, DeliveryGetParams**kwargs) -> WebhookDeliveryDetail` **get** `/v2/webhooks/{teamId}/{webhookId}/deliveries/{deliveryId}` A single delivery plus its full attempt timeline (including async retries). ### Parameters - `team_id: Optional[str]` - `webhook_id: str` - `delivery_id: str` ### Returns - `class WebhookDeliveryDetail: …` A delivery plus its full attempt timeline. - `attempt_history: Optional[List[WebhookDeliveryDetailAttemptHistory]]` - `attempt: int` 1-based attempt number. - `created_at: datetime` - `status: Literal["success", "failed"]` - `"success"` - `"failed"` - `error: Optional[str]` Failure reason, when status is failed. - `request_body: Optional[str]` Body sent to the endpoint (delivery only); may be truncated. - `response_body: Optional[str]` Body returned by the endpoint; may be truncated. - `status_code: Optional[int]` ### Example ```python import os from micro_so import Micro client = Micro( api_key=os.environ.get("MICRO_API_KEY"), # This is the default and can be omitted ) webhook_delivery_detail = client.webhooks.deliveries.get( delivery_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", webhook_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", ) print(webhook_delivery_detail) ``` #### Response ```json { "created_at": "2019-12-27T18:11:19.117Z", "delivery_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "status": "success", "type": "delivery", "webhook_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "attempts": 0, "event": "event", "status_code": 0, "team_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "updated_at": "2019-12-27T18:11:19.117Z", "url": "url", "attempt_history": [ { "attempt": 0, "created_at": "2019-12-27T18:11:19.117Z", "status": "success", "error": "error", "request_body": "request_body", "response_body": "response_body", "status_code": 0 } ] } ``` ## Domain Types ### Delivery List Response - `class DeliveryListResponse: …` - `data: List[WebhookDelivery]` - `created_at: datetime` - `delivery_id: str` - `status: Literal["success", "failed"]` - `"success"` - `"failed"` - `type: Literal["delivery", "verification"]` - `"delivery"` - `"verification"` - `webhook_id: str` - `attempts: Optional[int]` Number of attempts made so far (including async retries). - `event: Optional[str]` Event name (e.g. `webhook.test`); `verification` for handshake runs. - `status_code: Optional[int]` HTTP status of the latest attempt; null on a transport error. - `team_id: Optional[str]` - `updated_at: Optional[datetime]` - `url: Optional[str]` - `next_cursor: Optional[str]` Pass as `cursor` to fetch the next page; null when there are no more.