문서레퍼런스

채팅 상담 API · 웹훅

스토어의 고객 채팅 상담을 외부 헬프데스크나 봇에 잇는 API 와 웹훅입니다. 주소와 요청 형식 표는 채팅 서비스의 코드에서 만들어집니다.

중급백엔드 개발자
확장 앱웹훅· 로그인하면 쓸 수 있습니다
이 페이지에서9개 절
  1. 01무엇을 할 수 있나
  2. 02주소 · 인증 · 범위
  3. 03대화와 메시지
  4. 04읽기 (chat:read)
  5. 05쓰기 (chat:write)
  6. 06웹훅 이벤트
  7. 07서명 확인
  8. 08실시간 알림 (SSE)
  9. 09봇 만들기 예시

무엇을 할 수 있나#

확장 앱 토큰으로 그 스토어 창구의 고객 문의를 읽고 답합니다.

  • 대화 목록·검색, 메시지 읽기와 이어받기, 스토어 이름으로 답하기(글·상품 카드·사진), 내부 메모, 담당자 지정·태그·보류·종료, 자주 쓰는 답변·빠른 질문 관리
  • 웹훅으로 새 대화·메시지·배정·종료·만족도를 받습니다. 연결을 유지할 수 있으면 실시간 알림(SSE)도 쓸 수 있습니다.
  • 토큰이 속한 스토어 창구의 고객 문의만 다룹니다. 다른 스토어의 대화는 404, 파트너가 운영팀에 남긴 문의는 어떤 토큰으로도 보이지 않습니다.

주소 · 인증 · 범위#

범위이름닿는 데이터
chat:read채팅 상담 읽기 (개인정보)고객 이름과 채팅 대화 내용, 상담 상태·담당자, 채팅 설정. 계좌번호처럼 보이는 숫자는 가려집니다 → 채팅 API
chat:write채팅 상담 답하기 (개인정보)스토어 이름으로 고객에게 메시지를 보내고(‘자동 응답’ 표시), 담당자·태그·상태와 자주 쓰는 답변·빠른 질문을 바꿉니다
  • 주소는 https://api.alldayallmarket.com/ext/chat/… 이고, 스토어가 앱을 설치할 때 받은 토큰을 x-extension-token 헤더에 넣습니다. 다른 확장 앱 API 와 같습니다 → 확장 앱 API
  • 범위가 없으면 403, 토큰이 없거나 회수됐으면 401 입니다. 스토어가 동의를 회수하면 바로 막힙니다.
  • 속도 제한: 토큰당 60초에 읽기 300회 · 쓰기 120회. 넘으면 429 (code RATE_LIMITED)
  • 쓰기 요청에 Idempotency-Key 헤더(8~64자 영문·숫자·-·_)를 붙이면 같은 키의 요청은 한 번만 처리되고, 다시 보내면 처음 응답이 그대로 옵니다(x-idempotent-replay: true). 메시지는 본문의 clientMsgId 로도 같은 효과를 냅니다.
  • 앱의 조치(메시지·배정·종료·설정 변경)는 앱 이름과 함께 스토어의 활동 기록에 남습니다.
답을 기다리는 대화 읽기
curl "https://api.alldayallmarket.com/ext/chat/conversations?status=WAITING&limit=20" \
  -H "x-extension-token: $STORE_TOKEN"
메시지 보내기
curl -X POST https://api.alldayallmarket.com/ext/chat/conversations/{대화 ID}/messages \
  -H "x-extension-token: $STORE_TOKEN" -H "content-type: application/json" \
  -H "idempotency-key: reply-0001" \
  -d '{"kind":"TEXT","body":"안녕하세요! 주문하신 상품은 내일 출고됩니다."}'
사진 올리고 보내기
# 1) 사진 올리기 → {"id":"…"}
curl -X POST https://api.alldayallmarket.com/ext/chat/conversations/{대화 ID}/attachments \
  -H "x-extension-token: $STORE_TOKEN" -F "[email protected];type=image/jpeg"
# 2) 받은 id 로 보내기
curl -X POST https://api.alldayallmarket.com/ext/chat/conversations/{대화 ID}/messages \
  -H "x-extension-token: $STORE_TOKEN" -H "content-type: application/json" \
  -d '{"kind":"IMAGE","attachmentIds":["{첨부 ID}"],"body":"포장 상태 사진입니다"}'

대화와 메시지#

한 대화 안의 메시지는 1부터 빈틈없이 늘어나는 순번(seq)을 가집니다.

