Developer Guide · Ruby

How to add e-signatures
in Ruby

Add legally binding e-signatures to a Ruby app in four steps with the GetSigned REST API: get a token, create an envelope with a multipart upload, send the signing link, and handle the completion webhook in Sinatra or Rails.

Get free API keys →
1

Get a bearer token

Exchange your OAuth2 client credentials for a short-lived access token using Ruby's standard Net::HTTP library.

ruby
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://api.getsigned.app/oauth/token')
res = Net::HTTP.post_form(uri, {
  'grant_type'    => 'client_credentials',
  'client_id'     => ENV['GETSIGNED_CLIENT_ID'],
  'client_secret' => ENV['GETSIGNED_CLIENT_SECRET']
})
token = JSON.parse(res.body)['access_token']
2

Create an envelope

Upload the PDF with signers and fields as a multipart/form-data request. Use the multipart-post gem for clean multipart handling.

ruby
require 'net/http/post/multipart'

uri  = URI('https://api.getsigned.app/v1/envelopes')
file = UploadIO.new('nda.pdf', 'application/pdf', 'nda.pdf')

req = Net::HTTP::Post::Multipart.new(uri.path,
  'document' => file,
  'signers'  => JSON.generate([
    { name: 'Jamie', email: 'jamie@client.io' }
  ]),
  'fields'   => JSON.generate([
    { type: 'signature', page: 1, x: 420, y: 580 }
  ])
)
req['Authorization'] = "Bearer #{token}"

http     = Net::HTTP.new(uri.host, 443)
http.use_ssl = true
response = http.request(req)
envelope = JSON.parse(response.body) # { "id" => "env_..." }
3

Send for signing

Sending generates a tokenized, single-use link per signer and emails it. Signers verify identity with email/SMS OTP.

ruby
uri = URI("https://api.getsigned.app/v1/envelopes/#{envelope['id']}/send")
req = Net::HTTP::Post.new(uri)
req['Authorization'] = "Bearer #{token}"

http = Net::HTTP.new(uri.host, 443)
http.use_ssl = true
http.request(req)
4

Handle the completion webhook

When the last signer finishes, GetSigned POSTs envelope.completed to your endpoint. Verify the HMAC-SHA256 signature first. Works with Sinatra or Rails.

ruby
# Sinatra example
require 'sinatra'
require 'json'
require 'openssl'
require 'rack/utils'

WEBHOOK_SECRET = ENV['GETSIGNED_WEBHOOK_SECRET']

post '/webhooks/getsigned' do
  raw = request.body.read  # raw body, before JSON.parse
  sig = request.env['HTTP_X_GETSIGNED_SIGNATURE'].to_s
  expected = OpenSSL::HMAC.hexdigest('SHA256', WEBHOOK_SECRET, raw)
  halt 401 unless Rack::Utils.secure_compare(expected, sig)  # constant-time

  payload = JSON.parse(raw)

  if payload['event'] == 'envelope.completed'
    envelope_id = payload['envelope_id']
    # GET /v1/envelopes/#{envelope_id}/document -> sealed PDF
    # Update your database, notify parties, etc.
  end

  status 200
end

Frequently asked questions

How do I add e-signatures in Ruby?

Use Ruby's Net::HTTP (standard library) and the multipart-post gem to call the GetSigned REST API: POST client credentials to /oauth/token for a bearer token, create an envelope by uploading a PDF with signers and fields as a multipart request, send it to generate signing links, then handle the envelope.completed webhook in Sinatra or Rails. No dedicated e-signature SDK is required.

Do I need a special gem for multipart file uploads in Ruby?

The multipart-post gem (Net::HTTP::Post::Multipart) is the standard Ruby approach for multipart/form-data file uploads without pulling in a full HTTP client library like Faraday or HTTParty. If you already use one of those in your project, they handle multipart uploads natively and you can use those instead.

Does this work with Rails?

Yes. The Net::HTTP calls work in any Ruby environment — Rails, Sinatra, or a plain Ruby script. For the webhook handler in Rails, define a route in routes.rb and a controller action that reads request.raw_post, verifies the HMAC-SHA256 signature, then processes the event. Skip CSRF verification for the webhook route.

Is there a free tier to build against?

Yes. The free Starter plan includes full REST API access, PKCS#7 sealing, OTP verification, and webhooks, with 5 envelopes per month — enough to build and test a complete Ruby integration.

Other stacks: Node.js · Python · PHP · Go · Language-agnostic guide

Ship signing in your Ruby app today

Get free API keys →