Sending Contracts with Tokens (Render Data)
Part of the true power of using PactSafe is the ability to populate contracts with data dynamically before creating and sending. This is done through the use of "Tokens", which is a type of field that is specific to being populated with data by the sender.
Creating and Finding Your Tokens
We have more guides on the actual creation of tokens in our Help Center but the image below depicts in example Contract I have created with two tokens:
In the UI, I can see that my two tokens to be used will be first_token
and second_token
. I could also retrieve these via the API with a GET on https://api.pactsafe.com/v1.1/contracts/:id/versions/@published?expand=tokens
, which will contain a tokens
array with the tokens and the name
.
Now that I have the tokens, I can move on to creating a Request:
Create a Request
Now, when creating a request, I just use the render_data
property to can an object where the key is the token name and the value is the data I want in the contract.
{
"name": "My Request Name!",
"contracts": [100968],
"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!
"render_data": {
"first_token": "Hey, I'm a Dynamic Value!",
"second_token": "Dynamic contracts are fun!"
}
}
Send a Request (see it also populated)
As shown previously, you'll send using Send a Request to Signers and then the recipient will see the Request populated with the render_data
you provided!
Updated about 1 year ago