Skip to main content

Vortex Python SDK for invitation management and JWT generation

Project description

Vortex Python SDK

A Python SDK for Vortex invitation management and JWT generation.

Features

Invitation Delivery Types

Vortex supports multiple delivery methods for invitations:

  • email - Email invitations sent by Vortex (includes reminders and nudges)
  • phone - Phone invitations sent by the user/customer
  • share - Shareable invitation links for social sharing
  • internal - Internal invitations managed entirely by your application
    • No email/SMS communication triggered by Vortex
    • Target value can be any customer-defined identifier
    • Useful for in-app invitation flows where you handle the delivery
    • Example use case: In-app notifications, dashboard invites, etc.

Installation

pip install vortex-python-sdk

Note: The package will be available on PyPI once published. See PUBLISHING.md for publishing instructions.

Usage

Basic Setup

from vortex_sdk import Vortex

# Initialize the client with your Vortex API key
vortex = Vortex(api_key="your-vortex-api-key")

# Or with custom base URL
vortex = Vortex(api_key="your-vortex-api-key", base_url="https://custom-api.example.com")

JWT Generation

# Generate JWT for a user
user = {
    "id": "user-123",
    "email": "user@example.com",
    "user_name": "Jane Doe",                                    # Optional: user's display name
    "user_avatar_url": "https://example.com/avatars/jane.jpg",  # Optional: user's avatar URL
    "admin_scopes": ["autojoin"]                                # Optional: grants autojoin admin privileges
}

jwt = vortex.generate_jwt(user=user)
print(f"JWT: {jwt}")

# Or using type-safe models
from vortex_sdk import User

user = User(
    id="user-123",
    email="user@example.com",
    user_name="Jane Doe",                                       # Optional
    user_avatar_url="https://example.com/avatars/jane.jpg",     # Optional
    admin_scopes=["autojoin"]                              # Optional
)

jwt = vortex.generate_jwt(user=user)

Invitation Management

Get Invitations by Target

import asyncio

async def get_user_invitations():
    # Async version
    invitations = await vortex.get_invitations_by_target("email", "user@example.com")
    for invitation in invitations:
        print(f"Invitation ID: {invitation.id}, Status: {invitation.status}")

# Sync version
invitations = vortex.get_invitations_by_target_sync("email", "user@example.com")

Accept an Invitation

async def accept_user_invitation():
    # Async version
    result = await vortex.accept_invitation(
        invitation_id="inv-123",
        user={"email": "user@example.com"}
    )
    print(f"Result: {result}")

# Sync version
result = vortex.accept_invitation_sync(
    invitation_id="inv-123",
    user={"email": "user@example.com"}
)

Get Specific Invitation

async def get_invitation():
    # Async version
    invitation = await vortex.get_invitation("invitation-id")
    print(f"Invitation: {invitation.id}")

# Sync version
invitation = vortex.get_invitation_sync("invitation-id")

Revoke Invitation

async def revoke_invitation():
    # Async version
    result = await vortex.revoke_invitation("invitation-id")
    print(f"Revoked: {result}")

# Sync version
result = vortex.revoke_invitation_sync("invitation-id")

Group Operations

Get Invitations by Group

async def get_group_invitations():
    # Async version
    invitations = await vortex.get_invitations_by_group("organization", "org123")
    print(f"Found {len(invitations)} invitations")

# Sync version
invitations = vortex.get_invitations_by_group_sync("organization", "org123")

Delete Invitations by Group

async def delete_group_invitations():
    # Async version
    result = await vortex.delete_invitations_by_group("organization", "org123")
    print(f"Deleted: {result}")

# Sync version
result = vortex.delete_invitations_by_group_sync("organization", "org123")

Reinvite

async def reinvite_user():
    # Async version
    invitation = await vortex.reinvite("invitation-id")
    print(f"Reinvited: {invitation.id}")

# Sync version
invitation = vortex.reinvite_sync("invitation-id")

Context Manager Usage

# Async context manager
async with Vortex(api_key="your-api-key") as vortex:
    invitations = await vortex.get_invitations_by_target("email", "user@example.com")

# Sync context manager
with Vortex(api_key="your-api-key") as vortex:
    invitations = vortex.get_invitations_by_target_sync("email", "user@example.com")

Error Handling

from vortex_sdk import VortexApiError

try:
    invitation = vortex.get_invitation_sync("invalid-id")
except VortexApiError as e:
    print(f"API Error: {e.message} (Status: {e.status_code})")
except Exception as e:
    print(f"Unexpected error: {e}")

Development

Installation

# Install development dependencies
pip install -e ".[dev]"

Running Tests

pytest

Code Formatting

# Format code
black src/ tests/
isort src/ tests/

# Lint code
ruff check src/ tests/
mypy src/

License

MIT

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

vortex_python_sdk-0.9.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

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

vortex_python_sdk-0.9.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file vortex_python_sdk-0.9.0.tar.gz.

File metadata

  • Download URL: vortex_python_sdk-0.9.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for vortex_python_sdk-0.9.0.tar.gz
Algorithm Hash digest
SHA256 bcbd354a532b43679bade91e0a5bc30db9c9d02b7e99a92a813a108c275f8ded
MD5 79c4c0a34d97f6b3028640cb923c8365
BLAKE2b-256 6f5cc9247cf3f5346347a81f759bcccf5e36b1e7d8b43df64e48feb552324c3e

See more details on using hashes here.

File details

Details for the file vortex_python_sdk-0.9.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vortex_python_sdk-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abfabf5713ac34edfc351e0f5871a670fc1df68d4e37f8dd9bb407accb59ef8d
MD5 1d91eda102e3e31514c0c1ae391ad790
BLAKE2b-256 f4a921db70453498b08b5ef46bdec829131998f9eff8ceb46bd6ac97c0c2e632

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