Resources
Documents
Contracts, change orders, estimates, invoices and permits held against a project, plus the workspace's own document library. List and search them across the workspace or down to one project, and download any of them through a signed link that expires.
/v1/documentsSearch documents
Every project document in the workspace, newest first, each with a signed download link. Requires projects.view on the member who created the API key.
Query parameters
| Name | Type | Description |
|---|---|---|
| project_id | uuid | Only documents on this project. A project in another workspace, or a deleted one, returns 404. |
| q | string | Case-insensitive search over the document name and the original filename. At most 200 characters. Wildcard characters in your text are matched literally. |
| mime_type | string | Exact file type, such as application/pdf or image/png. |
| mime_group | enum | image, pdf, document, spreadsheet or other. A broader filter than mime_type; use one or the other. |
| folder_id | uuid | Only documents filed in this folder. |
| created_after | date | Documents created on or after this YYYY-MM-DD date, from midnight UTC. |
| created_before | date | Documents created on or before this YYYY-MM-DD date, through the end of that day UTC. |
| include_company_documents | boolean | Set true to also return the workspace document library. Excluded by default, and cannot be combined with project_id. See the note below. |
| limit | integer | Rows per page, 1 to 100. Defaults to 25. |
| offset | integer | Rows to skip. Combine with has_more to page. |
The workspace library is opt-in
Coastline keeps two document libraries: the files on each project, and a workspace-wide library for things like signed contracts, onboarding paperwork and report templates. A search of a project's files should never quietly surface the whole workspace library, so this endpoint returns project documents only and you ask for the rest with include_company_documents=true. Documents attached to a contact, a contractor or a team member are not project documents and are not returned by this endpoint at all.
/v1/opportunities/{id}/documentsList a project's documents
One project's own documents, newest first, in the same shape as a search result. Always scoped to that project, so the workspace library is never mixed in. Requires projects.view.
It takes the same filters as the search above except project_id and include_company_documents, which are refused here with a message pointing at /v1/documents: the path already names one project, and this endpoint is that project's own library.
| Name | Type | Description |
|---|---|---|
| q | string | Case-insensitive search over the document name and the original filename. |
| mime_type | string | Exact file type, such as application/pdf. |
| mime_group | enum | image, pdf, document, spreadsheet or other. |
| folder_id | uuid | Only documents filed in this folder. |
| created_after | date | Documents created on or after this YYYY-MM-DD date, from midnight UTC. |
| created_before | date | Documents created on or before this YYYY-MM-DD date, through the end of that day UTC. |
| limit | integer | Rows per page, 1 to 100. Defaults to 25. |
| offset | integer | Rows to skip. Combine with has_more to page. |
A project that has been archived is still readable: archiving makes it read only, and its signed contracts remain the record. A project outside your workspace, or one that has been deleted, returns 404. To add a document instead, see uploading documents.
/v1/documents/{id}Retrieve a document
One document with freshly signed links. A document in the workspace Trash returns 409 rather than a link: the trash holds a deleted record for 30 days before it is purged, so a link issued for one would work until the purge and then stop. Restore it in Coastline to read it again. A document in another workspace returns 404 and never 403, so the endpoint cannot be used to discover what exists elsewhere.
The document object
| Field | Type | Description |
|---|---|---|
| id | uuid | The document id. |
| object | string | Always document. |
| project_id | uuid | The project it belongs to. Null for a document in the workspace library. |
| folder_id | uuid | The folder it is filed in, if any. |
| name | string | The name shown in Coastline. |
| original_name | string | The filename as it was uploaded. |
| mime_type | string | The file type, used to pick a viewer or an icon. |
| size_bytes | integer | Size of the file. |
| uploaded_by | uuid | The workspace member who added it. Null when nobody is recorded. |
| created_at | string | When it was added, ISO 8601. |
| urls.download.url | string | Signed link to the file. Null only if the file could not be signed; re-fetch to try again. |
| urls.download.expires_at | string | When that link stops working. |
| urls.thumbnail.url | string | Signed link to a preview image. Null when no preview has been made, or the format has none. |
| urls.thumbnail.expires_at | string | When the preview link stops working. |
Links expire after an hour
Every download link is signed and valid for one hour, and needs no authentication to fetch. Treat one like a password: anyone holding it can read the file until it expires. An hour is deliberately shorter than the day a photo link lasts, because a document is more often a contract, an invoice or signed paperwork.
Store the document id rather than the link, and re-fetch when you need the bytes. Every link carries its own urls.download.expires_at, so you can check before you use one instead of discovering an expired link halfway through a download.
A preview is offered when Coastline has made one, which covers PDFs and images. There is none for other formats, and the field is null rather than an error.
Errors
| Status | When |
|---|---|
| 400 validation_error | A parameter has the wrong type or an unknown name. The message names the parameter. |
| 401 unauthorized | The API key is missing or has been revoked. |
| 403 forbidden | The key's owner does not have projects.view. |
| 404 not_found | The document or project does not exist in your workspace, or has been deleted. |
| 500 internal_error | Something went wrong on our end. Retry safe. |
See pagination and rate limits before writing a sweep over a workspace, and photos if it is job-site imagery rather than paperwork you are after.