값뜻
WAITING대기 — 고객 메시지가 답을 기다립니다 (waitingSince 부터)
OPEN진행 — 상담원이 답했거나 자동 안내 중
HOLD보류 — 확인 중. 고객이 다시 말하면 대기로 돌아갑니다
CLOSED종료 — 고객이 다시 메시지를 보내면 다시 열립니다
보낸 쪽 (`senderType`)뜻
CUSTOMER고객
AGENT스토어 상담 직원
BOT확장 앱이 API 로 보낸 메시지 (automated: true)
SYSTEM자동 안내(환영·부재·FAQ)와 기록(kind: EVENT — 종료·상담원 연결 요청 등)
  • 이어받기는 순번으로 합니다: 마지막으로 받은 seq 를 afterSeq 로 주면 그 뒤의 메시지만 옵니다. 같은 메시지를 두 번 받아도 seq 로 걸러 낼 수 있습니다.
  • 글은 2,000자, 내부 메모는 4,000자까지. 사진은 한 메시지에 4장, 한 장 8MB 까지 (JPEG · PNG · WEBP · GIF). 사진은 다시 인코딩되어 저장되고 주소는 30~60분 뒤 만료됩니다.
  • 종료된 대화에는 내부 메모만 남길 수 있습니다. 답하려면 먼저 status: OPEN 으로 다시 엽니다 (409).

읽기 (chat:read)#

주소필요 범위설명
GET`/ext/chat/settings`chat:read스토어의 채팅 설정: 상담 시간과 지금 상담 중인지(open), 다음 상담 시작(nextOpenAt), 환영·부재 문구, 빠른 질문, 배정 방법
GET`/ext/chat/agents`chat:read상담할 수 있는 직원과 접속 상태(online), 진행 중인 대화 수
GET`/ext/chat/conversations`chat:read대화 목록 (마지막 메시지가 최근인 순)
GET`/ext/chat/conversations/{id}`chat:read대화 한 건과 최근 메시지 50개
GET`/ext/chat/conversations/{id}/messages`chat:read메시지 이어받기
GET`/ext/chat/canned-replies`chat:read상담 직원이 / 로 부르는 자주 쓰는 답변 목록
GET`/ext/chat/quick-replies`chat:read고객 채팅 창에 단추로 보이는 빠른 질문
GET`/ext/chat/stream`chat:read실시간 알림 (SSE)

GET /ext/chat/settings#

스토어의 채팅 설정: 상담 시간과 지금 상담 중인지(open), 다음 상담 시작(nextOpenAt), 환영·부재 문구, 빠른 질문, 배정 방법. 필요 범위 chat:read.

GET /ext/chat/agents#

상담할 수 있는 직원과 접속 상태(online), 진행 중인 대화 수. 담당자를 지정할 때의 userId 가 여기 있습니다. 필요 범위 chat:read.

GET /ext/chat/conversations#

대화 목록 (마지막 메시지가 최근인 순). status·assigned·tag·productId 로 거르고 q 로 고객 이름·메시지를 찾습니다. since 는 그 시각 뒤로 바뀐 대화만. 필요 범위 chat:read · 페이지 넘김(cursor → nextCursor).

주소 뒤에 붙이는 값 (쿼리)

필드형식필수설명
status"WAITING" | "OPEN" | "HOLD" | "CLOSED" | "ACTIVE" | "ALL"선택 · 기본 "ACTIVE"
assigned"none" | "any"선택 · 기본 "any"
tag문자열 (30자 이하)선택
productId문자열 (40자 이하)선택
q문자열 (60자 이하)선택
since문자열 (40자 이하)선택
cursor문자열 (40자 이하)선택
limit숫자 (1 이상, 100 이하)선택 · 기본 50

GET /ext/chat/conversations/{id}#

대화 한 건과 최근 메시지 50개. afterSeq 를 주면 그 순번 뒤의 메시지(최대 200개)만 돌려줍니다. 필요 범위 chat:read.

주소 뒤에 붙이는 값 (쿼리)

필드형식필수설명
afterSeq숫자 (0 이상)선택

GET /ext/chat/conversations/{id}/messages#

메시지 이어받기. afterSeq(그 뒤) 또는 beforeSeq(그 앞, 이전 대화 보기). 응답의 lastSeq 는 그 대화의 마지막 순번입니다. 필요 범위 chat:read.

주소 뒤에 붙이는 값 (쿼리)

필드형식필수설명
afterSeq숫자 (0 이상)선택
beforeSeq숫자 (1 이상)선택
limit숫자 (1 이상, 200 이하)선택 · 기본 50

GET /ext/chat/canned-replies#

상담 직원이 / 로 부르는 자주 쓰는 답변 목록. 필요 범위 chat:read.

