You can create new parties via Zefort API simply by utilizing the post
request method.
Let's create new party called Company inc. and make it a permanent party, by setting it's
managed
value True
:
import requests
ZEFORT_APIKEY = 'ySLE1mhh6lfRsYa...'
payload = {
"name": "Company inc.",
"managed": True,
}
response = requests.post(
'https://sandbox.zefort.com/api/parties/',
auth=(ZEFORT_APIKEY,''),
json=payload)
print(response.json())
ZEFORT_APIKEY="ySLE1mhh6lfRsYa..."
curl -X POST "https://sandbox.zefort.com/api/parties/" \
-u $ZEFORT_APIKEY: \
-H "Content-Type: application/json" \
-d '{"name": "Company inc.", "managed": true}'
Response:
{
"id": "pty_1KcfIQry01dVhNt4tL",
"name": "Copany inc.",
"org_id": null,
"num_contracts": 0,
"managed": true,
"country": "",
"contact": "",
"group": "",
"t24_id": "",
"is_merging": false,
"previous_names": "",
"CUSTOM_soparo_type": "",
"CUSTOM_soparo_code": ""
}
Take a look at the Zefort API Reference for more information.
Here is an example of attaching a party to a contract. Contract id should be included in url and party id in payload json.
You will need to imply a role in the payload for the request to go through!
You can use undefined
, self
or counterparty
.
When using a custom role, you will need to insert role id.
import requests
import pprint
ZEFORT_APIKEY = 'ySLE1mhh6lfRsYa...'
CONTRACT_ID = 'ct_1KpVLzJ4MqtLMsBye8'
PARTY_ID = 'pty_1KcfIQry01dVhNt4tL'
payload = {
'party': PARTY_ID,
'role': "undefined"
}
response = requests.post(
f'https://sandbox.zefort.com/api/contracts/{CONTRACT_ID}/parties/',
auth=(ZEFORT_APIKEY,''),
json=payload)
print(response.json())
ZEFORT_APIKEY="ySLE1mhh6lfRsYa..."
CONTRACT_ID="ct_1KpVLzJ4MqtLMsBye8"
PARTY_ID="pty_1KcfIQry01dVhNt4tL"
curl -X POST "https://sandbox.zefort.com/api/contracts/$CONTRACT_ID/parties/" \
-u $ZEFORT_APIKEY: \
-H "Content-Type: application/json" \
-d '{"party": "'$PARTY_ID'", "role": "undefined"}'
Response:
{
"id": "pty_1KcfIQry01dVhNt4tL",
"name": "Copany inc.",
"org_id": null,
"role_id": "role_1KtVVIISXRAzixlW1I",
"role_name": "undefined",
"role": "undefined",
"editable": true,
"country": "",
"contact": "",
"group": "",
"t24_id": "",
"previous_names": "",
"CUSTOM_soparo_type": "",
"CUSTOM_soparo_code": ""
}