Nextcloud logo Nextcloud automation

Share a Nextcloud file with an expiring, password-protected link

You finish a proposal, drop it into the client folder on your Nextcloud, and then click through the sharing sidebar to make a link with a password and an end date, every time.

Cotlet does it in your own Nextcloud account with upload_file and share_file, called by your AI agent, an n8n workflow or a script.

Hosted · nothing to install or maintain

Can Nextcloud do this on its own?

Nextcloud offers this as an API and as a UI (checked 16 Oct 2026). WebDAV PUT uploads the file and the OCS Share API creates the link with password and expireDate, but you write both calls and handle the authentication yourself. The official MCP route, Context Agent, lists making public links among its Files tools and needs an admin to install it first.

How you do it in Nextcloud today

  1. On the Files page, open the target folder and upload the file, or drag it in.
  2. Click the Share icon on the file or folder to open the sharing sidebar.
  3. Create a public link and set its options: Password protect and Set expiration date, plus Note to recipient if you want one.
  4. For a folder, pick between Read only, Allow upload and editing, and File drop; Hide download only makes downloading harder, not impossible.
  5. Copy the link, which has the form https://cloud.example.com/s/ followed by a random token, and send the password to the client by another route.

How to share a Nextcloud file with an expiring, password-protected link

Prompt

Upload this report to /Clients/Acme in my Nextcloud, create a public link with a password that expires on 15 November, and give me the link to send.
  1. 01

    Check the folder and the name

    Your agent looks at the target folder with list_files first. If a file with the same name is already there, it stops and asks, because a plain upload replaces the old version without a warning.

  2. 02

    Upload with the right path

    upload_file writes the file into the folder you named. If the folder does not exist yet, the agent creates it with create_folder in the same run.

  3. 03

    Create one link, not three

    Before sharing, the agent lists existing shares of that file with list_shares and reuses a link that already has your expiry date, so the same report does not collect a pile of old links.

  4. 04

    Set password and end date from your prompt

    share_file creates the public link with the password and expiry date you gave. A link with no expiry or no password is created only if you asked for it, and the reply says so.

  5. 05

    Hand back the link and the password separately

    The agent returns the link and, in its own line, the password and the date it expires, so you can send them through two channels.

What you get back

Example data

Uploaded /Clients/Acme/proposal-q4.pdf (412 KB)
Public link: https://cloud.example.com/s/Kp3xTq9WmB2Rz7a
Password protected: yes
Expires: 2026-11-15
Permissions: read only

Other ways to ask

  • Upload every PDF in this folder to /Invoices/2026 and make a read-only link for each, expiring in 30 days.
  • Share /Projects/Launch with the group marketing and no public link.
  • Create a link to this folder where visitors can upload but not see the other files.
  • Every Friday, share the weekly report with a new link and expire last week's link.

What Nextcloud allows, and what to know first

  • The Share API default permission for a public link is read only; permissions are bit flags that you add together, so the agent only widens them when you say so.
  • A public link needs a date in the format YYYY-MM-DD for expireDate, and Nextcloud disables the share automatically when that date is reached.
  • Nextcloud can answer 403 when public upload is turned off by the admin, so a request for an upload link can fail on an instance that forbids it.
  • Some sharing options are unavailable on an instance because of administrative configuration, so the same prompt can create a link on one instance and be refused on another.
  • An upload that targets an existing path overwrites the file, which is why the agent checks the folder first.

upload_file and share_file ask for your OK by default. To run it on a schedule without you, switch confirmation off for those tools in your dashboard.

Sources: Nextcloud User Manual: File sharing · Nextcloud Developer Manual: Share API · Nextcloud Developer Manual: WebDAV basic APIs · Nextcloud Admin Manual: Context Agent

Call share_file from a script

curl

curl -X POST https://cotlet.dev/api/v1/nextcloud/file/share \
  -H "Authorization: Bearer $COTLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"path":"/Clients/Acme/proposal-q4.pdf","share_type":"link","password":"Fj82-mint-ocean","expire_date":"2026-11-15"}'

Example response

{
  "share_id": "460",
  "path": "/Clients/Acme/proposal-q4.pdf",
  "type": "link",
  "url": "https://cloud.example.com/s/Kp3xTq9WmB2Rz7a",
  "permissions": "read",
  "password_protected": true,
  "expires": "2026-11-15"
}

MCP: add https://cotlet.dev/mcp/v1 with the same key; the call is nextcloud_write → share_file. Example data.

Schedule it in n8n, Make, Zapier or cron

Nextcloud tools this automation uses

Cotlet Nextcloud tools used to share a Nextcloud file with an expiring, password-protected link
Tool Parameters
upload_file path, content, encoding, overwrite
share_file path, share_type, share_with, permissions, password, expire_date, note
All 15 Nextcloud tools with descriptions

Frequently asked questions

Is it safe to connect Nextcloud to Cotlet?

Yes. You sign in to Nextcloud yourself, in your own Cloud Browser in the EU, and we never save your password. Your agents only get Nextcloud once you enable it, every background request is listed, and the browser profile is stored encrypted with AES-256-GCM, the cipher 1Password uses for its vaults. The AI model never sees a login, posts and messages wait for your OK, and Disable for agents cuts access in one click. Independent scanners grade cotlet.dev A+ on Qualys SSL Labs, securityheaders.com and Mozilla Observatory; live results are on https://cotlet.dev/security.

Give your agent access to Nextcloud.

Free 7-day trial with 2,000 credits, no card needed. Cotlet is independent and not affiliated with Nextcloud.