Replace Attachment

Purpose

This API allows you to replace existing file attachments in a PDF document with new files.

Quick Reference

PropertyValue
MethodPOST
Request URL (Download)https://{zohoapis_domain}/pdfeditor/api/v1/pdf/attachment/replace
Request URL (Callback)https://{zohoapis_domain}/pdfeditor/api/v1/pdf/attachment/replace/callback

Body Parameters

ParameterValueMandatory/OptionalDescription
fileFile or StringMandatoryUpload the PDF file from your local drive or desktop. If the PDF file is available via a publicly accessible web URL, you can provide the URL using the same parameter.
replace_filesFileMandatoryUpload the replacement files using indexed form fields such as replace_files.
input_options{
  "target_files": ["old-report.pdf", "old-image.png"]
}
MandatorySpecify the existing attachment filenames to replace. Each filename is mapped to the replacement upload at the same index.
passwordStringOptionalIf the input PDF is password protected, specify the password to unlock it.
callback{
  "invoke_url": "<callback_url>",
  "timeout": 60,
  "retry_interval": 60,
  "headers": {
    "header_name": "header_value"
  },
  "http_method_type": "post"
}
Mandatory for callback variantSpecify the callback delivery configuration for the /callback variant.

input_options Parameters

ParameterData TypePossible ValuesDefault Value
target_filesJSON ArrayArray of existing attachment filenames to replace

callback Parameters

ParameterData TypePossible ValuesDefault Value
invoke_urlStringURL. Maximum length: 300 characters.
timeoutInteger10 to 120 seconds60 seconds
retry_intervalInteger60 to 28800 seconds60 seconds
headersJSON ObjectMaximum 10 keys. Allowed characters for keys: alphabets, numbers, hyphen, underscore, dot. Maximum key length: 100. Maximum value length: 2500.
http_method_typeStringput, postpost

Notes and Limits

  • The maximum file size allowed for the input PDF is 50 MB.
  • Supported replacement file types: PDF, JPEG, PNG.
  • Each item in target_files is mapped to the uploaded replacement file at the same index.
  • If the replacement file has a different filename, attachment-related links and highlights are updated to reference the new filename.
  • To use this API, an OAuth token should be generated with the following scopes: ZohoWriter.pdfEditor.ALL

Possible Errors

Refer to the following pages for the list of possible errors for this API:

Download Variant Sample Request

Copiedcurl --location --request POST "https://{zohoapis_domain}/pdfeditor/api/v1/pdf/attachment/replace" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form 'file=@/Users/username/Documents/Master.pdf' \
  --form 'password="pdf_password"' \
  --form 'replace_files=@/Users/username/Documents/updated-report.pdf' \
  --form 'input_options={
    "target_files": ["old-report.pdf"]
  }'

Callback Variant Sample Request

Copiedcurl --location --request POST "https://{zohoapis_domain}/pdfeditor/api/v1/pdf/attachment/replace/callback" \
  --header "Authorization: Zoho-oauthtoken xxx.yyy.zzz" \
  --form 'file=@/Users/username/Documents/Master.pdf' \
  --form 'password="pdf_password"' \
  --form 'replace_files=@/Users/username/Documents/updated-image.png' \
  --form 'input_options={
    "target_files": ["old-image.png"]
  }' \
  --form 'callback={"invoke_url": "https://www.example.com/v1/api/callback/savecallback", "timeout": 120, "retry_interval": 60, "http_method_type": "post"}'

Download Variant Sample Response

Copied{
  "status": "inprogress",
  "status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/attachment/replace/job/e9051e30fd7f0093cba4247d1f831e03e945a127bde429ed6e9ef3a703b15a6060b830256c650cb88a3f687773c33076"
}

Download Variant Success Response

Copied{
  "status": "success",
  "download_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/attachment/replace/download/f7e9c1d2b3a4f5e6d7c8b9a0f1e2d3c4",
  "response_generated_time": 1780912499331
}

Callback Variant Sample Response

Copied{
  "status": "inprogress",
  "status_check_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/attachment/replace/job/1d358192770dc68d173ca34b8f7c9dcb121ad0bf3d6307b7387be79e76dacf586f9d62cd253c26020f8c3dcf79d51b6b"
}

Callback Variant Success Response

Copied{
  "status": "success",
  "callback_response": {
    "invoked_time": 1780912655806,
    "http_status_code": 200,
    "message": {
      "download_url": "https://pdf.zoho.com/pdfeditor/api/v1/pdf/attachment/replace/download/f7e9c1d2b3a4f5e6d7c8b9a0f1e2d3c4",
      "response_generated_time": 1780912656237
    }
  }
}