Skip to content
Suomi

Start an export or a report

POST
/v1/projects/{projectId}/export-jobs
Code sample: Shell / cURL
curl --request POST \
--url https://api.whatsbuilt.fi/v1/projects/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/export-jobs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "kind": "csv_topics", "params": {} }'

csv_topics, csv_assets, csv_inspections: the app’s CSV exports. as_built_csv: one row per element with its as-built dates. report_md: the inspection report in Markdown. report_pdf: the PDF report with each failed step’s first photo (the organisation’s PDF report). handover: the handover package, a ZIP of the BCF file, the CSV files, the report and the finding photos with manifest.json. Each kind needs the project role the app’s export of it needs: admin for the CSV exports, as_built_csv and handover; inspector for report_pdf, and for report_md where the organisation has the PDF report, admin otherwise.

Answers 202 with the job; poll getExportJob until status is no longer queued or running, then download its files. Today the job is built within about 20 seconds while the call runs, a handover package up to 100 MB; a larger project answers refused, and so does a job that is not stored within 25 seconds. report_pdf draws from the project’s 20 PDF reports an hour, handover from its 20 BCF exports an hour and as_built_csv from its 20 as-built files an hour, all shared with the app; the CSV exports draw from 20 an hour and report_md from 20 an hour (429). A refused or failed job gives its draw back. A repeat with the same Idempotency-Key and body returns the first job with 200; after a timeout or 503, repeat with the same key and read the job.

projectId
required
string format: uuid
idempotency-key
string
/^[\x21-\x7e]{1,255}$/

A repeat with the same key and body returns the first answer instead of writing again. Keys are per integration and project.

Media typeapplication/json

The body of createExportJob.

object
kind
required

csv_topics, csv_assets, csv_inspections: the app’s CSV exports. as_built_csv: one row per element with its as-built dates. report_md: the inspection report in Markdown. report_pdf: the PDF report with each failed step’s first photo (the organisation’s PDF report). handover: the handover package, a ZIP of the BCF file, the CSV files, the report and the finding photos with manifest.json. Each kind needs the project role the app’s export of it needs: admin for the CSV exports, as_built_csv and handover; inspector for report_pdf, and for report_md where the organisation has the PDF report, admin otherwise.

string
Allowed values: csv_topics csv_assets csv_inspections as_built_csv report_md report_pdf handover
params
object
language

The report’s language; default the organisation’s

string
Allowed values: fi en
stages

For as_built_csv and handover: the template whose latest passed inspection dates each stage; a stage left out stays empty

object
factory_check
string format: uuid
delivered
string format: uuid
received
string format: uuid
installed
string format: uuid

The job an earlier call with the same Idempotency-Key started

Media typeapplication/json

An export job.

object
id
required
string format: uuid
project_id
required
string format: uuid
kind
required

What a job exports.

string
Allowed values: csv_topics csv_assets csv_inspections as_built_csv report_md report_pdf handover
status
required

Poll while queued or running. done: download each file. refused: message says why (too large, too slow). failed: start it again with a new Idempotency-Key; a job cut off before it ends reads failed a minute after it started. expired: the files are gone. New statuses may come.

string
Allowed values: queued running done refused failed cancelled expired
params
required

The parameters of an export job.

object
language

fi or en.

string
Allowed values: fi en
stages
object
key
additional properties
string
counts
required

What the files hold, by kind: rows, findings, photos

object | null
truncated
required

Files that stop at their row limit

Array<string>
omitted
required

Files a handover package left out because they could not be built in time

Array<string>
code
required

EXPORT_REFUSED or EXPORT_FAILED

string | null
message
required
string | null
created_at
required
string
started_at
required
string
finished_at
required
string | null
expires_at
required

When the files go; 24 hours after the job is done

string | null
files
required

Download file n with getExportJobFile and file=n

Array<object>

A file of an export job.

object
name
required
string
sha256
required

Hex SHA-256 of the file

string
size_bytes
required
integer format: int64
content_type
required
string

Example

{
"kind": "csv_topics",
"status": "queued",
"params": {
"language": "fi"
}
}

The job

Media typeapplication/json

An export job.

object
id
required
string format: uuid
project_id
required
string format: uuid
kind
required

