API cURL Cookbook
Praktyczne komendy cURL do developmentu lokalnego i smoke checków.
Wymagania
export API_URL="http://localhost:4000"
export EMAIL="developer@example.com"
Opcjonalny helper:
# macOS (opcjonalnie)
brew install jq
1) Wyślij OTP
curl -s -X POST "$API_URL/api/auth/request-otp" \
-H "Content-Type: application/json" \
-d '{"email":"'"$EMAIL"'","lang":"pl"}'
2) Zweryfikuj OTP i zapisz token
Podmień 12345678 na prawdziwy kod z Mailpit/providera.
OTP_CODE="12345678"
TOKEN=$(curl -s -X POST "$API_URL/api/auth/verify-otp" \
-H "Content-Type: application/json" \
-d '{"email":"'"$EMAIL"'","code":"'"$OTP_CODE"'"}' | jq -r '.token')
echo "$TOKEN"
3) Utwórz zgłoszenie (multipart + załącznik)
curl -s -X POST "$API_URL/api/tickets" \
-H "Authorization: Bearer $TOKEN" \
-F "title=Test zgłoszenia z API cookbook" \
-F "description=Szczegółowy opis reprodukcji do smoke checku." \
-F "category=other" \
-F "urgency_reporter=normal" \
-F "attachments=@./README.md"
4) Lista moich zgłoszeń
curl -s "$API_URL/api/tickets" \
-H "Authorization: Bearer $TOKEN" | jq
5) Pobierz szczegóły zgłoszenia
TICKET_ID="<ticket-id>"
curl -s "$API_URL/api/tickets/$TICKET_ID" \
-H "Authorization: Bearer $TOKEN" | jq
6) Developer: zmień status na verified
curl -s -X PATCH "$API_URL/api/tickets/$TICKET_ID" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"status":"verified"}' | jq
7) Dodaj closure summary i zamknij zgłoszenie
curl -s -X POST "$API_URL/api/tickets/$TICKET_ID/comments" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"content":"Wdrożono poprawkę i zweryfikowano QA.","type":"comment","is_internal":false,"is_closure_summary":true}' | jq
curl -s -X PATCH "$API_URL/api/tickets/$TICKET_ID" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"status":"closed"}' | jq
8) Sprawdź capabilities i statystyki outbox (developer)
curl -s "$API_URL/api/settings/capabilities" \
-H "Authorization: Bearer $TOKEN" | jq
curl -s "$API_URL/api/settings/events/outbox/stats" \
-H "Authorization: Bearer $TOKEN" | jq
9) Najczęstsze błędy
401 unauthorized: brak/wygaśnięty token.403 forbidden: ograniczenie roli lub ownership.400 closure_summary_required: brak closure summary przed zamknięciem.400 domain_not_allowed: domena email nie jest wallowed_domains.