メインコンテンツへスキップ

PDF文書を暗号化する API

PDF4me ドキュメント保護 PDF をパスワードで保護し、受信者がそれに対してできることを制限する REST エンドポイントです。ファイルを Base64 として POST します。 /api/v2/Protect パスワードとアクセス許可フラグを設定すると、AES暗号化された新しいPDFファイルが返されます。印刷、コピー、編集、フォームへの入力は、許可した場合のみ可能です。

このエンドポイントの機能

PDF4me ドキュメントを保護する 暗号化する PDF パスワードを使用して、単一の権限フラグを設定します REST 電話してください。 PDF として Base64パスワードと許可する操作(印刷、コピー、注釈、フォーム入力)を選択し、新しい AES暗号化された PDF 応答では、適用された暗号化は AES-128 または AES-256 あたり PDF 仕様、 GDPR、 HIPAAおよびその他のコンプライアンス主導型のワークフロー。

関連ブログ記事
この機能に関するブログ記事はまだありません。近日公開予定です。
その間、PDF4me ブログを閲覧して、あらゆるプラットフォームのチュートリアルやワークフローをご覧ください。
ブログをご覧ください →

認証 API リクエスト​

毎 PDF4me REST API 電話にはあなたの API キー Authorization ヘッダー。開発者ダッシュボードからキーを作成または選択し、サーバー側に保持してください。ブラウザのコードに公開しないでください。

見逃してはならない重要な事実​

パスワードと権限は一緒に適用されます
シングル パスワード フィールドゲート文書の開放。 PDFの許可 enum は、ドキュメントを開いた後にユーザーが実行できる操作を制御します。両方を組み合わせて使用して、 PDF パスワードが必要で、印刷やコピーも無効になる。
パーミッションフラグは許可リストであり、拒否リストではありません。
含めないもの PDFの許可 ブロックされています。 なし 開く以外のすべてのアクションをブロックするか、特定のフラグなど フォームに記入する フォームへの入力のみを許可し、それ以外の操作は一切許可しない。
情報源 PDF 変更されることはありません
の API 暗号化されたものを返します PDF レスポンスボディに生のバイナリバイトとして格納されます(Content-Type application/pdf)。元のファイルは変更されません。レスポンスバイトを新しい .pdf ファイルに直接書き込みます。保護されていないソースをそのまま保持する必要があるコンプライアンス監査証跡に役立ちます。

REST API 終点​

方法: 役職
URL: https://api.pdf4me.com/api/v2/Protect

送信 コンテンツタイプ: application/json そして 承認 ヘッダーにあなたの API キーを設定します。 非同期 に 間違い 同期応答の場合(HTTP 暗号化された200 PDF 生のバイナリバイトとして)、または 真実 受け取る HTTP 202プラスa 位置 バイナリで200が返されるまでポーリングするヘッダー PDF。

Postmanリクエストの設定​

設定価値
MethodPOST
URLhttps://api.pdf4me.com/api/v2/Protect
HeadersContent-Type: application/json
AuthorizationBasic Auth with your API key, or header Authorization: Basic YOUR_API_KEY
Bodyraw JSON with docContent, docName, password, pdfPermission, and async fields
Response (sync)When async is false: HTTP 200 with the encrypted PDF as raw binary bytes. Save the response body directly to a .pdf file.
Response (async)When async is true: HTTP 202 with a Location header. GET that URL until you receive 200 plus the binary PDF. Useful for large files or slow networks.

パラメータ​

常に必須: ドキュメントコンテンツ、 ドキュメント名、 パスワード、 PDFの許可. 非同期 フラグはオプションです(デフォルトは 間違い)そして、レスポンスを即座に返すか、ポーリングURL経由で返すかを制御します。

パラメータ必須その機能例
jobIdExtOptionalYour own reference for this call. It is stored with the API call log so you can correlate calls with your jobs. Type: string.
integrationsOptionalIntegration identifiers, forwarded unchanged with the job's notification settings. Type: array.
isAsyncOptionalSet to `true` to process the action asynchronously and get a job to poll at `/api/v2/GetActionStatus`. Only honoured by actions that support asynchronous processing. Type: boolean.false
docNameOptionalSource file name including its extension. Several actions dispatch on the extension, so it should always be set; when omitted a per-action default is used. Type: string.invoice.pdf
docContentRequiredThe source file. Accepts the base64-encoded file content, a `pdf4meblobid://<id>` reference to a previously uploaded blob, or an `https` URL to the source document. Required: an empty value fails with `File is empty`. Type: string.JVBERi0xLjQK...
docContentBytesOptionalAlternative raw byte payload for the source file. Type: string.
callBackUrlOptionalOptional URL notified when an asynchronous job completes. Type: string.
passwordOptionalPassword needed to open the protected PDF. It is set as both the user and the owner password. Type: string.Str0ng-P@ss!
pdfPermissionOptionalAn unrecognised value is rejected with 400. Type: string.Fill Forms

