Skip to main content

I would like to download the signed document after all the signers have completed the signatures. In trying to do so, I am trying to call download API by providing the file id:

https://{{api.box.com}}/2.0/files/{file_id}/content

After checking the status of sign request, which is “signed”, I am trying to download the document. However, it is still resulting in the document which is not signed/without signatures.

Can you please help me understand, how to get the signed document through API.

Thanks in advance.

Regards

Venky

Hi @venky929 😊 Welcome back to our community!

To retrieve a signed document using the Box Sign API, you can make a GET request to the specific endpoint that corresponds to the signed document. Make sure to include any necessary authentication credentials and parameters required by the API.

You may refer to the guide below:

  1. When you create a signing request, you will receive a response that includes the document_id of the signed document which you need to obtain.
  2. Please ensure that the signing process is complete. You can check the status of the signing workflow using the API endpoint:
    GET /sign_requests/{sign_request_id}
    This will return the current status of the signing request, including whether it has been completed.
  3. Once the document is signed, you can retrieve it using the following API endpoint:

    GET /documents/{document_id}
    Replace {document_id} with the actual ID of the signed document. This request will return the signed document.

  4. Check the response to ensure the document is returned in the correct format.
     

Here’s an example of how to retrieve a signed document:

GET https://api.box.com/2.0/documents/{document_id}

Authorization: Bearer YOUR_ACCESS_TOKEN


Let me know how it goes! 🤗​​​​​​


Hi @JeyBueno Box,

Thanks for the detailed response. Appreciate it.

when you say document id, i believe you are talking about the id under sign_files ->files node from the sign request response.

Attaching the response for reference. Can you please confirm if I am using the right id for fetching.

{
    "is_document_preparation_needed": false,
    "redirect_url": null,
    "declined_redirect_url": null,
    "are_text_signatures_enabled": true,
    "signature_color": null,
    "is_phone_verification_required_to_view": false,
    "email_subject": "Sign Request for MSA",
    "email_message": "Hello! Please sign the document below",
    "are_reminders_enabled": false,
    "signers":
        {
            "email": "demo@microsoft.com",
            "role": "final_copy_reader",
            "is_in_person": false,
            "order": 0,
            "verification_phone_number": null,
            "embed_url_external_user_id": null,
            "redirect_url": null,
            "declined_redirect_url": null,
            "login_required": false,
            "has_viewed_document": false,
            "signer_decision": null,
            "signer_group_id": null,
            "inputs": n],
            "embed_url": null,
            "iframeable_embed_url": null,
            "suppress_notifications": false
        },
        {
            "email": "demo@outlook.com",
            "role": "signer",
            "is_in_person": false,
            "order": 1,
            "verification_phone_number": null,
            "embed_url_external_user_id": null,
            "redirect_url": null,
            "declined_redirect_url": null,
            "login_required": false,
            "has_viewed_document": false,
            "signer_decision": null,
            "signer_group_id": null,
            "inputs": l],
            "embed_url": null,
            "iframeable_embed_url": null,
            "suppress_notifications": false
        },
        {
            "email": "demo@gmail.com",
            "role": "signer",
            "is_in_person": false,
            "order": 2,
            "verification_phone_number": null,
            "embed_url_external_user_id": null,
            "redirect_url": null,
            "declined_redirect_url": null,
            "login_required": false,
            "has_viewed_document": false,
            "signer_decision": null,
            "signer_group_id": null,
            "inputs": ],
            "embed_url": null,
            "iframeable_embed_url": null,
            "suppress_notifications": false
        }
    ],
    "id": "97270a79-07ad-4b1e-b7cc-a0c81d7ab22a",
    "prefill_tags": ],
    "days_valid": 0,
    "prepare_url": null,
    "source_files": ],
    "parent_folder": {
        "id": "284989499339",
        "etag": "0",
        "type": "folder",
        "sequence_id": "0",
        "name": "My Sign Requests"
    },
    "name": "MSA",
    "external_id": null,
    "type": "sign-request",
    "signing_log": null,
    "status": "created",
    "sign_files": {
        "files":
/
            {
                "id": "1651282432483",
                "etag": "0",
                "type": "file",
                "sequence_id": "0",
                "name": "MSA_Automation 2024-09-19 11:20:38.168772.pdf",
                "sha1": "19ed84fd3dc94eabb35a44237c7d022a8d743194",
                "file_version": {
                    "id": "1816342475683",
                    "type": "file_version",
                    "sha1": "19ed84fd3dc94eabb35a44237c7d022a8d743194"
                }
            }
        ],
        "is_ready_for_download": true
    },
    "auto_expire_at": null,
    "template_id": "72dcee4b-b13e-4e0e-beac-dcwt102ab6f60",
    "external_system_name": null
}

