Skip to main content

SendItWhenever Python SDK — 초정밀 예약 웹훅을 3줄로.

Project description

sendithq — SendItWhenever Python SDK

초정밀 예약 웹훅(HTTP)을 3줄로. Node SDK(@sendithq/sdk)와 동일한 표면을 Python 관용구로 제공합니다. 동기(SendIt) + 비동기(AsyncSendIt), 의존성은 httpx 하나.

pip install sendithq

Quickstart (sync)

from sendithq import SendIt

sendit = SendIt("sw_live_xxx")
ref = sendit.schedule(
    url="https://api.myapp.com/hook",
    in_="2h",                    # 또는 fire_at=datetime(...) / "2026-01-01T00:00:00Z"
    payload={"user_id": 42},     # dict → JSON + Content-Type 자동, str → 그대로
    idempotency_key="trial-end:42",
)
print(ref.id, ref.fire_at, ref.status)

in 은 Python 예약어라 상대 시간 인자는 in_ 을 씁니다(in_="30s" | "15m" | "2h" | "1d").

Quickstart (async)

import asyncio
from sendithq import AsyncSendIt

async def main():
    async with AsyncSendIt("sw_live_xxx") as sendit:
        ref = await sendit.schedule(url="https://api.myapp.com/hook", in_="2h")
        print(ref.id)

asyncio.run(main())

Constructor

SendIt(
    api_key,                                  # "sw_live_…" / "sw_test_…" — 형식 오류 시 즉시 예외
    base_url="https://api.sendit-whenever.com",
    timeout=30.0,                             # 초
    max_retries=2,                            # 멱등 경로 한정 재시도
    signing_secret=None,                      # verify_signature 기본 시크릿
)

Methods

메서드 반환 비고
schedule(url, *, fire_at|in_, payload, method, headers, idempotency_key) ScheduleRef idempotency_key 있을 때만 자동 재시도
schedule_many(items) BulkScheduleResult 부분성공. items 는 schedule() 키의 dict 리스트
list(*, status, q, limit, offset) ListResult 멱등 재시도
get(id) Schedule
get_attempts(id) list[DeliveryAttempt] 발송 시도 로그
reschedule(id, *, fire_at|in_) Schedule scheduled 상태에서만
replay(id) ScheduleRef 동일 암호문 재발송(비멱등)
clone(id, *, payload, fire_at|in_) ScheduleRef 새 페이로드(비멱등)
cancel(id) Schedule 멱등
verify_signature(body, headers, *, secrets|secret, tolerance_sec) bool 나가는 웹훅 HMAC 검증
signing_secrets.get() / .rotate() SigningSecretPair 2키 회전

AsyncSendIt 은 동일 표면이며 메서드가 코루틴입니다(await).

Verifying incoming webhooks

SendItWhenever 가 보내는 웹훅에는 항상 X-SendIt-Signature 헤더(HMAC-SHA256)가 붙습니다. 서명 대상은 raw 본문이므로 파싱 전 원본 바이트를 넘기세요.

# Flask 예시
from flask import request
from sendithq import SendIt

sendit = SendIt("sw_live_xxx")

@app.post("/hook")
def hook():
    secrets = sendit.signing_secrets.get()           # 무중단 회전 대비 2키
    ok = sendit.verify_signature(
        request.get_data(),                            # raw bytes
        request.headers,
        secrets=[secrets.current.secret, secrets.next.secret],
    )
    if not ok:
        return ("bad signature", 400)
    ...

Errors

모든 실패는 SendItError(code, message, status) 를 던집니다.

from sendithq import SendItError

try:
    sendit.get("missing")
except SendItError as err:
    if err.code == "NOT_FOUND":
        ...

codeUNAUTHORIZED | FORBIDDEN | NOT_FOUND | VALIDATION | CONFLICT | RATE_LIMITED | INTERNAL | NETWORK.

Links

MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sendithq-0.1.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sendithq-0.1.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file sendithq-0.1.0.tar.gz.

File metadata

  • Download URL: sendithq-0.1.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for sendithq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bbffcd7487774f1af540863ea4a8e5e4d3eaeefbcc00996c75ffe160d7fb9031
MD5 9d52dab716ec21bf95f9d805b8fbe45c
BLAKE2b-256 efc08fa6f9e72602a5cf8355d800f8a5bc5fc8949aae316b39fd89b51d18193a

See more details on using hashes here.

File details

Details for the file sendithq-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sendithq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for sendithq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3519c0a6141fb9b73f5397f4023a0896416d36c571ff9a56e47e31c2c7f654d0
MD5 0381975da395d1feccf12a74b894d36c
BLAKE2b-256 fd0c11c922464e01683c05bc2f7a57a0022c3c0056a5a8d0db1f73bcfcc27001

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page