どのpdfPermissionフラグを選択すればよいですか?​

パスワードとパーミッションフラグは、それぞれ異なる種類のものから保護する。パスワードはアクセスを許可するものであり、パーミッションフラグはアクセス後に何が起こるかを制御するものである。

パスワードと権限password 分野pdfPermission 分野
保護する許可されていない開口部開封後の望ましくない動作
影響を受ける人々パスワードをお持ちでない方文書を開いたすべての人
典型的な使用例機密配送読み取り専用契約書、校正コピー
最も制限的な値強力で固有のパスワードNone (オープンのみ)
全て何でも許される
開く、印刷する、コピーする、編集する、注釈を付ける、フォームに入力する。パスワードのみで保護され、その他の制限は一切ありません。
なしオープンのみ
印刷、コピー、編集、注釈、フォーム入力をブロックします。最も制限の厳しいオプションです。
コピーテキストまたは画像を開いてコピーする
ブロックの印刷、編集、注釈。
注釈を付ける開いて注釈を付ける
付箋やマーカーの使用は許可されています。コピー、印刷、編集は禁止です。
フォームに記入するフォームフィールドを開いて入力する
印刷、コピー、編集をブロックします。機密性の高い受付用紙によく使用されます。
障害者支援アクセシビリティツールで開く
スクリーンリーダーおよび支援ツールへのアクセス。デフォルトでアクセシブルなPDFファイルには必須です。
組み立てるページレベルの変更が可能
ページの挿入、削除、回転を行います。後続のツールでPDFの構造を再構築する必要がある場合に使用します。
デジタルプリント低解像度印刷のみ
高解像度印刷やコピーをブロックします。校正刷りなどに便利です。

リクエスト例​

例A:パスワードのみで暗号化(All 許可)​

{
"docContent": "JVBERi0xLjQK...",
"docName": "invoice.pdf",
"password": "Str0ng-P@ss!",
"pdfPermission": "All",
"async": false
}

例 B: 最大限の制限で暗号化 (None)​

ブロック印刷、コピー、編集、注釈付け、フォーム入力。

{
"docContent": "JVBERi0xLjQK...",
"docName": "confidential.pdf",
"password": "Str0ng-P@ss!",
"pdfPermission": "None",
"async": false
}

例C:暗号化してフォーム入力のみを許可する​

受領者が記入する必要はあるものの再配布してはならない機密性の高い受付フォームに便利です。

{
"docContent": "JVBERi0xLjQK...",
"docName": "intake-form.pdf",
"password": "Form-2026",
"pdfPermission": "Fill Forms",
"async": true
}

応答成功 (同期、 async: false)​

HTTP 暗号化された200 PDF 生のレスポンスボディとして(バイナリ) application/pdf)。 いいえ JSON ラップ処理。応答バイトを直接ファイルに保存します。

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="protected.pdf"

<binary PDF bytes>

応答成功 (非同期、 async: true)​

HTTP 202で Location ヘッダー。それをポーリングします。 URL と GET (同じ Authorization ヘッダー) を受け取るまで HTTP バイナリで200 PDF。

HTTP/1.1 202 Accepted
Location: https://api.pdf4me.com/api/v2/JobStatus/<job-id>

カールの例​

同期モード(レスポンスボディを直接ファイルに保存):

curl -X POST https://api.pdf4me.com/api/v2/Protect \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-o protected.pdf \
-d '{"docContent":"JVBERi0xLjQK...","docName":"invoice.pdf","password":"Str0ng-P@ss!","pdfPermission":"Fill Forms","async":false}'

非同期モード(注) -D headers.txt 捕獲するために Location (ポーリング用ヘッダー):

curl -X POST https://api.pdf4me.com/api/v2/Protect \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-D headers.txt \
-d '{"docContent":"...","docName":"invoice.pdf","password":"Str0ng-P@ss!","pdfPermission":"Fill Forms","async":true}'

APIはどのような値を返しますか?​

