Skip to content

Instantly share code, notes, and snippets.

@cw6365
Last active April 11, 2024 14:38
Show Gist options
  • Save cw6365/3cf8dbb446a3a886f7a11785f8ba5df8 to your computer and use it in GitHub Desktop.
Save cw6365/3cf8dbb446a3a886f7a11785f8ba5df8 to your computer and use it in GitHub Desktop.
When a user chooses a document to sign.. the document gets uploaded to E-Sign and we use the id in the response to create the E-Sign redirect url
curl -X 'POST' \
'https://sandbox.e-sign.co.uk/v3/uploads' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6InJRY0swLVNXUkFjUHFfSVAyV05kWlpVU0xzbklvdyIsImF1dGhfdG9rZW4iOiJQdnJzTmp6YlNoRWFtcVU0TUpveSIsInN1YiI6Ijc0MCIsInNjcCI6InVzZXIiLCJhdWQiOm51bGwsImlhdCI6MTcxMjg0NTY4MiwiZXhwIjoxNzE1MDA1NjgyLCJqdGkiOiI4NzRkN2ZkNS1hOTExLTQ0ZDAtOTBlNy1jNjA1NjQ4ZTE5YjYifQ.9O5afb3u9TNn3qa6RCPDEoaGIQ2QBhR1Ww2dFLNl9Hc' \
-H 'Content-Type: application/json' \
-d '{
"uploads": [
{
"title": "Test Contract",
"base64": "JVBERi0xLjMNCiXi48/TDQoNCjEgMCBvYmoNCjw8DQovVHlwZSAvQ2F0YWxvZw0KL091dGxpbmVzIDIgMCBSDQovUGFnZXMgMyAwIFINCj4+DQplbmRvYmoNCg0KMiAwIG9iag0KPDwNCi9UeXBlIC9PdXRsaW5lcw0KL0NvdW50IDANCj4+DQplbmRvYmoNCg0KMyAwIG9iag0KPDwNCi9UeXBlIC9QYWdlcw0KL0NvdW50IDINCi9LaWRzIFsgNCAwIFIgNiAwIFIgXSANCj4+DQplbmRvYmoNCg0KNCAwIG9iag0KPDwNCi9UeXBlIC9QYWdlDQovUGFyZW50IDMgMCBSDQovUmVzb3VyY2VzIDw8DQovRm9udCA8PA0KL0YxIDkgMCBSIA0KPj4NCi9Qcm9jU2V0I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bnMpDQovQ3JlYXRpb25EYXRlIChEOjIwMDYwMzAxMDcyODI2KQ0KPj4NCmVuZG9iag0KDQp4cmVmDQowIDExDQowMDAwMDAwMDAwIDY1NTM1IGYNCjAwMDAwMDAwMTkgMDAwMDAgbg0KMDAwMDAwMDA5MyAwMDAwMCBuDQowMDAwMDAwMTQ3IDAwMDAwIG4NCjAwMDAwMDAyMjIgMDAwMDAgbg0KMDAwMDAwMDM5MCAwMDAwMCBuDQowMDAwMDAxNTIyIDAwMDAwIG4NCjAwMDAwMDE2OTAgMDAwMDAgbg0KMDAwMDAwMjQyMyAwMDAwMCBuDQowMDAwMDAyNDU2IDAwMDAwIG4NCjAwMDAwMDI1NzQgMDAwMDAgbg0KDQp0cmFpbGVyDQo8PA0KL1NpemUgMTENCi9Sb290IDEgMCBSDQovSW5mbyAxMCAwIFINCj4+DQoNCnN0YXJ0eHJlZg0KMjcxNA0KJSVFT0YNCg==",
"extension": "pdf",
"type": "document"
}
]
}'
RESPONSE
{
"uploads": [
{
"id": "aef7c2c8-fbfe-4034-9c98-55d915475649", <<--- user this ID
"title": "Test Contract",
"processing": true,
"type": "document"
}
],
"links": []
}
CREATE AND REDIRECT
curl -X 'POST' \
'https://sandbox.e-sign.co.uk/v3/envelopes/redirect' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6InJRY0swLVNXUkFjUHFfSVAyV05kWlpVU0xzbklvdyIsImF1dGhfdG9rZW4iOiJQdnJzTmp6YlNoRWFtcVU0TUpveSIsInN1YiI6Ijc0MCIsInNjcCI6InVzZXIiLCJhdWQiOm51bGwsImlhdCI6MTcxMjg0NTY4MiwiZXhwIjoxNzE1MDA1NjgyLCJqdGkiOiI4NzRkN2ZkNS1hOTExLTQ0ZDAtOTBlNy1jNjA1NjQ4ZTE5YjYifQ.9O5afb3u9TNn3qa6RCPDEoaGIQ2QBhR1Ww2dFLNl9Hc' \
-H 'Content-Type: application/json' \
-d '{
"envelope": {
"title": "Contract Signing Pack",
"subject": "you have a envelope to sign",
"description": "please sign the documents",
"language": "english",
"documents": [
{
"title": "Test Contract",
"upload_file": {
"id": "aef7c2c8-fbfe-4034-9c98-55d915475649"
}
}
],
"signers": [
{
"name": "John Doe",
"email": "[email protected]"
}
],
"tags": [
{
"name": "sharepoint"
}
],
"redirect_uri": "https://example.com/redirect_back_to_my_site"
}
}'
RESPONSE
{
"redirect_uri": "https://xyz.e-sign.co.uk/#/envelopes?data=%7B%22redirect_uri%22%3A%22https%3A%2F%2Fexample.com%2Fredirect_back_to_my_site%22%2C%22title%22%3A%22Contract+Signing+Pack%22%2C%22subject%22%3A%22you+have+a+envelope+to+sign%22%2C%22description%22%3A%22please+sign+the+documents%22%2C%22language%22%3A%22english%22%2C%22documents%22%3A%5B%7B%22title%22%3A%22Test+Contract%22%2C%22upload_file%22%3A%7B%22id%22%3A%22aef7c2c8-fbfe-4034-9c98-55d915475649%22%7D%7D%5D%2C%22signers%22%3A%5B%7B%22name%22%3A%22John+Doe%22%2C%22email%22%3A%22user%40example.com%22%7D%5D%7D&j=eyJhbGciOiJIUzI1NiJ9.eyJpZCI6InJRY0swLVNXUkFjUHFfSVAyV05kWlpVU0xzbklvdyIsImF1dGhfdG9rZW4iOiJQdnJzTmp6YlNoRWFtcVU0TUpveSIsInN1YiI6Ijc0MCIsInNjcCI6InVzZXIiLCJhdWQiOm51bGwsImlhdCI6MTcxMjg0NjIxOSwiZXhwIjoxNzE1MDA2MjE5LCJqdGkiOiJjOTZlZjk1YS1iNjg1LTRjNjItOGMyMC1kMjdhNjNmN2Y1OTYifQ.JNxoUPyBebItc_zNXPhGhE_-UPtFNkl9-2O6Pectxn4"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment