# Creating contracts This guide explains how to create a new contract using the LawVu API. There are two main approaches: - **File Creation**: For all contract types, you must first upload a contract document and provide its ID when creating the contract. - **Wizard Creation**: For contract types which support a wizard (document template), you can create a contract without uploading a document. For more details on contract wizards, refer to the [Contract wizard help page](https://help.lawvu.com/en/articles/3378475-creating-a-new-contract-from-a-contract-wizard). ## Getting contract types Before creating a contract, you need to determine which contract type to use. You can retrieve a list of all available contract types for your organization using the `/v2/contractTypes` endpoint. **Request:** ```http GET /v2/contractTypes Authorization: Bearer ``` **Response:** ```json { "items": [ { "id": 1234, "name": "Contractor Agreement", "hasWizard": false, "teamAssignmentRequired": true, "parent": { "id": 5002, "name": "Employment" } }, { "id": 5678, "name": "NDA", "hasWizard": true, "teamAssignmentRequired": false, "parent": null } ] } ``` Use the `hasWizard` property to determine which creation method to use: - `hasWizard: false` - Use **File Creation** (upload document first) - `hasWizard: true` - Use **Wizard Creation** (no document required) or **File Creation** (upload document first) For more details, refer to the [Contract Types API documentation](https://api-docs.lawvu.com/new-api/lawvuapi.openapi/contracts/get-v2-contracttypes) and [Contract types and groups help page](https://help.lawvu.com/en/articles/2999834-contract-types-and-groups) ## Creating a contract with a file For contract types that do not support a wizard, you need to upload a contract document first. **Steps:** 1. Upload Contract Document For more details, refer to the [Files guide for Contract creation](https://api-docs.lawvu.com/docs/guides/files#3-creating-a-file-for-contract-creation) or the [Files API documentation](https://api-docs.lawvu.com/new-api/lawvuapi.openapi/files) Request: ```http POST /v2/files Authorization: Bearer Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="contract.pdf" Content-Type: application/pdf ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="targetResourceType" ContractCreation ------WebKitFormBoundary7MA4YWxkTrZu0gW-- ``` Response: ```json { "id": 9456 // The file ID } ``` 2. **Create Contract Using File** After uploading the document, use the selected Contract Type ID and the ID of the created file to create the contract: ```http POST /v2/contracts Authorization: Bearer Content-Type: application/json { "type": { "id": 1234 }, "name": "Service Agreement", "document": { "id": 9456 }, "fields": { "my_text_field": "my text value", "my_option_field": { "value": "option_1" } } } ``` Response: ```json { "id": 789 // The contract ID } ``` ## Wizard-based contract creation Some contract types have a wizard (document template), allowing you to create a contract without providing a document. **Steps:** 1. **Create contract using wizard** For contract types with `hasWizard: true`, use the following request to create a contract. The field values provided may be used by the wizard to populate the document: ```http POST /v2/contracts Authorization: Bearer Content-Type: application/json { "type": { "id": 5678 }, "name": "NDA", "fields": { "my_text_field": "my text value", "my_option_field": { "value": "option_1" } } } ``` Response: ```json { "id": 123 // The contract ID } ``` For more details, refer to the [Create Contract API documentation](https://api-docs.lawvu.com/new-api/lawvuapi.openapi/contracts/post-v2-contracts).