Adding documents to contracts

Use the API to securely upload contracts and attachments.

  1. Upload the cover document
  2. Delete document

1. Upload the cover document

Contracts can have any number of files attached to them. Typically they are documents in PDF or office formats, but you can add any type of file.

Let's upload a document. You can use this sample PDF file, or one of your own.

You can upload files with a multipart/form-data HTTP POST to the api/contracts/{contract_id}/add_file/ endpoint. Include the file in the blob field and the parent contract ID in the contract field:

import requests

ZEFORT_APIKEY = "ySLE1mhh6lfRsYa..."
CONTRACT_ID = "ct_1JrjJRTzEMlHVHls"
FILE = open('file/path/to/Sample_NDA.pdf','rb')

response = requests.post(
    f'https://sandbox.zefort.com/api/contracts/{CONTRACT_ID}/add_file/', 
    auth=(ZEFORT_APIKEY, ''),
    files={"blob": FILE}
)
print(response.json())
ZEFORT_APIKEY="ySLE1mhh6lfRsYa..."
CONTRACT_ID='ct_1JrjJRTzEMlHVHls'

curl -X POST "https://sandbox.zefort.com/api/contracts/$CONTRACT_ID/add_file/" \
     -u $ZEFORT_APIKEY: \
     -F "blob=@Sample_NDA.pdf" \

Response:

{
    "attributes": {
        "title": "Important contract1",
        "end_date": null,
        "effective_date": null,
        ...
    },
    "cover_document": {
        "id": "doc_1JRsUv1mFM31qmLxNY",
        "content_type": "application/pdf",
        "role": "contract",
        "status": "complete",
        "num_pages": 1,
        "filename": "Important pdf.pdf",
        "receive_time": "2022-12-28T13:00:18.085600Z",
        "taggings": [],
        "ordinal": 1,
        "text_available": true,
        "valid_signature": null,
        "is_signable": true,
        "signatures": []
    },
    "id": "ct_1JUWQqIG2xtvymgmFQ",
    "incomplete": false,
    "num_emails": 1,
    "num_files": 5,
    "num_users": 2,
    "owner": {
        ...
    },
    "parties": [],
    "permission": "full",
    "receive_time": "2022-12-28T13:00:16.266666Z",
    "related_contracts": [],
    "status": "review",
    "is_duplicate": false,
    "favorite_of": [],
    "last_modified": "2022-12-28T13:00:16.538337Z",
    "trashed": false,
    "esigns": [],
    "num_signed_documents": 0,
    "activities": [],
    "allow_emails": false,
    "documents": []
    ...
}

As a response, you'll get all the data of the corresponding contract. The first document uploaded to a contract will become its cover_document, and the subsequental documents will be shown in contract's documents.
Again, an ID has been allocated: doc_1JRsUv1mFM31qmLxNY. Note how Zefort objects IDs have a short prefix indicating the type of the object.

If you refresh the user interface, you'll see that the contract card is updated with a thumbnail view of our document.

A contract card with our sample NDA document as the cover document

Next steps

Now that you know how to attach documents to your contracts, it's time to update contract metadata.