Why REST for documents?
GraphQL operates with JSON payloads and doesn’t have built-in support for binary file data. For document operations, Pylon uses REST endpoints that:- Accept file uploads via
multipart/form-data - Handle large file transfers efficiently
Environments
Every endpoint on this page is available in both the sandbox and production environments. The only difference is the host:| Environment | Base URL |
|---|---|
| Sandbox | https://sandbox.pylon.mortgage |
| Production | https://pylon.mortgage |
BASE_URL constant so you only change it in one place:
Access tokens are environment-specific — a sandbox token will not authenticate against production, and vice versa. See the authentication guide for details.
Two ways to upload a document
Pylon has two distinct upload endpoints. Choosing the right one keeps documents correctly organized on the loan. Both are REST endpoints that acceptmultipart/form-data and are authorized with the create:document scope.
Task documents
The document satisfies a specific borrower task — a W-2 for income verification, a gift letter, a payoff demand. Upload it to the task endpoint, which attaches the file and marks the task complete.
General documents
The document belongs on the loan but doesn’t cleanly fit any task — supplemental correspondence, an ad-hoc statement, a miscellaneous file. Upload it as a general document attached directly to the loan.
Uploading documents for a task
When a document fulfills a specific task, upload it to that task’s document endpoint. The upload attaches the file to the task and completes the task in a single call — there is no separate “request an upload URL” step.| Parameter | Location | Description |
|---|---|---|
loanApplicationId | Path | The ID of the loan application the task belongs to. |
taskId | Path | The ID of the task being fulfilled. |
borrower-task-files | Body (multipart) | One or more files. Repeat the field to send multiple files. |
Your access token must be authorized for the loan application. Uploads to an application your client can’t access return
403.General documents that don’t fit a task
Not every document maps to a task. When you have a file that belongs on the loan but doesn’t correspond to any particular task, use the general upload endpoint below. Files uploaded this way are attached directly to the loan and filed as Uncategorized, with no task association.
The endpoint
General uploads go to a fixed loan endpoint, keyed by loan ID rather than a task:| Parameter | Location | Description |
|---|---|---|
loanId | Path | The ID of the loan to attach the documents to. |
document-files | Body (multipart) | One or more files. Repeat the field to send multiple files. |
Note the different multipart field name (
document-files) and that this endpoint takes a loan ID, whereas the task endpoint takes a loan application ID and a task ID. Your access token must be authorized for the loan.Uploading a general document
200 response with an empty body. To confirm the documents landed and retrieve download URLs, query the loan’s documents through GraphQL as shown in Downloading documents.
Downloading documents
Downloading goes through GraphQL to obtain a signed URL, regardless of how the document was uploaded.Query document metadata via GraphQL
Query the loan to get its documents, including a signed download URL for each.
Querying document metadata
Documents are exposed on theloan query:
documentLink.url field is a signed download URL. The uploadStatus is one of UPLOADING, COMPLETE, or FAILED.
Using download URLs
Signed download URLs expire after about an hour, so fetch them shortly after querying:Authentication
Both upload endpoints use the same OAuth Bearer token authentication as GraphQL requests, and require a token with thecreate:document scope:
File requirements
- Maximum upload size: 30 MB per request (across all files in the request).
- File types: There is no enforced file-type restriction, but you should upload standard document formats — PDFs, images (JPG, PNG), and Office documents.
Error handling
Best practices
- Pick the right upload path - Use the task endpoint for documents that fulfill a task; use the general endpoint only for files that don’t fit one. This keeps the loan’s documents organized.
- Stay under the size limit - Each request is capped at 30 MB across all files. Split large batches across multiple requests.
- Handle URL expiration - Download URLs expire after about an hour. Re-query document metadata to get fresh URLs if needed.
-
Check upload status - Verify
uploadStatusisCOMPLETEbefore attempting to download.
Related resources
- Tasks - The task catalog and the documents each task expects
- Authentication - Obtaining and managing access tokens
- Forming calls with GraphQL - GraphQL query and mutation basics