Skip to main content
plainrouter-sdk is the official Ruby SDK for Plainrouter’s signed OpenAPI contract. Gem 0.6.1 targets signed API contract 0.5.0 and exposes a compact client over the generated API. The source is in plainrouter/sdk. Review release notes before upgrading while the gem remains in the 0.x series.

What changes when upgrading?

Version 0.6.1 loads Pathname for standalone multipart requests and corrects the Launcher import route. Inventory GetAccountInventory404Response is now an anyOf module using .build, not a message model with .new or .build_from_hash. Inspect the selected ApiRouteNotFound or account-error branch. When upgrading from releases before 0.6.0, replace PlainRouter::OpenAPI::DeploymentPlan with PlainRouter::OpenAPI::DeploymentPlanRead. Hand-built destination models require attention_reason, held_count and notices. Creative projection classes have also changed; update any explicit class checks using the release notes. The curated client defaults to JSON responses and raises PlainRouter::OpenAPI::ApiError on API redirects without following them. Closed request objects reject unknown keys. Omit an optional page argument for the default and follow returned cursors for incomplete results. Review the published release notes and the shared upgrade checks.

Requirements

  • Ruby 3.2 or newer.
  • A Signals workspace secret for production Conversion API operations.
  • Server-side code. Do not put the secret in browser or distributed client code.

Install

Install plainrouter-sdk 0.6.1:
Or add the gem to your Gemfile, then run bundle install:

Create an authenticated client

Pass the Signals workspace secret when you create the client:
The client sends the Signals workspace secret as a bearer token. It does not read credentials from the environment automatically.

Send a Meta conversion

This recipe calls Plainrouter’s Conversion API, not Meta Graph API directly. Before sending a real purchase, connect a Meta destination and read the actual payment and advertising-consent records from your application. Keep Ruby as the purchase owner; do not also send this purchase through the managed browser or Stripe settlement flow. The function takes your persisted order ID, original payment time, decimal amount, currency, and consent snapshot. paid_at and consent_captured_at are Ruby Time objects. The consent hash uses symbol keys matching the three API consent fields. Replace the source URL with your checkout URL.
A new event returns status: 202; a retry of the same event ID returns status: 200 and duplicate: true. Persist the payload before sending, and reuse its ID and original payment time after an uncertain timeout. Check that advertising use remains permitted before a later retry. Duplicate ingestion does not resend a failed Meta delivery or update the original event.

How do I confirm delivery?

Use the returned receipt ID to read the event. This function returns delivery statuses without logging identity fields:
accepted means Meta accepted a delivery. queued, sent, or retrying means its outcome is pending. An empty list proves no delivery acceptance; inspect the destination and event eligibility. Meta acceptance does not prove ad attribution. See all delivery statuses.

Handle API failures

Inspect validation details in a controlled development environment. Do not log the complete exception or response body in production; it can include request-related details. Generated Ruby models do not replace server-side validation.

Choose an API group

Generated models, API errors, configuration, response metadata, and every generated operation remain available under PlainRouter::OpenAPI.

Verify Signal ingestion

The operation is idempotent. A repeated verification returns the existing event with duplicate: true. The event confirms ledger receipt but is not real arrival evidence and does not complete onboarding.

What happened to sandbox methods?

The unauthenticated sandbox is retired. An installed client.sandbox facade does not establish availability; its calls return HTTP 410 with sandbox_retired. Use the matching workspace credential for supported operations. Migration guidance.

Configure another API origin or timeout

The default API base URL is https://plainrouter.com/api/v1 and the default timeout is 30 seconds. Override either value only for a Plainrouter-provided region or a controlled test environment:

Handle credentials safely

The Ruby SDK accepts a Signals workspace secret for production Conversion API calls. It does not accept an MCP workspace execution token or OAuth management credential. Keep the secret in server-side credential storage. Never include it in prompts, URLs, logs, source control, or client-side code. For request and response fields, use the Conversion API reference.