첨부파일
AgentSend에 파일을 업로드해 발신 메시지에 첨부하세요. 프리사인드 URL을 가져와 첨부파일 콘텐츠를 다운로드하거나 공유합니다.
먼저 첨부파일을 업로드한 다음 메시지를 보낼 때 attachmentIds 필드에서 id를 참조하세요. 첨부파일은 안전하게 저장되며 시간 제한 프리사인드 URL을 통해 접근 가능합니다.
첨부파일 업로드
POST
/attachments
파일을 업로드하고 Attachment 객체를 반환합니다. 반환된 id를 사용해 파일을 메시지에 첨부하세요. 요청은 multipart/form-data 인코딩을 사용해야 합니다.
요청 본문
Content-Type: multipart/form-data
| 필드 | 타입 | 설명 |
|---|---|---|
file 필수 |
file | 업로드할 파일. 파일명과 콘텐츠 타입은 업로드된 부분에서 유추됩니다. |
요청 예시
bash
curl -X POST https://api.agentsend.io/attachments \ -H "x-api-key: $AGENTSEND_API_KEY" \ -F "file=@/path/to/report.pdf"
javascript
const form = new FormData(); form.append("file", fileBlob, "report.pdf"); const res = await fetch("https://api.agentsend.io/attachments", { method: "POST", headers: { "x-api-key": process.env.AGENTSEND_API_KEY }, body: form, }); const attachment = await res.json(); console.log(attachment.id); // use this id when sending a message
응답 — 201 Created
json
{
"id": "att_01j9zxkp4qbc7n3m8td5e6fvg2",
"filename": "report.pdf",
"contentType": "application/pdf",
"size": 204800,
"url": "https://storage.agentsend.io/att_01j9zxkp4qbc7n3m8td5e6fvg2/report.pdf?token=...",
"createdAt": "2025-11-10T08:15:00Z"
}첨부파일 조회
GET
/attachments/{id}
첨부파일의 메타데이터와 단기 프리사인드 다운로드 URL을 가져옵니다. url 필드를 사용해 파일 콘텐츠를 직접 다운로드하거나 표시하세요.
경로 파라미터
| 파라미터 | 타입 | 설명 |
|---|---|---|
id 필수 |
uuid | 가져올 첨부파일의 ID. |
요청 예시
bash
curl https://api.agentsend.io/attachments/att_01j9zxkp4qbc7n3m8td5e6fvg2 \
-H "x-api-key: $AGENTSEND_API_KEY"응답 — 200 OK
json
{
"id": "att_01j9zxkp4qbc7n3m8td5e6fvg2",
"filename": "report.pdf",
"contentType": "application/pdf",
"size": 204800,
"url": "https://storage.agentsend.io/att_01j9zxkp4qbc7n3m8td5e6fvg2/report.pdf?token=...",
"createdAt": "2025-11-10T08:15:00Z"
}Attachment 객체
| 필드 | 타입 | 설명 |
|---|---|---|
id |
string | 첨부파일의 고유 식별자. |
filename |
string | 업로드 시 제공된 원본 파일명. |
contentType |
string | 파일의 MIME 타입 (예: application/pdf, image/png). |
size |
number | 파일 크기 (바이트). |
url |
string | 파일을 다운로드하기 위한 프리사인드 URL. 이 URL은 시간 제한이 있습니다; 만료되면 이 엔드포인트를 다시 호출해 새로운 URL을 가져오세요. |
createdAt |
string | 첨부파일이 업로드된 ISO 8601 타임스탬프. |
프리사인드 URL은 짧은 시간 후 만료됩니다. 첨부파일을 공유하거나 다시 다운로드해야 하는 경우 GET /attachments/{id}를 다시 호출해 새로운 URL을 얻으세요.