Set author attachments
API call: POST /api/v2/documents/{document_id}/setattachments
This API call:
- sets or removes author attachments for the document
- replaces any existing attachments, so all attachments must be set by any use of this call
Note: The JSON structure has two variants, one with file_param and the other with file_id.
- file_param refers to a named parameter that must also be included in this API call. This is the suggested way to include files.
- file_id refers to a file in the Scrive system. You must have the rights to access the file_id to use it.
Example 1: Set attachments
We want to set the following two author attachments:
- terms_and_conditions.pdf
- proof_of_purchase.pdf
To do this, we need to include the two files as form data in our request. We can then choose names for the form data elements:
- toc_file
- proof_file
The attachments JSON must then resemble:
[
{
"name": "Terms and Conditions",
"required": true,
"add_to_sealed_file": false,
"file_param": "toc_file"
},
{
"name": "Proof of purchase",
"required": false,
"add_to_sealed_file": true,
"file_param": "proof_file"
}
]
If the call was successful, Scrive will respond with updated JSON.
Example 2: add new attachment
To add a new attachment to the same document and keep the ones attached in the “setattachments” call in Example 1, we need to include:
- the list of existing author attachments to prevent them from being removed from the document JSON
- the new attachment we want to add
We will add a new attachment to the previous process, so the result will be the following three attachments:
- Terms_and_condition.pdf
- Proof_of_purchase.pdf
- Additional_company_attachment.pdf (new)
To do this, we need to include both previous attachments in the API call.
To quickly acquire the previous attachments, see previous JSON and look for the value of “author_attachments”: ]
POST /api/v2/documents/{document_id}/setattachments
[
{
"name": "Terms and Conditions",
"required": true,
"add_to_sealed_file": false,
"file_id": "404464"
},
{
"name": "Proof of purchase",
"required": true,
"add_to_sealed_file": false,
"file_id": "404465"
},
{
"name": "Addition company attachment",
"required": true,
"add_to_sealed_file": false,
"file_param": "aca_file"
}
]
Scrive will respond with updated JSON.