REST API
자동화
댓글 → DM, 키워드 답장 같은 자동화를 템플릿으로 만들고, 읽고, 고치고, 켜고, 실행 기록을 봅니다.
자동화 하나는 JSON 문서 하나입니다. 트리거(댓글, DM, 멘션, 스토리 답장)와 그 뒤의 단계로 이루어집니다. 대시보드 마법사, 캔버스, 이 API 가 모두 같은 문서를 고치므로 여기서 만든 흐름이 대시보드에서 열리고 그 반대도 됩니다.
대부분은 템플릿에서 시작합니다. 새 흐름은 켜기 전까지 초안이고, 그 전에는 누구에게도 아무것도 나가지 않습니다. 계정이 아직 채널 웹훅을 구독하지 않았으면 응답에 warning 이 함께 실립니다. 그 계정을 다시 연결하지 않으면 흐름이 아무 사건도 받지 못합니다.
템플릿과 채널별 가능 범위
GET/v1/automations/templates
템플릿 전부. id, 채널, 인자(JSON Schema), 필요한 심사 대상 기능.
GET/v1/automations/capabilities
채널마다 흐름에 쓸 수 있는 트리거와 단계.
만들기
POST/v1/automations/quick/{template}
템플릿과 인자로 흐름을 만듭니다. 가장 흔한 길입니다.
| 이름 | 타입 | 설명 |
|---|---|---|
template필수 | path | A template id from GET /v1/automations/templates, e.g. comment_to_dm, comment_public_reply, keyword_dm, default_reply. |
accountId필수 | string | The connected account the flow runs on. |
params필수 | object | The template's parameters. Their schema is in the template's params. |
enabled | boolean | true to turn it on right away. Defaults to false (a draft). |
name | string | Defaults to the template's title. |
curl -X POST https://api.uplika.com/v1/automations/quick/comment_to_dm \
-H "Authorization: Bearer $UPLIKA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"accountId": "acc_7f3c",
"params": {
"post": "any",
"keywords": ["link"],
"message": "Thanks for the comment. Tap below and I will send the link.",
"buttonTitle": "Send me the link",
"deliver": { "text": "Here it is.", "links": [{ "title": "Open", "url": "https://example.com" }] }
}
}'POST/v1/automations
문서 전체로 흐름을 만듭니다.
| 이름 | 타입 | 설명 |
|---|---|---|
accountId필수 | string | The connected account the flow runs on. |
doc필수 | object | The flow document: triggers and nodes. POST /v1/automations/validate checks it first. |
name | string | Defaults to Untitled automation. |
enabled | boolean | Defaults to false. |
postId | string | Ties the flow to one of your posts. |
POST/v1/automations/validate
저장하지 않고 문서를 검사합니다. 문제 목록을 주고, 괜찮으면 빈 목록입니다.
목록과 읽기
GET/v1/automations
워크스페이스의 흐름 전부, 최근 것부터.
GET/v1/automations/{id}
흐름 하나. 문서, 판, 실행 수, 그 채널의 가능 범위.
고치기, 켜고 끄기
PUT/v1/automations/{id}
문서를 바꿉니다. 읽은 판을 보내고, 그 뒤에 다른 저장이 있으면 409 version_conflict 입니다.
| 이름 | 타입 | 설명 |
|---|---|---|
version필수 | number | The version you read. A newer save answers 409 version_conflict with the current version. |
doc | object | The new document. Or send template instead. |
template | object | { id, params }: rebuild the document from a template, as the dashboard wizard does. |
name | string | A new name. |
PATCH/v1/automations/{id}
이름을 바꾸거나 enabled 로 켜고 끕니다.
POST/v1/automations/{id}/enable
켭니다. 이때부터 실제 사람에게 메시지가 나갑니다.
POST/v1/automations/{id}/disable
끕니다. 기다리던 실행은 이어지지 않습니다.
POST/v1/automations/{id}/duplicate
같은 문서와 템플릿 인자로 새 초안을 만듭니다.
DELETE/v1/automations/{id}
흐름과 그 실행 · 판을 지웁니다.
실행과 판
멈춘 실행은 error 나 기록에 이유를 남깁니다. 24시간 메시지 창이 닫혔으면 window_closed, 댓글이 7일을 넘겼으면 private_reply_expired, 다른 앱이 대화를 쥐고 있으면 주소가 붙은 문장입니다. GET /v1/help?code=<이유> 가 할 일을 알려 줍니다.
GET/v1/automations/{id}/runs
흐름이 돌 때마다 일어난 일. 상태, 멈춘 이유, 단계 기록.
| 이름 | 타입 | 설명 |
|---|---|---|
limit | query | 1-200, defaults to 50. |
before | query | A run id from the previous page. |
GET/v1/automations/{id}/versions
저장된 문서의 판, 최근 것부터.
GET/v1/automations/{id}/versions/{version}
저장된 판 하나의 문서.