Getting Started with TQL <> OTR — Factoring Data Exchange

Introduction

Overview

The TQL <> OTR Factoring Data Exchange API enables factoring clients to submit carrier invoices against loads managed by TQL, upload supporting documentation, search for invoices, and check processing status including any outstanding exceptions.

Key Capabilities

  • Invoice SubmissionPOST /api/invoices — Submit a factoring company invoice referencing a TQL load, including carrier details, stops, charges, and reference numbers.
  • Invoice SearchPOST /api/invoices/search — Search and retrieve a paginated list of invoices with status and last-updated timestamps.
  • Invoice StatusGET /api/invoices/{invoiceNumber} — Retrieve the current processing status of an invoice, including any outstanding exceptions.
  • Document UploadPOST /api/documents — Upload a supporting document (BOL, rate confirmation, proof of delivery, etc.) via multipart/form-data and link it to an invoice. Supports arbitrary key-value tags for metadata.
  • Carrier AssignmentPUT /api/assignments — Notify TQL that a factoring company has been assigned to (or unassigned from) a carrier, including the effective date.
  • Load LookupGET /api/loads/{loadNumber} — Verify a load exists in TQL's system and retrieve basic details (carrier, status, dates).
  • Load SearchPOST /api/loads/search — Search for TQL loads by carrier, date range, or status.

Authentication

This API uses OAuth 2.0 Client Credentials for authentication. TQL will provision each factoring partner with a unique Client ID and Client Secret during onboarding.

How it works:

  1. Obtain an access token — Make a POST request to the TQL token endpoint with your Client ID and Client Secret using the client_credentials grant type.

  2. Include the token — Pass the access token as a Bearer token in the Authorization header on every API request: Authorization: Bearer <access_token>

  3. Token expiry — Access tokens have a limited lifetime (typically 1 hour). When the token expires, request a new one from the token endpoint. Do not request a new token on every API call — cache and reuse the token until it expires.

Required scopes:

  • Factoring.Write — Submit invoices, upload documents, manage assignments
  • Factoring.Read — Query invoice status, search invoices The scopes your client is allowed to request are configured during onboarding. Include the required scope(s) in the scope parameter when requesting a token.

Example token request:

POST /oauth2/token HTTP/1.1 Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id=<your_client_id>
&client_secret=<your_client_secret>
&scope=Factoring.Write Factoring.Read

TQL will provide the exact token endpoint URL, Client ID, and Client Secret during partner onboarding.

Philosophy

  • Authentication — All endpoints require a valid OAuth 2.0 Bearer token in the Authorization header. See the Authentication section above for details.
  • Asynchronous processing — Write endpoints return 202 Accepted immediately; poll GET /api/invoices/{invoiceNumber} for completion and exceptions.
  • Error handling — Non-2xx responses follow RFC 7807 Problem Details with title, status, and detail fields.

Install the Package

Install the gem from the command line:

gem install apimatic-tql-sdk -v 0.0.1

Or add the gem to your Gemfile and run bundle:

gem 'apimatic-tql-sdk', '0.0.1'

For additional gem details, see the RubyGems page for the apimatic-tql-sdk gem.

IRB Console Usage

You can explore the SDK interactively using IRB in two ways

1. Use IRB with Installed Gem

Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.

irb

Now you can load the SDK in the IRB

require 'tql_otr_factoring_data_exchange'
include TqlOtrFactoringDataExchange

2. Use IRB within SDK

Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.

cd path/to/tql_otr_factoring_data_exchange

Now you can start the preconfigured irb console by running the following command

ruby bin/console

Note: This automatically loads the SDK from lib/

Initialize the API Client

Note: Documentation for the client can be found here.

The following parameters are configurable for the API Client:

Parameter Type Description
connection Faraday::Connection The Faraday connection object passed by the SDK user for making requests
adapter Faraday::Adapter The Faraday adapter object passed by the SDK user for performing http requests
timeout Float The value to use for connection timeout.
Default: 30
max_retries Integer The number of times to retry an endpoint call if it fails.
Default: 0
retry_interval Float Pause in seconds between retries.
Default: 1
backoff_factor Float The amount to multiply each successive retry's interval amount by in order to provide backoff.
Default: 2
retry_statuses Array A list of HTTP statuses to retry.
Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]
retry_methods Array A list of HTTP methods to retry.
Default: %i[get put]
http_callback HttpCallBack The Http CallBack allows defining callables for pre and post API calls.
proxy_settings ProxySettings Optional proxy configuration to route HTTP requests through a proxy server.
logging_configuration LoggingConfiguration The SDK logging configuration for API calls
client_credentials_auth_credentials ClientCredentialsAuthCredentials The credential object for OAuth 2 Client Credentials Grant

The API client can be initialized as follows:

Code-Based Client Initialization

require 'tql_otr_factoring_data_exchange'
include TqlOtrFactoringDataExchange

client = Client.new(
  client_credentials_auth_credentials: ClientCredentialsAuthCredentials.new(
    oauth_client_id: 'OAuthClientId',
    oauth_client_secret: 'OAuthClientSecret',
    oauth_scopes: [
      OauthScope::FACTORING_WRITE,
      OauthScope::FACTORING_READ
    ]
  ),
  logging_configuration: LoggingConfiguration.new(
    log_level: Logger::INFO,
    request_logging_config: RequestLoggingConfiguration.new(
      log_body: true
    ),
    response_logging_config: ResponseLoggingConfiguration.new(
      log_headers: true
    )
  )
)

Environment-Based Client Initialization

require 'tql_otr_factoring_data_exchange'
include TqlOtrFactoringDataExchange

# Create client from environment
client = Client.from_env

See the Environment-Based Client Initialization section for details.

Authorization

This API uses the following authentication schemes.

List of APIs

SDK Infrastructure

Configuration

HTTP

Utilities