엔드 투 엔드
3개의 curl 호출로 완성하는 전체 통합.
BASE_URL="https://api.morphic.com/v1/partner" # a mor_test_ key uses https://api.morphic.today/v1/partner
# 1. what this workflow needs
curl -s "$BASE_URL/workflows/$WORKFLOW_ID/inputs" \
-H "Authorization: Bearer $MORPHIC_API_KEY"
# 2. start the run
curl -s -X POST "$BASE_URL/workflow-runs" \
-H "Authorization: Bearer $MORPHIC_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"org_id": "'"$ORG_ID"'",
"project_id": "'"$PROJECT_ID"'",
"workflow_id": "'"$WORKFLOW_ID"'",
"idempotency_key": "story-48213-v2",
"inputs": {
"story_document": "https://cdn.example.com/stories/48213.pdf",
"tone": "thriller"
}
}'
# 3. follow it to a terminal status
curl -s "$BASE_URL/workflow-runs/$RUN_ID?wait=45" \
-H "Authorization: Bearer $MORPHIC_API_KEY"프로덕션 연동에는
- 작업 단위마다 하나의
idempotency_key를 자체 레코드와 함께 저장해, 타임아웃 후 재시도해도 두 번째 실행이 시작되지 않게 합니다. - 다른 어떤 작업보다 먼저 해당 레코드에 실행 ID가 저장됩니다 — 이미 비용이 청구되고 있는 작업을 가리키는 유일한 식별자입니다.
- 웹훅을 사용하고, 아직 알지 못한 실행은 폴링을 대체 수단으로 유지합니다.
- 자산은 도착하는 즉시 자체 저장소로 다운로드합니다.
url은 만료되기 때문입니다. - 모든 응답의
x-morphic-trace-id를 로그에 기록합니다.