Contract import and AI extract

This tutorial shows you how to create a contract by importing, and use the AI extract feature on the imported contract using the Public API and the Oneflow application. You will also learn what data elements you'll need for this and how to obtain them.

📘

Note:

The contract import feature lets you import contracts with your own documents, and extract their details using the AI extract feature.

📘

Note:

When the contract is imported, the imported tag appears on the contract, and it will be in an imported draft state by default.

From the Oneflow application

Step 01

To use the import feature from the application, navigate to Documents and click Import as shown below:

Import button at documents section

Step 02

After selecting Import, you have two options:

  1. Manual import: Import your document as a oneflow contract, or use a template tagged import to create the oneflow contract.

  2. AI extract: Upload and import the document as a oneflow contract and the AI extract analyzes it and sets the contract data automatically.

From the Public API

Contract import

Step 01

To import a contract from Public API you will need the following data,

Headers
x-oneflow-api-token You will only be able to run the script by providing a valid API token. You can create an API token in the Oneflow web application. Find out more in the Authentication section.
x-oneflow-user-email Your Oneflow user account email. You can find all user-related information using the users endpoint.
Body
workspace_id The unique ID of the workspace where you want to create your contract. You can find the workspace ID using the workspaces endpoint.
playbook_id (optional) The unique ID of the playbook where you want to create your contract. You can find the playbook ID using the playbooks endpoint.

To use the contract import via the Public API, you can call the contract import endpoint. The imported contract is created directly in an imported draft state.

Step 02

Use the following cURL to import a contract using the contract import endpoint.

Example request body to import a contract:

