Protect an Excel Workbook with Aspose.Cells Cloud API

This REST API protects an Excel workbook.

REST API

API HTTP Method Description Swagger Link
/cells/{name}/protection POST Protect a workbook PostProtectDocument

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.

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" }'
    

Expected Responses

HTTP Status Description Example Payload
200 Workbook protected successfully. { "Code": "200", "Status": "OK" }
401 Unauthorized – missing or invalid token. { "Code": "401", "Message": "Invalid access token." }
400 Bad request – malformed JSON or unsupported ProtectionType. { "Code": "400", "Message": "Invalid request data." }
500 Internal server error. { "Code": "500", "Message": "An unexpected error occurred." }

Cloud SDK Family

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: