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:
Use the sandbox for development and testing, and switch the base URL to production when you go live. The examples below read the host from a
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.
See Tasks for how tasks are created and how to find the task IDs that need documents.
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: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.1
Query document metadata via GraphQL
Query the loan to get its documents, including a signed download URL for each.
2
Use the download URL
Fetch the file from the signed URL in the
documentLink.url field.3
Handle the file
Process the downloaded file and handle URL expiration if needed.
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:
Attributing an upload
By default an uploaded document is attributed to whoever the token represents — your integration, for a machine credential. To record a specific uploader instead, a machine credential can add thex-pylon-on-behalf-of header to either upload call:
cont_…) or a borrower id (borr_…); the uploader then appears on the document’s uploadedBy field. This is attribution only — it never changes what your token is allowed to do. See Acting on behalf of a user for the full rules and Contributors for the concept.
File requirements
- Maximum upload size: 50 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 50 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