Developer documentation

TrueViewly API v1

Create production-ready location-risk reports from latitude and longitude coordinates. Start with the quickstart, then add batch processing, webhooks, and usage visibility as your integration grows.

Integration guide

How the API works

The API creates production-ready location-risk reports from latitude/longitude coordinates. Reports are generated asynchronously and can be consumed as JSON summaries, full report JSON, branded PDFs, batch result files, or webhook events.

Quickstart

Before your first API request

Use an active Business API workspace, or another plan explicitly showing API access. Free, Essentials and Professional do not include API access.

Switch to the correct workspace. Only its owner or admin can create and manage keys in Developer & API keys. Keys are workspace-scoped; a browser login is not an API credential.

Create a key with reports:create and reports:read for the quickstart; add reports:pdf for PDFs. Batch endpoints need bulk:create/bulk:read, but consume API generation quota, not CSV bulk-upload rows.

Compare plans and monthly allowances
  1. Choose an eligible workspace and create a scoped key in Developer & API keys.
  2. Create a report job with coordinates.
  3. Poll the job URL until it is completed.
  4. Fetch detail=summary for integration-friendly output.
  5. Register a webhook or create a batch when your workflow scales.
BASE_URL="https://portal.trueviewly.com"
# Set TRUEVIEWLY_API_KEY securely in your environment; do not commit it.
curl -X POST "$BASE_URL/api/v1/location-risk/report-jobs" \
  -H "Authorization: Bearer $TRUEVIEWLY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: site-001-2026-06-01" \
  -d '{"latitude":36.98154,"longitude":-122.02934}'

A new job returns 202 Accepted with a Location header and statusUrl. Replaying the same idempotency key and payload can return 200 OK. Poll the returned URL, respecting pollAfterSeconds, until completed or failed.

JOB_ID="replace_with_returned_job_id"
curl "$BASE_URL/api/v1/location-risk/report-jobs/$JOB_ID" \
  -H "Authorization: Bearer $TRUEVIEWLY_API_KEY"

# After completion, use the returned result.reportId.
REPORT_ID="replace_with_returned_report_id"
curl "$BASE_URL/api/v1/location-risk/reports/$REPORT_ID?detail=summary" \
  -H "Authorization: Bearer $TRUEVIEWLY_API_KEY"

Authentication

Send the API key as a bearer token. X-API-Key is also accepted for systems that cannot set the Authorization header.

Authorization: Bearer tvly_live_...
Store API keys like passwords. Use scoped keys, expiration dates, and IP allowlists for production integrations.

Async Jobs

Report generation is asynchronous. Create a job with reports:create, then poll with reports:read. Completed jobs include report and PDF links.

{
  "jobId": "job_xxxxx",
  "status": "completed",
  "result": {
    "reportId": "00000000-0000-0000-0000-000000000000",
    "reportUrl": "/api/v1/location-risk/reports/00000000-0000-0000-0000-000000000000",
    "pdfUrl": "/api/v1/location-risk/reports/00000000-0000-0000-0000-000000000000/pdf"
  }
}

Reports

Use detail=summary for clean decision fields: overall score, risk level, confidence, top risks, module scores, recommendations, review flags, and links. Use detail=full for the complete module payload.

GET /api/v1/location-risk/reports/{reportId}?detail=summary
GET /api/v1/location-risk/reports/{reportId}?detail=full
GET /api/v1/location-risk/reports/{reportId}/pdf

Batch API

Batch API accepts up to 100 coordinate items. Each valid item becomes a normal async report job, so quotas, retries, reports, and webhooks stay consistent.

{
  "name": "West Coast sample",
  "items": [
    { "externalId": "site-001", "latitude": 36.98154, "longitude": -122.02934 },
    { "externalId": "site-002", "latitude": 33.248205, "longitude": -116.670794 }
  ]
}

Webhooks

Webhooks let TrueViewly call your system when a job completes or fails. Verify every event with the signing secret returned when the endpoint is created.

TrueViewly-Timestamp: 1780300800
TrueViewly-Signature: v1=...
TrueViewly-Event: report.job.completed
TrueViewly-Delivery: wd_xxxxx

Compute HMAC-SHA256 over {timestamp}.{rawRequestBody} using the whsec_... signing secret. Reject timestamps older than five minutes to reduce replay risk.

Usage and Quotas

Usage endpoints expose current quota, remaining generations, reset windows, and daily usage history. Existing reports:read keys can read usage, while new keys should use usage:read.

Paid allowances refresh monthly even when billed annually; the workspace response supplies the exact cycle dates. A batch consumes API generation capacity per location. Polling and report reads are rate-limited separately. Current-cycle top-ups expire at the cycle end and do not roll over.

GET /api/v1/usage/current
GET /api/v1/usage/history?bucket=api&days=30

Common errors

Quota exhaustion is 403 quota_exhausted, not rate limiting. Rate limiting is 429 rate_limit_exceeded. Keep the returned request ID when contacting support; never send API keys.

Controller errors use the envelope below. Authentication challenges may use the legacy names Error, Code, Message and RequestId; integrations should accept either casing.

{"error":{"code":"quota_exhausted","message":"API report generation quota is exhausted for the current billing period.","requestId":"example-request-id"}}
CodeStatusMeaningFix
invalid_api_key401The key is missing, invalid, expired, revoked or blocked by its IP allowlist.Check the key, environment and allowed IPs.
insufficient_scope403The key lacks the scope required by this endpoint.Ask a workspace owner or admin for a key with the required scope.
feature_not_included403The workspace does not include API report generation.Select an active API-enabled workspace and use a key belonging to it.
quota_exhausted403There is not enough API report-generation quota in the current monthly cycle.Check usage and reset dates. The owner can review eligible top-ups or plans; do not repeatedly retry.
invalid_request400The request body or batch is invalid.Check JSON, required fields and the batch limit of 100 items.
invalid_latitude400Latitude is missing, non-finite or outside -90 to 90.Supply a valid latitude.
invalid_longitude400Longitude is missing, non-finite or outside -180 to 180.Supply a valid longitude.
unsupported_location422The report job location is outside supported coverage.Use a supported U.S. location. Coverage varies by source.
invalid_idempotency_key400The idempotency key has invalid characters or length.Use at most 160 characters: letters, digits, period, underscore, colon or hyphen.
idempotency_conflict409An idempotency key was reused with a different payload.Use the same payload for a retry, or a new key for a different request.
report_job_not_found404The job is missing or not accessible to this workspace.Check the job ID and workspace key.
report_not_found404The report is missing or not accessible to this workspace.Use the report ID from a completed job in the same workspace.
batch_not_found404The batch is missing or not accessible to this workspace.Check the batch ID and workspace key.
rate_limit_exceeded429Too many requests in the rate-limit window.Honor Retry-After when present; otherwise retry with bounded exponential backoff and jitter.

Versioning

Current endpoints are under `/api/v1`. Additive fields can appear without a version change. Breaking changes will use a new URL version and a deprecation period for v1.