Tags make it easier to sort and search contracts.
Let's make a new active tag for employment contracts:
import requests
ZEFORT_APIKEY = 'ySLE1mhh6lfRsYa...'
payload = {
"tag_name": "employment-contracts",
"active": True,
}
response = requests.post('https://sandbox.zefort.com/api/tags/',
auth=(ZEFORT_APIKEY,''),
json=payload)
print(response.json())
ZEFORT_APIKEY="ySLE1mhh6lfRsYa..."
curl -X POST https://sandbox.zefort.com/api/tags/ \
-u $ZEFORT_APIKEY: \
-H "Content-Type: application/json" \
-d '{"tag_name": "employment-contracts", "active": true}'
Response:
{
"id": "tag_1KYjSqmiPdCtXdtq5J",
"tag_name": "employment-contracts",
"active": true,
"num_contracts": 0
}
Next we are going to attach contracts to our new employment-contracts
tag. Our example company has
a few contracts titled Contract-to-tag-<number>
, and we would like to tag them all. If we happened to
know all the id's of the contracts we want to tag, we could use the list of them as a payload for our request
like this: json={'contracts': [ct_123, ct_124, ct_125 ...]}
.
Because we don't have the ids memorized, we'll use the search term q
to use a part of the contract title as a search parameter:
import requests
ZEFORT_APIKEY = 'ySLE1mhh6lfRsYa...'
TAG_ID = "tag_1KYjSqmiPdCtXdtq5J"
response = requests.post(f'https://sandbox.zefort.com/api/tags/{TAG_ID}/contracts/',
auth=(ZEFORT_APIKEY,''),
json={
'search':{
"q" : "Contract-to"
}
})
print(response.json())
ZEFORT_APIKEY="ySLE1mhh6lfRsYa..."
TAG_ID="tag_1KeePY6M9v6MGSEM9l"
curl -X POST "https://sandbox.zefort.com/api/tags/$TAG_ID/contracts/" \
-u $ZEFORT_APIKEY: \
-H "Content-Type: application/json" \
-d '{"search": {"q": "Contract-to"}}'
Contract tagging 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_1L3lqasNAeDDNb67kq",
"details": {"query_params": {}, "data": {"search": {"q": "Contract-to"}}},
"backend_status": "pending",
"backend_status_info": "",
"frontend_status": "pending",
"description": "Contract Bulk operation"
}
Let's say your co-worker, the company's summer intern, has already created a tag titled employment
and has been using it to tag a number of contracts.
Now there are contracts under two very similiar tags. What a terrible mistake!
Instead of falling into despair we will fix the situation by merging the similiar tags:
import requests
ZEFORT_APIKEY = 'ySLE1mhh6lfRsYa...'
payload = {
"tag_name": "contracts of service",
"merged": [
'tag_1KcllLPVkP9lIpCBMk',
'tag_1JpFsrWs8V7d6jc5Ye'
]
}
response = requests.post('https://sandbox.zefort.com/api/tags/merge/',
auth=(ZEFORT_APIKEY,''),
json=payload)
ZEFORT_APIKEY="ySLE1mhh6lfRsYa..."
TAG_IDS='["tag_1Ka0utI1ZWqUwlljnA","tag_1KIdjQMAB9H3RvIuR3"]'
curl -X POST "https://sandbox.zefort.com/api/tags/merge/" \
-u $ZEFORT_APIKEY: \
-H "Content-Type: application/json" \
-d '{"tag_name": "contracts of service", "merged": '$TAG_IDS'}'
Now all our employment contracts lay under the one and only contracts of service
tag.