Project

authensure

0.0
No release in over 3 years
Ruby SDK for Authensure - the electronic signature and document authentication platform. Provides a simple interface to create envelopes, manage documents, handle signatures, and integrate webhooks.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.0
~> 1.0
~> 0.22
~> 3.0
~> 0.9

Runtime

>= 1.0, < 3.0
 Project Readme

Authensure Ruby SDK

Gem Version Downloads Ruby Version License: MIT

Official Ruby SDK for Authensure - the electronic signature and document authentication platform.

Features

  • Full API Coverage - Access all Authensure API endpoints
  • Ruby 3.0+ - Modern Ruby with full type annotations via YARD
  • Automatic Retries - Built-in exponential backoff for transient errors
  • Rate Limit Handling - Automatic rate limit detection and backoff
  • Webhook Verification - Easy webhook signature verification
  • File Uploads - Simplified document upload handling
  • Debug Mode - Detailed logging for development

Installation

Add this line to your application's Gemfile:

gem 'authensure'

And then execute:

bundle install

Or install it yourself as:

gem install authensure

Quick Start

require 'authensure'

# Initialize with API key
client = Authensure::Client.new(api_key: 'your_api_key')

# Or use class methods
client = Authensure::Client.with_api_key('your_api_key')

# Create an envelope
envelope = client.envelopes.create(
  name: 'Contract Agreement',
  message: 'Please review and sign this document'
)

puts "Created envelope: #{envelope[:id]}"

Configuration

Global Configuration

Authensure.configure do |config|
  config.api_key = 'your_api_key'
  config.base_url = 'https://api.authensure.app/api'  # Optional
  config.timeout = 30                                   # Optional
  config.retry_attempts = 3                             # Optional
  config.debug = false                                  # Optional
end

client = Authensure.client

Per-Client Configuration

client = Authensure::Client.new(
  api_key: 'your_api_key',
  base_url: 'https://api.authensure.app/api',
  timeout: 30,
  retry_attempts: 3,
  debug: true
)

Using Access Token

client = Authensure::Client.with_access_token('your_access_token')

API Reference

Envelopes

# List envelopes
envelopes = client.envelopes.list(status: 'DRAFT')

# Get an envelope
envelope = client.envelopes.get('envelope_id')

# Create an envelope
envelope = client.envelopes.create(name: 'My Contract', message: 'Please sign')

# Add a recipient
recipient = client.envelopes.add_recipient(
  'envelope_id',
  email: 'signer@example.com',
  name: 'John Doe',
  role: 'signer'
)

# Send for signing
envelope = client.envelopes.send_envelope('envelope_id')

# Void an envelope
envelope = client.envelopes.void('envelope_id', reason: 'Contract cancelled')

Documents

# Upload a document
document = client.documents.upload(
  envelope_id: 'envelope_id',
  file: File.read('contract.pdf'),
  filename: 'contract.pdf'
)

# Get signed document URL
result = client.documents.get_signed_url('document_id')
puts result[:url]

# Download a document
content = client.documents.download('document_id')

Templates

# List templates
templates = client.templates.list

# Create from template
envelope = client.templates.use(
  'template_id',
  name: 'New Contract',
  recipients: [
    { roleId: 'role_1', email: 'signer@example.com', name: 'John Doe' }
  ]
)

Contacts

# List contacts
contacts = client.contacts.list(search: 'acme', limit: 20)

# Create a contact
contact = client.contacts.create(
  email: 'contact@example.com',
  name: 'Jane Smith',
  company: 'Acme Inc'
)

Webhooks

# Create a webhook
webhook = client.webhooks.create(
  url: 'https://your-app.com/webhooks/authensure',
  events: ['envelope.signed', 'envelope.completed']
)

# Verify webhook signature
is_valid = Authensure::Resources::Webhooks.verify_signature(
  payload,
  signature,
  'your_webhook_secret'
)

# Construct verified event
event = Authensure::Resources::Webhooks.construct_event(
  payload,
  signature,
  'your_webhook_secret'
)
puts "Event type: #{event[:event]}"

Error Handling

begin
  envelope = client.envelopes.get('invalid_id')
rescue Authensure::NotFoundError
  puts 'Envelope not found'
rescue Authensure::AuthenticationError
  puts 'Invalid API key'
rescue Authensure::RateLimitError => e
  puts "Rate limited, retry after: #{e.retry_after} seconds"
rescue Authensure::ValidationError => e
  puts "Validation errors: #{e.validation_errors}"
rescue Authensure::Error => e
  puts "API error: #{e.message} (code: #{e.code})"
end

Rails Integration

Add to your config/initializers/authensure.rb:

Authensure.configure do |config|
  config.api_key = Rails.application.credentials.authensure_api_key
  config.debug = Rails.env.development?
end

Use in your controllers:

class EnvelopesController < ApplicationController
  def create
    envelope = authensure_client.envelopes.create(
      name: params[:name],
      message: params[:message]
    )
    render json: envelope
  end

  private

  def authensure_client
    @authensure_client ||= Authensure.client
  end
end

Development

After checking out the repo:

bundle install

Run the tests:

bundle exec rspec

Run the linter:

bundle exec rubocop

Resources

License

This gem is available as open source under the terms of the MIT License.