Let's add some contracts to a binder!
There is two ways to approach this operation in Zefort API:
So let's say we have a list of ids for contracts we want to bind to our binder. We can add it to our payload json and just like that, those contracts will be bound like nobody's business!
import requests
ZEFORT_APIKEY = 'ySLE1mhh6lfRsYa...'
BINDER_ID = 'bnd_1KkRayN40nouuVTujc'
CT_IDS = [
"ct_1KmjVahd4Hg6W7l18c",
"ct_1JXncwxR5skmpC4dDB"
]
response = requests.post(
f'https://sandbox.zefort.com/api/binders/{BINDER_ID}/contracts/',
auth=(ZEFORT_APIKEY, ''),
json={'contracts': CT_IDS})
print(response.json())
ZEFORT_APIKEY='ySLE1mhh6lfRsYa...'
BINDER_ID='bnd_1KkRayN40nouuVTujc'
CT_IDS='["ct_1Ka0utI1ZWqUwlljnA","ct_1KIdjQMAB9H3RvIuR3","ct_1Ki5qHWmY9KAuoGuSQ"]'
curl -X POST https://sandbox.zefort.com/api/binders/$BINDER_ID/contracts/ \
-u $ZEFORT_APIKEY: \
-H "Content-Type: application/json" \
-d '{"contracts": '$CT_IDS'}'
If you want to assign the list of contract ids to a variable, make sure to double quote the ids, and wrap the list
in single quotes!
Otherwise your parsed -d will look like this:
-d {"contracts": [ct_1Ka0utI1ZWqUwlljnA,ct_1KIdjQMAB9H3RvIuR3,ct_1Ki5qHWmY9KAuoGuSQ]}
While it should look like this:
-d {"contracts": ["ct_1Ka0utI1ZWqUwlljnA","ct_1KIdjQMAB9H3RvIuR3","ct_1Ki5qHWmY9KAuoGuSQ"]}
When you have hundreds of thousands of contracts, having to try and find the ids of all the contracts you want to bind would not be benefitical, so you can also use a search instead of id list.
In this example, the company has a few contracts named Searchable-named-contract-<number>
, and they
want to bind all of these to the same binder:
import requests
ZEFORT_APIKEY = 'ySLE1mhh6lfRsYa...'
BINDER_ID = 'bnd_1KkRayN40nouuVTujc'
response = requests.post(
f'https://sandbox.zefort.com/api/binders/{BINDER_ID}/contracts/',
auth=(ZEFORT_APIKEY,''),
json={
'search': {"q": "Searchable-named-contr"}
})
print(response.json())
ZEFORT_APIKEY="ySLE1mhh6lfRsYa..."
BINDER_ID="bnd_1KkRayN40nouuVTujc"
curl -X POST "https://sandbox.zefort.com/api/binders/$BINDER_ID/contracts/" \
-u $ZEFORT_APIKEY: \
-H "Content-Type: application/json" \
-d '{"search": {"q": "Searchable-named-contr"}}'
Using the search parameter q
means a string search, which tries to match your string to contracts' titles and text content.
You can find more information on Zefort API queries here.
Contract binding is a bulk operation. That means the request launches a task in Zefort API's back-end, and returns task information like this:
{
"id": "task_1K8WmjFq1eqaeawrUi",
"details": {"query_params": {},
"data": {"search":
{"q": "Searchable-named-contr"}}},
"backend_status": "pending",
"backend_status_info": "",
"frontend_status": "pending",
"description": "Contract Bulk operation"
}