Create an endpoint
First, choose a server environment, such as a cloud service like AWS, Google Cloud, or a self-hosted server, that supports receiving and processing webhook events or callback messages. Then, define an endpoint URL on your server where the webhook events and callback messages will be sent.Implement handling logic
After you create the endpoint, you need to implement the logic on the server to handle the webhook events or callback messages, including parsing the API request, verifying the signature, responding to the request and adding other handling logic if necessary.Verify the signature
To prevent unauthorized access, when you receive a webhook event or a callback message, you need to validate the authenticity of the API request by verifying the signature. The verification steps are as follows:-
Retrieve raw body and timestamp.
Extract the original body string from the request payload and the timestamp from the request headers.
-
Retrieve the signature.
Fetch the signature value from the request header.
-
Concatenate and hash the message.
-
Select Cobo’s Public Key.
Depending on the environment that you use, select the corresponding public key for verification:
- Development environment:
a04ea1d5fa8da71f1dcfccf972b9c4eba0a2d8aba1f6da26f49977b08a0d2718 - Production environment:
8d4a482641adb2a34b726f05827dba9a9653e5857469b8749052bf4458a86729
- Development environment:
-
Verify the signature using the Ed25519 algorithm.
Respond to the API request
Properly responding to webhook events and callback messages is crucial for ensuring that webhooks and callbacks are processed as expected. This section describes the expected response from both webhook and callback endpoints.Webhook events
When your webhook endpoint receives a webhook event, it should respond with a status code of200 or 201 to indicate that the event has been successfully received and processed. Once this response is sent, the WaaS service will stop retrying to send the event and the event status will become Delivered on Cobo Portal.
The default timeout for each webhook event is 2 seconds. If the webhook endpoint does not respond or responds with a status code other than 200 or 201, the WaaS service will continue to retry sending the event. If the number of retry attempts reaches 10 , the WaaS service will stop sending the event and the event status will become Failed· You can resend the event by clicking Retry on Cobo Portal > Developer > WaaS 2.0 > Webhook Events.
Cobo does not guarantee that events will be delivered in the order they are generated. For example, creating a transfer will generate the following events:
wallets.transaction.createdwallets.transaction.updatedwallets.transaction.succeeded
Callback messages
When your callback endpoint receives a callback message, it should respond with a status code of200 or 201 and a response body of ok or deny to indicate transaction approval or rejection. Once this response is sent, the WaaS service will stop retrying to send the message and the callback message status will become Deliveredon Cobo Portal.
If the callback endpoint does not respond, responds with a status code other than 200 or 201, or the response body does not contain ok or deny, the WaaS service will continue to retry sending the message. If the number of retry attempts reaches 30, the WaaS service will stop sending the message and the callback message status will become Failed. You can resend the message by using the Retry callback message operation.
Common delivery failures
The following table lists the most frequent reasons why callback messages or webhook events fail to deliver, and how to fix them.| Symptom | Root cause | Fix |
|---|---|---|
Callback message status is Retrying or Failed; response body in the Portal log shows {"result":"ok"} or similar JSON | Response body is JSON instead of plain text | Change your response body to the exact string ok or deny — no JSON wrapping, no quotes. |
| Callback message shows no delivery attempts for a new URL | Endpoint not publicly reachable (e.g. ngrok tunnel is not running or has restarted) | Start or restart your ngrok tunnel and verify the URL is reachable from outside your local network before registering. |
Webhook events show status_code: 301 or 302 in delivery logs | Server returned a redirect | Serve the response directly from the registered URL. Cobo does not follow redirects. |
| Delivery attempts fail with TLS or SSL error | Endpoint TLS certificate is invalid or expired | Renew the certificate on your server. The endpoint must use HTTPS with a valid certificate. |
| Events or messages stop arriving after a period | Retry limit exhausted | Webhook events retry up to 10 times; callback messages retry up to 30 times. After the limit is reached, status becomes Failed. Manually retry from Cobo Portal or via the API. |
You can inspect the detailed response body and status code for each delivery attempt in Cobo Portal under Developer > Webhook Events / Callback Messages > click an event or message > Delivery logs.
Code samples
To see examples of how to implement the handling logic, refer to the following files in the WaaS SDK GitHub repository:- Python: server_demo.py (implemented based on the FastAPI framework)
- Java: DemoController.java (implemented based on the SpringBoot framework)
- JavaScript: ServerDemo.js
- Go: server_demo.go
Advanced usage
Wallet-level webhook routing
In certain business scenarios, you may need to apply different Webhook handling logic for different wallets. For example:- Multiple business teams share the same WaaS account
- A single system manages multiple independent projects
- Webhook events need to be forwarded to different microservices
wallet_id.
The following example demonstrates how to extend the Cobo-provided Webhook/Callback sample code (server_demo.py) to implement wallet-level Webhook routing.
This example uses Python for demonstration, but the same logic can be applied to other languages. You may adapt this approach in the sample code of the language you are using.
