SERVICE API / V1
| | |
|---|
| POST | /api/service/v1/cdk/check | |
| POST | /api/service/v1/tasks | |
| GET | /api/service/v1/tasks/{task_id} | |
| GET | /api/service/v1/requests/{request_id} | |
curl -X POST https://127.0.0.1:8443/api/service/v1/cdk/check \
-H 'Authorization: Bearer svc_fictional_example' \
-H 'Content-Type: application/json' \
-d '{"cdk_code":"PLB-FICTIONAL-EXAMPLE","expected_plan":"PLUS"}'
curl -X POST https://127.0.0.1:8443/api/service/v1/tasks \
-H 'Authorization: Bearer svc_fictional_example' \
-H 'Idempotency-Key: example-request-001' \
-H 'Content-Type: application/json' \
-d '{"request_id":"example-request-001","cdk_code":"PLB-FICTIONAL-EXAMPLE","expected_plan":"PLUS","confirmed":true,"session_json":{"demo":true,"email":"buyer@example.test","current_plan":"free"}}'
curl https://127.0.0.1:8443/api/service/v1/requests/example-request-001 \
-H 'Authorization: Bearer svc_fictional_example'
import time
import ssl
import httpx
request_id = "example-request-001"
body = {
"request_id": request_id,
"cdk_code": "PLB-FICTIONAL-EXAMPLE",
"expected_plan": "PLUS",
"confirmed": True,
"session_json": {"demo": True, "email": "buyer@example.test"}
}
with httpx.Client(verify=ssl.create_default_context(), base_url="https://127.0.0.1:8443", headers={"Authorization": "Bearer svc_fictional_example"}, timeout=20) as client:
response = client.get(f"/api/service/v1/requests/{request_id}")
if response.status_code == 404:
try:
response = client.post("/api/service/v1/tasks", json=body, headers={"Idempotency-Key": request_id})
except httpx.TransportError:
response = client.get(f"/api/service/v1/requests/{request_id}")
response.raise_for_status()
task_id = response.json()["task_id"]
for attempt in range(60):
response = client.get(f"/api/service/v1/tasks/{task_id}")
if response.status_code == 429 or response.status_code >= 500:
time.sleep(min(60, 2 ** min(attempt, 6)))
continue
response.raise_for_status()
task = response.json()
if task["status"] in ("completed", "failed", "review"):
break
time.sleep(5)
{
"task_id": "fictional-task-id",
"request_id": "example-request-001",
"status": "processing",
"phase": "provider_processing",
"error_code": null,
"key_reusable": null
}
| HTTP / code | |
| 401 · invalid_api_key | |
| 404 · task_not_found | |
| 409 · idempotency_conflict | |
| 422 · validation_error | |
| 429 · rate_limited | |
| 5xx / timeout | |
| checkout_pricing_unavailable:401 | |
| customer_action / CAPTCHA / 3-D Secure | |
| review | |