暗号化された文書自体。保護は以下で適用されます。 AES暗号化 定義により PDF仕様そのため、標準規格に準拠したリーダーはパスワードの入力を求め、アクセス許可フラグを適用します。

分野タイプ内容物
Response body (HTTP 200)BinaryThe encrypted PDF bytes (Content-Type application/pdf). Write them straight to a new .pdf file; the source file is never modified.
Location header (HTTP 202)String (URL)Returned when async is true and processing continues in the background. GET this URL with the same Authorization header.
Poll response (HTTP 200)BinaryThe finished encrypted PDF, returned once the async job completes.
Poll response (HTTP 202)EmptyJob still processing. Wait and poll the same Location URL again.

コードサンプル​

統合例​

一般的なREST統合パターンTypical ways developers call Protect Document.
配送用の請求書を一括暗号化する
  1. 各請求書を読んでください PDF フォルダから、 S3 バケット、またはデータベースキュー。
  2. Base64-バイトをエンコードして POST 保護するために PDFの許可 設定 フォームに記入する。
  3. 応答バイトを直接.pdfファイル(生バイナリ)に書き込み、暗号化されたファイルを電子メールまたはオブジェクトストレージにアップロードします。
  4. すべてのファイルをループ処理します。エンドポイントはステートレスであり、レート制限内であれば並列呼び出しも安全に行えます。
法的ワークフローのために暗号化してから署名する
  1. POST 情報源 PDF に /api/v2/Protect 受信者のパスワードと選択された権限で。
  2. バイナリ応答バイトを取得し、再エンコードして Base64そして、 ドキュメントコンテンツ へ デジタルサイネージ 終点。
  3. 1つ受け取る PDF それは両方です AES暗号化および暗号署名済み。法的およびコンプライアンス上の用途において、改ざん防止機能を備えています。
GDPR または HIPAA 受信者ごとの暗号化
  1. 受信者ごとに固有のパスワードを生成します(UUID または共有秘密鍵から派生したもの)。
  2. POST そのパスワードで保護し、 PDFの許可 設定 なし すべてのコピーと印刷をブロックする。
  3. 暗号化されたメール PDF パスワードは、コンプライアンス監査証跡のために別のチャネルを通じて送信されます。

よくある質問​

What encryption strength does the Protect endpoint apply?+
PDF4me applies AES encryption per the PDF specification (ISO 32000). Modern PDF readers use 128-bit or 256-bit AES depending on the PDF version of the source. Both meet GDPR and HIPAA encryption requirements for documents in transit and at rest.
Can I set an owner password and a user password separately?+
The password field is applied as the user password (required to open). The pdfPermission enum is the owner-level signal controlling what is allowed once the document is open. Together they behave like a combined owner-and-user setup. The endpoint does not currently accept two distinct passwords in one call.
How do I disable printing or copying on the encrypted PDF?+
Pick a pdfPermission value that does NOT include the action you want to block. Set it to None to block everything except opening. Set it to Copy to allow text or image copy only. Set it to Fill Forms to allow form filling only. The flag is allow-list: anything not explicitly listed is blocked.
Is the original PDF modified, or is a new copy returned?+
The original file is never touched. The API returns the encrypted PDF as raw binary bytes in the response body (Content-Type application/pdf). Write the response bytes directly to a new .pdf file. Useful when the unprotected source must remain intact for audit trails.
Can I encrypt PDFs in bulk?+
Each call protects one PDF and the endpoint is stateless. For bulk encryption, loop over files in your script (Python for loop, C# foreach, Node async map) or use a Make, Zapier, Power Automate, or n8n scenario that fires the Protect action per file picked up by a folder watcher.
Does this work as an alternative to SmallPDF, iLovePDF, or Adobe Acrobat password protection?+
Yes. The Protect endpoint provides the same outcome (password-encrypted PDF with permission control) through a REST API. No per-user license, no manual upload, and full automation. The same call from a script handles one document or one thousand.
Is the response binary or Base64?+
The response body is the raw binary PDF (Content-Type application/pdf), not JSON. Write the response bytes straight to a .pdf file: response.content in Python requests, response.body in fetch, await Content.ReadAsByteArrayAsync in C#. The Base64 envelope is only used for input (the docContent field you send in the request), not for the output.
How do I test the API without writing code?+
Open the Protect Document API Tester, paste your API key, upload a PDF, type a password, and pick a pdfPermission flag. The tester shows the request and lets you download the encrypted PDF directly.

関連アクション​

他のプラットフォームでも同じタスクを実行​

ヘルプが必要な場合​