将隐形水印集成到您的应用程序中
/embed认证所有 API 请求需要通过 API 密钥或会话 Cookie 进行认证。请在请求头中包含您的 API 密钥:
curl -X POST https://www.copyseal.online/api/embed \
-H "X-Api-Key: YOUR_API_KEY" \
-F "file=@example.png" \
-F "watermarkText=hello"// Browser / Deno / Node 18+
const form = new FormData();
form.append("file", fileInput.files[0]);
form.append("watermarkText", "hello");
const res = await fetch("https://www.copyseal.online/api/embed", {
method: "POST",
headers: { "X-Api-Key": "YOUR_API_KEY" },
body: form,
});
const data = await res.json();import requests
res = requests.post(
"https://www.copyseal.online/api/embed",
headers={"X-Api-Key": "YOUR_API_KEY"},
files={"file": open("example.png", "rb")},
data={"watermarkText": "hello"},
)
print(res.json())import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Path;
HttpRequest req = HttpRequest.newBuilder(URI.create("https://www.copyseal.online/api/embed"))
.header("X-Api-Key", "YOUR_API_KEY")
.header("Content-Type", "multipart/form-data; boundary=---xyz")
.POST(HttpRequest.BodyPublishers.ofFile(Path.of("example.png")))
.build();
HttpResponse<String> res = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());API 密钥在 Business 和 Enterprise 套餐中可用。Free、Starter 和 Creator 用户可使用 Web 仪表板或基于会话的认证。
/embed嵌入水印在图片或 PDF 中隐藏隐形水印文本。统一端点通过 Content-Type 调度接受两种格式。
Content-Type: multipart/form-data
{
"file": <binary>, // Image (PNG/JPG/WebP) or PDF
"watermarkText": "string", // Text to hide
}{
"id": "uuid",
"file_type": "image" | "pdf",
"wm_shape": 42,
"watermark_content": "hello",
"download_url": "/api/download/{id}",
"expires_at": "2024-01-02T00:00:00Z"
}curl -X POST https://www.copyseal.online/api/embed \
-H "X-Api-Key: YOUR_API_KEY" \
-F "file=@example.png" \
-F "watermarkText=hello"const form = new FormData();
form.append("file", fileInput.files[0]);
form.append("watermarkText", "hello");
const res = await fetch("https://www.copyseal.online/api/embed", {
method: "POST",
headers: { "X-Api-Key": "YOUR_API_KEY" },
body: form,
});
const { id, download_url, watermark_content } = await res.json();import requests
res = requests.post(
"https://www.copyseal.online/api/embed",
headers={"X-Api-Key": "YOUR_API_KEY"},
files={"file": open("example.png", "rb")},
data={"watermarkText": "hello"},
)
data = res.json()
print(data["id"], data["download_url"], data["watermark_content"])import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Path;
HttpRequest req = HttpRequest.newBuilder(URI.create("https://www.copyseal.online/api/embed"))
.header("X-Api-Key", "YOUR_API_KEY")
.header("Content-Type", "multipart/form-data; boundary=---xyz")
.POST(HttpRequest.BodyPublishers.ofFile(Path.of("example.png")))
.build();
HttpResponse<String> res = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());POST /embed 根据上传文件的 Content-Type 进行调度:image/* 走图片分支(需要 watermarkText),application/pdf 走 PDF 分支(watermarkText 可选,仅用于追踪)。响应结构始终一致 —— 根据上传类型填充图片字段 (wm_shape、watermark_content) 或 PDF 字段 (key_id、pages_marked、page_count、frame),另一组为 null。
/extract提取水印从先前嵌入的图片中揭示隐藏的水印。
Content-Type: multipart/form-data
{
"file": <binary>,
"wmShape": 42,
}{
"watermark_content": "Copyright 2024"
}curl -X POST https://www.copyseal.online/api/extract \
-H "X-Api-Key: wsk_your_api_key" \
-F "file=@watermarked_photo.png" \
-F "wmShape=42"const form = new FormData();
form.append("file", fileInput.files[0]);
form.append("wmShape", "42");
const res = await fetch("https://www.copyseal.online/api/extract", {
method: "POST",
headers: { "X-Api-Key": "YOUR_API_KEY" },
body: form,
});
const { watermark_content } = await res.json();import requests
res = requests.post(
"https://www.copyseal.online/api/extract",
headers={"X-Api-Key": "YOUR_API_KEY"},
files={"file": open("watermarked_photo.png", "rb")},
data={"wmShape": 42},
)
print(res.json()["watermark_content"])import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Path;
HttpRequest req = HttpRequest.newBuilder(URI.create("https://www.copyseal.online/api/extract"))
.header("X-Api-Key", "YOUR_API_KEY")
.header("Content-Type", "multipart/form-data; boundary=---xyz")
.POST(HttpRequest.BodyPublishers.ofFile(Path.of("watermarked_photo.png")))
.build();
HttpResponse<String> res = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());/extract/pdf提取 PDF 水印从已加水印的 PDF 中提取 key_id。使用 key_id 追踪是哪个用户/账户嵌入了文件。
curl -X POST https://www.copyseal.online/api/extract/pdf \
-H "X-Api-Key: wsk_your_api_key" \
-F "file=@watermarked_contract.pdf;type=application/pdf"const form = new FormData();
form.append("file", fileInput.files[0]);
const res = await fetch("https://www.copyseal.online/api/extract/pdf", {
method: "POST",
headers: { "X-Api-Key": "YOUR_API_KEY" },
body: form,
});
const { key_id, frame, page_index, plaintext } = await res.json();import requests
with open("watermarked_contract.pdf", "rb") as f:
res = requests.post(
"https://www.copyseal.online/api/extract/pdf",
headers={"X-Api-Key": "YOUR_API_KEY"},
files={"file": ("watermarked_contract.pdf", f, "application/pdf")},
)
data = res.json()
print(data["key_id"], data["page_index"], data["plaintext"])import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Path;
HttpRequest req = HttpRequest.newBuilder(URI.create("https://www.copyseal.online/api/extract/pdf"))
.header("X-Api-Key", "YOUR_API_KEY")
.header("Content-Type", "multipart/form-data; boundary=---xyz")
.POST(HttpRequest.BodyPublishers.ofFile(Path.of("watermarked_contract.pdf")))
.build();
HttpResponse<String> res = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());{
"key_id": "8f3a2b1c4d5e6f70",
"frame": "F3",
"page_index": 3,
"plaintext": "optional-payload"
}`page_index` 从 0 开始计数:文档的第一页是 0,第二页是 1。若要显示读者习惯的页码,请加 1。
如果未找到水印或 key_id 不属于当前认证用户,则返回 404。
API 速率限制取决于您的订阅套餐。
| 套餐 | 每月文件数 | 最大图片大小 | 最大 PDF 大小 | 最大图片分辨率 | PDF 页面尺寸(渲染) | 最大 PDF 页面尺寸 | 最大 PDF 页面尺寸(整页照片) | 每日 API 调用 | 批量限制 |
|---|---|---|---|---|---|---|---|---|---|
| Free | 5 | 5 MB | 5 MB | 1024 px | 1800 px | B5 | A5 | — | Not available |
| Starter | 25 | 10 MB | 10 MB | 2048 px | 2850 px | Legal | Legal | — | Not available |
| Creator | 100 | 10 MB | 50 MB | 3000 px | 3500 px | Tabloid | Tabloid | — | 10 files |
| Business | 500 | 10 MB | 50 MB | 3000 px | 4400 px | A2 | Tabloid | 100 calls/day | 50 files |
| Enterprise | 2,000 | 10 MB | 50 MB | 3000 px | 6100 px | ANSI D | ANSI D | 1,000 calls/day | 500 files |
图片和 PDF 共用同一份月度额度:无论您处理的是图片还是 PDF,每处理一个文件都只计一次。
通过 POST /webhooks 注册一个回调地址,当有任务完成时 CopySeal 会向它发送 POST 请求。每次投递都带有签名,因此你的回调可以确认请求确实来自 CopySeal。
Webhook 是企业版功能。回调的签名密钥只在创建时返回一次,之后无法再次获取。
一个回调可以订阅一个或多个事件。填写列表之外的事件名会收到 422 拒绝,错误信息中会列出允许的事件。
embed.completed水印嵌入完成时触发。携带新资产的 id、类型、原始文件名以及过期时间。
{
"image_id": "0d4f8a2c",
"file_type": "image",
"original_filename": "photo.jpg",
"expires_at": "2026-01-08T12:00:00Z"
}extract.completed水印读取完成时触发。携带资产 id、使用的 WM Shape 密钥和原始文件名。读取出的水印内容永远不会发送。
{
"image_id": "0d4f8a2c",
"file_type": "image",
"wm_shape": 42,
"original_filename": "photo.jpg"
}batch.completed批量任务完成时触发。携带批量任务 id、执行的操作和文件计数。逐个文件的结果仍保存在 CopySeal。
{
"batch_id": "b91c40ae",
"job_id": "b91c40ae",
"operation": "embed",
"total": 12,
"completed": 11,
"failed": 1
}share.created创建分享链接时触发。携带分享 id、来源资产 id 和接收方。分享令牌永远不会发送。
{
"share_id": "c07d2f18",
"parent_image_id": "0d4f8a2c",
"recipient_id": "5a90b3c7"
}每次投递都是同一个信封结构:投递 id、事件名、创建时间,以及该事件自己的数据。下面的示例为了易读做了缩进——线上传输的是紧凑的 JSON。
{
"id": "7f3c1d9e2b4a6058",
"event": "embed.completed",
"created_at": "2026-01-01T12:00:00Z",
"data": {
"image_id": "0d4f8a2c",
"file_type": "image",
"original_filename": "photo.jpg",
"expires_at": "2026-01-08T12:00:00Z"
}
}每次投递带有三个请求头:X-CopySeal-Event 重复事件名,X-CopySeal-Delivery 是投递 id,X-CopySeal-Signature 是签名。签名是对原始请求体字节计算出的 HMAC-SHA256,以回调的签名密钥为密钥,进行 hex 编码并加上 sha256= 前缀。
import hashlib
import hmac
def verify(secret: str, raw_body: bytes, header: str) -> bool:
"""Check the X-CopySeal-Signature header against the raw body."""
expected = hmac.new(secret.encode("utf-8"), raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(header, "sha256=" + expected)import { createHmac, timingSafeEqual } from "node:crypto";
function verify(secret: string, rawBody: Buffer, header: string): boolean {
const expected =
"sha256=" + createHmac("sha256", secret).update(rawBody).digest("hex");
// timingSafeEqual throws when the lengths differ, so check first.
return (
expected.length === header.length &&
timingSafeEqual(Buffer.from(expected), Buffer.from(header))
);
}请用你实际收到的字节来校验。解析 JSON 后重新序列化再计算哈希会得到不同的字节,校验将失败。
使用密钥 3f9a2c7e5b1d8f406a2c9e7b3d5f1a08 时,下面的请求体就是上面请求头中那个签名对应的内容。
X-CopySeal-Event: embed.completed
X-CopySeal-Delivery: 7f3c1d9e2b4a6058
X-CopySeal-Signature: sha256=4817dd115249c788e98b2c47b7e4416c2e0df1594fd29f78545dc5ea5dd2a200
{"id":"7f3c1d9e2b4a6058","event":"embed.completed","created_at":"2026-01-01T12:00:00Z","data":{"image_id":"0d4f8a2c","file_type":"image","original_filename":"photo.jpg","expires_at":"2026-01-08T12:00:00Z"}}一次投递最多尝试 3 次,每次尝试的超时为 10 秒。发生网络错误、429 或 5xx 时会重试,其他 4xx 不会重试。重试期间投递 id 保持不变,因此你的回调可以识别重复投递并忽略它。回调持续失败也不会让触发它的操作失败。
请求无效 - 文件过大、无效或超出您套餐的图片分辨率或 PDF 页面尺寸上限
未授权 - API 密钥无效或缺失
禁止 - 您的套餐不包含此功能
请求体过大 - 加水印后的 PDF 超出最大输出大小。请拆分为更小的文件后重试。
请求过多 - 已达到月度文件限额
内部服务器错误 - 处理失败
本页论断背后的论文、标准与机构链接。每一个链接都经过验证,无需付费墙或登录即可打开。
2002 年关于小波域所有权验证的论文——CopySeal 的嵌入方法正出自这一脉,也清楚说明了这类水印能证明什么、不能证明什么。
2016 年对 DWT-SVD 与 DCT 两种版权保护水印方案的比较,其鲁棒性取舍与 CopySeal 自己的实测结论一致。
内容凭证背后的规范:随文件一同传播的、带签名的来源记录。
W3C 关于「谁对文件做了什么」的记录词汇表——内容溯源的底层语法。
JPEG 标准本身:CopySeal 水印所面对、也是被实测的那一种压缩。
创建免费账户,开始保护您的图片。