I tried that in /document/{documentid} but it errored out with 404 Not found.

However, when i tried the /files/{file_id}/content, I am able to see the document but it is not signed.

Regards

Venky
 


Hi @venky929

Thanks for your question. While creating a sining request, a copy of the original file is created. It’s available in the destination folder (the field is called a “parent folder” in the request). You correctly identified the signed document with the “sign_files.files.id” from the API response. Additionally, you correctly retrieve the content with the download request. https://{{api.box.com}}/2.0/files/{file_id}/content. 

Would you mind sharing how do you check if the file has been signed? Are you using a webhook? 

Thank you!


Hi @ostefaniuk Box,

I was using an API itself by passing the id (from create sign response) as parameter.

https://{{api.box.com}}/2.0/sign_requests/{sign_request_id}

From the response below, I am checking the status field to confirm if it is signed or not.

If status=”signed”, I was considering that as sign completed. It(status field) is just above the sign_files node in the response.

Below is the response for reference:


{
    "is_document_preparation_needed": false,
    "redirect_url": null,
    "declined_redirect_url": null,
    "are_text_signatures_enabled": true,
    "signature_color": null,
    "is_phone_verification_required_to_view": false,
    "email_subject": "Sign Request for MSA",
    "email_message": "Hello! Please sign the document below",
    "are_reminders_enabled": false,
    "signers": ,
        {
            "email": "demo@gmail.com",
            "role": "final_copy_reader",
            "is_in_person": false,
            "order": 0,
            "verification_phone_number": null,
            "embed_url_external_user_id": null,
            "redirect_url": null,
            "declined_redirect_url": null,
            "login_required": false,
            "has_viewed_document": false,
            "signer_decision": null,
            "signer_group_id": null,
            "inputs": "],
            "embed_url": null,
            "iframeable_embed_url": null,
            "suppress_notifications": false
        },
        {
            "email": "demo@gmail.com",
            "role": "signer",
            "is_in_person": false,
            "order": 1,
            "verification_phone_number": null,
            "embed_url_external_user_id": null,
            "redirect_url": null,
            "declined_redirect_url": null,
            "login_required": false,
            "has_viewed_document": true,
            "signer_decision": {
                "type": "signed",
                "finalized_at": "2024-09-19T11:22:26.359Z",
                "additional_info": null
            },
            "signer_group_id": null,
            "inputs": g
                {
                    "document_tag_id": null,
                    "text_value": "Venky",
                    "checkbox_value": null,
                    "date_value": null,
                    "type": "signature",
                    "content_type": "signature",
                    "page_index": 5,
                    "read_only": false
                },
                {
                    "document_tag_id": null,
                    "text_value": "Sep 19, 2024",
                    "checkbox_value": null,
                    "date_value": "2024-09-19",
                    "type": "date",
                    "content_type": "date",
                    "page_index": 5,
                    "read_only": false
                }
            ],
            "embed_url": null,
            "iframeable_embed_url": null,
            "suppress_notifications": false
        },
        {
            "email": "demo@gmail.com",
            "role": "signer",
            "is_in_person": false,
            "order": 2,
            "verification_phone_number": null,
            "embed_url_external_user_id": null,
            "redirect_url": null,
            "declined_redirect_url": null,
            "login_required": false,
            "has_viewed_document": true,
            "signer_decision": {
                "type": "signed",
                "finalized_at": "2024-09-19T11:23:46.808Z",
                "additional_info": null
            },
            "signer_group_id": null,
            "inputs":
                {
                    "document_tag_id": null,
                    "text_value": "Venkatesh Y",
                    "checkbox_value": null,
                    "date_value": null,
                    "type": "signature",
                    "content_type": "signature",
                    "page_index": 5,
                    "read_only": false
                },
                {
                    "document_tag_id": null,
                    "text_value": "Sep 19, 2024",
                    "checkbox_value": null,
                    "date_value": "2024-09-19",
                    "type": "date",
                    "content_type": "date",
                    "page_index": 5,
                    "read_only": false
                }
            ],
            "embed_url": null,
            "iframeable_embed_url": null,
            "suppress_notifications": false
        }
    ],
    "id": "97270a79-07ad-4b1e-b7cc-a0c81d7ab22a",
    "prefill_tags": ],
    "days_valid": 0,
    "prepare_url": null,
    "source_files": ],
    "parent_folder": {
        "id": "284989499339",
        "etag": "0",
        "type": "folder",
        "sequence_id": "0",
        "name": "My Sign Requests"
    },
    "name": "MSA",
    "external_id": null,
    "type": "sign-request",
    "signing_log": {
        "id": "1651284042593",
        "etag": "1",
        "type": "file",
        "sequence_id": "1",
        "name": "MSA Signing Log.pdf",
        "sha1": "b23c25dc128e6281888d24b570582556301c621e",
        "file_version": {
            "id": "1816347988583",
            "type": "file_version",
            "sha1": "b23c25dc128e6281888d24b570582556301c621e"
        }
    },
    "status": "signed",
    "sign_files": {
        "files": "
            {
                "id": "1651282432483",
                "etag": "2",
                "type": "file",
                "sequence_id": "2",
                "name": "MSA_Automation 2024-09-19 11:20:38.168772.pdf",
                "sha1": "fb153d3be67bdad055d5e9dc2b1f21e1c15671c4",
                "file_version": {
                    "id": "1816342475683",
                    "type": "file_version",
                    "sha1": "19ed84fd3dc94eabb35a44237c7d022a8d743194"
                }
            }
        ],
        "is_ready_for_download": true
    },
    "auto_expire_at": null,
    "template_id": "72dcee4b-b13e-4e0e-beac-dcc102ab6f60",
    "external_system_name": null
}

