> ## Documentation Index
> Fetch the complete documentation index at: https://agents.nanonets.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Decrypt File (PGP)

> Decrypts a PGP/GPG-encrypted file with the private key stored in a workspace PGP integration.

# Decrypt File (`decrypt_file`)

This document covers `decrypt_file` (display name **"Decrypt File (PGP)"**), the agent tool that decrypts a PGP/GPG-encrypted file with the private key stored in a workspace PGP integration.

Typical use: partner SFTP drops of `*.zip.pgp` / `*.zip.gpg` archives picked up by the [SFTP File Import Trigger](sftp-file-import.md) — decrypt first, then unzip with `file_utils` and route the contents.

## Authentication and enablement

The tool uses a workspace PGP credential integration (`integrations.service_name = 'pgp'`), which stores an ASCII-armored private key, an optional passphrase, and optionally the ASCII-armored public key of the exchange partner. The hidden `integration_id` is resolved from the configured tool binding with `first_active`; key material is loaded inside the Go worker only after verifying that the integration belongs to the task workspace and is active. Keys never appear in persisted tool args and are never sent to external services (in particular, never to the Python sandbox).

The integration validates key material at save time: supplied keys must parse as armored OpenPGP blocks, and a passphrase-protected private key must actually unlock with the given passphrase.

`DefaultEnabled` is **false** — enable and configure the tool for each agent that receives encrypted files. It is billed at the same flat per-call rate as the other file utilities.

## Inputs

Required:

* `file_url`: URL of the encrypted file — a task file URL or the output variable of a previous step.

The encrypted input may be a binary OpenPGP message or ASCII-armored (`BEGIN PGP MESSAGE`); both are detected automatically. The `.pgp` and `.gpg` extensions are both accepted throughout the platform import path.

## Behavior

1. Resolve and verify the PGP integration (workspace scope, service, active status).
2. Parse the private key and unlock it with the passphrase if needed.
3. Download the encrypted file.
4. Decrypt. The plaintext is treated as an opaque blob — the tool makes no assumption about what was encrypted (an archive, a PDF, anything).
5. Upload the decrypted file to platform storage and return its URL and variable reference.

The output filename is the source name with one trailing `.pgp`/`.gpg` stripped (`archive.zip.pgp` → `archive.zip`). A source without either suffix keeps its name prefixed with `decrypted_`.

## Limits

* Encrypted input: **200 MB** maximum.
* Decrypted output: **200 MB** maximum.

Both sides are buffered in worker memory, so the caps bound worst-case memory while sitting far above real-world encrypted archives (tens of MB). Inputs beyond a cap fail with a clear error; nothing is truncated silently.

## Expected errors

All failures return a clear tool error (never a partial or empty output file):

* integration missing, inactive, or belonging to another workspace
* integration has no private key (public-key-only integrations cannot decrypt)
* private key unusable (bad armor, missing or wrong passphrase)
* file encrypted for a different key than the integration holds
* input that is not a valid PGP message, or corrupt/truncated ciphertext
* input or output exceeding the size caps

## Output

The structured result contains `tool_name` and `result.file` with `filename`, `file_id`, and `file_url` (the decrypted file), plus `result.size_bytes`.
