Sending Contracts with Fields
Sending Contracts with fields is very similar to the previous section Sending Contracts 101, except you'll be adding a new object to your Request!
Get Your Contract Fields
Before following along, be sure your Contract has fields and has been published! You may want to keep the contract open in another tab or grab the field names using GET https://api.pactsafe.com/v1.1/contracts/:id/versions/@published
, which you'll see a fields
array in the response body with that data you'll need.
In my example contract, I have the following fields array (some properties intentionally omitted) that we'll use to continue:
"fields": [
{
"type": "text",
"required": true,
"assignment_value": "signer",
"name": "first_name",
"label": "First Name",
"id": "5f5fd8096913350000a87073"
},
{
"type": "text",
"required": true,
"assignment_value": "signer",
"name": "last_name",
"label": "Last Name",
"id": "5f5fd81669133506cfa87074"
},
{
"type": "signature",
"required": true,
"assignment_value": "signer",
"name": "signature",
"label": "signature",
"id": "5f5fd81f6913350000a87075"
}
]
Create a Request
Now, when I create my request, I'm going to reference the fields within the contract and do a couple of new things that the Sending Contracts 101 did not have.
Using the Create a Request route and the following body:
{
"name": "My Request Name!",
"contracts": [100631],
"signers": [
{
"signer_id": "[email protected]",
"signer": {
"email": "[email protected]",
"mobile_number": "317-123-1234",
"additional_attributes": {
"first_name": "Test",
"last_name": "Test"
}
},
"send_to": {
"email": true,
"mobile_number": true
}
}
],
// New stuff here!
"fields": [
{
"name": "first_name",
"assigned_to": "[email protected]"
},
{
"name": "last_name",
"assigned_to": "[email protected]"
},
{
"name": "last_name",
"assigned_to": "[email protected]"
}
]
}
As you can see above, we are essentially overriding the Contract fields when the Request is being created with who (signer_id) we want to be assigned to which fields.
Send a Request
Now, you can send your Request using Send a Request to Signers.
Updated about 1 year ago