GET /ext/chat/quick-replies#

고객 채팅 창에 단추로 보이는 빠른 질문. 필요 범위 chat:read.

GET /ext/chat/stream#

실시간 알림 (SSE). 이 스토어의 대화가 바뀔 때마다 data: {"t":"inbox","id":"<대화 ID>","reason":"message"} 한 줄이 옵니다. 내용은 대화 API 로 이어받습니다. 서버 배포·점검 때는 data: {"t":"reconnect","afterMs":…} 가 온 뒤 연결이 닫힙니다 — afterMs 뒤 다시 연결하세요(끊긴 동안 바뀐 대화는 대화 목록 API 의 since 로 확인합니다). 필요 범위 chat:read.

쓰기 (chat:write)#

주소필요 범위설명
POST`/ext/chat/conversations/{id}/messages`chat:write스토어 이름으로 메시지를 보냅니다
POST`/ext/chat/conversations/{id}/attachments`chat:write보낼 사진을 올립니다 (multipart/form-data 의 file)
POST`/ext/chat/conversations/{id}/read`chat:writeseq 까지 읽었다고 표시합니다
POST`/ext/chat/conversations/{id}/assign`chat:write담당 직원을 지정합니다
PUT`/ext/chat/conversations/{id}/tags`chat:write대화의 태그를 통째로 바꿉니다 (없는 태그는 만들어집니다)
POST`/ext/chat/conversations/{id}/status`chat:writeHOLD(보류) · CLOSED(종료 — 고객에게 종료 안내와 만족도 평가가 뜹니다) · OPEN(다시 진행/다시 열기)
POST`/ext/chat/canned-replies`chat:write자주 쓰는 답변 추가
PUT`/ext/chat/canned-replies/{id}`chat:write자주 쓰는 답변 수정 (보낸 필드만 바뀝니다)
DELETE`/ext/chat/canned-replies/{id}`chat:write자주 쓰는 답변 삭제
PUT`/ext/chat/quick-replies`chat:write빠른 질문을 통째로 바꿉니다

POST /ext/chat/conversations/{id}/messages#

스토어 이름으로 메시지를 보냅니다. kind: TEXT(글) · PRODUCT(상품 카드, productId) · IMAGE(사진, 먼저 올린 attachmentIds) · NOTE(내부 메모 — 고객에게 보이지 않음). 고객 화면에는 앱 이름과 자동 응답 표시가 붙습니다. 필요 범위 chat:write · Idempotency-Key 로 다시 보내도 한 번만 처리.

본문

필드형식필수설명
kind"TEXT" | "IMAGE" | "PRODUCT" | "NOTE"선택 · 기본 "TEXT"
body문자열 (4,000자 이하)선택
productId문자열 (300자 이하)선택
attachmentIds배열 [문자열 (40자 이하)] (4개 이하)선택
clientMsgId문자열 (형식 ^[A-Za-z0-9_-]{8,64}$)선택

POST /ext/chat/conversations/{id}/attachments#

보낼 사진을 올립니다 (multipart/form-data 의 file). 돌려받은 id 를 메시지의 attachmentIds 에 넣습니다. 한 시간 안에 보내지 않으면 지워집니다. 필요 범위 chat:write · 새로 만들면 HTTP 201.

POST /ext/chat/conversations/{id}/read#

seq 까지 읽었다고 표시합니다. 고객 화면의 ‘읽음’ 표시가 바뀝니다. 필요 범위 chat:write.

본문

필드형식필수설명
seq숫자 (0 이상)필수

POST /ext/chat/conversations/{id}/assign#

담당 직원을 지정합니다. userId: null 이면 담당자를 비웁니다. 필요 범위 chat:write · Idempotency-Key 로 다시 보내도 한 번만 처리.

본문

필드형식필수설명
userId문자열 (40자 이하) | 값필수

PUT /ext/chat/conversations/{id}/tags#

대화의 태그를 통째로 바꿉니다 (없는 태그는 만들어집니다). 필요 범위 chat:write.

본문

필드형식필수설명
tags배열 [문자열 (1자 이상, 20자 이하)] (10개 이하)필수

POST /ext/chat/conversations/{id}/status#

HOLD(보류) · CLOSED(종료 — 고객에게 종료 안내와 만족도 평가가 뜹니다) · OPEN(다시 진행/다시 열기). 필요 범위 chat:write · Idempotency-Key 로 다시 보내도 한 번만 처리.

본문

필드형식필수설명
status"OPEN" | "HOLD" | "CLOSED"필수

POST /ext/chat/canned-replies#

