Get data to create a contract

In many cases, when building an integration with Oneflow, hardcoding the workspace and template works just fine, as we already described in the tutorials for creating contracts.

However, mostly this solution is not optimal. For instance, it could hardly be possible to build a CRM integration with only one workspace and one template available. What if a CRM user doesn’t have access to that workspace? Or if the template is changed to no longer have the template type required by the integration?

To solve the problems mentioned above, Oneflow has created the contract_create_data helper endpoint. This endpoint will return all the workspaces and templates relevant for a specific user within a particular integration.

The endpoint returns:

  • All workspaces where the user has permission to create contracts with at least one template.
  • All active templates sorted by workspace and filtered (optional) by template type.

For more information about the template type extension, please see Building a partner system integration.

Step 1. Obtain necessary information

To run the script described in this tutorial, you’ll need the following data:

Headers
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 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.
Query parameters
extension_type Template type subtype used by partner system integration. See Building a partner system integration for details.
template_type_id The unique ID of a template type. You can find template type ID using the GET/templates endpoint.

Step 2. Run the code

Example request:

curl --request GET \
  --url https://api.oneflow.com/v1/helpers/contract_create_data \
  --header 'Accept: application/json' \
  --header 'x-oneflow-api-token: API_TOKEN' \
  --header 'x-oneflow-user-email: USER_EMAIL'
import requests

headers = {
    'Accept': "application/json",
    'x-oneflow-api-token': API_TOKEN,
    'x-oneflow-user-email': USER_EMAIL
    }

response = requests.get('https://api.oneflow.com/v1/helpers/contract_create_data', 
                        headers=headers)

print(response.json())

Expected response

The above call will result in output similar to the following:

[
  {
    "id": 121212,
    "name": "My workspace",
    "templates": [
      {
        "available_options": {
          "can_receive_attachments": true,
          "can_receive_expanded_pdf": false,
          "can_receive_products": true,
          "delivery_channels": [
            {
              "name": "email",
              "preferred": true,
              "required_participant_attributes": [
                "email"
              ]
            },
            {
              "name": "none",
              "preferred": false,
              "required_participant_attributes": []
            }
          ],
          "sign_methods": [
            {
              "name": "standard_esign",
              "preferred": true
            }
          ],
          "two_step_authentication_methods": [
            {
              "name": "email",
              "preferred": true,
              "required_participant_attributes": [
                "email"
              ]
            },
            {
              "name": "none",
              "preferred": false,
              "required_participant_attributes": []
            }
          ]
        },
        "created_time": "2020-05-04T12:00:20+00:00",
        "id": 1186806,
        "name": "Sales Template",
        "template_type": null,
        "updated_time": "2020-05-12T13:40:10+00:00"
      },
      {
        "available_options": {
          "can_receive_attachments": false,
          "can_receive_expanded_pdf": true,
          "can_receive_products": false,
          "delivery_channels": [
            {
              "name": "email",
              "preferred": true,
              "required_participant_attributes": [
                "email"
              ]
            },
            {
              "name": "none",
              "preferred": false,
              "required_participant_attributes": []
            }
          ],
          "sign_methods": [
            {
              "name": "standard_esign",
              "preferred": true
            }
          ],
          "two_step_authentication_methods": [
            {
              "name": "email",
              "preferred": false,
              "required_participant_attributes": [
                "email"
              ]
            },
            {
              "name": "none",
              "preferred": true,
              "required_participant_attributes": []
            }
          ]
        },
        "created_time": "2020-05-04T12:00:20+00:00",
        "id": 1186807,
        "name": "Sample Hubspot Template",
        "template_type": {
          "created_time": "2020-04-27T16:45:40+00:00",
          "description": "Hubspot data fields",
          "extension_type": "hubspot",
          "id": 1,
          "name": "Hubspot Template",
          "updated_time": "2020-06-07T07:30:00+00:00"
        },
        "updated_time": "2020-05-12T13:40:10+00:00"
      }
    ],
    "updated_time": "2020-06-11T13:44:42+00:00"
  }
]

Response codes

StatusMeaningDescription
200OKReturns the workspaces with embedded templates for creating a contract.
400Bad RequestInvalid format or content of the request.
403ForbiddenThe request is not authorized by the server.