Skip to content

Sign the Contract or Mandate ​

Find this scenario in our Bruno collection

Save time in your implementation by observing the sequence of calls and retrieving requests directly from Bruno.

Display the Contract to the User ​

If the sold product is associated with a contract model (product.contractModel is set), a contract is automatically generated with the sale and must be signed.

To visually display the contract to the client, simply perform a GET /:clientToken/sales/:saleId/contract, which will return the raw PDF content to display.

curl --location 'https://.../demoapi/sales/12345/contract' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJOdDmWEJwl2Zqc' \
--header 'x-user-club-id: /onfit/clubs/2325' \
--header 'x-user-network-node-id: /onfit/network_nodes/2229' \
--header 'x-gravitee-api-key: xxx-yyy-zzz'

Note

You receive the raw PDF content, so you need to create an endpoint that serves this content with the correct HTTP headers.

Initiate the Signature Process via SMS ​

The electronic signature process involves sending an SMS to the contact. This SMS contains a code they must use to validate the signature in the next step.

This process is the same for contracts and mandates:

  • If you have only a contract, provide the saleId (/:clientToken/sales/:id) as targetId
  • If you have only a mandate, provide the mandateId (/:clientToken/mandate/:id) as targetId
  • If you have both a contract and a mandate to sign, you can sign both in a single call by providing both IDs in a targetIds array

POST /{clientToken}/signature_requests ​

parameterdescriptionexample
contactIdContact ID in IRI format/{clientToken}/contacts/1
targetIdID of the mandate to sign in IRI format/{clientToken}/mandates/373969
targetIdsArray of IDs (in IRI format) of items to sign/{clientToken}/mandates/373969

Example ​

POST /{clientToken}/signature_requests

Body

json5
{
    "contactId": "/{clientToken}/contacts/1",
    // "targetId": "/{clientToken}/mandates/373969"
    "targetIds": [
        "/{clientToken}/mandates/373969",
        "/{clientToken}/sales/936973"
    ]
}

Response 201 Created

json5
{  
   "@context":"\/clientToken\/contexts\/SignatureRequest",
   "@id":"\/clientToken\/signature_requests\/3451",         // <-- signature process ID
   "@type":"SignatureRequest",
  // ...
}

Complete the Signature Process ​

Once the SMS is received, the application orchestrating the signature must collect the code from the targeted contact and complete the signature process by validating this code.

POST ​

/{clientToken}/signature_requests/{signatureRequestId}/transitions

parameterdescriptionexample
signatureRequestIdID of the previously created signature process3451
transitionType of transition. Possible values are validate or cancelvalidate
codeValidation code received via SMS1234

Example ​

POST /{clientToken}/signature_requests/3451/transitions

Body

json5
{
    "transition": "validate",
    "code": "94852"
}

Response 201 Created