API 요청
/rest/pdf_merge요청 파라미터 3개 · 필수 2
pdf1pdf2pdf3응답 필드 파일
정상 응답은 파일 본문입니다. 실패 시 JSON 오류가 올 수 있으므로 HTTP 상태와 Content-Type을 먼저 확인하세요.
PDF 파일 두 개 이상을 올린 순서대로 이어 붙여 PDF 파일 하나로 돌려줍니다. 응답은 JSON이 아닌 PDF 파일입니다.
https://apick.app/rest/pdf_merge왜 PDF 파일 합치기인가
제출 서류가 여러 파일로 나뉘어 있으면 담당자는 하나씩 열다 빠뜨리고, 고객은 합치는 법을 몰라 헤맵니다. PDF 두 개를 하나로 합쳐 깔끔한 단일 서류로 관리하게 합니다.
REQUEST_TOO_LARGE 오류가 반환되며 과금되지 않습니다.
표지·본문·첨부 서류처럼 따로 만든 PDF를 제출용 파일 하나로 묶을 때 사용합니다.
파일 필드는 pdf1, pdf2, pdf3 … 처럼 1부터 빠짐없이 번호를 붙입니다. pdf1과 pdf2는 필수이고, 번호 순서대로 합쳐집니다. 번호가 중간에 빠지면 그 뒤의 파일은 합치지 않습니다.
요금은 합친 결과의 전체 페이지당 2P입니다(3페이지 + 5페이지 = 8페이지분). 실패·시간 초과 응답은 과금되지 않습니다. 실제 차감액은 응답 헤더 cost로 확인하세요.
/rest/pdf_mergepdf1pdf2pdf3정상 응답은 파일 본문입니다. 실패 시 JSON 오류가 올 수 있으므로 HTTP 상태와 Content-Type을 먼저 확인하세요.
POST https://apick.app/rest/pdf_mergeAuthorization: Bearer 내 계정의 API 인증키multipart/form-data상황별로 보내는 값과 응답에서 확인할 값을 모았습니다. 언어 탭에서 그대로 복사해 쓸 수 있습니다.
표지와 본문처럼 따로 만든 PDF를 순서대로 합칩니다.
/rest/pdf_mergecurl --fail-with-body --request POST 'https://apick.app/rest/pdf_merge' \
--header "Authorization: Bearer $APICK_API_KEY" \
--form 'pdf1=@./cover.pdf' \
--form 'pdf2=@./body.pdf' \
--dump-header response.headers --output result.bin
# response.headers의 Content-Type을 확인한 뒤 파일을 사용하세요.import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("pdf1", new Blob([await readFile("./cover.pdf")]), "cover.pdf");
form.append("pdf2", new Blob([await readFile("./body.pdf")]), "body.pdf");
const response = await fetch("https://apick.app/rest/pdf_merge", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.APICK_API_KEY },
body: form,
signal: AbortSignal.timeout(120_000),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
if ((response.headers.get("content-type") || "").includes("json")) {
throw new Error(JSON.stringify(await response.json()));
}
const { writeFile } = await import("node:fs/promises");
await writeFile("result.bin", new Uint8Array(await response.arrayBuffer()));import os
import requests
parts = [
("pdf1", ("cover.pdf", open("./cover.pdf", "rb"))),
("pdf2", ("body.pdf", open("./body.pdf", "rb"))),
]
response = requests.request("POST", "https://apick.app/rest/pdf_merge",
headers={"Authorization": "Bearer " + os.environ["APICK_API_KEY"]},
files=parts,
timeout=(10, 120), stream=True)
response.raise_for_status()
if "json" in response.headers.get("Content-Type", ""):
raise RuntimeError(response.json())
with open("result.bin", "wb") as output:
for chunk in response.iter_content(65536):
output.write(chunk)<?php
$headers = ["Authorization: Bearer " . getenv("APICK_API_KEY")];
$form = [
'pdf1' => new CURLFile('./cover.pdf'),
'pdf2' => new CURLFile('./body.pdf'),
];
$curl = curl_init('https://apick.app/rest/pdf_merge');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $form,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 120,
]);
$body = curl_exec($curl);
if ($body === false) { throw new RuntimeException(curl_error($curl)); }
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$type = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: "";
curl_close($curl);
if ($status >= 400) { throw new RuntimeException($body); }
if (strpos($type, "json") !== false) { throw new RuntimeException($body); }
file_put_contents('result.bin', $body);Content-Type이 application/pdf이면 output.pdf로 저장합니다.cost는 합친 전체 페이지 수 × 페이지당 요금입니다.첨부 서류까지 붙일 때는 pdf3, pdf4 … 처럼 번호를 빠짐없이 이어서 보냅니다.
/rest/pdf_mergecurl --fail-with-body --request POST 'https://apick.app/rest/pdf_merge' \
--header "Authorization: Bearer $APICK_API_KEY" \
--form 'pdf1=@./cover.pdf' \
--form 'pdf2=@./body.pdf' \
--form 'pdf3=@./appendix.pdf' \
--dump-header response.headers --output result.bin
# response.headers의 Content-Type을 확인한 뒤 파일을 사용하세요.import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("pdf1", new Blob([await readFile("./cover.pdf")]), "cover.pdf");
form.append("pdf2", new Blob([await readFile("./body.pdf")]), "body.pdf");
form.append("pdf3", new Blob([await readFile("./appendix.pdf")]), "appendix.pdf");
const response = await fetch("https://apick.app/rest/pdf_merge", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.APICK_API_KEY },
body: form,
signal: AbortSignal.timeout(120_000),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
if ((response.headers.get("content-type") || "").includes("json")) {
throw new Error(JSON.stringify(await response.json()));
}
const { writeFile } = await import("node:fs/promises");
await writeFile("result.bin", new Uint8Array(await response.arrayBuffer()));import os
import requests
parts = [
("pdf1", ("cover.pdf", open("./cover.pdf", "rb"))),
("pdf2", ("body.pdf", open("./body.pdf", "rb"))),
("pdf3", ("appendix.pdf", open("./appendix.pdf", "rb"))),
]
response = requests.request("POST", "https://apick.app/rest/pdf_merge",
headers={"Authorization": "Bearer " + os.environ["APICK_API_KEY"]},
files=parts,
timeout=(10, 120), stream=True)
response.raise_for_status()
if "json" in response.headers.get("Content-Type", ""):
raise RuntimeError(response.json())
with open("result.bin", "wb") as output:
for chunk in response.iter_content(65536):
output.write(chunk)<?php
$headers = ["Authorization: Bearer " . getenv("APICK_API_KEY")];
$form = [
'pdf1' => new CURLFile('./cover.pdf'),
'pdf2' => new CURLFile('./body.pdf'),
'pdf3' => new CURLFile('./appendix.pdf'),
];
$curl = curl_init('https://apick.app/rest/pdf_merge');
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $form,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 120,
]);
$body = curl_exec($curl);
if ($body === false) { throw new RuntimeException(curl_error($curl)); }
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$type = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: "";
curl_close($curl);
if ($status >= 400) { throw new RuntimeException($body); }
if (strpos($type, "json") !== false) { throw new RuntimeException($body); }
file_put_contents('result.bin', $body);HTTP 성공과 업무 결과를 구분하세요. 경로별 응답 필드와 예시는 위 요청과 응답에 함께 있습니다.
성공하면 합쳐진 PDF 본문이 바로 옵니다. 내려받기 파일명은 output.pdf입니다.
1이면 합치기에 성공한 것입니다.application/pdf응답을 아래 순서로 확인하세요. 결과 유무와 과금 여부는 서로 다릅니다.
실패하면 PDF 대신 JSON이 옵니다. HTTP 상태와 Content-Type을 먼저 확인하고, JSON이면 data.error 문구를 기록하세요. 실패 응답의 api.cost는 0입니다.
pdf1과 pdf2를 모두 보냈는지 확인하세요.data.success가 3입니다. 파일 수를 줄여 나눠 합친 뒤 결과를 다시 합치세요.FORM_DATA_INVALIDFORM_DATA_FIELD_CONFLICTMULTIPART_LIMIT_OR_PARSE_ERROR실제 차감 금액은 응답의 api.cost로 확인하세요. 상세 요금은 요금정책에서 볼 수 있습니다.
파일 2개를 함께 올리는 예시입니다. 키는 환경변수 APICK_API_KEY 에서 읽습니다.