Skip to content

Commit bd4fbdd

Browse files
authored
Update webhooks.md
1 parent ab896c2 commit bd4fbdd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Diff for: docs/features/webhooks.md

+31
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,37 @@ curl -X POST "https://example.com/webhooks/signal/order-workflow/1/mark-as-shipp
8181
-H "Content-Type: application/json"
8282
```
8383

84+
## Webhook URL Helper
85+
The `$this->webhookUrl()` helper generates webhook URLs for starting workflows or sending signals.
86+
87+
```
88+
$activity->webhookUrl();
89+
$activity->webhookUrl('signalMethod');
90+
```
91+
92+
Parameters
93+
- string $signalMethod = '' (optional)
94+
95+
If empty, returns the URL for starting the workflow.
96+
97+
If provided, returns the URL for sending a signal to an active workflow instance.
98+
99+
```
100+
use Workflow\Activity;
101+
102+
class ShipOrderActivity extends Activity
103+
{
104+
public function execute(string $email, StoredWorkflow $storedWorkflow): void
105+
{
106+
$startUrl = $this->webhookUrl();
107+
// $startUrl = '/webhooks/start/order-workflow';
108+
109+
$signalUrl = $this->webhookUrl('markAsShipped');
110+
// $signalUrl = '/webhooks/signal/order-workflow/{workflowId}/mark-as-shipped';
111+
}
112+
}
113+
```
114+
84115
## Webhook Authentication
85116
By default, webhooks don't require authentication but this can be configured in `config/workflows.php`.
86117

0 commit comments

Comments
 (0)