# File upload guide ## Multipart form data All file uploads using the LawVu API requires the use of `multipart/form-data` for uploading files. This allows you to send both file content and metadata in a single request. ## File upload resource types When uploading a new file, you need to provide details about what resource you want the file to be uploaded to either via the `resourceType` and `resourceId` form data parts, or from the route e.g. `/v2/matters/{matterId}/files` will inherently use `resourceType=Matter` and `resourceId={matterId}` The following table describes the different `resourceType` and `resourceId` values | `resourceType` | `resourceId` | | | --- | --- | --- | | Matter | {matterId} | Uploads the file to the matter with the ID {matterId} | | Contract | {contractId} | Uploads the file to the contract with the ID {contractId} | | ContractCreation | | Uploads the file to be passed for creating a contract | ### 1. Creating a file on a matter To create a new file on a matter with the ID 12345, the following request can be used: **Request:** ```http POST /v2/files Authorization: Bearer Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="example.pdf" Content-Type: application/pdf ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="resourceType" Matter ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="resourceId" 12345 ------WebKitFormBoundary7MA4YWxkTrZu0gW-- ``` ### 2. Creating a file on a contract To create a file on a contract with the ID 67890, use the following request: **Request:** ```http POST /v2/files Authorization: Bearer Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="example.pdf" Content-Type: application/pdf ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="resourceType" Contract ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="resourceId" 67890 ------WebKitFormBoundary7MA4YWxkTrZu0gW-- ``` ### 3. Creating a file for contract creation To upload a file to be used during contract creation, use the following request: **Request:** ```http POST /v2/files Authorization: Bearer Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="example.pdf" Content-Type: application/pdf ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="resourceType" ContractCreation ------WebKitFormBoundary7MA4YWxkTrZu0gW-- ``` ### 4. Uploading a file to an existing file To upload a new version of an existing file, use the following request: Replace `{fileId}` with the ID of the file you want to update. **Request:** ```http POST /v2/files/{fileId} Authorization: Bearer Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="example.pdf" Content-Type: application/pdf ------WebKitFormBoundary7MA4YWxkTrZu0gW-- ``` ### 5. Uploading a file to a folder To upload a new file to a folder on an existing Matter or Contract, use the following request: **Request:** ```http POST /v2/files Authorization: Bearer Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="example.pdf" Content-Type: application/pdf ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="resourceType" Contract ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="resourceId" 67890 ------WebKitFormBoundary7MA4YWxkTrZu0gW-- Content-Disposition: form-data; name="folder" 45890 ------WebKitFormBoundary7MA4YWxkTrZu0gW-- ``` For more details, refer to the [Files API documentation](https://api-docs.lawvu.com/new-api/lawvuapi.openapi/files).