Skip to content

Webhooks

Manage and test webhook event delivery. Webhook events are sent to the callback_url configured in your agent profile via PATCH /me.

---

List Webhook Events

GET /webhooks | Auth: Required

Retrieve a paginated list of webhook delivery attempts.

Request

#### Query Parameters

FieldTypeRequiredDefaultDescription
statusstringNo--Filter by delivery status: "pending", "delivered", or "failed"
event_typestringNo--Filter by event type (e.g., "swap.completed")
limitintegerNo20Number of results per page (max 100)
offsetintegerNo0Number of results to skip for pagination

Response

FieldTypeDescription
successbooleanWhether the request succeeded
eventsarrayList of webhook event objects
paginationobjectPagination metadata

#### Event Object

FieldTypeDescription
idstringUnique event identifier
event_typestringType of event (e.g., "swap.completed", "swap.failed")
statusstringDelivery status: "pending", "delivered", or "failed"
attemptsintegerNumber of delivery attempts made
last_errorstring \nullError message from the most recent failed attempt
response_statusinteger \nullHTTP status code returned by your callback endpoint
callback_urlstringThe URL the event was sent to
created_atstringISO 8601 timestamp when the event was created
delivered_atstring \nullISO 8601 timestamp when the event was successfully delivered

#### Pagination Object

FieldTypeDescription
totalintegerTotal number of matching events
limitintegerCurrent page size
offsetintegerCurrent offset
has_morebooleanWhether more results exist beyond this page

Example Response

{

"hl-key">"success": true,

"hl-key">"events": [

{

"hl-key">"id": "evt_9f3a1b2c",

"hl-key">"event_type": "swap.completed",

"hl-key">"status": "delivered",

"hl-key">"attempts": 1,

"hl-key">"last_error": null,

"hl-key">"response_status": 200,

"hl-key">"callback_url": "https://yourapp.com/webhooks/suwappu",

"hl-key">"created_at": "2026-03-07T14:30:00Z",

"hl-key">"delivered_at": "2026-03-07T14:30:01Z"

},

{

"hl-key">"id": "evt_7d4e5f6a",

"hl-key">"event_type": "swap.failed",

"hl-key">"status": "failed",

"hl-key">"attempts": 3,

"hl-key">"last_error": "Connection timeout",

"hl-key">"response_status": null,

"hl-key">"callback_url": "https://yourapp.com/webhooks/suwappu",

"hl-key">"created_at": "2026-03-07T12:15:00Z",

"hl-key">"delivered_at": null

}

],

"hl-key">"pagination": {

"hl-key">"total": 87,

"hl-key">"limit": 20,

"hl-key">"offset": 0,

"hl-key">"has_more": true

}

}

---

Test Webhook

POST /webhooks/test | Auth: Required

Send a test event to your configured callback_url. You must have a callback_url set in your agent profile (via PATCH /me) before calling this endpoint.

Request

No body required.

Response

FieldTypeDescription
successbooleanWhether the test delivery succeeded
callback_urlstringThe URL the test event was sent to
status_codeintegerHTTP status code returned by your callback endpoint
response_time_msintegerRound-trip response time in milliseconds

Example Response

{

"hl-key">"success": true,

"hl-key">"callback_url": "https://yourapp.com/webhooks/suwappu",

"hl-key">"status_code": 200,

"hl-key">"response_time_ms": 142

}

---

Errors

StatusErrorCause
400"No callback_url configured"You have not set a callback_url in your agent profile
400"Invalid status filter"The status parameter is not "pending", "delivered", or "failed"
400"limit must be between 1 and 100"The limit parameter is out of range
401"Unauthorized"Missing or invalid API key

---

Code Examples

curl

-str">"hl-comment"># List webhook events
-kw">curl -str">"https://api.suwappu.bot/v1/agent/webhooks?status=failed&limit=10" \

-H -str">"Authorization: Bearer suwappu_sk_your_api_key"

-str">"hl-comment"># Test webhook delivery -kw">curl -X POST https://api.suwappu.bot/v1/agent/webhooks/test \

-H -str">"Authorization: Bearer suwappu_sk_your_api_key"

Python

import requests

headers = {class="hl-str">"Authorization": class="hl-str">"Bearer suwappu_sk_your_api_key"}

class=class="hl-str">"hl-comment"># List webhook events

response = requests.get(

class="hl-str">"https:class="hl-commentclass="hl-str">">//api.suwappu.bot/v1/agent/webhooks",

headers=headers,

params={class="hl-str">"status": class="hl-str">"failed", class="hl-str">"limit": 10},

)

data = response.json()

if data[class="hl-str">"success"]:

for event in data[class="hl-str">"events"]:

print(fclass="hl-str">"{event[class="hl-str">'event_type']}: {event[class="hl-str">'status']} (attempts: {event[class="hl-str">'attempts']})")

class=class="hl-str">"hl-comment"># Test webhook

response = requests.post(

class="hl-str">"https:class="hl-commentclass="hl-str">">//api.suwappu.bot/v1/agent/webhooks/test",

headers=headers,

)

data = response.json()

if data[class="hl-str">"success"]:

print(fclass="hl-str">"Delivered to {data[class="hl-str">'callback_url']} in {data[class="hl-str">'response_time_ms']}ms")

TypeScript

const headers = {

Authorization: class="hl-str">"Bearer suwappu_sk_your_api_key",

};

class=class="hl-str">"hl-comment">// List webhook events const params = new URLSearchParams({ status: class="hl-str">"failed", limit: class="hl-str">"10" }); const listResponse = await fetch(

https:class=class="hl-str">"hl-comment">//api.suwappu.bot/v1/agent/webhooks?${params},

{ headers }

);

const listData = await listResponse.json(); if (listData.success) {

for (const event of listData.events) {

console.log(

${event.event_type}: ${event.status} (attempts: ${event.attempts})

);

}

}

class=class="hl-str">"hl-comment">// Test webhook const testResponse = await fetch(

class="hl-str">"https:class="hl-commentclass="hl-str">">//api.suwappu.bot/v1/agent/webhooks/test",

{ method: class="hl-str">"POST", headers }

);

const testData = await testResponse.json(); if (testData.success) {

console.log(

Delivered to ${testData.callback_url} in ${testData.response_time_ms}ms

);

}