Smart-ID signing service allows your customers to fill in the blanks in document template and sign the document right after that.

Here are some examples: Demo ContractNDA

To get started go HERE and create your first contract template. Then just copy-paste piece of code (iFrame) to your webpage and that’s it.

Enhanced contract templates

It is also possible to personalize the contract before showing it to the customer and asking him to sign it. It is useful if you want to pre fill the contract with products or services that customer wants to buy. Pre filling fields can be done over API query https://id.smartid.ee/api/v2/prepare_external_contract.

This call must have client_id and secret values that you got when you registered your website with Smart ID. In addition there is GET parameter tag_values that is url encoded JSONobject that contains values of the tags defined in the original contract. Field values are remembered up to 24h, after this time passes the API call must be done again to get new code.

Example call is https://id.smartid.ee/api/v2/prepare_external_contract?client_id=j9..oE&secret=Wh..Ix&tag_values=%7B%22Firstname%22%3A%22Toomas%22%2C%22Lastname%22%3A%22Ilves%22%7D

Similarly it is possible to have editable default values. Instead of tag_values use tag_defaults urlencoded json

Returned value is also JSON object with status either “OK” or “error”. If status is “OK” then there is another field “code” which value is needed in next step where you redirect the customer to sign the contract page. If the status is “error” then it includes “message” which contains details of what exactly went wrong.

Final step is to customize the signing page iframe url parameters and add the code value from the first step. Example sign page url with some blanks prefilled by the API call is https://id.smartid.ee/sign_contract?client_id=j9FXBpH0SMfipcDoArwxbq8ipF7xqiex&contract_id=5&code=K3kCchQxer97IGX8W1NcCQ2OITHc0XCtcPP4wccy

Custom document signing

In some cases the document template still does not give you enough flexibility. In this case it is possible to prepare the file that will be signed yourself. This process contains 2 steps like enhanced contract templates.

Firstly document will be sent via HTTP POST with 3 mandatory URL parameters: client_id, secret and filename and one optional parameter signature_redirect. client_id and secret are taken from smartid admin and filename can be whatever you like it to be in the signed doc. signature_redirect will be location where user is redirected 5s after sining if value present. Call is sent to query to https://id.smartid.ee/api/v2/prepare_external_doc?client_id=j9FXBpH0SMfipcDoArwxbq8ipF7xqiex&secret=j9FXBpH0SMfipcDoArwxbq8ipF7xqiex&filename=my_doc_to_be_signed.pdf&signature_redirect=https%3A%2F%2Fexample.com%2Fcallback. Document content will be POST call body in base64 encoded format.

Response to above call is JSON. If successful then the status will be OK and doc_id value is string like {“status”:”OK”,”doc_id”:”rawaQxqrlYrsaGvslt7JFFCcMYztXHHwedFMPbze”} . If there is error then status is error with message like {“status”:”error”,”message”:”Missing filename for the document”} .

Second step is redirecting the customer to the signing page. Page can also be embedded in the iFrame for smoother experience. URL for the signing page needs to have 2 GET parameters: client_id and doc_id. Example of the signing page URL is this https://id.smartid.ee/sign_contract_external?client_id=j9FXBpH0SMfipcDoArwxbq8ipF7xqiex&doc_id=rawaQxqrlYrsaGvslt7JFFCcMYztXHHwedFMPbze

Optionally it is possible to download the signed document over API as well.

Use the previously received doc_id with client_id and secret to get the document after signing. API HTTP GET endpoint is https://id.smartid.ee/files/download_external_signed_doc?client_id=j9FXBpH0SMfipcDoArwxbq8ipF7xqiex&secret=j9FXBpH0SMfipcDoArwxbq8ipF7xqiex&doc_id=rawaQxqrlYrsaGvslt7JFFCcMYztXHHwedFMPbze

If the call is successful then signed_file_contents has base64 encoded format of bdoc container. Example response will be {“status”:”OK”,”signed_file_contents”:”UEsDBAo…..Ah8AAAAA”,”signer_id”:”38112086027″,”filename”:”my_doc_to_be_signed.pdf_MARGUS_PALA_20170904121905.bdoc”}