Skip to main content

QR API

QR endpoints exposed by the Devotel CPaaS API Base path: /api/v1/qr Endpoint count: 3

Worked QR samples

The endpoint list below documents every operation’s parameters; this overlay walks a QR render the way a checkout or loyalty integration actually uses it: render the JSON envelope → save the PNG binary → branch on the script-scheme rejection. Success envelopes are { data, meta } when you ask for JSON (format=json), and raw binary when you let the default image/png content-type carry the pixels — see How to read a worked sample. Rendering runs fully in-cluster — the payload never leaves the platform. Every response carries meta.request_id. Quote it when you report a render the SDK will not link to, or a phone number that failed the normalization the SMS route applies.

1. Render a QR for arbitrary data, returned as a JSON envelope

Pass format=json to get the base64 data URL inside the standard { data, meta } envelope instead of raw PNG bytes:
200

2. Save the QR as a raw PNG

Omit format (or pass format=png) and the route streams image/png bytes straight to disk — useful for batch print jobs and attach-to-CDN pipelines:
cURL
  • The output is square; the size query param (50–1024, default 300) sets the edge length.
  • Responses are cacheable for five minutes (private, max-age=300), so a CDN between you and the API can serve repeat scans without a re-render.
GET /api/v1/qr/sms encodes an sms:<phone>?body=… deep link — scanning it opens the device’s native SMS composer addressed to the given number with an optional pre-filled body. The number is validated and normalised to E.164 before render.
200
  • The envelope echoes the exact sms_link encoded into the QR, plus the normalised E.164 phone — pass a national-format number and the route returns the same envelope with E.164 applied.
  • A 400 fires when the phone is undialable under the numbering plan; the rejected input is echoed back, not stored.

4. Click-to-chat a WhatsApp conversation from a QR

GET /api/v1/qr/whatsapp encodes a https://wa.me/<phone>?text=… click-to-chat deep link — scanning it opens a WhatsApp chat with the given number and an optional pre-filled message. Same envelope shape as the SMS route, so a checkout scanner picks the channel by preference and renders the data URL inline:
200
  • The whatsapp_link is the exact deep link encoded into the QR — paste it into a <a href> for an SMS-fallback path when the scanner strips wa.me.
  • phone is echoed in bare-digit form (no +), matching the seeded recipient string wa.me itself renders.

5. Errors

Errors follow the { error, meta } envelope. The failure every integrator builds a branch for: 400 — script-scheme rejection. A payload starting with javascript:, data:, vbscript: or another pseudo-scheme never reaches the renderer, so a misrouted user gesture cannot become a stored XSS in someone’s scanner; plain text and http(s) URLs still encode:
400

Generate a QR code for arbitrary data

GET /api/v1/qr/generate
Render a QR code for any text or URL payload. Returns image/png bytes by default, or a base64 data URL in the standard envelope when format=json. Script-execution URL schemes (javascript:, data:, vbscript:, …) are rejected with 400; rendering runs fully in-cluster — the payload never leaves the platform.
string
required
Payload to encode (plain text or a URL, max 2048 chars). Must not start with a script-execution URL scheme such as javascript: or data:.
integer
Image edge length in pixels (50–1024, default 300). The output PNG is always square.
string (enum: png|json)
png (default) returns raw image/png bytes; json returns the standard envelope with data.qr_data_url as a base64 data URL.
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

GET /api/v1/qr/sms
Render a QR code that encodes an sms:&lt;phone&gt;?body=… deep link: scanning it opens the device’s native SMS composer addressed to the given number with an optional pre-filled body. The phone number is validated and normalised to E.164 before encoding. Returns image/png bytes by default, or a base64 data URL in the standard envelope when format=json.
string
required
Destination phone number in international format (e.g. +15551234567). Rejected with 400 when it is not a dialable international number.
string
Optional pre-filled message body for the deep link (max 1024 chars). URL-encoded into the encoded wa.me / sms: payload.
integer
Image edge length in pixels (50–1024, default 300). The output PNG is always square.
string (enum: png|json)
png (default) returns raw image/png bytes; json returns the standard envelope with data.qr_data_url as a base64 data URL.
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.

Generate a WhatsApp click-to-chat QR code

GET /api/v1/qr/whatsapp
Render a QR code that encodes a https://wa.me/&lt;phone&gt;?text=… click-to-chat deep link: scanning it opens a WhatsApp chat with the given number and an optional pre-filled message. The phone number is validated as a dialable international number before encoding. Returns image/png bytes by default, or a base64 data URL in the standard envelope when format=json.
string
required
Destination phone number in international format (e.g. +15551234567). Rejected with 400 when it is not a dialable international number.
string
Optional pre-filled message body for the deep link (max 1024 chars). URL-encoded into the encoded wa.me / sms: payload.
integer
Image edge length in pixels (50–1024, default 300). The output PNG is always square.
string (enum: png|json)
png (default) returns raw image/png bytes; json returns the standard envelope with data.qr_data_url as a base64 data URL.
string (enum: true|false)
Sandbox opt-in for Clerk-session-authenticated requests. Set to true to route the call through the test-mode pipeline: no real provider delivery, no credits deducted, response meta.test_mode: true. Ignored for live API keys (dv_live_sk_*) — server-to-server clients must use a test-prefixed key (dv_test_sk_*) to exercise sandbox. Test-prefixed keys unconditionally enable sandbox regardless of this header.