Create a contract with an owner-side party
In Oneflow, contracts are created between a party that owns the contract, called the owner-side party and other counterparties.
Whether or not the party is the owner-side party is defined by the my_party
attribute. Any party that is not the owner-side party is a counterparty. Please, see more in the Party section.
Note:
The owner-side party should always be set to
company
and cannot beindividual
.
Inheriting contract creator role from template
Adding the creator_inherit_settings_from_template
attribute to the my_party
object will control if the creator of the contract should inherit the contract roles and permissions from the template settings.
Note:
- This will only apply if the creator participant is explicitly included in the participants list.
- If the creator is omitted from the participants list, then the roles and permissions are inherited from the template regardless of the value of this field.
Note:
When this setting is set to true (
"creator_inherit_settings_from_template": true
), then the role and permission (signatory
,organizer
, and thecontract:update
permission) fields of the creator participant are ignored.
This tutorial shows you how to create a new contract with an owner-side party using the REST API. You will also learn what data elements you’ll need for this and how to obtain them.
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 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. |
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. |
My party | |
my_party
|
The party that creates the contract - the owner-side (precisely one.) |
Participants | participants [array]
|
The owner-side party participant (at least one.) There can be maximum of 29 owner-side party participants. |
email
|
The email of the owner-side party contract participant. Note that the email must belong to an active user in your Oneflow account. |
Step 2. Run the code
Replace the values of the parameters in the following command with the actual data from your account and run it:
curl --location --request POST 'https://api.oneflow.com/v1/contracts/create' \
--header 'x-oneflow-api-token: API_TOKEN' \
--header 'x-oneflow-user-email: USER_EMAIL' \
--header 'Content-Type: application/json' \
--data-raw '{
"workspace_id": WORKSPACE_ID,
"template_id": TEMPLATE_ID,
"name": "Create with owner-side party",
"my_party":{
"country_code": "SE",
"creator_inherit_settings_from_template": false,
"identification_number": "1122334455",
"name": "Owner-side Company",
"participants":[
{
"_permissions": {
"contract:update": true
},
"email": "[email protected]",
"identification_number": "2233445566",
"name": "Sales Executive Person",
"organizer": false,
"phone_number": "+111222333444",
"signatory": true,
"title": "Sales Executive"
},
{
"_permissions": {
"contract:update": true
},
"email": "[email protected]",
"identification_number": "3344556677",
"name": "Junior Sales Person",
"organizer": false,
"phone_number": "+222333444555",
"signatory": true,
"title": "Junior Sales"
}
]
}
}'
import requests
payload = {
'workspace_id': WORKSPACE_ID,
'template_id': TEMPLATE_ID,
'name': 'Create with owner-side party',
'my_party': {
'country_code': 'SE',
'identification_number': '1122334455',
'name': 'Owner-side Company',
'participants': [
{
'_permissions': {'contract:update': True},
'email': '[email protected]',
'identification_number': '2233445566',
'name': 'Sales Executive Person',
'organizer': False,
'phone_number': '+111222333444',
'signatory': True,
'title': 'Sales Executive',
},
{
'_permissions': {'contract:update': True},
'email': '[email protected]',
'identification_number': '3344556677',
'name': 'Junior Sales Person',
'organizer': False,
'phone_number': '+222333444555',
'signatory': True,
'title': 'Junior Sales',
},
],
},
}
headers = {
'x-oneflow-api-token': 'API_TOKEN',
'x-oneflow-user-email': 'USER_EMAIL',
'Content-Type': 'application/json'
}
response = requests.post("https://api.oneflow.com/v1/contracts/create",
headers=headers, json=payload)
print(response.json())
When you create a contract using the template ID, Oneflow copies the template’s contents to the new contract. See the data model Contract for more information.
Expected response
This request will output details about the contract you created in the JSON format.
Please see the Party 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 almost 2 years ago