Request Bins¶
7 endpoints for request capture, inspection, and replay.
| Method |
Endpoint |
Purpose |
POST |
/v1/bins |
Create a request bin |
GET |
/v1/bins/{bin_id} |
Retrieve bin metadata |
DELETE |
/v1/bins/{bin_id} |
Delete a bin |
GET |
/v1/bins/{bin_id}/requests |
List captured requests |
GET |
/v1/bins/{bin_id}/requests/{request_id} |
Retrieve one captured request |
POST |
/v1/bins/{bin_id}/requests/{request_id}/replay |
Replay a captured request |
ANY |
/v1/catch/{bin_id} |
Public endpoint that captures traffic into a bin |
Python SDK Examples¶
Create a request bin¶
from toolkitapi import Webhook
with Webhook(api_key="tk_...") as wh:
created = wh.create_bin(
name="payment-webhooks",
ttl_seconds=7200,
)
bin_id = created["bin"]["bin_id"]
catch_path = created["bin"]["catch_url"]
print(bin_id)
print(f"https://webhook.toolkitapi.io{catch_path}")
Capture traffic in the bin¶
The catch endpoint is public and can receive any HTTP method.
curl -X POST "https://webhook.toolkitapi.io/v1/catch/{bin_id}?event=invoice.paid" \
-H "Content-Type: application/json" \
-H "X-Provider-Signature: test-signature" \
-d '{"id":"evt_123","type":"invoice.paid"}'
List captured requests¶
from toolkitapi import Webhook
with Webhook(api_key="tk_...") as wh:
requests = wh.list_bin_requests("<bin_id>", limit=50, offset=0)
print(requests["total"])
for req in requests["requests"]:
print(req["request_id"], req["method"], req["path"], req["timestamp"])
Inspect one captured request¶
from toolkitapi import Webhook
with Webhook(api_key="tk_...") as wh:
detail = wh.get_bin_request("<bin_id>", "<request_id>")
req = detail["request"]
print(req["method"], req["path"])
print(req["query_string"])
print(req["headers"].get("content-type"))
print(req["body"])
Replay a captured request to a target URL¶
from toolkitapi import Webhook
with Webhook(api_key="tk_...") as wh:
replay = wh.replay_bin_request(
"<bin_id>",
"<request_id>",
target_url="https://httpbin.org/anything",
)
print(replay["response_status"])
print(replay["elapsed_ms"])
Delete a bin when done¶
from toolkitapi import Webhook
with Webhook(api_key="tk_...") as wh:
result = wh.delete_bin("<bin_id>")
print(result["message"])
Request Parameters¶
POST /v1/bins¶
| Parameter |
Type |
Description |
name |
string |
Optional friendly name, max 128 chars |
ttl_seconds |
integer |
Lifetime in seconds, 60 to 172800 |
GET /v1/bins/{bin_id}/requests¶
| Parameter |
Type |
Description |
limit |
integer |
Page size, 1 to 200 (default 50) |
offset |
integer |
Pagination offset, >= 0 |
POST /v1/bins/{bin_id}/requests/{request_id}/replay¶
| Parameter |
Type |
Description |
target_url |
string |
Destination URL for replay |
Response Fields¶
| Field |
Type |
Description |
bin.bin_id |
string |
Bin identifier |
bin.name |
string |
Optional bin name |
bin.created_at |
string |
ISO timestamp |
bin.expires_at |
string |
ISO timestamp |
bin.request_count |
integer |
Number of captured requests |
bin.catch_url |
string |
Relative catch path (/v1/catch/{bin_id}) |
Captured request summary¶
| Field |
Type |
Description |
request_id |
string |
Captured request identifier |
method |
string |
HTTP method |
path |
string |
Request path |
source_ip |
string |
Source IP address |
timestamp |
string |
Capture timestamp |
content_length |
integer |
Body size in bytes |
Captured request detail¶
| Field |
Type |
Description |
headers |
object |
Captured request headers |
body |
string |
Request body as decoded text |
query_string |
string |
Raw query string |
content_type |
string |
Content type header value |
Replay response¶
| Field |
Type |
Description |
replayed_to |
string |
Target URL used for replay |
response_status |
integer |
Status from target server |
response_headers |
object |
Target response headers |
response_body |
string |
Response body (truncated for safety) |
elapsed_ms |
float |
Replay duration in milliseconds |
Tip
Keep ttl_seconds short for test bins to reduce accidental exposure. If a provider needs a stable URL during a longer test, recreate bins intentionally and update the integration endpoint explicitly.