CLI Tool
Triggering Webhooks with CLI
The Webhook Simulator CLI tool allows you to trigger webhook events manually, which is incredibly useful for testing your webhook handlers without waiting for actual events to occur.
Triggering a Webhook Event
To trigger a webhook event, use the following command:
ws-cli trigger [provider-name] [event-name]
Replace [provider-name]
with the name of the webhook provider (e.g., Stripe, Coinbase) and [event-name]
with the specific event you want to trigger (e.g., customer.created, order.paid).
Example:
ws-cli trigger Stripe customer.created
How It Works
- API Request: The CLI sends a POST request to the Webhook Simulator API with the specified event type.
- Event Generation: The server generates a simulated event payload based on the provider and event type.
- Webhook Dispatch: The simulated event is sent to your configured webhook URL.
- Response Capture: If you're also running the listen command, the CLI will capture and display the response from your endpoint.
Options Coming Soon
You can also specify a forwarding URL directly with the trigger command:
ws-cli trigger [provider-name] [event-name] --forward-to [yourLocalAppUrl]
This allows you to trigger an event and forward it to a specific URL in one command.
Best Practices
- Testing Various Scenarios: Use the trigger command to test how your application handles different event types.
- Debugging: Trigger specific events that you're having trouble with to debug your webhook handlers.
- Integration Testing: Incorporate webhook triggering into your automated test suites for comprehensive integration testing.
Viewing Results
After triggering an event, you'll see output in your terminal including:
- Confirmation that the event was triggered
- The simulated payload (if using the listen command)
- The response from your webhook handler (if using the listen command)
Error Handling
If there's an issue triggering the webhook (e.g., invalid event type, authentication error), the CLI will display an error message with details about what went wrong.
Limitations
- The triggered events are simulations and may not contain all the details of a real event. Always verify critical integrations with real events as well.
- The number of events you can trigger might be limited based on your Webhook Simulator plan.
Troubleshooting
- If you're unable to trigger events, ensure your CLI is properly authenticated.
- Verify that you're using the correct provider name and event type.
- Check your internet connection if you're having trouble communicating with the Webhook Simulator API.
Triggering webhooks via the CLI is a powerful way to test and validate your webhook handling logic quickly and efficiently. Use this feature to ensure your integrations are robust and ready for production use.