Regards

Venky


Hi @venky929,

Thanks for the details, I was able to reproduce this behavior. Could please you try to retrieve the data from GET /sign_requests/{sign_request_id}  and pass the file ID from that response, opposed to the data from the create sign response? I noticed that the file ID of the signed document changes after singing the document. Let me know if that helps. 

Best,

Olga


Hi @ostefaniuk Box,

I actually tried the same. I am not seeing the behavior that you have mentioned. I see that the file id is the same when we do a get on /sign_requests/{sign_request_id} in my scenario.

Therefore, getting the file without the signature.

Regards

Venky


Hi @venky929,

Thanks for quick response. I retested this case again, and I cannot reproduce the change if the ID. Are you not able to receive the signed document at all? Or is it appearing on the document once you eg. timeout the request? 

Have you considered using Sign webhooks, to make sure the sign request is successfully processed? I’d suggest checking the SIGN_REQUEST.SIGNER_SIGNED.

https://developer.box.com/sign/webhooks/#sign-related-events

Best,

Olga


Hi @ostefaniuk Box,

I have given my own email id and I have signed the document and then trying to do the get call for file id.

I am able to get the response from https://{{api.box.com}}/2.0/files/{file_id}/content. However, as I have mentioned earlier, it is not giving the signed copy but the actual document without signature.

Is there any other way to download the signed document through APIs?

Regards

Venky


Hello @venky929

Thanks for your patience and reporting this behavior, I got a temporary workaround for you. 

  1. Get the file ID and the file sequence id from the sign file object:

"id": "FILE_ID", 

"etag": "2",

"type": "file",

"sequence_id": "2",

  1. Use https://api.box.com/2.0/files/{{file_id}} to get additional information about the file. The sequence id and the file id should match.
  2. From the response, get the file_version id.
  3. Download the file from https://api.box.com/2.0/files/{{file_id}}/content?version={{file_version_id}}

This should ensure that you get the signed file. Let me know if that helps. I’ll mare sure to let you know once, this is improved on our side and no additional parameters are needed to download the signed document.

Best,

Olga


Hi @ostefaniuk Box,

I tried https://{{api.box.com}}/2.0/files/{file_id}/content?sequence=2 
and https://{{api.box.com}}/2.0/files/{file_id}/content?version={file_version_id

In both the cases, I am still getting the unsigned document and not the signed one.

Additionally, the name that is coming in the response of the API and the filename in the my sign request are the same. In My Sign requests, I am able to see the signed document, but through API I am not getting the signed one. Not sure if this is of any help but felt like sharing.

 


 


