Using the API from Python
How to call OpenSequence from Python without an SDK: the REST API directly, or a client generated from the OpenAPI file with openapi-python-client.
There is no Python SDK: the repository ships only the TypeScript SDK. From Python, call the REST API directly or generate a client from the OpenAPI file.
Call the API directly
The API is small and regular: JSON in, an envelope out, a bearer key (Conventions).
import os, requests
SEQ = os.environ["SEQ_URL"]
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['SEQ_KEY']}"
r = session.put(f"{SEQ}/v1/contacts/p_7", json={"first_name": "Dana", "email": "dana@example.com"})
body = r.json()
if not body["success"]:
raise RuntimeError(f"{body['error']['code']}: {body['error']['message']}")
contact = body["data"]Generate a client
Your instance serves its OpenAPI document at /docs/json; this site has a copy at /openapi.json.
pip install openapi-python-client
openapi-python-client generate --url https://sequences.example.com/docs/jsonThe generated request bodies and query parameters are typed. Responses are not: the OpenAPI file declares every data as any value, so read the shapes from the API reference pages.
Webhooks
Deliveries follow Standard Webhooks, so the standardwebhooks package verifies them with the endpoint secret (whsec_…) and the raw body. See Verifying for the scheme.