Code examples
The examples show the common tasks in PHP, Node.js, Python and C#, without any package beyond the language's standard library. Each language has a small client that the other examples use; copy it into your project and adapt the error handling to your own code.
Configuration
The examples read the base URL and the key from the environment, never from the source code:
export UPPU_API_BASE=https://messaging-staging.uppu.net/v1 # production: https://messaging.uppu.net/v1
export UPPU_API_KEY=uppu_test_... # production: uppu_live_...
export UPPU_WEBHOOK_SECRET=whsec_... # the signing secret of your webhook endpoint
- The ids in the examples (
01j9z0ch5k2m4n6p8q0r2s4t6vand the like) are placeholders: take the channel id fromGET /v1/channels, and contact and message ids from your webhook events. - The client retries network errors,
5xxanswers and errors markedretryablewith the sameIdempotency-Key, so a retry never sends a message twice. - A webhook receiver checks the signature over the raw body before anything else and answers
2xxat once.
Examples
| Task | PHP | Node.js | Python | C# |
|---|---|---|---|---|
| A minimal client | client.php | client.mjs | uppu_client.py | UppuClient.cs |
| Send a text message | send-text.php | send-text.mjs | send_text.py | SendText.cs |
| Send a template message | send-template.php | send-template.mjs | send_template.py | SendTemplate.cs |
| List messages | list-messages.php | list-messages.mjs | list_messages.py | ListMessages.cs |
| Mark a message as read | mark-read.php | mark-read.mjs | mark_read.py | MarkRead.cs |
| Verify a webhook signature | verify-webhook.php | verify-webhook.mjs | verify_webhook.py | UppuWebhook.cs |