자주 쓰는 답변 추가. shortcut 은 스토어 안에서 겹칠 수 없습니다. 필요 범위 chat:write · 새로 만들면 HTTP 201 · Idempotency-Key 로 다시 보내도 한 번만 처리.

본문

필드형식필수설명
shortcut문자열 (형식 ^[0-9a-z가-힣_-]{1,20}$)필수
title문자열 (1자 이상, 40자 이하)필수
body문자열 (1자 이상, 2,000자 이하)필수
sortOrder숫자 (0 이상, 9999 이하)선택 · 기본 0

PUT /ext/chat/canned-replies/{id}#

자주 쓰는 답변 수정 (보낸 필드만 바뀝니다). 필요 범위 chat:write.

본문

필드형식필수설명
shortcut문자열 (형식 ^[0-9a-z가-힣_-]{1,20}$)선택
title문자열 (1자 이상, 40자 이하)선택
body문자열 (1자 이상, 2,000자 이하)선택
sortOrder숫자 (0 이상, 9999 이하)선택

DELETE /ext/chat/canned-replies/{id}#

자주 쓰는 답변 삭제. 필요 범위 chat:write.

PUT /ext/chat/quick-replies#

빠른 질문을 통째로 바꿉니다. kind 가 CUSTOM 이면 answer 가 필요합니다. 필요 범위 chat:write.

본문

필드형식필수설명
quickReplies배열 [{ key, label, kind, answer }] (8개 이하)필수

웹훅 이벤트#

앱에 등록한 웹훅 주소, 또는 개발자 웹훅에서 고른 이벤트로 옵니다. 그 스토어에 설치돼 있고 chat:read 에 동의한 앱에만 보냅니다.

이벤트언제data 의 필드
chat.conversation.created고객이 새 대화를 시작했을 때storefrontId, appId, installId, conversation
chat.message.created메시지가 저장됐을 때 (고객 · 상담원 · 앱이 보낸 것 모두. 내부 메모는 오지 않습니다)storefrontId, appId, installId, conversation, message, sender, fromCustomer, fromAgent, automated
chat.conversation.assigned담당자가 정해지거나 바뀌었을 때storefrontId, appId, installId, conversation (assigneeId, assigneeName)
chat.conversation.closed대화가 종료됐을 때storefrontId, appId, installId, conversation, closedBy, resolutionSec
chat.rating.submitted고객이 만족도를 남겼을 때storefrontId, appId, installId, conversation, rating (score 1~5, comment)
본문 예시 (chat.message.created)
{
  "event": "chat.message.created",
  "at": "2026-10-13T01:20:05.000Z",
  "data": {
    "storefrontId": "cmv6example0000store0001",
    "conversation": {
      "id": "cmv6example0000chat000001",
      "status": "WAITING",
      "origin": "STORE",
      "customer": {
        "name": "홍길동",
        "member": true
      },
      "topic": "배송 문의",
      "tags": [],
      "assigneeId": null,
      "assigneeName": null,
      "productId": "cmv6example0000product001",
      "orderId": null,
      "lastSeq": 3,
      "humanRequested": false,
      "createdAt": "2026-10-13T01:20:00.000Z",
      "closedAt": null
    },
    "message": {
      "id": "cmv6example0000message01",
      "seq": 3,
      "kind": "TEXT",
      "body": "오늘 주문하면 언제 받을 수 있나요?",
      "createdAt": "2026-10-13T01:20:05.000Z",
      "product": null,
      "order": null,
      "attachmentCount": 0
    },
    "sender": {
      "type": "CUSTOMER",
      "name": "홍길동",
      "appId": null
    },
    "fromCustomer": true,
    "fromAgent": false,
    "automated": false,
    "appId": "cmv6example0000app000001",
    "installId": "cmv6example0000install01"
  }
}
  • 전달·서명·재시도는 다른 웹훅과 같습니다 → 웹훅 레퍼런스. 전달은 1분 안쪽 간격으로 모아 보내므로, 몇 초 안에 답해야 하면 아래 실시간 알림(SSE)을 함께 쓰세요.
  • 같은 전달이 다시 올 수 있습니다. x-jangteo-delivery 값이나 message.id 로 중복 처리를 막으세요.
  • 내가 API 로 보낸 메시지도 chat.message.created 로 옵니다 (sender.type: BOT, sender.appId = 내 앱). 여기에 다시 답하면 끝없이 되풀이되니 fromCustomer 가 참일 때만 답하세요.

서명 확인#

받은 본문 원문과 x-jangteo-timestamp 로 서명을 다시 계산해 x-jangteo-signature 와 비교합니다.