What a job exports.

string
Allowed values: csv_topics csv_assets csv_inspections as_built_csv report_md report_pdf handover
status
required

Poll while queued or running. done: download each file. refused: message says why (too large, too slow). failed: start it again with a new Idempotency-Key; a job cut off before it ends reads failed a minute after it started. expired: the files are gone. New statuses may come.

string
Allowed values: queued running done refused failed cancelled expired
params
required

The parameters of an export job.

object
language

fi or en.

string
Allowed values: fi en
stages
object
key
additional properties
string
counts
required

What the files hold, by kind: rows, findings, photos

object | null
truncated
required

Files that stop at their row limit

Array<string>
omitted
required

Files a handover package left out because they could not be built in time

Array<string>
code
required

EXPORT_REFUSED or EXPORT_FAILED

string | null
message
required
string | null
created_at
required
string
started_at
required
string
finished_at
required
string | null
expires_at
required

When the files go; 24 hours after the job is done

string | null
files
required

Download file n with getExportJobFile and file=n

Array<object>

A file of an export job.

object
name
required
string
sha256
required

Hex SHA-256 of the file

string
size_bytes
required
integer format: int64
content_type
required
string

Example

{
"kind": "csv_topics",
"status": "queued",
"params": {
"language": "fi"
}
}

Invalid body, parameters or Idempotency-Key

Media typeapplication/json

The error body of every /v1 answer of 400 or more.

object
error
required

A sentence for people; it may change

string
code
required

Part of the contract

string
details

What the code names, where it names something

request_id
required

The X-Request-Id of the call

string

Example generated

{
"error": "example",
"code": "example",
"details": "example",
"request_id": "example"
}

Missing, malformed, expired or revoked token

Media typeapplication/json

The error body of every /v1 answer of 400 or more.

object
error
required

A sentence for people; it may change

string
code
required

Part of the contract

string
details

What the code names, where it names something

request_id
required

The X-Request-Id of the call

string

Example generated

{
"error": "example",
"code": "example",
"details": "example",
"request_id": "example"
}

INSUFFICIENT_SCOPE; INSUFFICIENT_PROJECT_ROLE below the role the kind needs; FEATURE_OFF for report_pdf where the organisation lacks the PDF report; PUBLIC_API_DISABLED

Media typeapplication/json

The error body of every /v1 answer of 400 or more.

object
error
required

A sentence for people; it may change

string
code
required

Part of the contract

string
details

What the code names, where it names something

request_id
required

The X-Request-Id of the call

string

Example generated

{
"error": "example",
"code": "example",
"details": "example",
"request_id": "example"
}

No such project, job or template

Media typeapplication/json

The error body of every /v1 answer of 400 or more.

object
error
required

A sentence for people; it may change

string
code
required

Part of the contract

string
details

What the code names, where it names something

request_id
required

The X-Request-Id of the call

string

Example generated

{
"error": "example",
"code": "example",
"details": "example",
"request_id": "example"
}

RESOURCE_DELETED: what this Idempotency-Key created has since been deleted; details.id names it

Media typeapplication/json

The error body of every /v1 answer of 400 or more.

object
error
required

A sentence for people; it may change

string
code
required

Part of the contract

string
details

What the code names, where it names something

request_id
required

The X-Request-Id of the call

string

Example generated

{
"error": "example",
"code": "example",
"details": "example",
"request_id": "example"
}

IDEMPOTENCY_KEY_REUSED: the key was used with another body

Media typeapplication/json

The error body of every /v1 answer of 400 or more.

object
error
required

A sentence for people; it may change

string
code
required

Part of the contract

string
details

What the code names, where it names something

request_id
required

The X-Request-Id of the call

string

Example generated

{
"error": "example",
"code": "example",
"details": "example",
"request_id": "example"
}

RATE_LIMITED; wait for Retry-After seconds

Media typeapplication/json

The error body of every /v1 answer of 400 or more.

object
error
required

A sentence for people; it may change

string
code
required

Part of the contract

string
details

What the code names, where it names something

request_id
required

The X-Request-Id of the call

string

Example generated

{
"error": "example",
"code": "example",
"details": "example",
"request_id": "example"
}