Contract creation
Integration Toolkit > Contract creation
In this section, you'll learn how to create a basic contract using the Oneflow public API, as a start to use your simple integration. Follow the steps below to create a Oneflow contract via your app with the entities in your platform. Detailed instructions for CRM, ATS, and HR systems can be found in their respective sections.

Create a simple contract
As mentioned in the previous section, after getting the workspace and template details, you can use them in the contract creation.
Example:
A POST request to create a contract in the workspace with the ID 13001 using the template with the ID 17001, will look like here.
You may send separate GET requests to obtain the workspace and template IDs.
Your integration will use a specific setup method that has its own way of handling API tokens (i.e. Show Token/Automatic. For the x-oneflow-api-token
use the token you get from your integration according to its setup method. This token should already be stored in your integration's database after successful authentication.
FUNCTION CreateContractSimple
INPUT: user (includes API token and email), workspace ID, template ID
OUTPUT: JSON repsonse of created contract or error
BEGIN
SET email = "YOUR_USER_EMAIL" # Assuming you have user with email
SET token = "YOUR_API_TOKEN" # Assuming you have user with token
SET workspace_id = workspace ID
SET template_id = template ID
# ~ Begin the contract creation part ~
SET url = "https://api.oneflow.com/v1/contracts/create"
# Create the payload for the contract create request
SET payload = {
"workspace_id": workspace_id,
"template_id": template_id
}
# Add the necessary headers
SET headers = {
"x-oneflow-api-token": token,
"x-oneflow-user-email": email,
"Content-Type": "application/json",
"Accept": "application/json"
}
# Send the request to the contract create endpoint
TRY
SEND POST request to url
WITH headers = headers
WITH data = payload
RECEIVE response
RETURN response.json # Assuming successful execution
CATCH (Exception as error)
RETURN error.json # Return the error
END
Create a complex contract
Here we are trying to create a contract with additional data and attributes. Therefore, we can add participants, products, data fields, and tags for a complex contract with more attributes. However, the other core attributes of the contract will be the same as those of a simple contract creation.
FUNCTION CreateContractComplex
INPUT: user (includes API token and email), workspace ID, template ID, other data
OUTPUT: JSON repsonse of created contract or error
BEGIN
SET email = "YOUR_USER_EMAIL" # Assuming you have user with email
SET token = "YOUR_API_TOKEN" # Assuming you have user with token
SET workspace_id = workspace ID
SET template_id = template ID
# If you have participants/contacts or something similar in other data
SET my_party = participants that can be added as ownerside participants in Oneflow contract
SET parties = participants that can be added as counterparties in Oneflow contract
# If you have products/line items or something similar in other data
SET product_groups = product details that can be added as product tables in Oneflow contract
# We can also add data fields or/and tags if you have them in other data
SET data_fields = data fields or custom properties
SET tags = tags
# ~ Begin the contract creation part ~
SET url = "https://api.oneflow.com/v1/contracts/create"
# Create the payload for the contract create request
SET payload = {
"workspace_id": workspace_id,
"template_id": template_id,
"my_party": my_party,
"parties": parties,
"product_groups": product_groups,
"data_fields": data_fields,
"tags": tags
}
# Add the necessary headers
SET headers = {
"x-oneflow-api-token": token,
"x-oneflow-user-email": email,
"Content-Type": "application/json",
"Accept": "application/json"
}
# Send the request to the contract create endpoint
TRY
SEND POST request to url
WITH headers = headers
WITH data = payload
RECEIVE response
RETURN response.json # Assuming successful execution
CATCH (Exception as error)
RETURN error.json # Return the error
END
In the above contract creation, when you add participants to a party, you can map the details from your platform to Oneflow participant as follows.
Example: For a CRM system
Your platform attribute | Oneflow attribute |
---|---|
Company name | Party name |
Country/Region | Party country code |
Contact name | Participant name |
Contact email | Participant email |
Contact phone number | Participant email |
Note:
You can also add other entities to the contract. See API reference to learn more.
Updated about 1 month ago