Create a contract with a PDF

To support your legacy or third-party contract management workflow that relies on PDF documents for either all or parts of the contract content, Oneflow allows you to upload PDF documents to contracts.

You can choose whether the PDF should be displayed as an expanded document in the contract or an attachment that can be viewed on click. Please, see the Contract file data model for more information.

In this tutorial, you will learn how to create a contract out of an existing PDF document using the expanded_pdf file type.

Step 1. Save PDF file locally

To add a PDF document to a contract, you need a PDF file saved on your device.

Step 2. Create a contract

The contract must have only one PDF document section to be able to receive PDF documents via the Oneflow API.

To add a PDF document to your contract using the API, you must manually add the PDF document section to the contract template using the Oneflow application UI.

  1. In your contract template, click the + icon > PDF document.
  1. Now that the PDF document section is in place, click Save template.



Since there can be only one PDF section per contract, adding additional PDF documents to the PDF section will overwrite the current PDF document.

You can now add a PDF document to your contract.

Step 3. Obtain necessary information

Now you need to obtain information to upload your PDF document to the contract using our API. To run the script described in Step 4 of this tutorial, you’ll need the following data:

x-oneflow-api-token You will only be able to run the script by using a valid API token. You can create an API token in the Oneflow web application. Find more in the Authentication section.
x-oneflow-user-email Your Oneflow user account email.
Content-Type: Indicates the media type of the resource and must be set to multipart/form-data.
upload_as The file type of the file to be imported must be set to expanded_pdf.
file File path to the PDF document saved on your device. In the example below, we use /home/joe/Documents/my_contract_text.pdf.

Step 4. Run the code

Replace the values of the parameters in the following command with the actual data from your account and run it:

curl --request POST '' 
--header 'x-oneflow-api-token: API_TOKEN' 
--header 'x-oneflow-user-email: USER_EMAIL' 
--header 'Content-Type: multipart/form-data; boundary=----MyFormBoundary' 
--form 'upload_as="expanded_pdf"' 
--form '[email protected]"/home/joe/Documents/my_contract_text.pdf"'
import requests

data = {'upload_as': 'expanded_pdf'}
files = {'file': open('/path/to/file.pdf','rb')}

headers = {
  'x-oneflow-api-token': 'API_TOKEN',
  'x-oneflow-user-email': 'USER_EMAIL', 

response ='', 
                         data=data, files=files, headers=headers)


Please see the Contract file section in the Data model category for more information about the output.

Response codes






Returns an empty JSON object.


Bad Request

Invalid format or content of the request.


Not Found

A required entity is missing.



A conflict occurred with the current state of the target resource.



Repeating the request using the same contract ID with another file will replace the existing PDF.

File attachments

In Oneflow, you can also include files as attachments to the contract. You can add up to 30 files, each of which does not exceed 20 MB, for a total of 50 MB per contract.



Only PDF and TIFF files will be directly visible in the contract PDF. All attachments will always be part of the signed contract.

To add attachments to your contract using API, you must manually add an Attachments section to the contract template using the Oneflow application UI.

  1. In your contract template, click the + icon > Attachments.
  1. Now that the Attachment section is in place, click Save template.

You can now attach files to your contract.

Did this page help you?