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

# Output encryption

> Request authenticated JWE ciphertext for document artifacts.

Encrypt exported files for an RSA public key by setting `output_encryption` on a prompt or conversion:

```json theme={null}
{
  "output_encryption": {
    "format": "jwe",
    "public_key_pem": "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----"
  }
}
```

Supply an RSA SubjectPublicKeyInfo public PEM, 2048–8192 bits. Your application owns the private key; send only the public key. For read/comment prompts, output encryption requires `export_document: true`.

## What is encrypted

Exported artifact bytes are compact JWE using `RSA-OAEP-256` and `A256GCM`. Messages and receipt metadata remain ordinary JSON and may contain document content. Revise and the inference provider process plaintext inputs; output encryption is not end-to-end input encryption.

The download endpoint returns `application/jose` and a `.jwe` filename. Artifact `bytes` and `sha256` describe ciphertext; `content_type` and `filename` in the artifact metadata describe the original plaintext file.

Verify ciphertext length and SHA-256 before decrypting. Use a JWE library restricted to `RSA-OAEP-256` and `A256GCM`, and authenticate the protected header and GCM tag before releasing plaintext. A decoded header alone is not proof of authenticity.

Validate these protected header fields against the expected result:

| Header | Expected value |
| - | - |
| `kid` | `artifact.encryption.key_id`, the base64url SHA-256 JWK thumbprint of your public key. |
| `cty` | The original plaintext MIME type. |
| `prompt_id` or `conversion_id` | The job that produced the artifact. |
| `artifact_id` | The selected artifact ID. |
| `variant` | `clean`, `tracked_changes`, or `converted`, matching metadata. |

## Chaining encrypted output

Encrypted artifacts cannot be used directly as another input. Decrypt and authenticate locally, then upload the plaintext if another request needs it.

Even a plaintext artifact cannot be submitted by `artifact_id` to a new encrypted-output prompt. Download and reupload it as a file instead. The TypeScript `edit` helper handles this step for plaintext artifact sources, subject to the 18 MiB upload limit.

```ts theme={null}
import { readFile } from "node:fs/promises";
import { ReviseClient, Source } from "@reviseio/api";

const revise = new ReviseClient({ apiKey: process.env.REVISE_API_KEY! });
const publicKey = await readFile("recipient-public.pem", "utf8");
const output = await revise.convert(
  Source.fromText("# Confidential report", { filename: "report.md" }),
  "pdf",
  { outputEncryption: { format: "jwe", public_key_pem: publicKey } },
);
const ciphertext = await output.bytes();
console.log(output.contentType); // application/jose
console.log(output.filename); // ends in .jwe
```

The client retrieves and verifies ciphertext. It does not generate keys or decrypt. Its `Source` reports ciphertext MIME and filenames, including tracked variants, while `source.artifact` retains the original format metadata.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.