Were you able see the signed document from your end based on the process you have mentioned by passing the version id?

Regards

Venky


Hi @venky929,

Thanks for sharing and the context, I need some time to investigate, let me get back to you asap. Thanks again for your patience.

Best,

Olga


Hi @venky929,

I’m still investigating, so please bare with me, I reached out for support for this case. 

Best, Olga


Hi @ostefaniuk Box,

 

Thanks for the update. Hoping for a positive response.

Regards

Venky


Hi @venky929

Let me just ask some clarifying questions for further investigation:

  1. I realized the responses you pasted the source files field is empty. Does this happen every time you get a response?
  2. Could you paste the request example that you’re sending? (do not pass any sensitive data, so dummy values are great, I just want to make sure we can reproduce the case)
  3. And lastly, just to make sure, this behavior happens for all files you tried to download or just a particular one?

Thank you!

Olga


Hi @ostefaniuk Box ,

  1. while creating a sign request, I am not passing anything in the source files. Therefore, it is always empty.
  2. Below is the create sign request:

    {

        "email_subject": "Sign Request from Box",

        "email_message": "Hello! Please sign the document below",

        "name": "MSA",

        "template_id": "72dcee4b-b13e-4e0e-beac-dcc102ab6f60",

        "signers": "

            {

                "email": "example@gmail.com",

                "role": "signer",

                "order": 1

            },

            {

                "email": "example@gmail.com",

                "role": "signer",

                "order": 2

            }

        ]

    }
     

  3. This behavior is for all the files. I mean I used the same template all the time. But I tried with multiple sign requests and every time, its the same behavior.


Regards

Venky


Hi @venky929,

Thanks for passing all details, this will help to investigate the case closely. I’ll get back to you one I have updates. 

Thanks for your patience, 

Olga


@ostefaniuk Box 

 Is there any progress on this request?

 

Regards

Venky


Hi @venky929, I’m still waiting for the team’s reply. Let me ask about the status.

Best,

Olga


Thanks @ostefaniuk Box.

 

This has been the missing piece in our project and has been pending for a long time now.

 

Kindly let the team know, if they can take this on priority, it would be of great help.

 

Appreciate all the support from you.

 

Regards

Venky


Hello @venky929,

Yeah, I totally understand. As we are still waiting for the team to investigate, I can offer a debugging live session, we can go over the code together if you feel like double checking this on your side. Let me know if that’s something you’d be interested in.

Best,

Olga  


Hi @ostefaniuk Box ,

Thanks for offering the debugging session. Although, I think I have given all the information which I am trying to do. However, I am just trying these API calls through Postman. If you want to review the API requests in Postman for debugging, then sure. we can connect and look into it.

Regards

Venky


Hi @venky929,

Could you please follow the next steps and check if that solves your issue:

1. Create sign request on a File (PDF). 

2. Query the Sign Request and get its response.

3. Signer 1 and Signer 2 finish signing the doc.

4. Query the Sign Request and get its response.

Note the responses:

  1. From response 2 & 4: sign_files.filess0].sha1 has a different value than sign_files.filese0].file_version.sha1.
  2. The sign_files.filese0].file_version.id value of Number 2, is the same as Number 4.

5. Take the sign_files.filese0].id and call the endpoint to get the current file version for the signed file_id.

You should be able to see from the response in 5, that the current file_version for the signed file is actually different than the version_id provided by the Get Sign Request data, which indicated file_version.

6. Take the new file_version and call the API with: https://app.box.com/api/2.0/files/*20171786/content?version=*abc

If you’re using Postman, you cannot rely on the Preview in Postman to view the pdf that is downloaded; please save within Postman the response as a PDF file and use a PDF reader to view. 

Looking forward to hearing from you.

Best,

Olga


Hi @ostefaniuk Box ,

This helped.

Thank you so much for the detailed explanation.

Just so you know, It was my bad that the postman was not displaying the response correctly. So, I was doubting the process.

Like you mentioned, I followed all these steps and could confirm that it is working as expected without providing the version also.

Appreciate all the help that you have provided. Sorry If caused any trouble.

Regards

Venky


Hi @venky929,

I’m happy that this helped with your case, great to know it’s already working for you!

Should you have any additional questions, feel free to reach me out.

Best,

Olga


Reply