apimatic-tql-sdk
v0.0.1
Published
this is a sample SDK generated by APIMatic
Readme
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 Submission —
POST /api/invoices— Submit a factoring company invoice referencing a TQL load, including carrier details, stops, charges, and reference numbers. - Invoice Search —
POST /api/invoices/search— Search and retrieve a paginated list of invoices with status and last-updated timestamps. - Invoice Status —
GET /api/invoices/{invoiceNumber}— Retrieve the current processing status of an invoice, including any outstanding exceptions. - Document Upload —
POST /api/documents— Upload a supporting document (BOL, rate confirmation, proof of delivery, etc.) viamultipart/form-dataand link it to an invoice. Supports arbitrary key-value tags for metadata. - Carrier Assignment —
PUT /api/assignments— Notify TQL that a factoring company has been assigned to (or unassigned from) a carrier, including the effective date. - Load Lookup —
GET /api/loads/{loadNumber}— Verify a load exists in TQL's system and retrieve basic details (carrier, status, dates). - Load Search —
POST /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:
Obtain an access token — Make a
POSTrequest to the TQL token endpoint with your Client ID and Client Secret using theclient_credentialsgrant type.Include the token — Pass the access token as a Bearer token in the
Authorizationheader on every API request:Authorization: Bearer <access_token>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 assignmentsFactoring.Read— Query invoice status, search invoices The scopes your client is allowed to request are configured during onboarding. Include the required scope(s) in thescopeparameter 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.ReadTQL 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
Authorizationheader. See the Authentication section above for details. - Asynchronous processing — Write endpoints return
202 Acceptedimmediately; pollGET /api/invoices/{invoiceNumber}for completion and exceptions. - Error handling — Non-2xx responses follow RFC 7807 Problem Details with
title,status, anddetailfields.
Install the Package
Run the following command from your project directory to install the package from npm:
npm install [email protected]For additional package details, see the Npm page for the [email protected] npm.
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 |
| --- | --- | --- |
| timeout | number | Timeout for API calls.Default: 30000 |
| httpClientOptions | Partial<HttpClientOptions> | Stable configurable http client options. |
| unstableHttpClientOptions | any | Unstable configurable http client options. |
| logging | PartialLoggingOptions | Logging Configuration to enable logging |
| clientCredentialsAuthCredentials | ClientCredentialsAuthCredentials | The credential object for clientCredentialsAuth |
The API client can be initialized as follows:
Code-Based Client Initialization
import { Client, LogLevel, OauthScope } from 'apimatic-tql-sdk';
const client = new Client({
clientCredentialsAuthCredentials: {
oauthClientId: 'OAuthClientId',
oauthClientSecret: 'OAuthClientSecret',
oauthScopes: [
OauthScope.FactoringWrite,
OauthScope.FactoringRead
]
},
timeout: 30000,
logging: {
logLevel: LogLevel.Info,
logRequest: {
logBody: true
},
logResponse: {
logHeaders: true
}
},
});Configuration-Based Client Initialization
import * as path from 'path';
import * as fs from 'fs';
import { Client } from 'apimatic-tql-sdk';
// Provide absolute path for the configuration file
const absolutePath = path.resolve('./config.json');
// Read the configuration file content
const fileContent = fs.readFileSync(absolutePath, 'utf-8');
// Initialize client from JSON configuration content
const client = Client.fromJsonConfig(fileContent);See the Configuration-Based Client Initialization section for details.
Environment-Based Client Initialization
import * as dotenv from 'dotenv';
import * as path from 'path';
import * as fs from 'fs';
import { Client } from 'apimatic-tql-sdk';
// Optional - Provide absolute path for the .env file
const absolutePath = path.resolve('./.env');
if (fs.existsSync(absolutePath)) {
// Load environment variables from .env file
dotenv.config({ path: absolutePath, override: true });
}
// Initialize client using environment variables
const client = Client.fromEnvironment(process.env);See the Environment-Based Client Initialization section for details.
Authorization
This API uses the following authentication schemes.
List of APIs
SDK Infrastructure
Configuration
- HttpClientOptions
- RetryConfiguration
- ProxySettings
- Configuration-Based Client Initialization
- Environment-Based Client Initialization
- PartialLoggingOptions
- PartialRequestLoggingOptions
- PartialResponseLoggingOptions
- LoggerInterface
