문서 생성
POST /api/document
새로운 문서를 생성합니다.
요청
Headers
Content-Type: application/json
Body
interface CreateDocumentRequest {
title: string;
content?: string;
documentType?: "html" | "sfdt";
}
예시
{
"title": "새 문서",
"content": "<p>문서 내용</p>",
"documentType": "html"
}
응답
성공 (201)
{
"id": "doc_abc123",
"title": "새 문서",
"content": "<p>문서 내용</p>",
"documentType": "html",
"userId": "user_xyz",
"createdAt": "2024-01-01T12:00:00Z",
"updatedAt": "2024-01-01T12:00:00Z"
}
에러
| 코드 | 설명 |
|---|---|
| 400 | 제목 누락 |
| 401 | 인증 필요 |
| 500 | 서버 오류 |
코드 예시
const response = await fetch("/api/document", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
title: "새 문서",
content: "<p>문서 내용</p>",
}),
});
const document = await response.json();