Attach files to contracts

Contracts in Torii have multiple contract fields, such as status, contract value, currency and others. Some of the fields are of type fileUpload which allows to attach files to the contract, the default field for uploading documents is named documents. Usually, the PDF of the signed contract is attached and any additional related files.

Step 1

Upload the file and get the unique idFile identifier, see the Uploading files guide to learn more.

Step 2

To create a new contract and attach one uploaded document, use the Create contract API and replace the ID_FILE placeholder with the value from the previous step.

curl --request POST \
     --url https://api.toriihq.com/v1.0/contracts \
     --header 'Authorization: Bearer API_KEY' \
     --header 'accept: */*' \
     --header 'content-type: application/json' \
     --data '
{
  "name": "My contract name",
  "idApp": 1,
  "status": "active",
  "documents": [
    {
      "idUpload": ID_FILE,
      "name": "myFile_final_final.pdf"
    }
  ]
}
'

You can follow the same body structure when updating a contract using the Update contract API:

curl --request PUT \
     --url https://api.toriihq.com/v1.0/contracts/ID_CONTRACT \
     --header 'Authorization: Bearer API_KEY' \
     --header 'accept: */*' \
     --header 'content-type: application/json' \
     --data '
{
  "documents": [
    {
      "idUpload": ID_FILE,
      "name": "myFile_final_final.pdf"
    }
  ]
}
'