Skip to main content

Installation

Add this line to your application’s Gemfile:
And then execute:
Or install it yourself as:

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).
Example response:

Record Usage Events

You can send either an event_name or a feature_key when recording usage events.

Advanced Usage Recording

Sample response:

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 customer
  • update(customer_key, data) - Update a customer
  • get_customer(params) - Get a customer
  • get_details(params) - Get detailed customer information
  • list(params) - List customers with pagination and filters
  • delete_customer(params) - Delete a customer
  • archive(customer_key) - Archive a customer
  • unarchive(customer_key) - Restore an archived customer
  • has_active_subscription?(params) - Check for active subscription
  • upload_csv(file_path) - Upload customers via CSV
  • bulk_create(params) - Create multiple customers in one call
Usages:
  • check_access(params) - Check feature access
  • record_usage(params) - Record a usage event
  • list_events(...) - List recorded usage events with optional filters and pagination
  • quantity_price(customer_key:, feature_key:, quantity:) - Compute the price of a usage quantity (requires finance API feature)
Checkout:
  • url(params) - Generate a checkout URL
  • card_collection_url(subscription_id:, order_id:) - Generate a hosted card-collection URL
Wallets:
  • list(customer_key) - List a customer’s credit wallets
  • list_credit_allocations(wallet_id, status:) - List credit allocations for a wallet
  • get_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

The Ruby SDK follows Ruby conventions and integrates seamlessly with Rails, Sinatra, and other Ruby frameworks.