Protect an Excel Workbook Using Aspose.Cells Cloud API

This REST API protects an Excel workbook, enabling you to securely protect an Excel workbook with password and protection options using Aspose.Cells Cloud.

PostProtectDocument API

POST https://api.aspose.cloud/v3.0/cells/{name}/protection

Security and Authentication

The Aspose.Cells Cloud APIs are secure and require JWT token-based authentication.

Query Parameters

Parameter Name Type Description
folder string Folder that contains the source workbook. (optional)
storageName string Name of the storage location. (optional; default = “Default”)

Request Body Parameters

Parameter Name Type Description
protection WorkbookProtectionRequest Object that defines the protection settings for the workbook.

WorkbookProtectionRequest

Parameter Name Type Description
ProtectionType string Type of protection to apply. Allowed values (case‑insensitive): ALL, CONTENTS, NONE, OBJECTS, SCENARIOS, STRUCTURE, WINDOWS.
Password string Optional password to set for the protection.

Response

{
  "Status":"OK",
  "Code":200
}

HTTP Status Codes

Code Meaning Description
200 OK Filter applied successfully; response contains operation details.
400 Bad Request Missing or invalid parameters (e.g., unsupported file type).
401 Unauthorized Invalid or missing JWT token.
413 Payload Too Large Uploaded file exceeds size limit.
500 Internal Server Error Unexpected server error.

How to Use the PostProtectDocument API with SDKs

Prerequisites

Before calling the API, ensure you have completed the following steps:

  • Obtain a JWT access token using the authentication flow described in the security section.
  • Upload the workbook to your Aspose Cloud storage or confirm it already exists in the target folder.
  • Know the storage name (default is "Default" if not specified) and the exact file name you wish to protect.

PostProtectDocument API Specification

The OpenAPI Specification defines a publicly accessible programming interface and lets you carry out REST interactions directly from a web browser.

Example: Protect a Workbook with cURL

  1. Obtain an access token as described in Prerequisites / Authentication.

  2. Execute the request:

    curl -X POST "https://api.aspose.cloud/v3.0/cells/test.xlsx/protection?folder=MyFolder&storageName=MyStorage" \
         -H "accept: application/json" \
         -H "Content-Type: application/json" \
         -H "Authorization: Bearer <access_token>" \
         -d '{ "ProtectionType": "ALL", "Password": "aspose" }'
    

    The response will include a status object confirming the protection succeeded.

Use Aspose.Cells Cloud SDKs

Using an SDK is the fastest way to develop against Aspose.Cells Cloud. An SDK abstracts low‑level details, allowing you to focus on your business logic. See the GitHub repository for a complete list of Aspose.Cells Cloud SDKs.

The following code examples demonstrate how to call Aspose.Cells web services using various SDKs:

Sample Full Response

{
  "Status": "OK",
  "Code": 200,
  "Workbook": {
    "Name": "test.xlsx",
    "Path": "/MyFolder/test.xlsx",
    "Protection": {
      "ProtectionType": "ALL",
      "Password": true
    }
  }
}