curl --location 'https://api.oneflow.com/v1/contracts/import' \
--header 'Content-Type: application/json' \
--header 'x-oneflow-api-token: API_TOKEN' \
--header 'x-oneflow-user-email: USER_EMAIL' \
--data-raw '{
  "workspace_id": 130001,
  "folder_id": 380001,
  "name": "My First Contract",
  "playbook_id": 870001,
  "my_party": {
    "_private_ownerside": {
      "custom_id": "custom_id_party_1"
    },
    "country_code": "SE",
    "identification_number": "11223344-5566",
    "name": "Own Company AB",
    "participants": [
      {
        "_permissions": {
          "contract:update": true
        },
        "email": "[email protected]",
        "identification_number": "10034544-0066",
        "name": "First Last",
        "organizer": false,
        "phone_number": "+111222333444",
        "signatory": true,
        "sign_method": "standard_esign",
        "title": "Sales Manager",
        "type": "colleague"
      },
      {
        "_permissions": {
          "contract:update": true
        },
        "email": "[email protected]",
        "name": "First Former",
        "phone_number": "+111222333445",
        "signatory": true,
        "title": "Sales Manager",
        "type": "former_colleague"
      }
    ]
  },
  "parties": [
    {
      "_private_ownerside": {
        "custom_id": "custom_id_party_2"
      },
      "country_code": "SE",
      "identification_number": "11223344-5577",
      "name": "Company AB",
      "type": "company",
      "participants": [
        {
          "_permissions": {
            "contract:update": true
          },
          "_private_ownerside": {
            "custom_id": "custom_id_participant_1"
          },
          "delivery_channel": "none",
          "email": "[email protected]",
          "identification_number": "10034544-0077",
          "name": "Firstname Lastname",
          "phone_number": "+111222333555",
          "sign_method": "standard_esign",
          "signatory": true
        }
      ]
    },
    {
      "country_code": "SE",
      "type": "individual",
      "participant": {
        "_permissions": {
          "contract:update": true
        },
        "delivery_channel": "none",
        "email": "[email protected]",
        "identification_number": "10034544-0088",
        "name": "Firstname2 Lastname2",
        "phone_number": "+111222333666",
        "sign_method": "standard_esign",
        "signatory": true
      }
    }
  ]
}'
{
  "_integration_permissions": [],
  "_links": {
    "comments": {
      "href": "https://api.oneflow.com/v1/contracts/10001/comments"
    },
    "data_fields": {
      "href": "https://api.oneflow.com/v1/contracts/10001/data_fields"
    },
    "events": {
      "href": "https://api.oneflow.com/v1/contracts/10001/events"
    },
    "files": {
      "href": "https://api.oneflow.com/v1/contracts/10001/files"
    },
    "parties": {
      "href": "https://api.oneflow.com/v1/contracts/10001/parties"
    },
    "publish": {
      "href": "https://api.oneflow.com/v1/contracts/10001/publish"
    },
    "self": {
      "href": "https://api.oneflow.com/v1/contracts/10001"
    },
    "template": {
      "href": null
    },
    "template_type": {
      "href": null
    },
    "workspace": {
      "href": "https://api.oneflow.com/v1/workspaces/130001"
    }
  },
  "_permissions": {
    "contract:delete": true,
    "contract:download:pdf": true,
    "contract:send": true
  },
  "_private": {
    "date_format": "YYYY-MM-DD",
    "folder": {
      "id": 380001,
      "name": "Test Folder",
      "parent_id": null,
      "path": [
        380001
      ]
    },
    "language": "en",
    "name": "My First Contract",
    "signing_period_expiration": {
      "expire_days_after_publish": 14,
      "type": "days_after_publish"
    },
    "value": null,
    "workspace_id": 130001
  },
  "_private_ownerside": {
    "created_time": "2023-04-27T11:29:36+00:00",
    "template_id": null,
    "template_type_id": null
  },
  "attachment_file_groups": [],
  "available_options": {
    "can_receive_attachments": false,
    "can_receive_expanded_pdf": true,
    "can_receive_products": false,
    "delivery_channels": [
      {
        "name": "email",
        "preferred": false,
        "required_participant_attributes": [
          "email"
        ]
      },
      {
        "name": "none",
        "preferred": true,
        "required_participant_attributes": []
      },
      {
        "name": "same_device",
        "preferred": false,
        "required_participant_attributes": [
          "sign_method"
        ]
      },
      {
        "name": "sms",
        "preferred": false,
        "required_participant_attributes": [
          "phone_number"
        ]
      }
    ],
    "sign_methods": [
      {
        "name": "finnish_bankid",
        "preferred": false
      },
      {
        "name": "sms",
        "preferred": false
      },
      {
        "name": "standard_esign",
        "preferred": true
      },
      {
        "name": "swedish_bankid",
        "preferred": false
      }
    ],
    "two_step_authentication_methods": [
      {
        "name": "email",
        "preferred": false,
        "required_participant_attributes": [
          "email"
        ]
      },
      {
        "name": "none",
        "preferred": true,
        "required_participant_attributes": []
      },
      {
        "name": "sms",
        "preferred": false,
        "required_participant_attributes": [
          "phone_number"
        ]
      }
    ]
  },
  "data_fields": [],
  "draft_approval_workflow": null,
  "id": 10001,
  "imported": true,
  "lifecycle_settings": null,
  "lifecycle_state": null,
  "parties": [
    {
      "_private_ownerside": {
        "created_time": "2023-04-27T11:29:36+00:00",
        "custom_id": "custom_id_party_1",
        "updated_time": "2023-04-27T11:29:36+00:00"
      },
      "country_code": "SE",
      "id": 470001,
      "identification_number": "11223344-5566",
      "my_party": true,
      "name": "Own Company AB",
      "participants": [
        {
          "_permissions": {
            "contract:update": true
          },
          "_private_ownerside": {
            "created_time": "2023-04-27T11:29:36+00:00",
            "custom_id": null,
            "first_visited_time": "2023-04-27T11:29:36+00:00",
            "last_visited_time": "2023-04-27T11:29:36+00:00",
            "updated_time": "2023-04-27T11:29:36+00:00",
            "visits": 1
          },
          "delivery_channel": "email",
          "delivery_status": "success",
          "draft_approver": false,
          "email": "[email protected]",
          "id": 230001,
          "identification_number": "10034544-0066",
          "my_participant": true,
          "name": "First Last",
          "organizer": false,
          "pending_approver": false,
          "phone_number": "+111222333444",
          "sign_method": "standard_esign",
          "sign_state": "undecided",
          "sign_state_updated_time": null,
          "signatory": true,
          "title": "Sales Manager",
          "two_step_authentication_method": "none"
        },
        {
          "_permissions": {
            "contract:update": true
          },
          "_private_ownerside": {
            "created_time": "2023-04-27T11:29:36+00:00",
            "custom_id": null,
            "first_visited_time": null,
            "last_visited_time": null,
            "updated_time": "2023-04-27T11:29:36+00:00",
            "visits": 0
          },
          "delivery_channel": "none",
          "delivery_status": "success",
          "draft_approver": false,
          "email": "[email protected]",
          "id": 230001,
          "identification_number": "",
          "my_participant": false,
          "name": "First Former",
          "organizer": false,
          "pending_approver": false,
          "phone_number": "+111222333445",
          "sign_method": "standard_esign",
          "sign_state": "undecided",
          "sign_state_updated_time": null,
          "signatory": true,
          "title": "Sales Manager",
          "two_step_authentication_method": "none"
        }
      ],
      "type": "company"
    },
    {
      "_private_ownerside": {
        "created_time": "2023-04-27T11:29:36+00:00",
        "custom_id": "custom_id_party_2",
        "updated_time": "2023-04-27T11:29:36+00:00"
      },
      "country_code": "SE",
      "id": 470002,
      "identification_number": "11223344-5577",
      "my_party": false,
      "name": "Company AB",
      "participants": [
        {
          "_permissions": {
            "contract:update": true
          },
          "_private_ownerside": {
            "created_time": "2023-04-27T11:29:36+00:00",
            "custom_id": "custom_id_participant_1",
            "first_visited_time": null,
            "last_visited_time": null,
            "updated_time": "2023-04-27T11:29:36+00:00",
            "visits": 0
          },
          "delivery_channel": "none",
          "delivery_status": "success",
          "draft_approver": false,
          "email": "[email protected]",
          "id": 230002,
          "identification_number": "10034544-0077",
          "my_participant": false,
          "name": "Firstname Lastname",
          "organizer": false,
          "pending_approver": false,
          "phone_number": "+111222333555",
          "sign_method": "standard_esign",
          "sign_state": "undecided",
          "sign_state_updated_time": null,
          "signatory": true,
          "title": "",
          "two_step_authentication_method": "none"
        }
      ],
      "type": "company"
    },
    {
      "_private_ownerside": {
        "created_time": "2023-04-27T11:29:36+00:00",
        "custom_id": null,
        "updated_time": "2023-04-27T11:29:36+00:00"
      },
      "country_code": "SE",
      "id": 470003,
      "identification_number": "10034544-0088",
      "my_party": false,
      "name": "Firstname2 Lastname2",
      "participant": {
        "_permissions": {
          "contract:update": true
        },
        "_private_ownerside": {
          "created_time": "2023-04-27T11:29:36+00:00",
          "custom_id": null,
          "first_visited_time": null,
          "last_visited_time": null,
          "updated_time": "2023-04-27T11:29:36+00:00",
          "visits": 0
        },
        "delivery_channel": "none",
        "delivery_status": "success",
        "draft_approver": false,
        "email": "[email protected]",
        "id": 230003,
        "identification_number": "10034544-0088",
        "my_participant": false,
        "name": "Firstname2 Lastname2",
        "organizer": false,
        "pending_approver": false,
        "phone_number": "+111222333666",
        "sign_method": "standard_esign",
        "sign_state": "undecided",
        "sign_state_updated_time": null,
        "signatory": true,
        "title": "",
        "two_step_authentication_method": "none"
      },
      "type": "individual"
    }
  ],
  "pdf_file_groups": [
    {
      "_private_ownerside": {
        "created_time": "2023-04-27T11:29:36+00:00",
        "updated_time": "2023-04-27T11:29:36+00:00"
      },
      "files": [],
      "id": 920002,
      "type": "pdf"
    }
  ],
  "product_groups": [],
  "published_time": null,
  "sign_order": [],
  "signing_period_expiry_time": null,
  "state": "draft",
  "state_updated_time": "2023-04-27T11:29:36+00:00",
  "tags": [
    {
      "id": 1,
      "name": "__system_import"
    }
  ],
  "updated_time": "2023-04-27T11:29:36+00:00"
}
📘

Note:

You have to use the contract file upload endpoint to upload a document with expanded_pdf option before the AI extract.

📘

Note:

You can send the playbook_id, so they will belong to a specific playbook which is connected to a specific integration blueprint.

AI extract

After importing the contract with an expanded document, you can use AI extract on the imported contract to extract the document content into structured, actionable data. AI extract identifies and extracts the key information in the contract. You can review the results and adjust them as needed.

Step 03

The following data elements are needed to use AI extract via the Public API:

Headers
x-oneflow-api-token You will only be able to run the script by providing a valid API token. You can create an API token in the Oneflow web application. Find out more in the Authentication section.
x-oneflow-user-email Your Oneflow user account email. You can find all user-related information using the users endpoint.
Parameters
contract_id The unique ID of the imported contract where you want to extract the data from.

AI extract assigns the necessary details of the contract as shown below.

Before the AI Extract


After the AI Extract

As shown in the images above, the details available in the document were analyzed and sorted into structured, actionable data. You can review and update these fields accordingly.

Step 04

The imported document will be available in the documents section as shown below,

Imported contracts in a workspace

📘

Note:

The AI extract feature can extract important information of the contract such as contract duration, contract parties and participants, contract values etc.


Did this page help you?