서명 = HMAC-SHA256(키, "<x-jangteo-timestamp>.<본문 원문>") 의 16진수 글자입니다. 아래 값으로 내 구현을 확인해 보세요.

항목값
키whsec_example_do_not_use
x-jangteo-timestamp1791854405000
본문위 ‘본문 예시’를 공백 없이 한 줄로 만든 글 (JSON.stringify 결과 그대로)
x-jangteo-signature5ec1496043b09a49e81f209ee49b8d40e37e8e15e3642160c26b24d8d780d171
서명에 쓰인 본문 (한 줄)
{"event":"chat.message.created","at":"2026-10-13T01:20:05.000Z","data":{"storefrontId":"cmv6example0000store0001","conversation":{"id":"cmv6example0000chat000001","status":"WAITING","origin":"STORE","customer":{"name":"홍길동","member":true},"topic":"배송 문의","tags":[],"assigneeId":null,"assigneeName":null,"productId":"cmv6example0000product001","orderId":null,"lastSeq":3,"humanRequested":false,"createdAt":"2026-10-13T01:20:00.000Z","closedAt":null},"message":{"id":"cmv6example0000message01","seq":3,"kind":"TEXT","body":"오늘 주문하면 언제 받을 수 있나요?","createdAt":"2026-10-13T01:20:05.000Z","product":null,"order":null,"attachmentCount":0},"sender":{"type":"CUSTOMER","name":"홍길동","appId":null},"fromCustomer":true,"fromAgent":false,"automated":false,"appId":"cmv6example0000app000001","installId":"cmv6example0000install01"}}

실시간 알림 (SSE)#

웹훅을 받을 서버가 없거나 더 빨리 알아야 할 때 씁니다.

연결
curl -N https://api.alldayallmarket.com/ext/chat/stream -H "x-extension-token: $STORE_TOKEN"

data: {"t":"ready","conn":"…","heartbeatMs":20000,"serverTime":"2026-10-13T01:20:00.000Z"}

data: {"t":"inbox","id":"cmv6example0000chat000001","reason":"message"}
  • inbox 한 줄 = 그 대화가 바뀌었다는 뜻입니다 (reason: created · message · note · human · assigned · status · closed · read · tags · rating). 내용은 GET /ext/chat/conversations/{id}/messages?afterSeq=… 로 이어받습니다.
  • 20초마다 빈 줄(: keep-alive)이 옵니다. 연결은 길어도 1시간 뒤 끊기므로 끊기면 다시 붙고, 그 사이에 놓친 것은 since 로 대화 목록을 읽어 메우세요.
  • 게이트웨이를 거치는 연결은 30초 뒤 끊길 수 있습니다. 운영 주소(API 호스트)는 이 주소를 채팅 서비스로 바로 넘기도록 설정돼 있습니다.

봇 만들기 예시#

고객 메시지를 받아 답하는 가장 작은 흐름입니다.

웹훅 처리
// 고객 메시지에 자동으로 답하는 가장 작은 봇 (Node.js 22+)
const BASE = "https://api.alldayallmarket.com", TOKEN = process.env.STORE_TOKEN;
const api = (path, init = {}) => fetch(BASE + path, { ...init, headers: { "x-extension-token": TOKEN, "content-type": "application/json", ...init.headers } }).then((r) => r.json());

// 웹훅(chat.message.created)을 받았을 때 부르는 함수. 서명 확인은 아래 "서명 확인" 참고
export async function onChatMessage(event) {
  const { conversation, message, fromCustomer, automated } = event.data;
  if (!fromCustomer || automated) return;            // 내가 보낸 답·자동 안내에는 답하지 않는다 (되돌이 방지)
  if (conversation.humanRequested) return;           // 고객이 상담원을 찾으면 끼어들지 않는다
  if (message.kind !== "TEXT") return;
  const answer = await myAnswer(message.body);       // 내 서비스의 답 만들기
  if (!answer) return;
  await api(`/ext/chat/conversations/${conversation.id}/messages`, {
    method: "POST",
    headers: { "idempotency-key": `reply-${message.id}` },   // 웹훅이 다시 와도 한 번만 답한다
    body: JSON.stringify({ kind: "TEXT", body: answer }),
  });
}
  • fromCustomer 가 참이고 automated 가 거짓인 메시지에만 답한다
  • conversation.humanRequested 가 참이면 답하지 않는다 (상담원이 이어받는다)
  • 답할 수 없는 질문에는 아무것도 보내지 않는다 — 고객 화면에는 항상 ‘상담원 연결’ 단추가 있다
  • Idempotency-Key 를 붙여 웹훅 재전달에도 한 번만 답한다
  • 토큰과 대화 내용을 로그에 남기지 않는다