Ruby for Uploading Documents in Rossum API

This Ruby code shows how to upload a document automatically using Rossum API to a particular Rossum queue.

This Ruby code demonstrates how to upload a document using Rossum API to a particular Rossum queue. Set the options at the beginning of the script – they store your credentials, and also the identifier of the queue to upload in. You can find out the queue id by looking at your main screen URL, it is the number 12345 in

See the reference API documentation for more details about how to use the upload API.

require 'date'
require 'faraday'
require 'json'

def authorize(username, password)
  response =
  {'username': username, 'password': password}.to_json,
  {'Content-Type': 'application/json'})
  auth_token = JSON.parse(response.body)['key']
  return auth_token

def upload_document(file_path, queue_id, auth_token)
  conn ='') do |f|
    f.request :multipart
    f.adapter Faraday.default_adapter 

  payload = { :content =>, 'application/pdf') }
  headers = {'Authorization': "token #{auth_token}"}
  response ="/v1/queues/#{queue_id}/upload", payload, headers)
  return JSON.parse(response.body)

username = '[email protected]'
password = 'some.secret.password'
queue_id = 12345
file_path = 'invoice.pdf'

auth_token = authorize(username, password)
upload_document(file_path, queue_id, auth_token)