Skip to content

About

A Python client for the Vertesia Platform

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Vertesia Python Client

Python client for the Vertesia API.

pip install vertesia-client==1.7.0.dev20261120100641

Quick Start

from vertesia_client import Client

client = Client(api_key="sk-...")
account = client.accounts.get_current_account()
print(account.name)

Client is the recommended entry point. It configures the generated clients, routes Studio and Store APIs, exchanges secret keys for short-lived tokens, and sets the stable x-api-version header. Every request also sends a User-Agent naming the SDK, its version and the runtime, for example vertesia-client-python/1.7.0 python/3.12.4.

Authentication

Use an sk- secret key when you want the client to exchange credentials through STS:

client = Client(api_key="sk-...")

Use token when you already have a bearer token:

client = Client(token="eyJ...")

Set either api_key or token, not both.

Endpoints

By default the client uses the unified global API:

client = Client(api_key="sk-...")

Use region for a hosted regional API:

client = Client(region="us1", api_key="sk-...")

Use preview when you need the hosted preview API:

client = Client(region="us1", preview=True, api_key="sk-...")

For public client usage, prefer the default global API or a hosted Vertesia region. Studio and Store requests are routed through the same public API host.

site is available as an advanced override when you need to provide the exact Vertesia API host:

client = Client(site="api.us1.vertesia.io", api_key="sk-...")

server_url, store_url, and token_server_url are intended for Vertesia developers testing split local or branch environments. When using api_key with custom split endpoints, set token_server_url unless STS can be inferred from a Vertesia api* host. Direct token authentication does not require STS.

The facade exposes both generated clients:

client.studio.projects
client.store.objects

It also exposes convenience aliases such as client.accounts and client.objects where routing is unambiguous.

Raw Generated Client

The OpenAPI generated client remains available for advanced use:

from vertesia_client.openapi.api.accounts_api import AccountsApi
from vertesia_client.openapi.api_client import ApiClient
from vertesia_client.openapi.configuration import Configuration

configuration = Configuration(host="https://api.us1.vertesia.io/api/v1", access_token="YOUR_TOKEN")
api_client = ApiClient(configuration)
api_client.set_default_header("x-api-version", "20260319")

account = AccountsApi(api_client).get_current_account()

Generated APIs and models are importable from vertesia_client.openapi.

Testing

Unit tests run without credentials:

python -m unittest discover -s test

Live integration tests are opt-in. They run only when VERTESIA_LIVE_TESTS=1 and VERTESIA_API_KEY is set to a non-placeholder sk- secret key. For Vertesia developers running the client tests locally:

cp .env.example .env
# Edit .env and set VERTESIA_LIVE_TESTS=1 plus VERTESIA_API_KEY=sk-...
python -m unittest discover -s test

Without VERTESIA_LIVE_TESTS=1, live integration tests are skipped even when a local .env file exists.

The .env file is for local development only and should not be committed.

Generation

This repository is generated from the Vertesia OpenAPI specification. Generated code is committed so Python consumers can install released packages without running OpenAPI Generator.

The public OpenAPI contract for the committed client is tracked at spec/vertesia-openapi.json and spec/vertesia-openapi.yaml. The JSON file is the source used to generate the committed client source; the YAML file is included for tools and readers that prefer YAML.

To regenerate locally, refresh the tracked spec files, then run:

scripts/regenerate.sh

It runs the OpenAPI Generator release pinned in generator/Dockerfile with Docker, applies scripts/patch_forward_compat_enums.py, and runs the tests.

Generated files under vertesia_client/openapi/ and spec/ are owned by internal generation automation. Do not edit or commit them manually. Pull requests that change either directory are rejected by CI.

Hand-written client surface changes, such as Client, tests, examples, README, workflows, and generator configuration, should go through normal pull request review.

The generation automation should regenerate the client, run tests, and push the generated diff directly to main using a dedicated bot or GitHub App. It should stage only the expected generated files and package metadata:

git add vertesia_client/openapi spec pyproject.toml .openapi-generator

Compatibility

The generated Python models ignore unknown response fields, so newer server fields do not break older clients. Unknown enum values are accepted for forward compatibility as well: standalone generated enum classes preserve the raw unknown value, and inline enum validators do not reject values that already match the underlying JSON type.

A union variant added by a newer server is kept as the JSON value it was received as: actual_instance and raw return it, and to_dict() / to_json() write it back unchanged. raw is None for a known variant. The variant stays raw in a copy and after an edit of its contents, until actual_instance is replaced, by assignment or by model_copy(update=...). A union with a published discriminator does this only for a discriminator value it does not know; a known value must decode into its branch, and a missing one is an error.

ModelOptions and McpConnectionParameter are anyOf unions whose branches carry a literal tag (_option_id, type; optional in ModelOptions). A tag selects its branch, and a branch is used only when it writes every received property back with the same value, so options merged from several model families are not lost.

Models check types but not the value constraints of the API specification (pattern, minimum / maximum, minLength / maxLength, minItems / maxItems, multipleOf). A newer server can widen them, for example raise a maximum from 10 to 15, and an older client still decodes the responses that use the new room and writes them back unchanged. A string field still requires a string, and an integer field an integer. Models you build for a request are not checked against those constraints either: the server validates each request against its own, current, rules and answers 400 with the reason, while a copy of the rules in a released client could only be older and would reject values the server accepts. Operation parameters (path and query) keep the checks the generator emits.

scripts/patch_forward_compat_enums.py applies these rules after generation.

Generated API version headers

