Installation
Add this line to your application’s Gemfile:Quick Start
Configuration
Get your API key from Settings → API Keys in your Metrifox dashboard.
Customer Management
Create a Customer
Update a Customer
The
customer_key is immutable and cannot be changed after creation.Get Customer Data
Delete a Customer
Archive / Unarchive a Customer
CSV Upload
Usage Tracking & Access Control
Check Feature Access
Access checks are served by the Metrifox Meter service (
https://api-meter.metrifox.com).Record Usage Events
You can send either an
event_name or a feature_key when recording usage events.Advanced Usage Recording
List Usage Events
Compute Quantity Price
Compute the price for a given quantity of a feature for a customer, based on their plan. Useful for previewing upgrade costs or showing customers the cost of additional usage before they commit.Only available to tenants whose plan includes the finance API feature.
Checkout & Billing
Generate Checkout URL
Card Collection URL
Generate a hosted URL for collecting a payment method against an existing subscription or order. Useful for trial-to-paid conversions and re-collecting card details after expiry.Wallets & Credit Allocations
Type Safety with Structs
The SDK exposes lightweight structs for usage and checkout helpers:Error Handling
Framework Integration
Rails
Sinatra
API Reference
Available Methods
Customers:create(data)- Create a customerupdate(customer_key, data)- Update a customerget_customer(params)- Get a customerget_details(params)- Get detailed customer informationlist(params)- List customers with pagination and filtersdelete_customer(params)- Delete a customerarchive(customer_key)- Archive a customerunarchive(customer_key)- Restore an archived customerhas_active_subscription?(params)- Check for active subscriptionupload_csv(file_path)- Upload customers via CSVbulk_create(params)- Create multiple customers in one call
check_access(params)- Check feature accessrecord_usage(params)- Record a usage eventlist_events(...)- List recorded usage events with optional filters and paginationquantity_price(customer_key:, feature_key:, quantity:)- Compute the price of a usage quantity (requires finance API feature)
url(params)- Generate a checkout URLcard_collection_url(subscription_id:, order_id:)- Generate a hosted card-collection URL
list(customer_key)- List a customer’s credit walletslist_credit_allocations(wallet_id, status:)- List credit allocations for a walletget_credit_allocation(allocation_id)- Get a single allocation with transaction history
Type Structs
Configuration
Environment Variables
Custom URLs
Default URLs
- Production API:
https://api.metrifox.com/api/v1/ - Meter Service:
https://api-meter.metrifox.com/ - Web App:
https://app.metrifox.com
Requirements
- Ruby 2.7+
Support
- Email: support@metrifox.com
- Documentation: https://docs.metrifox.com
- GitHub: https://github.com/metrifox/metrifox-ruby
- Discord https://discord.gg/GGMHDDBdw
The Ruby SDK follows Ruby conventions and integrates seamlessly with Rails, Sinatra, and other Ruby frameworks.

