Create a contract with data fields
Data fields are simply put contract variables. Using data fields, it is possible to send in any text data into a contract and use them in either text and image sections or product descriptions. You can set the data field values either on contract creation or by updating them later.
In the multiple integrations model, a playbook defines the available data fields and maps them to fields from connected integration blueprints. A template can be linked to one playbook and can store values for those fields. You can set values only for data fields available in the selected template.
Note
- Templates now link to a playbook which contains data fields. A playbook orchestrates how one or more integration blueprints work together for a contract workflow.
Step 1. Create a playbook with data fields
To create a playbook, you can follow the process shown below,
-
Go to the Oneflow application Admin > Playbooks tab, and add a playbook. After creating the playbook, you can add data fields to the new playbook.

-
You can now create a new playbook and add data fields to it.

-
Open Connected integrations and connect the integration blueprints required for your workflow.

-
Select how fields from each integration blueprint should be added.

-
After configuring a playbook, open the template you want to use and assign the playbook as shown below.

-
Confirm that the playbook data fields appear in the template.

Step 2. 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 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. |
template_id
|
The unique ID of the template you want to use for creating your contract. You can find the template ID using the templates endpoint. |
| Data fields | |
data_fields
|
The data_fields attribute is an array of data field objects. Each of these data field objects has two required attributes: custom_id and value.
|
custom_id
|
The unique name that was given to the data field when it was added to the integration blueprint. |
value
|
The value that will be displayed in the contract for the data field. |
Step 3. Run the code
Replace the values of the parameters in the following command with the actual data from your account:
curl --request POST \
--url https://api.oneflow.com/v1/contracts/create \
--header 'content-type: application/json' \
--header 'x-oneflow-api-token: API_TOKEN' \
--header 'x-oneflow-user-email: USER_EMAIL' \
--data '{"workspace_id": WORKSPACE_ID,"template_id": TEMPLATE_ID, "data_fields": [{"custom_id": "first_name", "value": "Bob"},{"custom_id": "last_name", "value": "Ross"}]}'import requests
headers = {
'content-type': 'application/json',
'x-oneflow-api-token': 'API_TOKEN',
'x-oneflow-user-email': 'USER_EMAIL',
}
data = {
"workspace_id": WORKSPACE_ID,
"template_id": TEMPLATE_ID,
"data_fields": [
{
"custom_id": "first_name",
"value": "Bob"
},
{
"custom_id": "last_name",
"value": "Ross"
}
]
}
response = requests.post('https://api.oneflow.com/v1/contracts/create',
headers=headers, json=data)
print(reponse.json())When setting data fields in the create contract request, you can expect the following behavior:
| Data field is in request | Data field is in template | Result |
|---|---|---|
| ✅ | ✅ | The request value replaces the value stored in the template and appears in the contract. |
| ✅ | ❌ | An error will occur, and the contract will not be created. |
| ❌ | ✅ | The value stored in the template remains unchanged in the contract. |
Expected response
This request will output details about the contract with the data fields you created in the JSON format. The output will be similar to the output of the Create contract request.
Please see the Data field section in the Data model category for more information about the output.
Response codes
| Status | Meaning | Description |
|---|---|---|
| 200 | OK | Returns the created contract. |
| 400 | Bad Request | Invalid format or content of the request. |
| 404 | Not Found | A required entity is missing. |
| 409 | Conflict | A conflict occurred with the current state of the target resource. |
Updated 1 day ago

