Skip to navigation

API Guide

Conventions shared by every endpoint, and notes on the ones that need more explanation.
View as Markdown

This guide covers how the API behaves in general, plus the endpoints that aren’t self-explanatory. For a complete list of endpoints, see the API Reference. The examples assume you’ve set CREDENTIAL as described in Authentication.

Responses

A successful response wraps its payload in a body field:

{ "body": { "id": "5f0c…", "slug": "spring", "enabled": true } }

List endpoints return an array in body. Failed requests return an error message and a stable errorCode. See Rate Limits & Errors. The HTTP status line is the only place the status is reported.

Pagination

List endpoints that return a meta block accept two query parameters:

ParameterDescription
pageThe page to return, starting at 1.
sizeResults per page, from 1 to 256. Defaults to 20.
curl "https://api.divert.ly/v1/organizations/{org_id}/audit-events?page=2&size=50" \
-H "Authorization: Key $CREDENTIAL"

meta reports currentPage, pageSize, totalCount, and totalPages, so you know when to stop.

Enable or disable a domain

PUT /v1/domains/{domain_id}/toggle flips the domain’s enabled flag and returns the old and new values. A disabled domain stops serving redirects but keeps its configuration.

curl -X PUT https://api.divert.ly/v1/domains/{domain_id}/toggle \
-H "Authorization: Key $CREDENTIAL"
{ "body": { "oldValue": true, "newValue": false } }

Because it flips rather than sets, calling it twice reverses it. If a call times out and you aren’t sure whether it applied, read the domain and check enabled before calling again.

Verify a domain

Verification is two calls. GET /v1/domains/{domain_id}/verify-info returns the DNS records to publish (cnameKey, cnameValue, txtKey, txtValue). Once they’re in place, GET /v1/domains/{domain_id}/verify looks for the record and marks the domain verified. The response’s verified field tells you the result. See Bring Your Own Domain.

Risk verdicts

Domains and targets have a risk verdict, described in Security & Risk.

# Read the stored verdict
curl https://api.divert.ly/v1/domains/{domain_id}/risk \
-H "Authorization: Key $CREDENTIAL"
# Force a fresh check
curl -X POST https://api.divert.ly/v1/domains/{domain_id}/risk \
-H "Authorization: Key $CREDENTIAL"

The same pair of endpoints exists for a target at /v1/domains/{domain_id}/routes/{route_id}/targets/{target_id}/risk. The verdict has a status (unknown, pending, clean, or flagged), a score, the thresholdAtCheck it was compared with, an optional reason, and lastCheckedAt. A POST bypasses the cache and is rate limited separately from your normal API limit, so use it when you need a fresh answer, not on a schedule. If the risk service can’t be reached, the check is recorded as pending. See Errata.

QR codes

A route can have one QR code at a time.

CallPurpose
POST /v1/domains/{domain_id}/routes/{route_id}/qrGenerate the QR code.
GET /v1/domains/{domain_id}/routes/{route_id}/qrRead the QR code’s metadata.
GET /v1/domains/{domain_id}/routes/{route_id}/qr.pngDownload the image.
DELETE /v1/domains/{domain_id}/routes/{route_id}/qrDelete it, so you can generate a new one.
curl https://api.divert.ly/v1/domains/{domain_id}/routes/{route_id}/qr.png \
-H "Authorization: Key $CREDENTIAL" -o route-qr.png

Outbound email

GET /v1/organizations/{org_id}/emails lists the email the platform has sent on your organization’s behalf, most recent first. That includes welcome emails and notices about domain verification and risk changes. Each entry has the recipient, subject, type, and delivery status. Use it to confirm that a notification went out. It’s paginated.

Entitlements

GET /v1/organizations/{org_id}/entitlements returns what your plan allows: clickLimit, domainLimit, rateLimitCpm, and targetStrategies. Limits are enforced. See Subscriptions.

Who am I

GET /v1/whoami resolves a credential to its organization. Use it to check that a key works.

Not yet available

Traffic metrics aren’t available through the API yet. They’re coming soon.