The high-level client supplies required generated x_api_version arguments from its configured API version before validation, including calls with positional payloads. A per-call x_api_version keyword overrides that default. Raw generated clients still require the declared arguments.

OIDC federation for provisioned users

Use one client per user/project/resource/scope combination. Users must already be SCIM-provisioned and the organization must configure federation trust. The facade does not create or adopt users.

from vertesia_client import Client, ClientOptions, FederationOptions, exchange_federation_token

policy = FederationOptions(
    connection_id="connection-id",
    project_id="project-id",
    resource="https://api.us1.vertesia.io",
    subject_token_provider=get_fresh_idp_token,  # callable returning a current assertion
    # scope="content:read",  # omit for current delegable permissions
)
options = ClientOptions(region="us1", federation=policy)
client = Client(options)
# Use client.projects, client.objects, etc. as usual.

# One-shot exchange; caller manages token lifetime:
issued = exchange_federation_token(options, policy, idp_assertion)
# issued.access_token, issued.expires_in, issued.scope

The first authenticated request exchanges an assertion. Studio and Store share the cached token; after 90% of its lifetime, the next request obtains a fresh assertion and exchanges again. Renewal is serialized across threads, uses no background worker or refresh token, and propagates failures instead of sending expired credentials. API writes are not automatically retried on a 401. Your provider must fetch a current assertion on each renewal. federation, api_key and token are mutually exclusive.

subject_token_type defaults to urn:ietf:params:oauth:token-type:jwt. The endpoint defaults to resolved STS plus /oauth/token; use token_endpoint for a full tenant endpoint or explicit token_server_url for custom split URLs. HTTPS is required except loopback HTTP; redirects are rejected. Assertions and secrets are excluded from the new configuration/result representations and exchange error messages.

Optional middleware authentication: set client_id plus client_secret for client_secret_post; add client_secret_basic=True for Basic instead. Or set client_id and a client_assertion_provider callback for private_key_jwt. It must mint a new short-lived signed assertion with a unique jti for each exchange; the single-string aud must be the Vertesia authorization-server issuer from discovery, including any tenant. Do not mix authentication methods.

Exchange results report conservative remaining expires_in seconds after subtracting the STS round trip (rounded up). Time spent obtaining IdP/client assertions does not consume the delegated token's lifetime. Already-expired results are rejected in both one-shot and automatic modes. Implicit STS routing is limited to recognized Vertesia STS domains; custom api* hostnames require an explicit STS URL or complete token endpoint, even when their names resemble hosted endpoints.

An API 401 invalidates only the bearer token that request used. The SDK does not replay the request; the next call attempts a fresh exchange. Concurrent late 401s do not evict a different newer token. Failed automatic exchanges are cached for one second to avoid repeatedly calling the IdP/STS during an outage. Finite lifetimes up to one day are accepted, including fractional seconds; returned remaining seconds are rounded down. The server's current five-minute cap is not a client limit.

Catch FederationExchangeError to inspect status_code and error_code, for example to distinguish invalid_scope from invalid_grant or identify HTTP 429/503. Only known OAuth codes are exposed; remote descriptions and unknown error text remain redacted. The one-shot function takes arguments in the same order as the Go/Java facades: options, federation policy, subject assertion.

Verify webhooks from Vertesia

Vertesia signs webhooks with Standard Webhooks: the deliveries of event subscriptions with signing enabled, and the workflow notifications (notify_endpoints) of a project that signs its notifications. Verify them with the Standard Webhooks library and the whsec_ secret Vertesia returned when the subscription was created or the secret rotated; a project's notifications all share the project's notification secret. During a rotation a request carries one signature per active secret, and either verifies.

An event subscription signed before Vertesia adopted Standard Webhooks keeps its earlier X-Vertesia-Signature header until its secret is rotated, and that first rotation switches formats at once, with no overlap: deploy a receiver that accepts either format before rotating.

pip install standardwebhooks
import os

from flask import Flask, request
from standardwebhooks.webhooks import Webhook, WebhookVerificationError

app = Flask(__name__)
app.config["MAX_CONTENT_LENGTH"] = 10 * 1024 * 1024  # cap unauthenticated bodies before reading them
wh = Webhook(os.environ["VERTESIA_WEBHOOK_SECRET"])  # whsec_...


# Flask, for example; any framework works with the raw body and the request headers.
@app.post("/vertesia/webhook")
def vertesia_webhook():
    try:
        payload = wh.verify(request.get_data(), dict(request.headers))
    except WebhookVerificationError:  # the signature or the timestamp is not valid
        return "", 401
    # Handle payload.
    return "", 204

Pass the raw request body exactly as received. The webhook-id header stays the same across retries, so deduplicate on it.

Release

The Release workflow accepts a synchronized spec version such as v1.6.0 from release/1.6, or v1.6.0-dev.20261021.123456Z from main. Optional source_sha pins the exact tested commit. dry_run=true (the default) validates, tests and builds distributions without creating tags or publishing.

Dev artifact versions use PEP 440, for example 1.6.0.dev20261021123456. The publisher stamps this unique version in the build workspace; generator/source metadata can keep its existing .dev0 convention. It also pins the install command in the Installation section, since this README becomes the PyPI description, so each PyPI page shows its own version. The branch's README is pinned separately, after publication. PyPI trusted publishing uses the existing pypi environment and Release workflow identity. GitHub releases are marked as prereleases for dev cohorts. Retries never replace a source tag; an already published version requires a matching tag at the same commit.

About

A Python client for the Vertesia Platform

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages