Vortex Rust SDK
This crate provides the Vortex Rust SDK for authentication and invitation management.
With this SDK, you can generate JWTs for use with the Vortex Widget and make API calls to the Vortex API.
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/customershare- Shareable invitation links for social sharinginternal- Internal invitations managed entirely by your application- No email/SMS communication triggered by Vortex
- Target value can be any customer-defined identifier (UUID, string, number)
- Useful for in-app invitation flows where you handle the delivery
- Example use case: In-app notifications, dashboard invites, etc.
Installation
Add the SDK to your Cargo.toml:
[]
= "1.0"
= { = "1.0", = ["full"] }
Getting Started
Once you have the SDK installed, login to Vortex and create an API Key. Keep your API key safe! Vortex does not store the API key and it is not retrievable once it has been created.
Your API key is used to:
- Sign JWTs for use with the Vortex Widget
- Make API calls against the Vortex API
Usage
Generate a JWT for the Vortex Widget
The Vortex Widget requires a JWT to authenticate users. Here's how to generate one:
use ;
Async API Usage
All API methods are async and require a tokio runtime:
use ;
async
Using with Axum (Web Framework)
Here's an example of using the SDK with the Axum web framework:
use ;
use ;
use Arc;
use VortexClient;
async
async
API Methods
All API methods are asynchronous and require the tokio runtime.
Invitation Management
Get Invitations by Target
let invitations = client
.get_invitations_by_target
.await?;
Get Invitation by ID
let invitation = client.get_invitation.await?;
Revoke Invitation
client.revoke_invitation.await?;
Accept an Invitation
use AcceptUser;
let user = new.with_email;
let result = client
.accept_invitation
.await?;
Get Invitations by Group
let invitations = client
.get_invitations_by_group
.await?;
Delete Invitations by Group
client
.delete_invitations_by_group
.await?;
Reinvite
let result = client.reinvite.await?;
Sync Internal Invitation
If you're using internal delivery type invitations and managing the invitation flow within your own application, you can sync invitation decisions back to Vortex when users accept or decline invitations in your system.
// Sync an internal invitation action (accept or decline)
let request = new;
let result = client.sync_internal_invitation.await?;
println!;
println!;
Parameters:
creator_id(String) — The inviter's user ID in your systemtarget_value(String) — The invitee's user ID in your systemaction("accepted" | "declined") — The invitation decisioncomponent_id(String) — The widget component UUID
Response:
processed(usize) — Count of invitations processedinvitation_ids(Vec) — IDs of processed invitations
Use cases:
- You handle invitation delivery through your own in-app notifications or UI
- Users accept/decline invitations within your application
- You need to keep Vortex updated with the invitation status
## Error Handling
The SDK uses a custom `VortexError` type for error handling:
```rust
use vortex_sdk::{VortexClient, VortexError};
match client.get_invitation("invalid-id").await {
Ok(invitation) => println!("Got invitation: {:?}", invitation),
Err(VortexError::ApiError(msg)) => eprintln!("API error: {}", msg),
Err(VortexError::HttpError(msg)) => eprintln!("HTTP error: {}", msg),
Err(e) => eprintln!("Other error: {}", e),
}
Requirements
- Rust 1.70 or higher
- Tokio runtime for async operations
Features
- Type-safe: Full type safety with Rust's type system
- Async/await: Built on tokio for efficient async operations
- React Compatible: JWTs generated using the same algorithm as Node.js SDK
- Comprehensive: All Vortex API endpoints supported
- Error handling: Rich error types for better debugging
- Flexible: User-based JWT generation with support for admin scopes and custom properties
License
MIT
Support
For support, please contact support@vortexsoftware.com or visit our documentation.