Borehole Analysis Pro API — v1.5
Upload a borehole log and retrieve the extracted results as structured data, AGS4, CSV, JSON or a formatted report.
On this page
Quickstart
No SDKs. Plain HTTP; examples in curl and Python.
Base URL
https://api.smartcivilapps.com/api/v1/boreholeAuthentication
Every request carries an API key issued against your Borehole Analysis Pro subscription.
Authorization: Bearer sca_1f4c9e2b7a8d3c5e6b04a9f18d2c7e35b06a4d9f28c1e5b7API keys are server-side credentials. Do not ship one to a browser or mobile client, and do not commit one. Rotate by creating a new key and revoking the old one.
Exception: the progress stream is authenticated by a ticket in its query string. See Live progress.
Without a usable key:
# No usable Authorization header
{
"error": "Authentication failed",
"message": "An API key is required: send it as Authorization: Bearer sca_…",
"code": "MISSING_API_KEY"
}
# Unknown or revoked key
{
"error": "Authentication failed",
"message": "Invalid or revoked API key",
"code": "INVALID_API_KEY"
}Where keys come from
- On your Borehole Analysis Pro subscription in the Dashboard, choose Manage API access, which opens the API Keys page.
- Turn on Enable API access. No keys can be created until it is on. On an organisation seat, your organisation administrator sets it.
- Choose Create Key, name it, and copy the key — it is shown once and never again.
Up to 5 active keys per subscription. A revoked key stops working immediately.
Your first call
curl -s https://api.smartcivilapps.com/api/v1/borehole/usage \
-H "Authorization: Bearer $SCA_API_KEY"Response:
# abridged — see the reference for the full record
{
"success": true,
"data": {
"usage": {
"documents_processed": 12,
"boreholes_processed": 47,
"page_limit": 200,
"pages_remaining": 106,
"month_year": "2026-09",
"topup_total": 100,
"topup_used": 0,
"topup_remaining": 100,
"topup_packages": [
{
"id": "aaaaaaaa-0000-4000-8000-000000000006",
"pages_total": 100,
"pages_used": 0,
"pages_remaining": 100,
"purchased_at": "2026-08-01T00:00:00.000Z",
"expires_at": "2027-08-01T00:00:00.000Z"
}
],
"next_expiry": { "date": "2027-08-01T00:00:00.000Z", "pages_expiring": 100 }
}
}
}Python:
# pip install requests
import os
import sys
import requests
BASE = "https://api.smartcivilapps.com/api/v1/borehole"
API_KEY = os.environ.get("SCA_API_KEY")
if not API_KEY:
sys.exit("SCA_API_KEY is not set. Create a key at https://smartcivilapps.com/api-keys")
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
r = requests.get(f"{BASE}/usage", headers=HEADERS, timeout=30)
r.raise_for_status()
usage = r.json()["data"]["usage"]
print(usage["pages_remaining"], "of", usage["page_limit"], "pages left this month")
print("plus", usage["topup_remaining"], "from top-ups")Conventions
- Every request with a body sends JSON and
Content-Type: application/json. - Request fields are camelCase.
- Stored records come back snake_case; computed fields are camelCase. So
POST /uploadsreturnsuploadIdandPOST /jobsreturnsjobId, while reading either record givesid. - Timestamps are ISO 8601 in UTC.
- Every successful response has the shape
{ "success": true, "data": … }, except the two DELETEs, which returnmessageand nodata, and the progress stream, which istext/event-stream. - Every response carries an
X-Request-Idheader. Quote it when you contact us. - Ignore fields you do not recognise. New ones are added without a version change.
- There is no sandbox. Every key is live and every completed job consumes allowance.
| Endpoint | Payload inside data |
|---|---|
| POST /uploads | data.uploadId, data.uploadUrl |
| GET /uploads | data (array) |
| GET /uploads/{id} | data |
| DELETE /uploads/{id} | no data; message |
| POST /jobs | data.jobId, data.queuePosition, data.estimatedWait, data.template |
| GET /jobs | data.jobs |
| GET /jobs/{id} | data.job |
| DELETE /jobs/{id} | no data; message |
| POST /jobs/{id}/stream-ticket | data.ticket, data.expiresIn |
| GET /jobs/{id}/stream | text/event-stream; no envelope |
| GET /jobs/{id}/data | data.extractedData |
| GET /jobs/{id}/export/ags, /csv, /json | data.downloadUrl, data.filename, plus one contents list |
| GET /templates | data (array) |
| POST /jobs/{id}/generate-report | data.reportStatus, data.templateId, data.reportLanguage |
| GET /jobs/{id}/report | data.report (a string) |
| GET /jobs/{id}/docx-url | data.downloadUrl, data.expiresIn, data.format, data.templateId |
| POST /jobs/{id}/regenerate-with-template | data.downloadUrl, data.templateId, data.templateName, data.reportId, data.generationTimeMs |
| POST /jobs/{jobId}/reports | data.downloadUrl, data.reportId, data.cached, data.generationTimeMs, data.success |
| GET /usage | data.usage |
| GET /topup | data.topup |
| GET /subscription | data.subscription |
| GET /languages | data.languages |
The processing flow
How the API is used
- One file is one upload.
POST /uploadsreturns anuploadIdand a storage URL; the bytes go to storage, not through the API. Uploads are the only files the API accepts. - One job is one extraction of one upload.
POST /jobsnames the upload byuploadId. One upload can back several jobs. - Ids are the handles. Store
uploadIdandjobIdwhen you receive them. - To recover them:
GET /uploadslists every upload from the last 7 days withfilename,file_sizeandstatus;GET /jobslists every job from the last 7 days withupload_id,file_nameandstatus.
1. POST /uploads → an upload id and a storage URL
2. PUT <the storage URL> → the file bytes, straight to storage
3. GET /uploads/{uploadId} → poll until status is "validated"
4. POST /jobs → an extraction job id
5. GET /jobs/{jobId} → poll until status is "completed"
6. GET /jobs/{jobId}/data → the structured result
GET /jobs/{jobId}/export/ags → AGS4, CSV or JSON download URLAllowance is counted per page, not per document: a 12-page file consumes 12. Every job is deleted 7 days after it is created, along with its exports and reports. Store your results as soon as a job completes.
There are no webhooks. Poll GET /jobs/{id} or use the progress stream.
The whole flow in Python
"""
Borehole Analysis Pro API v1 — complete example.
pip install requests
export SCA_API_KEY=sca_...
python extract.py site-investigation-BH01.pdf
"""
import os
import sys
import time
import requests
BASE = "https://api.smartcivilapps.com/api/v1/borehole"
API_KEY = os.environ.get("SCA_API_KEY")
if not API_KEY:
sys.exit("SCA_API_KEY is not set. Create a key at https://smartcivilapps.com/api-keys")
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
ALLOWED_EXTENSIONS = {"pdf", "png", "jpg", "jpeg", "ags"}
VALIDATION_POLL_SECONDS = 5
JOB_POLL_SECONDS = 10
VALIDATION_TIMEOUT_SECONDS = 300
JOB_TIMEOUT_SECONDS = 1800 # processing p90 is 209 s; queue wait is extra
def error_code(body):
"""The specific code: nested when the endpoint nests, top-level otherwise."""
nested = body.get("error")
if isinstance(nested, dict) and nested.get("code"):
return nested["code"]
return body.get("code")
class ApiError(RuntimeError):
def __init__(self, status, body):
self.status = status
self.body = body or {}
self.code = error_code(self.body)
super().__init__(f"HTTP {status} {self.code}: {self.body}")
def _json(response):
try:
return response.json()
except ValueError:
return {}
# Not waitable: retrying these in a loop cannot make them succeed.
UNWAITABLE = ("QUOTA_EXCEEDED", "CONCURRENCY_LIMIT_EXCEEDED", "QUEUE_LIMIT_EXCEEDED")
MAX_5XX_RETRIES = 3
MAX_RATE_LIMIT_WAITS = 10
def call(method, path, **kwargs):
"""One API request, with the retry policy from the Errors section."""
rate_limit_waits = 0
server_error_retries = 0
while True:
r = requests.request(method, BASE + path, headers=HEADERS, timeout=30, **kwargs)
# 401 is permanent: bad, revoked or missing key, or inactive account.
if r.status_code == 401:
raise ApiError(401, _json(r))
if r.status_code == 429:
body = _json(r)
code = error_code(body)
if code in UNWAITABLE:
raise ApiError(429, body)
if rate_limit_waits >= MAX_RATE_LIMIT_WAITS:
raise ApiError(429, body)
rate_limit_waits += 1
wait = int(body.get("retryAfter") or 15)
print(f"rate limited ({code}); sleeping {wait}s", file=sys.stderr)
time.sleep(wait)
continue
# UPLOAD_NOT_READY / JOB_NOT_COMPLETED / INVALID_STATE: poll the resource, then call again.
# Any other 4xx: the request is wrong. Do not retry.
if 400 <= r.status_code < 500:
raise ApiError(r.status_code, _json(r))
# 5xx: up to 3 retries, backing off 1, 2 then 4 seconds.
if r.status_code >= 500:
if server_error_retries >= MAX_5XX_RETRIES:
raise ApiError(r.status_code, _json(r))
time.sleep(2 ** server_error_retries)
server_error_retries += 1
continue
return r.json()
def request_upload(path):
"""Step 1 — reserve an upload and get a storage URL. Valid for 5 minutes."""
extension = os.path.splitext(path)[1].lstrip(".").lower()
if extension not in ALLOWED_EXTENSIONS:
sys.exit(f"unsupported file type: .{extension}")
body = {"filename": os.path.basename(path)}
data = call("POST", "/uploads", json=body)["data"]
return data["uploadId"], data["uploadUrl"]
def put_file(upload_url, path):
"""Step 2 — the bytes go straight to storage. No Authorization header here."""
with open(path, "rb") as handle:
r = requests.put(upload_url, data=handle, timeout=300)
r.raise_for_status()
def wait_for_validation(upload_id):
"""Step 3 — poll until the file has been checked."""
deadline = time.time() + VALIDATION_TIMEOUT_SECONDS
while time.time() < deadline:
upload = call("GET", f"/uploads/{upload_id}")["data"]
status = upload["status"]
if status == "validated":
return upload
if status == "failed":
raise RuntimeError("validation failed: " + str(upload["validation_error"]))
# "pending" and "uploaded" are transitional.
time.sleep(VALIDATION_POLL_SECONDS)
raise TimeoutError("upload was not validated in time")
def create_job(upload_id, output_language="auto"):
"""Step 4 — start extraction. Returns as soon as the job is queued.
There is no idempotency key: after a 5xx here, find any job that was
created before sending the request again.
"""
body = {"uploadId": upload_id, "outputLanguage": output_language}
try:
data = call("POST", "/jobs", json=body)["data"]
except ApiError as exc:
if exc.status < 500:
raise
existing = [
job for job in call("GET", "/jobs")["data"]["jobs"]
if job["upload_id"] == upload_id
]
if existing:
print(f"5xx on create; job {existing[0]['id']} already exists", file=sys.stderr)
return existing[0]["id"], 0
data = call("POST", "/jobs", json=body)["data"]
print(f"queued at position {data['queuePosition']}")
return data["jobId"], data["estimatedWait"]
def wait_for_job(job_id, estimated_wait=0):
"""Step 5 — poll until the job is finished."""
deadline = time.time() + min(estimated_wait + 900, JOB_TIMEOUT_SECONDS)
while time.time() < deadline:
job = call("GET", f"/jobs/{job_id}")["data"]["job"]
status = job["status"]
if status == "completed":
return job
if status in ("failed", "terminal"):
raise RuntimeError(f"job {status}: {job.get('error_message')}")
print(f"{status} {job['progress']}%")
time.sleep(JOB_POLL_SECONDS)
raise TimeoutError("job did not finish in time")
def get_data(job_id):
"""Step 6a — the structured result."""
return call("GET", f"/jobs/{job_id}/data")["data"]["extractedData"]
def download_export(job_id, fmt="ags", out_dir="."):
"""Step 6b — fmt is "ags", "csv" or "json". The URL is a direct storage link."""
export = call("GET", f"/jobs/{job_id}/export/{fmt}")["data"]
r = requests.get(export["downloadUrl"], timeout=300)
r.raise_for_status()
target = os.path.join(out_dir, os.path.basename(export["filename"]))
with open(target, "wb") as handle:
handle.write(r.content)
return target
def main(source):
upload_id, upload_url = request_upload(source)
put_file(upload_url, source)
wait_for_validation(upload_id)
job_id, estimated_wait = create_job(upload_id)
print("job", job_id)
wait_for_job(job_id, estimated_wait)
data = get_data(job_id)
metadata = data["extractionMetadata"]
print("unit system:", metadata["unitSystem"]) # "metric" or "imperial"
print("boreholes:", len(data["boreholes"]))
print("wrote", download_export(job_id, "ags"))
if __name__ == "__main__":
if len(sys.argv) != 2:
sys.exit("usage: python extract.py <file.pdf|.png|.jpg|.jpeg|.ags>")
main(sys.argv[1])The same steps in curl
Step 1 — request an upload URL
curl -s -X POST https://api.smartcivilapps.com/api/v1/borehole/uploads \
-H "Authorization: Bearer $SCA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename":"site-investigation-BH01.pdf"}'
{
"success": true,
"data": {
"uploadUrl": "https://smartcivilapps.com.s3.eu-central-1.amazonaws.com/borehole/aaaaaaaa-0000-4000-8000-000000000001/uploads/aaaaaaaa-0000-4000-8000-000000000002/site-investigation-BH01.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE1234567%2F20260902%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20260902T091203Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=7b1c0d4e9a2f5386bc47e0d19f8a63c25d704be18f39a6c07d2b5481e93f6a0c",
"uploadId": "aaaaaaaa-0000-4000-8000-000000000002"
}
}Step 2 — send the file
The bytes go straight to storage, not through the API. Do not send your key on this request; no other headers are required. Success is HTTP 200 with an empty body; after 5 minutes the URL returns 403 with an XML body from storage, and you request a new one.
# No Authorization header — this goes straight to storage.
curl -s -X PUT "$UPLOAD_URL" --upload-file site-investigation-BH01.pdf
# Empty body, HTTP 200.Step 3 — poll until validated
Uploading triggers a check of size, type and, for PDFs, page count. Poll every 5 seconds until status is validated or failed. Branch on status; validation_error is free text for display.
curl -s https://api.smartcivilapps.com/api/v1/borehole/uploads/aaaaaaaa-0000-4000-8000-000000000002 \
-H "Authorization: Bearer $SCA_API_KEY"
{
"success": true,
"data": {
"id": "aaaaaaaa-0000-4000-8000-000000000002",
"user_id": "aaaaaaaa-0000-4000-8000-000000000001",
"filename": "site-investigation-BH01.pdf",
"file_path": "borehole/aaaaaaaa-0000-4000-8000-000000000001/uploads/aaaaaaaa-0000-4000-8000-000000000002/site-investigation-BH01.pdf",
"file_size": 2458112,
"content_type": "application/pdf",
"status": "validated",
"validation_error": null,
"created_at": "2026-09-02T09:12:03.000Z",
"expires_at": "2026-09-09T09:12:03.000Z",
"page_count": 12
}
}Step 4 — create the job
curl -s -X POST https://api.smartcivilapps.com/api/v1/borehole/jobs \
-H "Authorization: Bearer $SCA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"uploadId":"aaaaaaaa-0000-4000-8000-000000000002","outputLanguage":"auto"}'
{
"success": true,
"data": {
"jobId": "aaaaaaaa-0000-4000-8000-000000000003",
"queuePosition": 1,
"estimatedWait": 25,
"template": null
}
}Step 5 — poll until completed
Poll every 10 seconds. Processing itself takes 2 to 4 minutes — measured p50 154 s, p90 209 s, longest 237 s — and estimatedWait seconds of queue wait come on top of that. status ends at completed, failed or terminal — treat the last two alike and read error_message. A job that fails consumes no allowance.
curl -s https://api.smartcivilapps.com/api/v1/borehole/jobs/aaaaaaaa-0000-4000-8000-000000000003 \
-H "Authorization: Bearer $SCA_API_KEY"
# abridged — see the reference for the full record
{
"success": true,
"data": {
"job": {
"id": "aaaaaaaa-0000-4000-8000-000000000003",
"upload_id": "aaaaaaaa-0000-4000-8000-000000000002",
"file_name": "site-investigation-BH01.pdf",
"status": "processing",
"progress": 45,
"error_message": null,
"extracted_data": null,
"report_status": null,
"report_error_message": null,
"output_language": "auto",
"detected_language": "en",
"created_at": "2026-09-02T09:13:00.000Z",
"completed_at": null,
"expires_at": "2026-09-09T09:13:00.000Z"
}
}
}Step 6 — fetch the results
Before you parse any number, read extractionMetadata.unitSystem. No depth or elevation in the payload carries its own unit — they are all in metres when it is "metric" and feet when it is "imperial".
curl -s https://api.smartcivilapps.com/api/v1/borehole/jobs/aaaaaaaa-0000-4000-8000-000000000003/data \
-H "Authorization: Bearer $SCA_API_KEY"
{
"success": true,
"data": {
"extractedData": {
"boreholes": [],
"extractionMetadata": {
"confidence": 0.92,
"model": "eu.anthropic.claude-haiku-4-5-20251001-v1:0",
"promptVersion": "v7.0.1",
"unitSystem": "metric"
}
}
}
}
curl -s https://api.smartcivilapps.com/api/v1/borehole/jobs/aaaaaaaa-0000-4000-8000-000000000003/export/ags \
-H "Authorization: Bearer $SCA_API_KEY"
{
"success": true,
"data": {
"downloadUrl": "https://smartcivilapps.com.s3.eu-central-1.amazonaws.com/exports/aaaaaaaa-0000-4000-8000-000000000003/v1/data_export.ags?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE1234567%2F20260902%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20260902T091640Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=2e5b90c1a7d34f68b012e9d5c8a4f37160bd29e4c5017a8f3b6d90c2e478a15b",
"filename": "Northg-aaaaa_data_export.ags",
"groupsGenerated": ["PROJ","TRAN","LOCA","GEOL","SAMP","GCHM","WSTD"]
}
}
# The download URL is a direct storage link, valid for 24 hours.
curl -s -o export.ags "$DOWNLOAD_URL"Extracted data
The payload at data.extractedData of GET /jobs/{id}/data. Depths and elevations are in the unit named by extractionMetadata.unitSystem.
HTTP/1.1 200 OK
{
"success": true,
"data": {
"extractedData": {
"projectInfo": {
"projectName": "Northgate Interchange Ground Investigation",
"client": "Northgate Regional Transport Authority",
"location": "Northgate Interchange, A41 at Mill Lane",
"drillingContractor": "Vale Drilling Services Ltd",
"drillingDates": { "start": "2026-07-14", "end": "2026-07-18" },
"reportDate": "2026-08-03",
"reportNumber": "NGI-2026-0417"
},
"siteDescription": {
"description": "Level made-ground platform on the north verge of the A41.",
"topography": "Flat, falling gently to the south-east",
"vegetation": "Rough grass with scattered hawthorn scrub",
"surfaceConditions": "Compacted granular haul road over topsoil"
},
"boreholes": [
{
"id": "BH-01",
"name": "BH-01",
"location": {
"description": "North verge, 12 m east of chainage 1450",
"coordinates": {
"lat": 52.4831,
"lng": -1.9027,
"easting": 407412.5,
"northing": 287905.2,
"system": "EPSG:27700"
},
"elevation": 96.4,
"coordinateSystem": "WGS84"
},
"totalDepth": 12.5,
"drillingMethod": "Cable percussion",
"layers": [
{
"depthFrom": 0,
"depthTo": 0.6,
"elevationTop": 96.4,
"elevationBase": 95.8,
"description": "MADE GROUND: brown sandy gravel with brick and concrete fragments",
"soilType": "GM",
"layerName": "Made Ground",
"detailedDescription": {
"color": "brown",
"moisture": "slightly moist",
"consistency": null,
"density": "loose",
"plasticity": null,
"origin": "anthropogenic"
},
"sptData": [],
"properties": {}
},
{
"depthFrom": 0.6,
"depthTo": 4.2,
"elevationTop": 95.8,
"elevationBase": 92.2,
"description": "Firm brown slightly sandy CLAY with occasional fine gravel",
"soilType": "CL",
"layerName": "Glacial Till",
"detailedDescription": {
"color": "brown",
"moisture": "moist",
"consistency": "firm",
"density": null,
"plasticity": "low to medium",
"origin": "glacial"
},
"sptData": [
{
"depth": 1.5,
"depthTop": 1.5,
"depthBase": 1.95,
"nValue": 9,
"blowCounts": "2-3-2-2-2-3",
"sampleId": "BH01-S1",
"sampleType": "SS",
"recoveryPercent": 92,
"condition": "Disturbed",
"sampleDescription": "Firm brown slightly sandy CLAY with occasional fine gravel"
},
{
"depth": 3.0,
"depthTop": 3.0,
"depthBase": 3.45,
"nValue": 14,
"blowCounts": "3-4-3-3-4-4",
"sampleId": "BH01-S2",
"sampleType": "SS",
"recoveryPercent": 88,
"condition": "Disturbed",
"sampleDescription": "Firm brown slightly sandy CLAY with occasional fine gravel"
}
],
"properties": { "moistureContent": 18.4 }
},
{
"depthFrom": 4.2,
"depthTo": 12.5,
"elevationTop": 92.2,
"elevationBase": 83.9,
"description": "Dense grey fine to coarse SAND and GRAVEL",
"soilType": "SW",
"layerName": "River Terrace Deposits",
"detailedDescription": {
"color": "grey",
"moisture": "wet",
"consistency": null,
"density": "dense",
"plasticity": "non-plastic",
"origin": "fluvial"
},
"sptData": [
{
"depth": 6.0,
"depthTop": 6.0,
"depthBase": 6.45,
"nValue": 34,
"blowCounts": "6-8-8-8-9-9",
"sampleId": "BH01-S3",
"sampleType": "SS",
"recoveryPercent": 74,
"condition": "Disturbed",
"sampleDescription": "Dense grey fine to coarse SAND and GRAVEL"
}
],
"properties": {}
}
],
"groundwater": {
"encountered": true,
"depths": [
{ "depth": 4.5, "date": "2026-07-14", "condition": "Seepage" },
{ "depth": 3.9, "date": "2026-07-15", "condition": "Rising" }
],
"monitoringWells": [
{ "wellId": "BH-01-STP", "depth": 12.0, "waterLevel": 3.7, "date": "2026-07-25" }
]
},
"testingData": [
{
"type": "Pocket Penetrometer",
"depth": 2.4,
"value": 105,
"units": "kPa",
"sampleType": "Undisturbed"
}
],
"laboratoryTests": [
{
"sampleId": "BH01-S1",
"boreholeId": "BH-01",
"depth": 1.5,
"testType": "Atterberg Limits",
"testMethod": "BS 1377-2:2022",
"sampleType": "Disturbed",
"results": { "liquidLimit": 38, "plasticLimit": 21, "plasticityIndex": 17 }
},
{
"sampleId": "BH01-S3",
"boreholeId": "BH-01",
"depth": 6.0,
"testType": "Grain Size Analysis",
"testMethod": "BS 1377-2:2022",
"sampleType": "Disturbed",
"results": { "gravelPercent": 41.2, "sandPercent": 55.6, "finesPercent": 3.2, "d60": 4.8, "d10": 0.21 }
}
]
},
{
"id": "BH-02",
"name": "BH-02",
"location": {
"description": "South verge, 40 m west of chainage 1450",
"coordinates": {
"lat": 52.4826,
"lng": -1.9041,
"easting": 407318.9,
"northing": 287849.6,
"system": "EPSG:27700"
},
"elevation": 95.1,
"coordinateSystem": "WGS84"
},
"totalDepth": 10.0,
"drillingMethod": "Cable percussion",
"layers": [
{
"depthFrom": 0,
"depthTo": 0.3,
"elevationTop": 95.1,
"elevationBase": 94.8,
"description": "TOPSOIL: dark brown silty sand with rootlets",
"soilType": "SM",
"layerName": "Topsoil",
"detailedDescription": {
"color": "dark brown",
"moisture": "moist",
"consistency": null,
"density": "very loose",
"plasticity": "non-plastic",
"origin": "residual"
},
"sptData": [],
"properties": {}
},
{
"depthFrom": 0.3,
"depthTo": 5.8,
"elevationTop": 94.8,
"elevationBase": 89.3,
"description": "Stiff grey-brown CLAY with occasional chalk fragments",
"soilType": "CH",
"layerName": "Glacial Till",
"detailedDescription": {
"color": "grey-brown",
"moisture": "moist",
"consistency": "stiff",
"density": null,
"plasticity": "high",
"origin": "glacial"
},
"sptData": [
{
"depth": 2.0,
"depthTop": 2.0,
"depthBase": 2.45,
"nValue": 18,
"blowCounts": "4-5-4-4-5-5",
"sampleId": "BH02-S1",
"sampleType": "SS",
"recoveryPercent": 95,
"condition": "Disturbed",
"sampleDescription": "Stiff grey-brown CLAY with occasional chalk fragments"
},
{
"depth": 4.5,
"depthTop": 4.5,
"depthBase": 4.95,
"nValue": 23,
"blowCounts": "5-6-5-6-6-6",
"sampleId": "BH02-S2",
"sampleType": "SS",
"recoveryPercent": 91,
"condition": "Disturbed",
"sampleDescription": "Stiff grey-brown CLAY with occasional chalk fragments"
}
],
"properties": { "moistureContent": 22.7 }
},
{
"depthFrom": 5.8,
"depthTo": 10.0,
"elevationTop": 89.3,
"elevationBase": 85.1,
"description": "Weak white structureless CHALK, grade D",
"soilType": "R",
"layerName": "Chalk",
"detailedDescription": {
"color": "white",
"moisture": "moist",
"consistency": null,
"density": null,
"plasticity": null,
"origin": "sedimentary rock"
},
"sptData": [
{
"depth": 8.0,
"depthTop": 8.0,
"depthBase": 8.3,
"nValue": null,
"blowCounts": "20-25-50 for 100mm",
"sampleId": "BH02-S3",
"sampleType": "CR",
"recoveryPercent": 68,
"condition": "Refusal",
"sampleDescription": "Weak white structureless CHALK, grade D"
}
],
"properties": {}
}
],
"groundwater": {
"encountered": false,
"depths": [],
"monitoringWells": []
},
"testingData": [],
"laboratoryTests": [
{
"sampleId": "BH02-S2",
"boreholeId": "BH-02",
"depth": 4.5,
"testType": "Triaxial",
"testMethod": "BS 1377-7:1990",
"sampleType": "Undisturbed",
"results": { "cohesionKpa": 62, "frictionAngleDeg": 24, "cellPressureKpa": 100 }
}
]
}
],
"unattributedLaboratoryTests": [],
"dataAvailability": {
"hasSPTData": true,
"hasGroundwater": true,
"hasLabTests": true,
"hasGrainSizeDistribution": true,
"hasAtterbergLimits": true,
"hasSitePlan": false,
"hasRegionalGeology": false
},
"extractionMetadata": {
"confidence": 0.92,
"model": "eu.anthropic.claude-haiku-4-5-20251001-v1:0",
"promptVersion": "v7.0.1",
"unitSystem": "metric"
}
}
}
}extractedData
| Field | Type | Presence | Meaning |
|---|---|---|---|
| boreholes | array | always | One entry per borehole in the document, in document order. |
| extractionMetadata | object | always | Model, prompt version and the document’s unit system. |
| projectInfo | object | optional | Project, client and drilling metadata from the title block. |
| siteDescription | object | optional | Narrative description of the site. |
| unattributedLaboratoryTests | array | optional | Laboratory tests that could not be assigned to a borehole. Each borehole’s own tests are at boreholes[].laboratoryTests. |
| dataAvailability | object | optional | Booleans saying which classes of data the document carried. |
| sitePlan | any | optional | Site-plan content captured with the whole-document pass. Its shape is not part of the v1 contract. |
| uiStrings | object | optional | Report and chart labels in the output language. |
| _columnOrder, _renames, _deleted | object | optional | Edit-history metadata. Every key beginning with an underscore is internal; ignore it. |
boreholes[]
| Field | Type | Presence | Meaning |
|---|---|---|---|
| id | string | always | Borehole identifier as printed on the log, for example "BH-01". |
| name | string | optional | Display name. Usually the same as id. |
| location | object | always | Where the borehole was sunk. See the next table. |
| totalDepth | number | optional, nullable | Depth to the base of the borehole. |
| drillingMethod | string | optional, nullable | For example "Cable percussion", "Rotary open hole". |
| layers | array | always | Strata, shallowest first. |
| groundwater | object | optional | Strikes and installations. See below. |
| testingData | array | optional | In-situ tests not tied to one layer. See below. |
| laboratoryTests | array | optional | Laboratory tests on samples from this borehole. See below. |
boreholes[].location
| Field | Type | Presence | Meaning |
|---|---|---|---|
| description | string | always | Position as printed on the log. |
| coordinates | object | optional, nullable | Any subset of lat, lng, easting, northing, system. A geographic pair and a projected pair can both be present; system names the projected CRS. |
| elevation | number | optional, nullable | Collar level. |
| coordinateSystem | string | optional, nullable | CRS for lat/lng. WGS84 when absent. |
boreholes[].layers[]
| Field | Type | Presence | Meaning |
|---|---|---|---|
| depthFrom | number | always | Depth to the top of the layer. |
| depthTo | number | always | Depth to the base of the layer. |
| elevationTop | number | optional, nullable | Level of the layer top. Takes precedence over the collar elevation when both are present. |
| elevationBase | number | optional, nullable | Level of the layer base. |
| description | string | always | Stratum description as printed. |
| soilType | string | always, nullable | USCS symbol: PT, OH, OL, CH, CL, CL-ML, ML, MH, SC, SM, SP, SW, SP-SM, SC-SM, GC, GM, GP, GW, GP-GM, TS or R. |
| layerName | string | optional | Formation or unit name. |
| detailedDescription | object | optional | color, moisture, consistency, density, plasticity, origin — each a string or null. |
| sptData | array | optional | SPT and sample records within the layer. |
| properties | object | optional | Any further printed properties, keyed by name. |
boreholes[].layers[].sptData[]
| Field | Type | Presence | Meaning |
|---|---|---|---|
| depth | number | always | Test depth. |
| depthTop | number | optional | Depth at the start of the drive. |
| depthBase | number | optional | Depth at the end of the drive. |
| nValue | number | always, nullable | SPT N. The N the log prints; else computed from the blow counts by their form (3 or 4 counts: 2nd + 3rd; UK 5 or 6 counts: the four test counts). null when neither gives one, for example on refusal. |
| blowCounts | string | optional | Blow counts as printed, in order, joined with hyphens, for example "2-3-2-2-2-3". |
| sampleId | string | optional | Sample reference. |
| sampleType | string | optional | ST, SS, CR, TW, BS, AS or RS. |
| recoveryPercent | number | optional | Recovery, 0–100. |
| condition | string | optional | Undisturbed, Disturbed, Remoulded, Refusal or Rock core. |
| sampleDescription | string | always, nullable | The part of the layer's description that applies to this sample. null when none applies. Kept current after each edit in Review. |
| units | object | optional | Unit per field on this row, keyed by field name, as printed on the document. |
| units_inferred | array | optional | Field names from units above whose unit was not printed and was inferred instead. |
boreholes[].groundwater
| Field | Type | Presence | Meaning |
|---|---|---|---|
| encountered | boolean | always | Whether water was struck. |
| depths | array | optional | One entry per strike: depth (number), date (string or null), condition (Static, Rising, Falling, Perched, Seepage or Dry). |
| monitoringWells | array | optional | One entry per installation: wellId, depth, waterLevel, date. |
boreholes[].testingData[]
| Field | Type | Presence | Meaning |
|---|---|---|---|
| type | string | always | Vane (Field), Pocket Penetrometer, Dynamic Penetration, SPT, CPT, Pressuremeter or Plate load. |
| depth | number | always | Test depth. |
| value | number | always | Measured value, in units. |
| units | string | always | kPa, MPa, blows/ft, blows/300mm or blows/100mm. |
| units_inferred | array | optional | Present as ["value"] when units above was not printed and was inferred instead. |
| sampleType | string | optional, nullable | Undisturbed, Disturbed, Remoulded, Rock core or Bag sample. |
boreholes[].laboratoryTests[]
| Field | Type | Presence | Meaning |
|---|---|---|---|
| sampleId | string | always | Sample reference. Matches sptData[].sampleId where the log ties them. |
| boreholeId | string | always, nullable | The id of the borehole the sample came from. Null when the record could not be assigned to a borehole (shown under Unattributed). |
| depth | number | always | Sample depth. |
| testType | string | always | Grain Size Analysis, Atterberg Limits, Consolidation, Permeability, Triaxial, Direct Shear, CBR, Proctor or Moisture Content. |
| testMethod | string | optional, nullable | Standard used, as printed. |
| sampleType | string | optional, nullable | Undisturbed, Disturbed, Remoulded, Rock core or Bag sample. |
| results | object | always | Result values keyed by name. The keys vary by testType. |
| units | object | optional | Unit per results key, as printed on the document. |
| units_inferred | array | optional | results keys from units above whose unit was not printed and was inferred instead. |
extractionMetadata
| Field | Type | Presence | Meaning |
|---|---|---|---|
| confidence | number | always | 0–1, job level. A placeholder, not a per-field measure. |
| model | string | always | The extraction model id. |
| promptVersion | string | always | The extraction prompt version. |
| unitSystem | "metric" | "imperial" | optional | metric = metres, imperial = feet. Applies to every depth and elevation in the payload. |
projectInfo
| Field | Type | Presence | Meaning |
|---|---|---|---|
| projectName | string | optional, nullable | Project title. |
| client | string | optional, nullable | Client name. |
| location | string | optional, nullable | Site location. |
| drillingContractor | string | optional, nullable | Contractor who sank the boreholes. |
| drillingDates | object | optional | start and end, each a string or null. |
| reportDate | string | optional, nullable | Date on the source report. |
| reportNumber | string | optional, nullable | Report reference. |
siteDescription
| Field | Type | Presence | Meaning |
|---|---|---|---|
| description | string | optional, nullable | Narrative site description. |
| topography | string | optional, nullable | Landform and slope. |
| vegetation | string | optional, nullable | Ground cover. |
| surfaceConditions | string | optional, nullable | Surfacing at the boreholes. |
unattributedLaboratoryTests[]
| Field | Type | Presence | Meaning |
|---|---|---|---|
| sampleId | string | always | Sample reference. Matches sptData[].sampleId where the log ties them. |
| boreholeId | string | always, nullable | The id of the borehole the sample came from. Null when the record could not be assigned to a borehole (shown under Unattributed). |
| depth | number | always | Sample depth. |
| testType | string | always | Grain Size Analysis, Atterberg Limits, Consolidation, Permeability, Triaxial, Direct Shear, CBR, Proctor or Moisture Content. |
| testMethod | string | optional, nullable | Standard used, as printed. |
| sampleType | string | optional, nullable | Undisturbed, Disturbed, Remoulded, Rock core or Bag sample. |
| results | object | always | Result values keyed by name. The keys vary by testType. |
| units | object | optional | Unit per results key, as printed on the document. |
| units_inferred | array | optional | results keys from units above whose unit was not printed and was inferred instead. |
dataAvailability
| Field | Type | Presence | Meaning |
|---|---|---|---|
| hasSPTData | boolean | optional | SPT results were found. |
| hasGroundwater | boolean | optional | Groundwater observations were found. |
| hasLabTests | boolean | optional | Laboratory results were found. |
| hasGrainSizeDistribution | boolean | optional | Grain-size results were found. |
| hasAtterbergLimits | boolean | optional | Atterberg results were found. |
| hasSitePlan | boolean | optional | A site plan was found. |
| hasRegionalGeology | boolean | optional | Regional geology text was found. |
Further has* flags may appear. The named string sets above are the vocabulary the extraction uses; any object may carry keys these tables do not list.
Reports
A report is built from a job that has finished extraction. It consumes no allowance and can be repeated with different templates.
- Pick a template.
GET /templates— take theid. - Queue the build.
POST /jobs/{id}/generate-reportreturns immediately with{"reportStatus": "generating"}. - Poll the job and watch
report_statusonGET /jobs/{id}. It movesgenerating→available, or →failed, normally in under a minute.report_statusis tracked separately fromstatus, which stayscompletedthroughout. - Download it.
GET /jobs/{id}/docx-urlreturns a storage URL valid for 24 hours. - Rebuild with a different template.
POST /jobs/{id}/regenerate-with-templatereturns the new download URL in the same response.
# Continues the flow script above: reuses call, job_id and time.
# Built from a completed job; consumes no allowance.
from datetime import datetime, timezone
REPORT_TIMEOUT_SECONDS = 300
def _report_time(value):
return datetime.fromisoformat(value.replace("Z", "+00:00")) if value else None
templates = call("GET", "/templates")["data"]
template_id = templates[0]["id"]
post_time = datetime.now(timezone.utc)
call("POST", f"/jobs/{job_id}/generate-report",
json={"templateId": template_id, "reportLanguage": "en"})
# -> {"success": true, "data": {"reportStatus": "generating", ...}}
# A regeneration starts from "available", so wait for the new report: confirm
# report_status has moved to "generating", or report_generated_at has moved past
# post_time, before trusting the next "available" as the new report.
deadline = time.time() + REPORT_TIMEOUT_SECONDS
while True:
if time.time() >= deadline:
raise TimeoutError("report generation did not start in time")
job = call("GET", f"/jobs/{job_id}")["data"]["job"]
generated_at = _report_time(job["report_generated_at"])
if job["report_status"] == "generating" or (generated_at and generated_at > post_time):
break
time.sleep(2)
# Poll the job and watch report_status, not status.
while True:
if time.time() >= deadline:
raise TimeoutError("report was not generated in time")
job = call("GET", f"/jobs/{job_id}")["data"]["job"]
if job["report_status"] == "available":
break
if job["report_status"] == "failed":
raise RuntimeError(job.get("report_error_message"))
time.sleep(5)
docx = call("GET", f"/jobs/{job_id}/docx-url")["data"]
print(docx["downloadUrl"], "valid for", docx["expiresIn"], "seconds")POST /jobs/{jobId}/reports builds a report synchronously and returns the download URL directly.
- Takes
templateIdandformat("pdf"or"docx"). - Writes only to its own record —
reportId, the storage key andgenerationTimeMs. It does not setreport_statusordocx_report_s3_keyon the job. - Renders in whatever language is already stored on the job. There is no
reportLanguagefield on this endpoint. - No server-side generation timeout.
generationTimeMsin the example is a measured value, not a bound — apply the 30-second client timeout from Errors.
Endpoint reference
Paths are relative to https://api.smartcivilapps.com/api/v1/borehole. Except where noted, every request needs the Authorization: Bearer sca_… header. Every endpoint can also return the 401 codes, 429 RATE_LIMIT_EXCEEDED and 500 INTERNAL_ERROR (the three exports return 500 EXPORT_ERROR instead); the tables below list endpoint-specific errors only. Every endpoint except POST /jobs/{jobId}/reports, GET /templates and the Account group returns 403 SUBSCRIPTION_REQUIRED without an active Borehole Analysis Pro subscription. Every endpoint with a path or body parameter, except POST /jobs/{jobId}/reports, returns 400 VALIDATION_ERROR when it is malformed; details[] names the field.
Uploads
Reserve an upload and return a storage URL to PUT the file to. Does not start processing.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| filename | string | yes | 1–255 characters, ending in .pdf, .png, .jpg, .jpeg or .ags (case-insensitive). Only the extension is constrained; any UTF-8 name is accepted. |
- The returned uploadUrl is valid for 5 minutes and may be retried within that window.
- The PUT to uploadUrl needs no headers. The file type is checked from the stored bytes and the size is measured from the stored object; both are written to the upload record at validation.
- Storage PUT responses: 200 with an empty body on success. After 5 minutes, 403 with an XML body from storage, not the JSON envelope — request a new URL.
- The URL grants access to the file until it expires. Treat it as a secret: do not log or share it.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"uploadUrl": "https://smartcivilapps.com.s3.eu-central-1.amazonaws.com/borehole/aaaaaaaa-0000-4000-8000-000000000001/uploads/aaaaaaaa-0000-4000-8000-000000000002/site-investigation-BH01.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE1234567%2F20260902%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20260902T091203Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=7b1c0d4e9a2f5386bc47e0d19f8a63c25d704be18f39a6c07d2b5481e93f6a0c",
"uploadId": "aaaaaaaa-0000-4000-8000-000000000002"
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_ERROR | A body field failed validation. Read details[]. |
| 403 | SUBSCRIPTION_REQUIRED | No active Borehole Analysis Pro subscription. |
| 500 | UPLOAD_URL_GENERATION_FAILED | The storage URL could not be generated. Retry. |
List your uploads and their validation status.
- file_size is a JSON number, not a numeric string.
- The whole list in one response: every upload from the last 7 days, newest first. No paging.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": [
{
"id": "aaaaaaaa-0000-4000-8000-000000000002",
"user_id": "aaaaaaaa-0000-4000-8000-000000000001",
"filename": "site-investigation-BH01.pdf",
"file_path": "borehole/aaaaaaaa-0000-4000-8000-000000000001/uploads/aaaaaaaa-0000-4000-8000-000000000002/site-investigation-BH01.pdf",
"file_size": 2458112,
"content_type": "application/pdf",
"status": "validated",
"validation_error": null,
"created_at": "2026-09-02T09:12:03.000Z",
"expires_at": "2026-09-09T09:12:03.000Z",
"page_count": 12
}
]
}Errors
| Status | Code | Meaning |
|---|---|---|
| 403 | SUBSCRIPTION_REQUIRED | No active Borehole Analysis Pro subscription. |
Read one upload. Poll this while the file is validated.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The uploadId returned by POST /uploads. |
- Validation checks size, type and, for PDFs, page count.
- status is one of pending, uploaded, validated, failed. pending and uploaded are transitional; branch on validated or failed, never on the text of validation_error. (uploaded is declared in the type; validation writes validated or failed directly.)
- On failed, validation_error carries the reason, for example "Document has 63 pages, exceeding the 50-page limit. Please split it into smaller files.", "Invalid file type. Allowed: pdf, png, jpg, jpeg, ags" or "File is empty".
- file_size is null until the upload is validated.
- page_count is the pages this upload uses from your allowance, set when validation completes. A job created from it reserves that figure; the charge at completion is the job's pages_consumed.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"id": "aaaaaaaa-0000-4000-8000-000000000002",
"user_id": "aaaaaaaa-0000-4000-8000-000000000001",
"filename": "site-investigation-BH01.pdf",
"file_path": "borehole/aaaaaaaa-0000-4000-8000-000000000001/uploads/aaaaaaaa-0000-4000-8000-000000000002/site-investigation-BH01.pdf",
"file_size": 2458112,
"content_type": "application/pdf",
"status": "validated",
"validation_error": null,
"created_at": "2026-09-02T09:12:03.000Z",
"expires_at": "2026-09-09T09:12:03.000Z",
"page_count": 12
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_ERROR | id is not a UUID. |
| 404 | UPLOAD_NOT_FOUND | Unknown upload, or it belongs to another account. |
Upload record fields
| Field | Type | Presence | Meaning |
|---|---|---|---|
| id | string (uuid) | always | Upload identifier. |
| user_id | string (uuid) | always | Internal; not for client use. |
| filename | string | always | Original filename. |
| file_path | string | always | Internal; not for client use. |
| file_size | number, nullable | always, nullable | Bytes; null until the upload is validated. |
| content_type | string, nullable | optional, nullable | Detected from the stored bytes. |
| status | string | always | pending, uploaded, validated or failed. |
| validation_error | string, nullable | optional, nullable | Failure reason when status is failed. |
| created_at | string (ISO 8601) | always | When the upload was created. |
| expires_at | string (ISO 8601) | always | 7 days after created_at. |
| page_count | number, nullable | always, nullable | Pages this upload uses from your allowance; null until the upload is validated. |
Delete an upload and its stored file. Allowed at any time.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The uploadId. |
- Jobs created from the upload keep their data, exports and reports. Their Compare source and the original-logs report appendix become unavailable. A job still processing may fail or be incomplete.
Response
HTTP/1.1 200 OK
{
"success": true,
"message": "Upload deleted successfully"
}Errors
| Status | Code | Meaning |
|---|---|---|
| 404 | UPLOAD_NOT_FOUND | Unknown upload, or already deleted. |
| 500 | DELETE_FAILED | The stored file could not be removed. Retry. |
Jobs
Start processing a validated upload. Consumes quota once extraction succeeds.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| uploadId | string (uuid) | yes | An upload whose status is validated. |
| outputLanguage | string | no | Defaults to "auto" (detect from the document). One of auto, en, de, fr, es, it, pt, nl, pl, sv, da, no, fi, cs, el, ro, hu. |
| templateId | string (uuid) | no | Pre-selects a report template. |
- One upload can back several jobs. Re-posting the same uploadId creates a new jobId. There is no idempotency key.
- queuePosition is 1-based: the number of pending jobs queued ahead of yours, plus one.
- estimatedWait is queuePosition × 25 seconds. It is an estimate, not a guarantee.
- template is null when you send no templateId; otherwise {"id","name","type"} for the template you named.
Response
HTTP/1.1 201 Created
{
"success": true,
"data": {
"jobId": "aaaaaaaa-0000-4000-8000-000000000003",
"queuePosition": 1,
"estimatedWait": 25,
"template": null
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | UPLOAD_NOT_READY | The upload is not validated yet. Body echoes uploadStatus and validationError. |
| 400 | FILE_NOT_FOUND_IN_S3 | The stored file is gone. Upload again. |
| 400 | TEMPLATE_NOT_FOUND | templateId is unknown or not available to you. |
| 404 | UPLOAD_NOT_FOUND | Unknown upload, or it belongs to another account. |
| 429 | QUOTA_EXCEEDED | Monthly page allowance and top-ups exhausted, and the usage meter is off. Body carries your counts. |
| 429 | CONCURRENCY_LIMIT_EXCEEDED | 2 jobs are already running. |
| 429 | QUEUE_LIMIT_EXCEEDED | 5 jobs are already queued. |
| 503 | QUEUE_UNAVAILABLE | The job could not be queued and nothing was created. |
List your jobs, newest first.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | no | Default 50, capped at 100. |
| offset | integer | no | Default 0. |
- Default 50 per page, maximum 100. Page with offset until a page comes back shorter than limit. Jobs are deleted 7 days after creation, so the list never grows beyond that window.
- This list omits the six heavy columns: extracted_data, extracted_data_original, report_content, ui_strings, grounding_map and section_map. When tracking several jobs, poll this list once rather than GET /jobs/{id} per job.
- upload_id is the uploadId the job was created from. Use it to find jobs you may already have created for an upload.
- boreholes_consumed is the number of boreholes charged to your allowance for this job, set when the job completes; null before completion.
- pages_consumed is the number of pages charged to your allowance for this job, set when the job completes; null before completion.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"jobs": [
{
"id": "aaaaaaaa-0000-4000-8000-000000000003",
"user_id": "aaaaaaaa-0000-4000-8000-000000000001",
"subscription_id": "aaaaaaaa-0000-4000-8000-000000000004",
"org_app_subscription_id": null,
"upload_id": "aaaaaaaa-0000-4000-8000-000000000002",
"file_name": "site-investigation-BH01.pdf",
"file_path": "borehole/aaaaaaaa-0000-4000-8000-000000000001/uploads/aaaaaaaa-0000-4000-8000-000000000002/site-investigation-BH01.pdf",
"file_size": 2458112,
"source_s3_key": null,
"status": "completed",
"progress": 100,
"processing_time_ms": 168420,
"error_message": null,
"output_language": "auto",
"detected_language": "en",
"template_id": "a1b2c3d4-5e6f-4708-9a1b-2c3d4e5f6071",
"docx_report_s3_key": "reports/aaaaaaaa-0000-4000-8000-000000000003/a1b2c3d4-5e6f-4708-9a1b-2c3d4e5f6071_report.docx",
"report_status": "available",
"report_language": "en",
"report_progress": 100,
"report_generated_at": "2026-09-02T09:17:44.000Z",
"report_error_message": null,
"version": 1,
"boreholes_consumed": 2,
"pages_consumed": 12,
"created_at": "2026-09-02T09:13:00.000Z",
"completed_at": "2026-09-02T09:16:12.000Z",
"updated_at": "2026-09-02T09:17:44.000Z",
"expires_at": "2026-09-09T09:13:00.000Z"
}
]
}
}Read one job.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
- status is one of pending, processing, completed, failed, terminal. terminal means the job exhausted its 3 processing attempts, or a worker died mid-processing and the job was reconciled at startup. Treat failed and terminal alike as final failure and read error_message.
- error_message is free text, with no machine-readable code. Common values: "System pressure: …" (the server shed load), "This document is approximately 7 page(s), but you only have 3 remaining (45/200 monthly used, 2 reserved by other jobs). Please try a smaller document or purchase additional pages." (the document needs more allowance than you hold and the usage meter is off), "reconciled: worker died mid-processing", or the underlying failure text.
- progress is 0–100.
- output_language is the value you sent as outputLanguage, "auto" when you sent none. detected_language is the language extraction resolved for the job — the document language when outputLanguage is "auto" — and is null until extraction resolves it.
- report_status tracks report generation separately from status, and is one of null, generating, available, failed. On failed, report_error_message carries the reason.
- This response is the whole stored row: the columns GET /jobs returns plus extracted_data, extracted_data_original, report_content, ui_strings, grounding_map and section_map. On completion extracted_data holds the same payload GET /jobs/{id}/data returns. Until then the six heavy columns are null, so polling this endpoint for one job is cheap.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"job": {
"id": "aaaaaaaa-0000-4000-8000-000000000003",
"user_id": "aaaaaaaa-0000-4000-8000-000000000001",
"subscription_id": "aaaaaaaa-0000-4000-8000-000000000004",
"org_app_subscription_id": null,
"upload_id": "aaaaaaaa-0000-4000-8000-000000000002",
"file_name": "site-investigation-BH01.pdf",
"file_path": "borehole/aaaaaaaa-0000-4000-8000-000000000001/uploads/aaaaaaaa-0000-4000-8000-000000000002/site-investigation-BH01.pdf",
"file_size": 2458112,
"source_s3_key": null,
"status": "processing",
"progress": 45,
"processing_time_ms": null,
"error_message": null,
"extracted_data": null,
"extracted_data_original": null,
"report_content": null,
"ui_strings": null,
"grounding_map": null,
"section_map": null,
"output_language": "auto",
"detected_language": "en",
"template_id": null,
"docx_report_s3_key": null,
"report_status": null,
"report_language": null,
"report_progress": null,
"report_generated_at": null,
"report_error_message": null,
"version": 1,
"boreholes_consumed": null,
"pages_consumed": null,
"created_at": "2026-09-02T09:13:00.000Z",
"completed_at": null,
"updated_at": "2026-09-02T09:13:00.000Z",
"expires_at": "2026-09-09T09:13:00.000Z"
}
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_ERROR | id is not a UUID. |
| 404 | NOT_FOUND | {"error":"Not found","message":"Job not found or access denied","code":"NOT_FOUND"} |
Job record fields
| Field | Type | Presence | Meaning |
|---|---|---|---|
| id | string (uuid) | always | Job identifier. |
| user_id | string (uuid) | always | Internal; not for client use. |
| subscription_id | string (uuid), nullable | always, nullable | Internal; not for client use. |
| org_app_subscription_id | string (uuid), nullable | always, nullable | Internal; not for client use. |
| upload_id | string (uuid) | always | The uploadId the job was created from. |
| file_name | string | always | Original filename. |
| file_path | string | always | Internal; not for client use. |
| file_size | number | always | File size in bytes. |
| source_s3_key | string, nullable | always, nullable | Internal; not for client use. |
| status | string | always | pending, processing, completed, failed or terminal. |
| progress | number | always | 0–100. |
| processing_time_ms | number, nullable | optional, nullable | Extraction duration once completed; null before. |
| error_message | string, nullable | always, nullable | Failure reason. Free text, no code. |
| extracted_data | object, nullable | optional, nullable | The structured extraction result; see Extracted data. Null until completion. |
| extracted_data_original | object, nullable | optional, nullable | The extraction as originally produced, before edits. Powers the Compare feature. |
| report_content | string, nullable | optional, nullable | The generated report text. Read it via GET /jobs/{id}/report, not this field. |
| ui_strings | object, nullable | optional, nullable | Internal; not for client use. |
| grounding_map | object, nullable | optional, nullable | Internal; not for client use. |
| section_map | object, nullable | optional, nullable | Internal; not for client use. |
| output_language | string | always | The value sent as outputLanguage, "auto" when none was sent. |
| detected_language | string, nullable | optional, nullable | The language extraction resolved for the job. |
| template_id | string (uuid), nullable | optional, nullable | The report template in use, if any. |
| docx_report_s3_key | string, nullable | always, nullable | Internal; not for client use. |
| report_status | string, nullable | always, nullable | null, generating, available or failed. |
| report_language | string, nullable | optional, nullable | The language the report was rendered in. |
| report_progress | number, nullable | optional, nullable | 0–100 during report generation. |
| report_generated_at | string (ISO 8601), nullable | optional, nullable | Set when report_status becomes available. |
| report_error_message | string, nullable | optional, nullable | Failure reason when report_status is failed. |
| version | number | always | Internal; not for client use. |
| boreholes_consumed | number, nullable | optional, nullable | Boreholes charged to your allowance for this job; null before completion. |
| pages_consumed | number, nullable | optional, nullable | Pages charged to your allowance for this job; null before completion. |
| created_at | string (ISO 8601) | always | When the job was created. |
| completed_at | string (ISO 8601), nullable | optional, nullable | Set when the job reaches completed, failed or terminal. |
| updated_at | string (ISO 8601) | always | Last write to this row. |
| expires_at | string (ISO 8601) | always | 7 days after created_at. |
Delete a job and everything stored with it, including the upload it came from and the stored file. Quota already consumed is not returned.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
- Other jobs created from the same upload keep their data; their Compare source and report appendix become unavailable.
Response
HTTP/1.1 200 OK
{
"success": true,
"message": "Job deleted successfully"
}Errors
| Status | Code | Meaning |
|---|---|---|
| 404 | NOT_FOUND | Unknown job, or it belongs to another account. |
Mint a single-use ticket for the progress stream. Authenticated with your API key; the stream is authenticated with the ticket.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
- expiresIn is 60 seconds. Mint the ticket immediately before you connect, not in advance.
- A ticket that has never been connected still occupies one of your 4 stream slots until it expires.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"ticket": "9f2c81a04e7b46d3ab15c8f2740e6b93",
"expiresIn": 60
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 404 | NOT_FOUND | Unknown job, or it belongs to another account. |
| 429 | STREAM_LIMIT_EXCEEDED | {"error":"Too many concurrent streams","message":"Maximum 4 concurrent progress streams allowed.","code":"STREAM_LIMIT_EXCEEDED","retryAfter":60} |
Server-Sent Events progress stream. Send the ticket in the query string; do not send your API key on this request.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| ticket | string | yes | A 32-character ticket from POST /jobs/{id}/stream-ticket. Consumed on first connection. |
- Every event except report_progress and keep-alives also carries job, the full job record GET /jobs/{id} returns.
Response (text/event-stream)
HTTP/1.1 200 OK
Content-Type: text/event-stream
data: {"type":"init","job":{"id":"aaaaaaaa-0000-4000-8000-000000000003","status":"processing","progress":0}}
# job abridged
data: {"type":"progress","jobId":"aaaaaaaa-0000-4000-8000-000000000003","progress":45,"status":"processing","job":{ … }}
# job abridged
data: {"type":"extraction_complete","jobId":"aaaaaaaa-0000-4000-8000-000000000003","progress":100,"status":"completed","job":{ … }}
: keep-aliveErrors
| Status | Code | Meaning |
|---|---|---|
| 401 | INVALID_STREAM_TICKET | Missing, expired, already-used, or wrong-job ticket. |
| 404 | NOT_FOUND | Job not found or access denied. |
Data & exports
The structured extraction result for a completed job, including any edits made to it since.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
- Field by field: see Extracted data.
- boreholes and extractionMetadata are always present. projectInfo, siteDescription, unattributedLaboratoryTests and dataAvailability are optional.
- Depths and elevations carry no unit of their own. Read extractionMetadata.unitSystem first ("metric" = metres, "imperial" = feet) and apply it to every depth in the payload. There is no thickness field; thickness is depthTo − depthFrom.
- Before extraction finishes this returns 404, not a 4xx naming the job state. Branch on GET /jobs/{id}.status instead.
- These three 404s share the code NOT_FOUND. Do not parse message; check GET /jobs/{id}.status. A completed job with no data is a support case.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"extractedData": {
"boreholes": [],
"extractionMetadata": {
"confidence": 0.92,
"model": "eu.anthropic.claude-haiku-4-5-20251001-v1:0",
"promptVersion": "v7.0.1",
"unitSystem": "metric"
}
}
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 404 | NOT_FOUND | {"error":"Not found","message":"Data not ready. Job is still processing.","code":"NOT_FOUND"} while the job is not completed. |
| 404 | NOT_FOUND | message "No extracted data available" — the job completed but stored nothing. |
| 404 | NOT_FOUND | message "Job not found or access denied" — unknown job, or it belongs to another account. |
Build an AGS4 file from the job and return a download URL for it.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
- downloadUrl is a direct storage link valid for 24 hours. Fetch it without an Authorization header.
- The file is UTF-8 with CRLF line endings and no byte-order mark.
- filename is {ProjectStub}-{jobIdPrefix}_data_export.{ext} — up to 6 alphanumeric characters from projectInfo.projectName (or "Export" when it is absent) plus the first 5 characters of the jobId. The URL’s object name differs.
- The URL grants access to the file until it expires. Treat it as a secret: do not log or share it.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"downloadUrl": "https://smartcivilapps.com.s3.eu-central-1.amazonaws.com/exports/aaaaaaaa-0000-4000-8000-000000000003/v1/data_export.ags?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE1234567%2F20260902%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20260902T091640Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=2e5b90c1a7d34f68b012e9d5c8a4f37160bd29e4c5017a8f3b6d90c2e478a15b",
"filename": "Northg-aaaaa_data_export.ags",
"groupsGenerated": ["PROJ","TRAN","LOCA","GEOL","SAMP","GCHM","WSTD"]
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | JOB_NOT_COMPLETED | Extraction has not finished. Body echoes currentStatus. |
| 400 | NO_EXTRACTED_DATA | The job holds no data to export. |
| 403 | ACCESS_DENIED | The job belongs to another account. |
| 404 | JOB_NOT_FOUND | Unknown job. |
| 500 | EXPORT_ERROR | Export generation failed. |
Build a ZIP of CSV tables from the job and return a download URL for it.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
- downloadUrl is a direct storage link valid for 24 hours. Fetch it without an Authorization header.
- Each CSV inside the ZIP is UTF-8 with a leading byte-order mark and CRLF line endings.
- Every CSV table has two header lines: the column headings, then a units row — the unit under each column that has one, blank elsewhere.
- in_situ_tests.csv: one row per test result. Borehole_ID, Test_Type, Depth, Sample_ID, Sample_Type; the SPT columns (N_Value, Blow_Counts, Seating_Blows, Main_Blows, Recovery_Percent, Condition, Sample_Description); one column per field test present, headed by the test name (Pocket_Penetrometer, …); Depth_Unit. A row fills only its own test's columns.
- laboratory_tests.csv: one row per record. Borehole_ID, Sample_ID, Sample_Depth, Test_Type, Test_Method, Sample_Type; one column per result key of each test type present, headed Test_Type.key (Atterberg_Limits.liquidLimit); Depth_Unit.
- geological_layers.csv, borehole_locations.csv, groundwater.csv, project_info.csv: the columns as before, with the units row showing the depth unit under every depth, elevation and water-level column.
- filename is {ProjectStub}-{jobIdPrefix}_data_export.{ext} — up to 6 alphanumeric characters from projectInfo.projectName (or "Export" when it is absent) plus the first 5 characters of the jobId. The URL’s object name differs.
- The URL grants access to the file until it expires. Treat it as a secret: do not log or share it.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"downloadUrl": "https://smartcivilapps.com.s3.eu-central-1.amazonaws.com/exports/aaaaaaaa-0000-4000-8000-000000000003/v1/data_export.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE1234567%2F20260902%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20260902T091645Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=51a0c73de8b924f6017cd35ba9e4820f6d3b17ce095a2f84b60d1e7392ca4058",
"filename": "Northg-aaaaa_data_export.zip",
"filesIncluded": ["project_info.csv","borehole_locations.csv","geological_layers.csv"]
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | JOB_NOT_COMPLETED | Extraction has not finished. Body echoes currentStatus. |
| 400 | NO_EXTRACTED_DATA | The job holds no data to export. |
| 403 | ACCESS_DENIED | The job belongs to another account. |
| 404 | JOB_NOT_FOUND | Unknown job. |
| 500 | EXPORT_ERROR | Export generation failed. |
Build a JSON file from the job and return a download URL for it.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
- downloadUrl is a direct storage link valid for 24 hours. Fetch it without an Authorization header.
- The file is UTF-8 with no byte-order mark.
- filename is {ProjectStub}-{jobIdPrefix}_data_export.{ext} — up to 6 alphanumeric characters from projectInfo.projectName (or "Export" when it is absent) plus the first 5 characters of the jobId. The URL’s object name differs.
- The URL grants access to the file until it expires. Treat it as a secret: do not log or share it.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"downloadUrl": "https://smartcivilapps.com.s3.eu-central-1.amazonaws.com/exports/aaaaaaaa-0000-4000-8000-000000000003/v1/data_export.json?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE1234567%2F20260902%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20260902T091649Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=b840c15e73d92a6f0148ce5b3fa27d906e14b8c25703df9a1b6e0c48532ad7f61",
"filename": "Northg-aaaaa_data_export.json",
"sectionsIncluded": ["project_info","borehole_locations","geological_layers","groundwater","laboratory_tests"]
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | JOB_NOT_COMPLETED | Extraction has not finished. Body echoes currentStatus. |
| 400 | NO_EXTRACTED_DATA | The job holds no data to export. |
| 403 | ACCESS_DENIED | The job belongs to another account. |
| 404 | JOB_NOT_FOUND | Unknown job. |
| 500 | EXPORT_ERROR | Export generation failed. |
Reports & templates
List the report templates available to you: shared templates plus your own.
- styles is the template’s extracted look: fonts, colors, headingStyles, paragraphStyle, pageLayout and tableStyle.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": [
{
"id": "a1b2c3d4-5e6f-4708-9a1b-2c3d4e5f6071",
"name": "Modern Professional",
"description": "Clean layout for client-facing reports",
"template_type": "system",
"thumbnail_key": "thumbnails/system/modern-professional.png",
"thumbnail_url": "https://smartcivilapps.com/thumbnails/system/modern-professional.png",
"styles": {
"fonts": { "heading": "Calibri", "body": "Calibri" },
"colors": { "primary": "#1F4E79", "heading": "#1F4E79", "text": "#212121" },
"headingStyles": {
"h1": { "fontSize": 18, "bold": true, "color": "#1F4E79" },
"h2": { "fontSize": 14, "bold": true, "color": "#1F4E79" },
"h3": { "fontSize": 12, "bold": true }
},
"paragraphStyle": { "fontSize": 11, "lineSpacing": 1.15, "alignment": "justify" },
"pageLayout": {
"size": "A4",
"orientation": "portrait",
"margins": { "top": 25, "right": 20, "bottom": 25, "left": 25 }
},
"tableStyle": { "headerBackground": "#1F4E79", "headerColor": "#FFFFFF", "borderColor": "#BFBFBF" }
},
"usage_count": 128,
"created_at": "2026-01-14T10:02:11.000Z"
}
]
}Queue report generation for a completed job. Returns immediately.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| templateId | string (uuid) | no | A template id from GET /templates. Defaults to the job's existing template, then to the default shared template. |
| reportLanguage | string | no | Defaults to the job's output language. One of en, de, fr, es, it, pt, nl, pl, sv, da, no, fi, cs, el, ro, hu. |
- Poll GET /jobs/{id} and watch report_status until it is available, then fetch the file from GET /jobs/{id}/docx-url.
- Calling this again on a job whose report_status is available regenerates the report.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"reportStatus": "generating",
"templateId": "a1b2c3d4-5e6f-4708-9a1b-2c3d4e5f6071",
"reportLanguage": "en"
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 403 | ACCESS_DENIED | The job belongs to another account. |
| 404 | JOB_NOT_FOUND | Unknown job. |
| 404 | VALIDATION_ERROR | Template not found or not available to you. The nested code is VALIDATION_ERROR even though the status is 404. |
| 409 | INVALID_STATE | Extraction has not finished, or a report is already being generated. |
| 500 | INTERNAL_ERROR | No default template is configured, or the report could not be queued. |
Read the generated report content for a job.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
- data.report is a string — the job’s stored report text, not an object. Its internal structure is not part of the v1 contract; for the formatted document use GET /jobs/{id}/docx-url.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"report": "# Northgate Interchange Ground Investigation\n\n## 1. Executive Summary\n\nTwo cable-percussion boreholes were sunk to 12.5 m and 10.0 m below existing ground level.\n"
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 404 | NOT_FOUND | {"error":"Not found","message":"Report not ready. Job is still processing.","code":"NOT_FOUND"} |
| 404 | NOT_FOUND | message "No report available" — the job completed but no report has been generated. |
| 404 | NOT_FOUND | message "Job not found or access denied" — unknown job, or it belongs to another account. |
Get a download URL for the generated .docx report.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
- expiresIn is in seconds — the URL is valid for 24 hours. Fetch it without an Authorization header.
- The URL grants access to the file until it expires. Treat it as a secret: do not log or share it.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"downloadUrl": "https://smartcivilapps.com.s3.eu-central-1.amazonaws.com/reports/aaaaaaaa-0000-4000-8000-000000000003/a1b2c3d4-5e6f-4708-9a1b-2c3d4e5f6071_report.docx?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE1234567%2F20260902%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20260902T091755Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=6c02f9a41d7b385e0ca6b1f294d80e37519bd6ac0834e7f21b95c0d6a4e8371f",
"expiresIn": 86400,
"format": "docx",
"templateId": "a1b2c3d4-5e6f-4708-9a1b-2c3d4e5f6071"
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | JOB_NOT_COMPLETED | Extraction has not finished. Body echoes currentStatus. |
| 403 | ACCESS_DENIED | The job belongs to another account. |
| 404 | JOB_NOT_FOUND | Unknown job. |
| 404 | DOCX_NOT_AVAILABLE | No report has been generated for this job yet. |
Rebuild the .docx for a job that already has a report, using a different template. Reuses the extraction; consumes no quota.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string (uuid) | yes | The jobId. |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| templateId | string (uuid) | yes | A template id from GET /templates. |
- The URL grants access to the file until it expires. Treat it as a secret: do not log or share it.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"downloadUrl": "https://smartcivilapps.com.s3.eu-central-1.amazonaws.com/reports/aaaaaaaa-0000-4000-8000-000000000003/a1b2c3d4-5e6f-4708-9a1b-2c3d4e5f6071_report.docx?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE1234567%2F20260902%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20260902T092012Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=af37105c8e2b64d90371fb5a2c8e40d61b9a7c0524ef836b1d0a97c4e582b361",
"templateId": "a1b2c3d4-5e6f-4708-9a1b-2c3d4e5f6071",
"templateName": "Modern Professional",
"reportId": "aaaaaaaa-0000-4000-8000-000000000007",
"generationTimeMs": 4820
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 403 | ACCESS_DENIED | The job belongs to another account. |
| 404 | JOB_NOT_FOUND | Unknown job. |
| 404 | VALIDATION_ERROR | Template not found or not available to you. The nested code is VALIDATION_ERROR even though the status is 404. |
| 409 | INVALID_STATE | The job has no report yet, one is already being generated, or extraction has not finished. |
| 500 | INTERNAL_ERROR | The rebuild failed; report_status is set to failed. |
Build a report synchronously and return its download URL in the same response.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| jobId | string (uuid) | yes | The jobId. |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| templateId | string (uuid) | yes | A template id from GET /templates. |
| format | string | yes | Either "pdf" or "docx". |
- The path parameter is {jobId} on this endpoint, {id} everywhere else.
- data carries its own success field. Read data.downloadUrl, not data.success.
- cached is true when the same job, template and format were built before and the stored file was reused.
- The URL grants access to the file until it expires. Treat it as a secret: do not log or share it.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"success": true,
"reportId": "aaaaaaaa-0000-4000-8000-000000000007",
"downloadUrl": "https://smartcivilapps.com.s3.eu-central-1.amazonaws.com/reports/aaaaaaaa-0000-4000-8000-000000000003/a1b2c3d4-5e6f-4708-9a1b-2c3d4e5f6071_report.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAEXAMPLE1234567%2F20260902%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20260902T092310Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=d51ca8067b23e9f4105d7c6b28a3ef90417c5b6d0e82a39f7b1450c6de297a38",
"cached": false,
"generationTimeMs": 4820
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | BAD_REQUEST | "Template ID is required", or format is not "pdf" or "docx". |
| 400 | BAD_REQUEST | The job has no extracted data or report content yet (message "Job data incomplete - missing extracted_data or report_content"). |
| 403 | FORBIDDEN | The job belongs to another account. |
| 404 | NOT_FOUND | Unknown job or template. |
| 500 | INTERNAL_ERROR | "Failed to generate report". |
Account
Your allowance for the current month.
- Remaining capacity is pages_remaining + topup_remaining.
- documents_processed counts files; boreholes_processed counts boreholes.
- month_year is the current UTC calendar month. Counters reset because a new month starts a new record: on 1 October at 00:00 UTC, documents_processed, boreholes_processed and pages_processed read 0 again. The response carries no reset timestamp — next_expiry is a top-up expiry date, not a monthly reset.
- meter_on is true while the usage meter is switched on in the web application. With the meter on, jobs are not refused for lack of pages: the pages used after pages_remaining and topup_remaining are spent are counted in metered_pages and billed monthly to your saved card. metered_pages and metered_amount are this month's figures and read 0 when no pages have been metered this month.
- On an organisation seat the administrator of your organisation switches the meter on, meter_on and metered_pages are as above, and metered_amount is always 0: your organisation is invoiced for the metered pages and no amount is billed to you.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"usage": {
"id": "aaaaaaaa-0000-4000-8000-000000000005",
"user_id": "aaaaaaaa-0000-4000-8000-000000000001",
"subscription_id": "aaaaaaaa-0000-4000-8000-000000000004",
"org_app_subscription_id": null,
"documents_processed": 12,
"boreholes_processed": 47,
"pages_processed": 94,
"total_cost_cents": 913,
"page_limit": 200,
"pages_remaining": 106,
"month_year": "2026-09",
"topup_total": 100,
"topup_used": 0,
"topup_remaining": 100,
"topup_packages": [
{
"id": "aaaaaaaa-0000-4000-8000-000000000006",
"pages_total": 100,
"pages_used": 0,
"pages_remaining": 100,
"purchased_at": "2026-08-01T00:00:00.000Z",
"expires_at": "2027-08-01T00:00:00.000Z"
}
],
"next_expiry": { "date": "2027-08-01T00:00:00.000Z", "pages_expiring": 100 },
"meter_on": false,
"metered_pages": 0,
"metered_amount": 0,
"created_at": "2026-09-01T00:04:12.000Z",
"updated_at": "2026-09-02T09:16:12.000Z"
}
}
}Usage record fields
| Field | Type | Presence | Meaning |
|---|---|---|---|
| id | string (uuid) | optional | Internal; not for client use. Present once a usage row exists for the month. |
| user_id | string (uuid) | optional | Internal; not for client use. |
| subscription_id | string (uuid), nullable | optional, nullable | Internal; not for client use. |
| org_app_subscription_id | string (uuid), nullable | optional, nullable | Internal; not for client use. |
| documents_processed | number | always | Files processed this month. |
| boreholes_processed | number | always | Boreholes processed this month. |
| pages_processed | number | always | Pages used this month from your monthly allowance. |
| total_cost_cents | number | always | Internal; not for client use. |
| page_limit | number | always | Your monthly allowance, in pages: 200 unless your plan includes more. |
| pages_remaining | number | always | Pages left in the monthly allowance. |
| month_year | string | always | The current UTC calendar month, "YYYY-MM". |
| created_at | string (ISO 8601), nullable | optional, nullable | Present once a usage row exists for the month. |
| updated_at | string (ISO 8601), nullable | optional, nullable | Present once a usage row exists for the month. |
| topup_total | number | always | Total top-up pages purchased and not yet expired. |
| topup_used | number | always | Top-up pages consumed. |
| topup_remaining | number | always | topup_total minus topup_used. |
| topup_packages | array | always | One entry per active top-up package. |
| next_expiry | object, nullable | always, nullable | Date and count of the next top-up pages to expire; null when none are due. |
| meter_on | boolean | always | true while your usage meter is switched on. With it on, pages beyond your monthly allowance and top-ups are metered and billed, and QUOTA_EXCEEDED is not returned. On an organisation seat the administrator of your organisation switches the meter on. |
| metered_pages | number | always | Pages metered this month: the pages used beyond your monthly allowance and top-ups while the meter was on. On an organisation seat these pages are invoiced to your organisation. |
| metered_amount | number | always | The amount for metered_pages this month at the meter rate in force when each page was counted, in the currency of your subscription. Billed monthly to your saved card. Always 0 on an organisation seat: your organisation is invoiced for the metered pages and no amount is billed to you. |
Your top-up package balances and the current top-up price. Top-ups are bought in the web application, not through this API.
- topup_price is the administrator-set price per top-up in topup_currency, and is null when no price is configured. topup_currency falls back to "EUR".
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"topup": {
"topup_total": 100,
"topup_used": 0,
"topup_remaining": 100,
"topup_packages": [
{
"id": "aaaaaaaa-0000-4000-8000-000000000006",
"pages_total": 100,
"pages_used": 0,
"pages_remaining": 100,
"purchased_at": "2026-08-01T00:00:00.000Z",
"expires_at": "2027-08-01T00:00:00.000Z"
}
],
"next_expiry": { "date": "2027-08-01T00:00:00.000Z", "pages_expiring": 100 },
"topup_price": null,
"topup_currency": "EUR"
}
}
}Your Borehole Analysis Pro access.
- via is "individual" for a personal subscription or "organization" for an organisation seat. id is null on a personal subscription. org_name is sent only for a seat; grace_period_days_remaining only for a seat whose organisation is in a billing grace period. grace_type is sent only while a grace period applies, extras_grace_days_remaining only with grace_type extras_addition; grace_type extras_addition means only extra pages may be removed.
- status is always "active" — the endpoint returns 404 when you have no access.
- pending_payment_status is null, "retry" — access continues while a failed renewal payment is retried — or "awaiting_authentication" — a bank authentication is outstanding.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"subscription": {
"id": null,
"user_id": "aaaaaaaa-0000-4000-8000-000000000001",
"status": "active",
"expires_at": "2027-01-31T23:59:59.000Z",
"via": "individual",
"in_grace_period": false,
"pending_payment_status": null
}
}
}Errors
| Status | Code | Meaning |
|---|---|---|
| 404 | NOT_FOUND | {"error":"Not found","message":"No active borehole subscription found","code":"NOT_FOUND"} |
The output languages you can pass as outputLanguage or reportLanguage.
- auto is included, for outputLanguage only. reportLanguage takes this list without auto.
Response
HTTP/1.1 200 OK
{
"success": true,
"data": {
"languages": [
{ "code": "auto", "name_english": "Auto-detect", "name_native": "Auto-detect" },
{ "code": "en", "name_english": "English", "name_native": "English" },
{ "code": "de", "name_english": "German", "name_native": "Deutsch" }
# abridged — 14 more languages
]
}
}Live progress
Progress as Server-Sent Events, in two steps: mint a ticket with your API key, then open the stream with that ticket in the query string.
# 1. Mint a ticket with your key. It lasts 60 seconds and is used once.
curl -s -X POST https://api.smartcivilapps.com/api/v1/borehole/jobs/aaaaaaaa-0000-4000-8000-000000000003/stream-ticket \
-H "Authorization: Bearer $SCA_API_KEY"
{"success":true,"data":{"ticket":"9f2c81a04e7b46d3ab15c8f2740e6b93","expiresIn":60}}
# 2. Open the stream with the ticket. No Authorization header on this request.
curl -N "https://api.smartcivilapps.com/api/v1/borehole/jobs/aaaaaaaa-0000-4000-8000-000000000003/stream?ticket=9f2c81a04e7b46d3ab15c8f2740e6b93"
data: {"type":"init","job":{"id":"aaaaaaaa-0000-4000-8000-000000000003","status":"processing","progress":0}}
# job abridged
data: {"type":"progress","jobId":"aaaaaaaa-0000-4000-8000-000000000003","progress":45,"status":"processing","job":{ … }}
# job abridged
data: {"type":"extraction_complete","jobId":"aaaaaaaa-0000-4000-8000-000000000003","progress":100,"status":"completed","job":{ … }}
: keep-alive- A ticket lasts 60 seconds and is consumed by the first connection. Reusing it returns 401.
- Up to 4 streams per account may be open at once. A minted-but-unused ticket holds a slot until it lapses; a 5th mint returns 429
STREAM_LIMIT_EXCEEDED. - The server never closes the stream — after the last event it keeps sending
: keep-alivecomment lines every 30 seconds. Detect completion yourself and disconnect. extraction_completedoes not carry the extracted data. Fetch it fromGET /jobs/{id}/datawhen you see it.
Event types
| type | Meaning |
|---|---|
| init | Always the first event. Carries job, the current job record. |
| progress | Extraction advanced. Carries jobId, progress, status and job. |
| extraction_complete | Extraction finished successfully. Fetch the data and disconnect. |
| extraction_failed | Extraction failed. Read error_message on the job. |
| report_progress | Report generation advanced. |
| report_complete | The report is ready. Fetch it from GET /jobs/{id}/docx-url. |
| report_failed | Report generation failed. |
Ignore any type you do not recognise.
Limits
| Limit | Value | What happens | How to recover |
|---|---|---|---|
| Requests per API key | 120 per minute | 429 RATE_LIMIT_EXCEEDED with retryAfter in seconds | Sleep for retryAfter, then continue. |
| Upload requests | 30 per hour per account | 429 RATE_LIMIT_EXCEEDED on POST /uploads, with retryAfter | Sleep for retryAfter. |
| Jobs running at once | 2 per account | 429 CONCURRENCY_LIMIT_EXCEEDED (no retryAfter) | Wait for a running job to finish, then submit the next one. |
| Jobs queued | 5 per account | 429 QUEUE_LIMIT_EXCEEDED (no retryAfter) | Drain the queue before submitting more. |
| Monthly pages | page_limit from GET /usage (200 unless your plan includes more), counted per page | 429 QUOTA_EXCEEDED, with pagesUsed, pageLimit, remaining, topupRemaining and monthYear. Not returned while the usage meter is on: the pages beyond your allowance and top-ups are metered and billed. | Buy top-ups, switch the usage meter on in the web application (on an organisation seat, ask the administrator of your organisation), or wait for the next month. Never retry this in a loop. |
| Concurrent progress streams | 4 per account | 429 STREAM_LIMIT_EXCEEDED with retryAfter 60 | Close a stream you no longer need, or wait 60 seconds for unused tickets to lapse. |
| Active API keys | 5 per subscription | Key creation is refused on the API Keys page | Revoke a key you no longer use, then create the new one. |
| Rejected key attempts | Limited per address | 429 "Too many invalid API key attempts from this address" | Fix the credential. Valid keys keep working from that address; only unknown keys are refused. |
| Stream ticket lifetime | 60 seconds, single use | 401 INVALID_STREAM_TICKET | Mint a fresh ticket immediately before opening the connection. |
| Upload URL lifetime | 5 minutes | The PUT to storage returns 403 with an XML body | Request a new upload URL. That costs one of your 30 uploads per hour. |
| File size | 10 MB per file | 400 VALIDATION_ERROR on POST /uploads, or the upload is marked failed | Split or compress the document. |
| Page count | 50 pages per PDF (50 passes, 51 is rejected) | The upload reaches status failed with the page count in validation_error | Split the document into smaller files. |
| Result retention | 7 days per job | The job, its exports and its source document are permanently deleted | Store results in your own system as soon as a job completes. Nothing is recoverable afterwards. |
The blanket per-address limiter sends RateLimit-Policy, RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset on every response, plus Retry-After on a 429. The per-key limit, the upload limit and the stream cap send no headers — read retryAfter from the JSON body.
Errors
Every error response carries a code and a message. Match on code, never on message text. Where error is an object, its code is the specific one. Every response also carries the same id in the X-Request-Id header, and unmatched routes and unhandled errors repeat it as requestId in the body.
# Most errors are flat:
{
"error": "Too many requests",
"message": "Maximum 120 requests per minute per key.",
"code": "RATE_LIMIT_EXCEEDED",
"retryAfter": 57
}
# The report endpoints nest theirs. The top-level code comes from the
# HTTP status; the nested code is the specific one.
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Template not found or access denied"
},
"code": "NOT_FOUND"
}
# Validation failures itemise every problem:
{
"error": "Validation failed",
"message": "The provided data is invalid",
"code": "VALIDATION_ERROR",
"details": [
{ "field": "filename", "message": "Invalid file extension. Allowed: pdf, png, jpg, jpeg, ags", "code": "invalid_string" }
],
"target": "body"
}Error codes
| Code | Status | Meaning | What to do |
|---|---|---|---|
| MISSING_API_KEY | 401 | No usable Authorization: Bearer sca_… header on the request. | Add the header. Never retry. |
| INVALID_API_KEY | 401 | The key is unknown or has been revoked. | Issue a new key. Never retry. |
| API_KEY_SUBSCRIPTION_INACTIVE | 401 | The subscription behind the key is not currently active. | Stop; contact us via the Contact button or info@smartcivilapps.com, quoting the X-Request-Id. Never retry. |
| USER_NOT_FOUND | 401 | The account behind the key no longer exists. | Stop; contact us via the Contact button or info@smartcivilapps.com, quoting the X-Request-Id. Never retry. |
| USER_INACTIVE | 401 | The account is not active. | Stop; contact us via the Contact button or info@smartcivilapps.com, quoting the X-Request-Id. Never retry. |
| EMAIL_NOT_VERIFIED | 401 | The account email address is unverified. | Complete verification in the web application. Never retry. |
| INVALID_STREAM_TICKET | 401 | Stream ticket missing, expired, already used, or minted for a different job. | Mint a new ticket and reconnect. |
| SUBSCRIPTION_REQUIRED | 403 | No active Borehole Analysis Pro subscription. | Stop; contact us via the Contact button or info@smartcivilapps.com, quoting the X-Request-Id. Never retry. |
| ACCESS_DENIED | 403 | The job belongs to another account. | Check the id. Never retry. |
| FORBIDDEN | 403 | On POST /jobs/{jobId}/reports: the job belongs to another account. | Check the id. Never retry. |
| VALIDATION_ERROR | 400 | A path parameter or body field failed validation. details[] itemises each failure. | Fix the request and resend. Never retry unchanged. |
| VALIDATION_ERROR | 404 | On generate-report and regenerate-with-template: the template was not found or is not available to you. The status is 404; the nested code is VALIDATION_ERROR. | Pick an id from GET /templates. Never retry unchanged. |
| BAD_REQUEST | 400 | On POST /jobs/{jobId}/reports: templateId is missing, or format is not "pdf" or "docx". | Fix the request and resend. Never retry unchanged. |
| UPLOAD_NOT_READY | 400 | The upload is not validated yet; uploadStatus and validationError are echoed back. | Keep polling GET /uploads/{id}. |
| FILE_NOT_FOUND_IN_S3 | 400 | The uploaded file is no longer in storage. | Start again from POST /uploads. Never retry unchanged. |
| TEMPLATE_NOT_FOUND | 400 | templateId is unknown or not available to you. | Pick an id from GET /templates. Never retry unchanged. |
| JOB_NOT_COMPLETED | 400 | An export or docx-url was requested before extraction finished. currentStatus is echoed back. | Keep polling GET /jobs/{id}. |
| NO_EXTRACTED_DATA | 400 | The job holds no data to export. | Check the job did not fail. Never retry unchanged. |
| UPLOAD_NOT_FOUND | 404 | Unknown upload, or it belongs to another account. | Check the id. Never retry. |
| JOB_NOT_FOUND | 404 | Unknown job, or it belongs to another account. | Check the id. Never retry. |
| NOT_FOUND | 404 | The requested job, data, report or subscription does not exist or is not ready. Read message. | Check the id, or keep polling if you expect it to appear. |
| DOCX_NOT_AVAILABLE | 404 | No report has been generated for this job yet. | Call POST /jobs/{id}/generate-report first. |
| INVALID_STATE | 409 | The job is not in a state that allows this call. | Read message; wait for the job or report to finish, then call again. |
| RATE_LIMIT_EXCEEDED | 429 | A rate limit was hit — per-key requests, uploads per hour, or rejected key attempts. | Sleep retryAfter seconds (15 if absent), then retry. |
| QUOTA_EXCEEDED | 429 | Monthly page allowance and top-ups exhausted, and the usage meter is off. | Not waitable. Stop. Buy top-ups, switch the usage meter on in the web application (on an organisation seat, ask the administrator of your organisation), or wait for the next month. |
| CONCURRENCY_LIMIT_EXCEEDED | 429 | 2 jobs are already running. | Not waitable. Wait on a job you already have in flight. |
| QUEUE_LIMIT_EXCEEDED | 429 | 5 jobs are already queued. | Not waitable. Wait on a job you already have in flight. |
| STREAM_LIMIT_EXCEEDED | 429 | 4 progress streams are already open or reserved. | Sleep retryAfter (60) seconds, then retry, or close a stream. |
| UPLOAD_URL_GENERATION_FAILED | 500 | The storage URL could not be generated. | Retry up to 3 times, backing off 1, 2 then 4 seconds. |
| QUEUE_UNAVAILABLE | 503 | On POST /jobs: the job could not be queued; nothing was created. | Retry up to 3 times, backing off 1, 2 then 4 seconds. |
| EXPORT_ERROR | 500 | Export generation failed. | Retry up to 3 times, backing off 1, 2 then 4 seconds. Then contact us via the Contact button or info@smartcivilapps.com, quoting the X-Request-Id. |
| INTERNAL_ERROR | 500 | Unexpected server error. | Retry up to 3 times, backing off 1, 2 then 4 seconds. On POST /jobs, list jobs for the uploadId first. |
| NOT_FOUND | 404 | Unknown path or method: {"error":"API endpoint not found","message":…,"requestId":…,"code":"NOT_FOUND"}. | Check the path and method. Never retry. |
Retry guidance
- 401 — never retry.
- Other 4xx — never resend unchanged. Three are retried by waiting for a state change, not by resending:
UPLOAD_NOT_READY,JOB_NOT_COMPLETEDandINVALID_STATE— poll the resource and call again when its status moves. - 429 — sleep for
retryAfterseconds, 15 if it is absent, then retry. ExceptQUOTA_EXCEEDED,CONCURRENCY_LIMIT_EXCEEDEDandQUEUE_LIMIT_EXCEEDED, which are not waitable: stop, and act on the cause. - 5xx — retry up to 3 times, backing off 1, 2 then 4 seconds.
- Never retry
POST /jobsafter a 5xx without first listing jobs for thatuploadId. There is no idempotency key, so a blind retry can create a second job and consume the allowance twice. - Set a client timeout of about 30 seconds on the synchronous calls. Extraction is asynchronous: do not time it out on the client, poll instead.
Version
This is v1.5, at /api/v1/borehole. The path version stays v1. The minor version changes when a field is renamed or removed; new fields may appear without one. Every change is listed in the changelog.
Changelog
- 1.5 — 19 October 2026.
GET /usageon an organisation seat:meter_onis true while the administrator of your organisation has switched the usage meter on for you, and 429QUOTA_EXCEEDEDis not returned then;metered_pagesis the pages you used beyond your monthly allowance and top-ups this month;metered_amountis always 0 — your organisation is invoiced for metered pages and no amount is billed to you. Personal subscriptions are unchanged. - 1.4 — 13 October 2026.
GET /usage:meter_on,metered_pagesandmetered_amountreport your usage meter. While the meter is on, pages beyond your monthly allowance and any top-ups are counted as metered pages and billed monthly to your saved card, and 429QUOTA_EXCEEDEDis not returned: a job is not refused, and does not fail, for lack of pages. The meter is switched on and off in the web application and covers every job of the subscription, including jobs made with an API key. With the meter off nothing changes. - 1.3 — 9 October 2026.
GET /usage:page_limitis your own monthly allowance — 200 unless your plan includes extra pages;pages_processedcounts the pages you used from it this month,pages_remainingfollows. 429QUOTA_EXCEEDED:pageLimitandpagesUsedfollow the same.GET /subscription:grace_type("access" or "extras_addition") is sent while a grace period applies,extras_grace_days_remainingonly with grace_type extras_addition; extras_addition means only your extra pages may be removed —in_grace_periodis unchanged. - 1.2, N values — 5 October 2026. SPT
nValue: where the log prints no N, the system computes it from the blow counts by their form.blowCountsare written with hyphens. CSV/JSONSeating_BlowsandMain_Blows, AGS4 ISPT_SEAT and ISPT_MAIN: the seating and main (test) drive blows by the same reading. - 1.2, new fields — 5 October 2026. SPT entries carry
sampleDescription: the part of the layer's description that applies to the sample, or null. CSV export:in_situ_tests.csvhasSample_Description. AGS4 export: SAMP carries SAMP_DESC; GEOL_DESC and SAMP_DESC are written in ASCII, line breaks as "; ". - 1.2 — 22 September 2026. Laboratory records sit under their borehole:
boreholes[].laboratoryTests, each record'sboreholeIdnullable; records no borehole claimed are inunattributedLaboratoryTests; the job-widelaboratoryTestslist is removed. SPT, in-situ testing and laboratory entries carryunitsandunits_inferred.GET /subscription:pending_payment_status. CSV export: every table has a units row under its headings;in_situ_tests.csvhas one column block per test andlaboratory_tests.csvone row per record with one block per test type — theUnits,Parameter_Name,Value,UnitandUnit_Inferredcolumns are gone. - 1.1 — 8 September 2026. The allowance is metered in document pages, 200 per month, instead of boreholes.
GET /usage:page_limit,pages_remainingandpages_processedreplaceborehole_limitandboreholes_remaining;documents_processedandboreholes_processedare unchanged.GET /usageandGET /topup: top-up packages carrypages_total,pages_used,pages_remaininginstead ofboreholes_total,boreholes_used,boreholes_remaining;next_expiry.pages_expiringreplacesboreholes_expiring; a top-up is 200 pages. Jobs:pages_consumed. Uploads:page_count.429 QUOTA_EXCEEDED:pagesUsedandpageLimitreplaceboreholesUsedandboreholeLimit. Existing balances were converted at 100 boreholes = 200 pages. - 1.0 — 4 September 2026. First release.
